fix home
deskripsi: - pemanggilan api di rapikan
This commit is contained in:
@@ -54,6 +54,11 @@
|
|||||||
"date": 1738549408639,
|
"date": 1738549408639,
|
||||||
"name": "logs/backend/combined-2025-02-03.log",
|
"name": "logs/backend/combined-2025-02-03.log",
|
||||||
"hash": "f3f6220a7d5836dbdd5893576479feee4d13abcdfe1ee2e89375e18abea72ee5"
|
"hash": "f3f6220a7d5836dbdd5893576479feee4d13abcdfe1ee2e89375e18abea72ee5"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"date": 1738635038169,
|
||||||
|
"name": "logs/backend/combined-2025-02-04.log",
|
||||||
|
"hash": "b197eb2d58bbab3566e05fdb2bcc52ee608c4fe6ffb54fc958060c8dc4ff305f"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"hashType": "sha256"
|
"hashType": "sha256"
|
||||||
|
|||||||
@@ -54,6 +54,11 @@
|
|||||||
"date": 1738549408637,
|
"date": 1738549408637,
|
||||||
"name": "logs/backend/error-2025-02-03.log",
|
"name": "logs/backend/error-2025-02-03.log",
|
||||||
"hash": "ffd13b033c90d60d10c935a41fe42f3a4d065311cbf7beda1b76b9c5c985e90b"
|
"hash": "ffd13b033c90d60d10c935a41fe42f3a4d065311cbf7beda1b76b9c5c985e90b"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"date": 1738635038164,
|
||||||
|
"name": "logs/backend/error-2025-02-04.log",
|
||||||
|
"hash": "7490b9f6c36fa2500bafa66c4aa590053c50234150ad9ad86ad9400f0ba76a43"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"hashType": "sha256"
|
"hashType": "sha256"
|
||||||
|
|||||||
@@ -5,3 +5,4 @@
|
|||||||
{"digest":"DYNAMIC_SERVER_USAGE","level":"error","message":"Error get data detail event: Dynamic server usage: Page couldn't be rendered statically because it used `request.url`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error","stack":"Error: Dynamic server usage: Page couldn't be rendered statically because it used `request.url`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error\n at new eS (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:26724)\n at e_ (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:27574)\n at i (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:32507)\n at get (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:32603)\n at <anonymous> (/Users/bagasbanuna/Documents/BIP/hipmi/.next/server/app/api/event/check-peserta/route.js)\n at GET (/Users/bagasbanuna/Documents/BIP/hipmi/.next/server/app/api/event/check-peserta/route.js)\n at <anonymous> (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:39714)\n at <anonymous> (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:33303)\n at <anonymous> (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/server/lib/trace/tracer.js:121:36)\n at run (node:async_hooks:64:22)","timestamp":"2025-02-03T06:56:34.648Z"}
|
{"digest":"DYNAMIC_SERVER_USAGE","level":"error","message":"Error get data detail event: Dynamic server usage: Page couldn't be rendered statically because it used `request.url`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error","stack":"Error: Dynamic server usage: Page couldn't be rendered statically because it used `request.url`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error\n at new eS (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:26724)\n at e_ (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:27574)\n at i (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:32507)\n at get (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:32603)\n at <anonymous> (/Users/bagasbanuna/Documents/BIP/hipmi/.next/server/app/api/event/check-peserta/route.js)\n at GET (/Users/bagasbanuna/Documents/BIP/hipmi/.next/server/app/api/event/check-peserta/route.js)\n at <anonymous> (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:39714)\n at <anonymous> (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:33303)\n at <anonymous> (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/server/lib/trace/tracer.js:121:36)\n at run (node:async_hooks:64:22)","timestamp":"2025-02-03T06:56:34.648Z"}
|
||||||
{"digest":"DYNAMIC_SERVER_USAGE","level":"error","message":"Error get data detail event: Dynamic server usage: Page couldn't be rendered statically because it used `request.url`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error","stack":"Error: Dynamic server usage: Page couldn't be rendered statically because it used `request.url`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error\n at Object.e_ [as staticGenerationBailout] (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:27571)\n at i (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:32508)\n at Object.get (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:32604)\n at GET (/Users/bagasbanuna/Documents/BIP/hipmi/.next/server/app/api/event/check-peserta/route.js:1:1219)\n at /Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:39715\n at /Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/server/lib/trace/tracer.js:121:36\n at NoopContextManager.with (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:7057)\n at ContextAPI.with (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:516)\n at NoopTracer.startActiveSpan (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18086)\n at ProxyTracer.startActiveSpan (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18847)","timestamp":"2025-02-03T07:06:48.864Z"}
|
{"digest":"DYNAMIC_SERVER_USAGE","level":"error","message":"Error get data detail event: Dynamic server usage: Page couldn't be rendered statically because it used `request.url`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error","stack":"Error: Dynamic server usage: Page couldn't be rendered statically because it used `request.url`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error\n at Object.e_ [as staticGenerationBailout] (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:27571)\n at i (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:32508)\n at Object.get (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:32604)\n at GET (/Users/bagasbanuna/Documents/BIP/hipmi/.next/server/app/api/event/check-peserta/route.js:1:1219)\n at /Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:39715\n at /Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/server/lib/trace/tracer.js:121:36\n at NoopContextManager.with (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:7057)\n at ContextAPI.with (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:516)\n at NoopTracer.startActiveSpan (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18086)\n at ProxyTracer.startActiveSpan (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18847)","timestamp":"2025-02-03T07:06:48.864Z"}
|
||||||
{"digest":"DYNAMIC_SERVER_USAGE","level":"error","message":"Error get data detail event: Dynamic server usage: Page couldn't be rendered statically because it used `request.url`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error","stack":"Error: Dynamic server usage: Page couldn't be rendered statically because it used `request.url`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error\n at Object.e_ [as staticGenerationBailout] (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:27571)\n at i (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:32508)\n at Object.get (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:32604)\n at GET (/Users/bagasbanuna/Documents/BIP/hipmi/.next/server/app/api/event/check-peserta/route.js:1:1219)\n at /Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:39715\n at /Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/server/lib/trace/tracer.js:121:36\n at NoopContextManager.with (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:7057)\n at ContextAPI.with (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:516)\n at NoopTracer.startActiveSpan (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18086)\n at ProxyTracer.startActiveSpan (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18847)","timestamp":"2025-02-03T07:32:02.910Z"}
|
{"digest":"DYNAMIC_SERVER_USAGE","level":"error","message":"Error get data detail event: Dynamic server usage: Page couldn't be rendered statically because it used `request.url`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error","stack":"Error: Dynamic server usage: Page couldn't be rendered statically because it used `request.url`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error\n at Object.e_ [as staticGenerationBailout] (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:27571)\n at i (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:32508)\n at Object.get (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:32604)\n at GET (/Users/bagasbanuna/Documents/BIP/hipmi/.next/server/app/api/event/check-peserta/route.js:1:1219)\n at /Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:39715\n at /Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/server/lib/trace/tracer.js:121:36\n at NoopContextManager.with (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:7057)\n at ContextAPI.with (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:516)\n at NoopTracer.startActiveSpan (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18086)\n at ProxyTracer.startActiveSpan (/Users/bagasbanuna/Documents/BIP/hipmi/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18847)","timestamp":"2025-02-03T07:32:02.910Z"}
|
||||||
|
{"id":"f6b224a2-3aeb-4cbc-afee-075a7965ab70","level":"info","message":"Success send message","status":"success","timestamp":"2025-02-03T09:53:34.492Z"}
|
||||||
|
|||||||
0
logs/backend/combined-2025-02-04.log
Normal file
0
logs/backend/combined-2025-02-04.log
Normal file
0
logs/backend/error-2025-02-04.log
Normal file
0
logs/backend/error-2025-02-04.log
Normal file
@@ -3,67 +3,82 @@ import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
export const dynamic = "force-dynamic";
|
export const dynamic = "force-dynamic";
|
||||||
|
|
||||||
|
|
||||||
// GET DATA HOME
|
// GET DATA HOME
|
||||||
export async function GET(request: Request) {
|
export async function GET(request: Request) {
|
||||||
try {
|
try {
|
||||||
let fixData
|
let fixData;
|
||||||
const { searchParams } = new URL(request.url)
|
const { searchParams } = new URL(request.url);
|
||||||
const kategori = searchParams.get("cat")
|
const kategori = searchParams.get("cat");
|
||||||
|
|
||||||
const userLoginId = await funGetUserIdByToken()
|
const userLoginId = await funGetUserIdByToken();
|
||||||
if (userLoginId == null) {
|
if (userLoginId == null) {
|
||||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan data, user id tidak ada" }, { status: 500 });
|
return NextResponse.json(
|
||||||
}
|
{
|
||||||
|
success: false,
|
||||||
|
message: "Gagal mendapatkan data, user id tidak ada",
|
||||||
|
},
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (kategori == "job") {
|
if (kategori == "job") {
|
||||||
fixData = await prisma.job.findMany({
|
fixData = await prisma.job.findMany({
|
||||||
take: 2,
|
take: 2,
|
||||||
orderBy: {
|
orderBy: {
|
||||||
createdAt: "desc",
|
createdAt: "desc",
|
||||||
},
|
},
|
||||||
where: {
|
where: {
|
||||||
isActive: true,
|
isActive: true,
|
||||||
masterStatusId: "1"
|
masterStatusId: "1",
|
||||||
},
|
},
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
Author: {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
Author: {
|
username: true,
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
username: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
title: true,
|
|
||||||
deskripsi: true
|
|
||||||
},
|
},
|
||||||
});
|
},
|
||||||
} else if (kategori == "cek_profile") {
|
title: true,
|
||||||
const data = await prisma.user.findUnique({
|
deskripsi: true,
|
||||||
where: {
|
},
|
||||||
id: userLoginId,
|
});
|
||||||
|
} else if (kategori == "cek_profile") {
|
||||||
|
const data = await prisma.user.findUnique({
|
||||||
|
where: {
|
||||||
|
id: userLoginId,
|
||||||
|
},
|
||||||
|
include: {
|
||||||
|
Profile: {
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
imageId: true,
|
||||||
},
|
},
|
||||||
include: {
|
},
|
||||||
Profile: {
|
},
|
||||||
select: {
|
});
|
||||||
id: true,
|
|
||||||
imageId: true,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
fixData = {
|
fixData = {
|
||||||
profile: data?.Profile?.id,
|
profile: data?.Profile?.id,
|
||||||
imageId: data?.Profile?.imageId
|
imageId: data?.Profile?.imageId,
|
||||||
}
|
};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
return NextResponse.json(
|
||||||
|
{ success: true, message: "Berhasil mendapatkan data", data: fixData },
|
||||||
return NextResponse.json({ success: true, message: "Berhasil mendapatkan data", data: fixData }, { status: 200 });
|
{ status: 200 }
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan data, coba lagi nanti ", reason: (error as Error).message, }, { status: 500 });
|
return NextResponse.json(
|
||||||
}
|
{
|
||||||
}
|
success: false,
|
||||||
|
message: "Gagal mendapatkan data, coba lagi nanti ",
|
||||||
|
reason: (error as Error).message,
|
||||||
|
},
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
await prisma.$disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ import { AccentColor, MainColor } from "@/app_modules/_global/color";
|
|||||||
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
|
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
|
||||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
||||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||||
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
import {
|
import {
|
||||||
ActionIcon,
|
ActionIcon,
|
||||||
Box,
|
Box,
|
||||||
Flex,
|
|
||||||
Grid,
|
Grid,
|
||||||
Group,
|
Group,
|
||||||
Image,
|
Image,
|
||||||
@@ -22,40 +22,20 @@ import { useRouter } from "next/navigation";
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { apiGetDataHome } from "../fun/get/api_home";
|
import { apiGetDataHome } from "../fun/get/api_home";
|
||||||
import { listMenuHomeBody, menuHomeJob } from "./list_menu_home";
|
import { listMenuHomeBody, menuHomeJob } from "./list_menu_home";
|
||||||
import { clientLogger } from "@/util/clientLogger";
|
|
||||||
|
|
||||||
export default function BodyHome() {
|
export default function BodyHome({ dataUser }: { dataUser: any | null }) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [dataUser, setDataUser] = useState<any | null>(null);
|
|
||||||
const [dataJob, setDataJob] = useState<any[] | null>(null);
|
const [dataJob, setDataJob] = useState<any[] | null>(null);
|
||||||
const [loadingJob, setLoadingJob] = useState(true);
|
const [loadingJob, setLoadingJob] = useState(true);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
cekUserLogin();
|
|
||||||
getHomeJob();
|
getHomeJob();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
async function cekUserLogin() {
|
|
||||||
try {
|
|
||||||
const response = await apiGetDataHome({
|
|
||||||
path: "?cat=cek_profile",
|
|
||||||
});
|
|
||||||
|
|
||||||
if (response) {
|
|
||||||
setDataUser(response.data);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
clientLogger.error("Error get data profile", error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async function getHomeJob() {
|
async function getHomeJob() {
|
||||||
try {
|
try {
|
||||||
setLoadingJob(true);
|
setLoadingJob(true);
|
||||||
|
|
||||||
const response = await apiGetDataHome({
|
const response = await apiGetDataHome({
|
||||||
path: "?cat=job",
|
path: "?cat=job",
|
||||||
});
|
});
|
||||||
@@ -101,21 +81,14 @@ export default function BodyHome() {
|
|||||||
border: `2px solid ${AccentColor.blue}`,
|
border: `2px solid ${AccentColor.blue}`,
|
||||||
}}
|
}}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (dataUser == null) {
|
if (!dataUser) {
|
||||||
return null;
|
return null;
|
||||||
} else if (
|
} else if (dataUser.profile === undefined) {
|
||||||
Object.keys(dataUser).length == 0 ||
|
|
||||||
dataJob?.length == null
|
|
||||||
) {
|
|
||||||
router.push(RouterProfile.create, { scroll: false });
|
router.push(RouterProfile.create, { scroll: false });
|
||||||
|
} else if (e.link == "") {
|
||||||
|
ComponentGlobal_NotifikasiPeringatan("Cooming Soon");
|
||||||
} else {
|
} else {
|
||||||
if (e.link == "") {
|
router.push(e.link, { scroll: false });
|
||||||
return ComponentGlobal_NotifikasiPeringatan(
|
|
||||||
"Cooming Soon !!"
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
router.push(e.link, { scroll: false });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -147,21 +120,14 @@ export default function BodyHome() {
|
|||||||
>
|
>
|
||||||
<Stack
|
<Stack
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (dataUser == null) {
|
if (!dataUser) {
|
||||||
return null;
|
return null;
|
||||||
} else if (
|
} else if (dataUser.profile === undefined) {
|
||||||
Object.keys(dataUser).length == 0 ||
|
|
||||||
dataJob?.length == null
|
|
||||||
) {
|
|
||||||
router.push(RouterProfile.create, { scroll: false });
|
router.push(RouterProfile.create, { scroll: false });
|
||||||
|
} else if (menuHomeJob.link == "") {
|
||||||
|
ComponentGlobal_NotifikasiPeringatan("Cooming Soon ");
|
||||||
} else {
|
} else {
|
||||||
if (menuHomeJob.link == "") {
|
router.push(menuHomeJob.link, { scroll: false });
|
||||||
return ComponentGlobal_NotifikasiPeringatan(
|
|
||||||
"Cooming Soon !!"
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return router.push(menuHomeJob.link, { scroll: false });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { APIs } from "@/app/lib";
|
import { APIs } from "@/app/lib";
|
||||||
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
|
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
|
||||||
|
import { MainColor } from "@/app_modules/_global/color";
|
||||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
||||||
|
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||||
import {
|
import {
|
||||||
ActionIcon,
|
ActionIcon,
|
||||||
Box,
|
Box,
|
||||||
@@ -9,37 +11,14 @@ import {
|
|||||||
Stack,
|
Stack,
|
||||||
Text,
|
Text,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { useShallowEffect } from "@mantine/hooks";
|
|
||||||
import { IconUserCircle } from "@tabler/icons-react";
|
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
|
||||||
import { apiGetDataHome } from "../fun/get/api_home";
|
|
||||||
import { Home_ComponentAvatarProfile } from "./comp_avatar_profile";
|
import { Home_ComponentAvatarProfile } from "./comp_avatar_profile";
|
||||||
import { listMenuHomeFooter } from "./list_menu_home";
|
import { listMenuHomeFooter } from "./list_menu_home";
|
||||||
import { MainColor } from "@/app_modules/_global/color";
|
import { IconUser } from "@tabler/icons-react";
|
||||||
import { clientLogger } from "@/util/clientLogger";
|
import { IconUserCircle } from "@tabler/icons-react";
|
||||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
|
||||||
|
|
||||||
export default function FooterHome() {
|
export default function FooterHome({ dataUser }: { dataUser: any | null }) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [dataUser, setDataUser] = useState<any | null>(null);
|
|
||||||
|
|
||||||
useShallowEffect(() => {
|
|
||||||
cekUserLogin();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
async function cekUserLogin() {
|
|
||||||
try {
|
|
||||||
const response = await apiGetDataHome({
|
|
||||||
path: "?cat=cek_profile",
|
|
||||||
});
|
|
||||||
if (response) {
|
|
||||||
setDataUser(response.data);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
clientLogger.error("Error get data profile", error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
@@ -51,95 +30,81 @@ export default function FooterHome() {
|
|||||||
bottom={0}
|
bottom={0}
|
||||||
h={"9vh"}
|
h={"9vh"}
|
||||||
>
|
>
|
||||||
{dataUser == null ? (
|
<SimpleGrid cols={listMenuHomeFooter.length + 1}>
|
||||||
<SimpleGrid cols={4}>
|
{listMenuHomeFooter.map((e) => (
|
||||||
{Array.from(new Array(4)).map((_, i) => (
|
<Center h={"9vh"} key={e.id}>
|
||||||
<Center h={"9vh"} key={i}>
|
|
||||||
<Stack align="center">
|
|
||||||
<CustomSkeleton radius={"lg"} height={40} w={40} />
|
|
||||||
</Stack>
|
|
||||||
</Center>
|
|
||||||
))}
|
|
||||||
</SimpleGrid>
|
|
||||||
) : (
|
|
||||||
<SimpleGrid cols={listMenuHomeFooter.length + 1}>
|
|
||||||
{listMenuHomeFooter.map((e) => (
|
|
||||||
<Center h={"9vh"} key={e.id}>
|
|
||||||
<Stack
|
|
||||||
align="center"
|
|
||||||
spacing={0}
|
|
||||||
onClick={() => {
|
|
||||||
if (dataUser == null) {
|
|
||||||
return null;
|
|
||||||
} else if (Object.keys(dataUser).length === 0) {
|
|
||||||
router.push(RouterProfile.create, { scroll: false });
|
|
||||||
} else {
|
|
||||||
if (e.link == "") {
|
|
||||||
ComponentGlobal_NotifikasiPeringatan("Cooming Soon");
|
|
||||||
} else {
|
|
||||||
router.push(e.link, { scroll: false });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<ActionIcon
|
|
||||||
radius={"xl"}
|
|
||||||
c={e.link === "" ? "gray" : MainColor.white}
|
|
||||||
variant="transparent"
|
|
||||||
>
|
|
||||||
{e.icon}
|
|
||||||
</ActionIcon>
|
|
||||||
<Text
|
|
||||||
lineClamp={1}
|
|
||||||
c={e.link === "" ? "gray" : MainColor.white}
|
|
||||||
fz={12}
|
|
||||||
>
|
|
||||||
{e.name}
|
|
||||||
</Text>
|
|
||||||
</Stack>
|
|
||||||
</Center>
|
|
||||||
))}
|
|
||||||
|
|
||||||
<Center h={"9vh"}>
|
|
||||||
<Stack
|
<Stack
|
||||||
align="center"
|
align="center"
|
||||||
spacing={2}
|
spacing={0}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (
|
if (!dataUser) {
|
||||||
dataUser.profile === undefined ||
|
return null;
|
||||||
dataUser?.profile === null
|
} else if (dataUser.profile === undefined) {
|
||||||
) {
|
|
||||||
router.push(RouterProfile.create, { scroll: false });
|
router.push(RouterProfile.create, { scroll: false });
|
||||||
|
} else if (e.link == "") {
|
||||||
|
ComponentGlobal_NotifikasiPeringatan("Cooming Soon");
|
||||||
} else {
|
} else {
|
||||||
|
router.push(e.link, { scroll: false });
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ActionIcon
|
||||||
|
radius={"xl"}
|
||||||
|
c={e.link === "" ? "gray" : MainColor.white}
|
||||||
|
variant="transparent"
|
||||||
|
>
|
||||||
|
{e.icon}
|
||||||
|
</ActionIcon>
|
||||||
|
<Text
|
||||||
|
lineClamp={1}
|
||||||
|
c={e.link === "" ? "gray" : MainColor.white}
|
||||||
|
fz={12}
|
||||||
|
>
|
||||||
|
{e.name}
|
||||||
|
</Text>
|
||||||
|
</Stack>
|
||||||
|
</Center>
|
||||||
|
))}
|
||||||
|
|
||||||
|
<Center h={"9vh"}>
|
||||||
|
<Stack align="center" spacing={2}>
|
||||||
|
{!dataUser ? (
|
||||||
|
<CustomSkeleton height={25} width={25} radius={"xl"} />
|
||||||
|
) : dataUser.profile === undefined ? (
|
||||||
|
<ActionIcon
|
||||||
|
variant={"transparent"}
|
||||||
|
onClick={() =>
|
||||||
|
router.push(RouterProfile.create, { scroll: false })
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<IconUserCircle color="white" />
|
||||||
|
</ActionIcon>
|
||||||
|
) : (
|
||||||
|
<ActionIcon
|
||||||
|
variant={"transparent"}
|
||||||
|
onClick={() => {
|
||||||
router.push(
|
router.push(
|
||||||
RouterProfile.katalogOLD + `${dataUser?.profile}`,
|
RouterProfile.katalogOLD + `${dataUser?.profile}`,
|
||||||
{
|
{
|
||||||
scroll: false,
|
scroll: false,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}}
|
||||||
}}
|
>
|
||||||
>
|
<Home_ComponentAvatarProfile
|
||||||
<ActionIcon variant={"transparent"}>
|
url={APIs.GET({
|
||||||
{dataUser.profile === undefined ||
|
fileId: dataUser?.imageId as string,
|
||||||
dataUser?.profile === null ? (
|
size: "50",
|
||||||
<IconUserCircle color={MainColor.white} />
|
})}
|
||||||
) : (
|
/>
|
||||||
<Home_ComponentAvatarProfile
|
|
||||||
url={APIs.GET({
|
|
||||||
fileId: dataUser?.imageId as string,
|
|
||||||
size: "50",
|
|
||||||
})}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
<Text fz={10} c={MainColor.white}>
|
)}
|
||||||
Profile
|
<Text fz={10} c={MainColor.white}>
|
||||||
</Text>
|
Profile
|
||||||
</Stack>
|
</Text>
|
||||||
</Center>
|
</Stack>
|
||||||
</SimpleGrid>
|
</Center>
|
||||||
)}
|
</SimpleGrid>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import { API_RouteNotifikasi } from "@/app/lib/api_user_router/route_api_notifikasi";
|
import { API_RouteNotifikasi } from "@/app/lib/api_user_router/route_api_notifikasi";
|
||||||
import { gs_count_ntf, gs_user_ntf } from "@/app/lib/global_state";
|
import { gs_count_ntf, gs_user_ntf } from "@/app/lib/global_state";
|
||||||
|
import global_limit from "@/app/lib/limit";
|
||||||
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
|
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
|
||||||
import { RouterNotifikasi } from "@/app/lib/router_hipmi/router_notifikasi";
|
import { RouterNotifikasi } from "@/app/lib/router_hipmi/router_notifikasi";
|
||||||
import { RouterUserSearch } from "@/app/lib/router_hipmi/router_user_search";
|
import { RouterUserSearch } from "@/app/lib/router_hipmi/router_user_search";
|
||||||
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
import { ActionIcon, Indicator, Text } from "@mantine/core";
|
import { ActionIcon, Indicator, Text } from "@mantine/core";
|
||||||
import { useShallowEffect } from "@mantine/hooks";
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
import { IconBell, IconUserSearch } from "@tabler/icons-react";
|
import { IconBell, IconUserSearch } from "@tabler/icons-react";
|
||||||
@@ -17,8 +19,6 @@ import { gs_notifikasi_kategori_app } from "../notifikasi/lib";
|
|||||||
import BodyHome from "./component/body_home";
|
import BodyHome from "./component/body_home";
|
||||||
import FooterHome from "./component/footer_home";
|
import FooterHome from "./component/footer_home";
|
||||||
import { apiGetDataHome } from "./fun/get/api_home";
|
import { apiGetDataHome } from "./fun/get/api_home";
|
||||||
import { clientLogger } from "@/util/clientLogger";
|
|
||||||
import CustomSkeleton from "../components/CustomSkeleton";
|
|
||||||
|
|
||||||
export default function HomeViewNew() {
|
export default function HomeViewNew() {
|
||||||
const [countNtf, setCountNtf] = useAtom(gs_count_ntf);
|
const [countNtf, setCountNtf] = useAtom(gs_count_ntf);
|
||||||
@@ -27,10 +27,6 @@ export default function HomeViewNew() {
|
|||||||
const [categoryPage, setCategoryPage] = useAtom(gs_notifikasi_kategori_app);
|
const [categoryPage, setCategoryPage] = useAtom(gs_notifikasi_kategori_app);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
useShallowEffect(() => {
|
|
||||||
onLoadNotifikasi();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
if (countNtf != null) {
|
if (countNtf != null) {
|
||||||
setCountNtf(countNtf + newUserNtf);
|
setCountNtf(countNtf + newUserNtf);
|
||||||
@@ -38,15 +34,32 @@ export default function HomeViewNew() {
|
|||||||
}
|
}
|
||||||
}, [newUserNtf, countNtf]);
|
}, [newUserNtf, countNtf]);
|
||||||
|
|
||||||
async function onLoadNotifikasi() {
|
useShallowEffect(() => {
|
||||||
const loadNotif = await fetch(API_RouteNotifikasi.get_count_by_id());
|
hanlderLoadData();
|
||||||
const data = await loadNotif.json().then((res) => res.data);
|
}, []);
|
||||||
setCountNtf(data);
|
|
||||||
|
async function hanlderLoadData() {
|
||||||
|
try {
|
||||||
|
const listLoadData = [
|
||||||
|
global_limit(() => onLoadNotifikasi()),
|
||||||
|
global_limit(() => cekUserLogin()),
|
||||||
|
];
|
||||||
|
|
||||||
|
await Promise.all(listLoadData);
|
||||||
|
} catch (error) {
|
||||||
|
clientLogger.error("Error handler load data", error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useShallowEffect(() => {
|
async function onLoadNotifikasi() {
|
||||||
cekUserLogin();
|
try {
|
||||||
}, []);
|
const loadNotif = await fetch(API_RouteNotifikasi.get_count_by_id());
|
||||||
|
const data = await loadNotif.json().then((res) => res.data);
|
||||||
|
setCountNtf(data);
|
||||||
|
} catch (error) {
|
||||||
|
clientLogger.error("Error load notifikasi", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function cekUserLogin() {
|
async function cekUserLogin() {
|
||||||
try {
|
try {
|
||||||
@@ -68,22 +81,26 @@ export default function HomeViewNew() {
|
|||||||
<UIGlobal_LayoutHeaderTamplate
|
<UIGlobal_LayoutHeaderTamplate
|
||||||
title="HIPMI"
|
title="HIPMI"
|
||||||
customButtonLeft={
|
customButtonLeft={
|
||||||
dataUser == null ? (
|
!dataUser && !countNtf ? (
|
||||||
<CustomSkeleton width={20} height={20} circle />
|
<ActionIcon radius={"xl"} variant={"transparent"}>
|
||||||
|
<IconUserSearch color={MainColor.white} />
|
||||||
|
</ActionIcon>
|
||||||
|
) : dataUser.profile === undefined ? (
|
||||||
|
<ActionIcon
|
||||||
|
radius={"xl"}
|
||||||
|
variant={"transparent"}
|
||||||
|
onClick={() => {
|
||||||
|
router.push(RouterProfile.create, { scroll: false });
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<IconUserSearch color={MainColor.white} />
|
||||||
|
</ActionIcon>
|
||||||
) : (
|
) : (
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
radius={"xl"}
|
radius={"xl"}
|
||||||
disabled={countNtf == null}
|
|
||||||
variant={"transparent"}
|
variant={"transparent"}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (
|
router.push(RouterUserSearch.main, { scroll: false });
|
||||||
dataUser.profile != undefined ||
|
|
||||||
dataUser?.profile != null
|
|
||||||
) {
|
|
||||||
router.push(RouterUserSearch.main, { scroll: false });
|
|
||||||
} else {
|
|
||||||
router.push(RouterProfile.create, { scroll: false });
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<IconUserSearch color={MainColor.white} />
|
<IconUserSearch color={MainColor.white} />
|
||||||
@@ -91,27 +108,32 @@ export default function HomeViewNew() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
customButtonRight={
|
customButtonRight={
|
||||||
dataUser == null ? (
|
!dataUser && !countNtf ? (
|
||||||
<CustomSkeleton width={20} height={20} circle />
|
<ActionIcon radius={"xl"} variant={"transparent"}>
|
||||||
|
<IconBell color={MainColor.white} />
|
||||||
|
</ActionIcon>
|
||||||
|
) : dataUser.profile === undefined ? (
|
||||||
|
<ActionIcon
|
||||||
|
radius={"xl"}
|
||||||
|
variant={"transparent"}
|
||||||
|
onClick={() => {
|
||||||
|
router.push(RouterProfile.create, { scroll: false });
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<IconBell color={MainColor.white} />
|
||||||
|
</ActionIcon>
|
||||||
) : (
|
) : (
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
variant="transparent"
|
variant="transparent"
|
||||||
disabled={countNtf == null}
|
disabled={countNtf == null}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (
|
setCategoryPage("Semua");
|
||||||
dataUser.profile != undefined ||
|
router.push(
|
||||||
dataUser?.profile != null
|
RouterNotifikasi.categoryApp({ name: "semua" }),
|
||||||
) {
|
{
|
||||||
setCategoryPage("Semua");
|
scroll: false,
|
||||||
router.push(
|
}
|
||||||
RouterNotifikasi.categoryApp({ name: "semua" }),
|
);
|
||||||
{
|
|
||||||
scroll: false,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
router.push(RouterProfile.create, { scroll: false });
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{countNtf != null && countNtf > 0 ? (
|
{countNtf != null && countNtf > 0 ? (
|
||||||
@@ -134,9 +156,9 @@ export default function HomeViewNew() {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
footer={<FooterHome />}
|
footer={<FooterHome dataUser={dataUser} />}
|
||||||
>
|
>
|
||||||
<BodyHome />
|
<BodyHome dataUser={dataUser} />
|
||||||
</UIGlobal_LayoutTamplate>
|
</UIGlobal_LayoutTamplate>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user