132
src/app/api/event/kontribusi/route.ts
Normal file
132
src/app/api/event/kontribusi/route.ts
Normal file
@@ -0,0 +1,132 @@
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import backendLogger from "@/util/backendLogger";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
export { GET };
|
||||
|
||||
async function GET(request: Request) {
|
||||
try {
|
||||
let fixData;
|
||||
const { searchParams } = new URL(request.url);
|
||||
const page = searchParams.get("page");
|
||||
const takeData = 5;
|
||||
const skipData = Number(page) * takeData - takeData;
|
||||
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
if (!userLoginId) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: false,
|
||||
message: "Gagal mendapatkan data",
|
||||
reason: "User not found",
|
||||
},
|
||||
{
|
||||
status: 401,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (!page) {
|
||||
fixData = await prisma.event_Peserta.findMany({
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
where: {
|
||||
userId: userLoginId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
Event: {
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
tanggal: true,
|
||||
deskripsi: true,
|
||||
Author: {
|
||||
select: {
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
Event_Peserta: {
|
||||
take: 5,
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
userId: true,
|
||||
User: {
|
||||
select: {
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
} else {
|
||||
fixData = await prisma.event_Peserta.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
where: {
|
||||
userId: userLoginId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
Event: {
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
tanggal: true,
|
||||
deskripsi: true,
|
||||
Author: {
|
||||
select: {
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
Event_Peserta: {
|
||||
take: 5,
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
userId: true,
|
||||
User: {
|
||||
select: {
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: true,
|
||||
message: "Success get kontribusi",
|
||||
data: fixData,
|
||||
},
|
||||
{ status: 200 }
|
||||
);
|
||||
} catch (error) {
|
||||
backendLogger.error("Error get kontribusi", error);
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: false,
|
||||
message: "Failed get kontribusi",
|
||||
reason: (error as Error).message,
|
||||
},
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
153
src/app/api/event/riwayat/[name]/route.ts
Normal file
153
src/app/api/event/riwayat/[name]/route.ts
Normal file
@@ -0,0 +1,153 @@
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import backendLogger from "@/util/backendLogger";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
export { GET };
|
||||
|
||||
interface Props {
|
||||
params: { name: string };
|
||||
}
|
||||
async function GET(request: Request, { params }: Props) {
|
||||
try {
|
||||
let fixData;
|
||||
const { name } = params;
|
||||
const { searchParams } = new URL(request.url);
|
||||
const page = searchParams.get("page");
|
||||
const takeData = 5;
|
||||
const skipData = Number(page) * takeData - takeData;
|
||||
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
if (!userLoginId) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: false,
|
||||
message: "Gagal mendapatkan data",
|
||||
reason: "Unauthorized",
|
||||
},
|
||||
{
|
||||
status: 401,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (!page) {
|
||||
if (name == "saya") {
|
||||
fixData = await prisma.event.findMany({
|
||||
orderBy: {
|
||||
tanggal: "desc",
|
||||
},
|
||||
where: {
|
||||
authorId: userLoginId,
|
||||
eventMaster_StatusId: "1",
|
||||
isArsip: true,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
tanggal: true,
|
||||
deskripsi: true,
|
||||
active: true,
|
||||
authorId: true,
|
||||
Author: {
|
||||
select: {
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
} else if (name === "semua") {
|
||||
fixData = await prisma.event.findMany({
|
||||
orderBy: {
|
||||
tanggal: "desc",
|
||||
},
|
||||
where: {
|
||||
eventMaster_StatusId: "1",
|
||||
isArsip: true,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
tanggal: true,
|
||||
deskripsi: true,
|
||||
active: true,
|
||||
authorId: true,
|
||||
Author: {
|
||||
select: {
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (name == "saya") {
|
||||
fixData = await prisma.event.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
tanggal: "desc",
|
||||
},
|
||||
where: {
|
||||
authorId: userLoginId,
|
||||
eventMaster_StatusId: "1",
|
||||
isArsip: true,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
tanggal: true,
|
||||
deskripsi: true,
|
||||
active: true,
|
||||
authorId: true,
|
||||
Author: {
|
||||
select: {
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
} else if (name === "semua") {
|
||||
fixData = await prisma.event.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
tanggal: "desc",
|
||||
},
|
||||
where: {
|
||||
eventMaster_StatusId: "1",
|
||||
isArsip: true,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
tanggal: true,
|
||||
deskripsi: true,
|
||||
active: true,
|
||||
authorId: true,
|
||||
Author: {
|
||||
select: {
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: "Berhasil mendapatkan data",
|
||||
data: fixData,
|
||||
});
|
||||
} catch (error) {
|
||||
backendLogger.error("Error get riwayat", error);
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: false,
|
||||
message: "Error get data",
|
||||
reason: (error as Error).message,
|
||||
},
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
85
src/app/api/event/status/[name]/route.ts
Normal file
85
src/app/api/event/status/[name]/route.ts
Normal file
@@ -0,0 +1,85 @@
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import backendLogger from "@/util/backendLogger";
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
export async function GET(
|
||||
request: Request,
|
||||
{ params }: { params: { name: string } }
|
||||
) {
|
||||
try {
|
||||
let fixData;
|
||||
const { name } = params;
|
||||
const { searchParams } = new URL(request.url);
|
||||
const page = searchParams.get("page");
|
||||
const takeData = 6;
|
||||
const skipData = Number(page) * takeData - takeData;
|
||||
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
if (!userLoginId) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: false,
|
||||
message: "Gagal mendapatkan data",
|
||||
reason: "User Unauthorized",
|
||||
},
|
||||
{
|
||||
status: 401,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (!page) {
|
||||
fixData = await prisma.event.findMany({
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
active: true,
|
||||
authorId: userLoginId,
|
||||
isArsip: false,
|
||||
},
|
||||
include: {
|
||||
EventMaster_Status: true,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
const fixStatusName = _.startCase(name);
|
||||
|
||||
fixData = await prisma.event.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
tanggal: "asc",
|
||||
},
|
||||
where: {
|
||||
active: true,
|
||||
authorId: userLoginId,
|
||||
isArsip: false,
|
||||
EventMaster_Status: {
|
||||
name: fixStatusName || name,
|
||||
},
|
||||
},
|
||||
include: {
|
||||
EventMaster_Status: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: "Success",
|
||||
data: fixData,
|
||||
});
|
||||
} catch (error) {
|
||||
backendLogger.error("Error get data event ", error);
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: false,
|
||||
message: "Failed to get data",
|
||||
reason: (error as Error).message,
|
||||
},
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,13 @@
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import { Event_DetailMain } from "@/app_modules/event";
|
||||
import { Event_countTotalPesertaById } from "@/app_modules/event/fun/count/count_total_peserta_by_id";
|
||||
|
||||
export default async function Page() {
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
// const totalPeserta = await Event_countTotalPesertaById(eventId);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Event_DetailMain
|
||||
userLoginId={userLoginId as string}
|
||||
// totalPeserta={totalPeserta as any}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
import { Event_DetailRiwayat } from "@/app_modules/event";
|
||||
import { Event_countTotalPesertaById } from "@/app_modules/event/fun/count/count_total_peserta_by_id";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
let eventId = params.id;
|
||||
const totalPeserta = await Event_countTotalPesertaById(eventId);
|
||||
|
||||
export default async function Page() {
|
||||
return (
|
||||
<>
|
||||
<Event_DetailRiwayat
|
||||
totalPeserta={totalPeserta as any}
|
||||
/>
|
||||
<Event_DetailRiwayat />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,11 +2,10 @@ import { Event_Kontribusi } from "@/app_modules/event";
|
||||
import { event_getListKontibusiByUserId } from "@/app_modules/event/fun/get/get_list_kontribusi_by_user_id";
|
||||
|
||||
export default async function Page() {
|
||||
const listKontribusi = await event_getListKontibusiByUserId({page: 1})
|
||||
|
||||
return (
|
||||
<>
|
||||
<Event_Kontribusi listKontribusi={listKontribusi as any}/>
|
||||
<Event_Kontribusi />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,32 +1,9 @@
|
||||
import { Event_Riwayat } from "@/app_modules/event";
|
||||
import { event_getListRiwayatSaya } from "@/app_modules/event/fun/get/riwayat/get_list_riwayat_saya";
|
||||
import { event_getListSemuaRiwayat } from "@/app_modules/event/fun/get/riwayat/get_list_semua_riwayat";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
let statusRiwayatId = params.id;
|
||||
|
||||
const dataSemuaRiwayat = await event_getListSemuaRiwayat({ page: 1 });
|
||||
const dataRiwayatSaya = await event_getListRiwayatSaya({ page: 1 });
|
||||
|
||||
if (statusRiwayatId == "1") {
|
||||
return (
|
||||
<>
|
||||
<Event_Riwayat
|
||||
statusId={statusRiwayatId}
|
||||
dataSemuaRiwayat={dataSemuaRiwayat as any}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
if (statusRiwayatId == "2") {
|
||||
return (
|
||||
<>
|
||||
<Event_Riwayat
|
||||
statusId={statusRiwayatId}
|
||||
dataRiwayatSaya={dataRiwayatSaya as any}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
export default async function Page() {
|
||||
return (
|
||||
<>
|
||||
<Event_Riwayat />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,25 +1,21 @@
|
||||
import { Event_StatusPage } from "@/app_modules/event";
|
||||
import {
|
||||
event_getAllByStatusId,
|
||||
event_getMasterStatus,
|
||||
event_getAllByStatusId,
|
||||
event_getMasterStatus,
|
||||
} from "@/app_modules/event/fun";
|
||||
|
||||
async function Page({ params }: { params: { id: string } }) {
|
||||
let statusId = params.id;
|
||||
const listStatus = await event_getMasterStatus();
|
||||
// let statusId = params.id;
|
||||
// const listStatus = await event_getMasterStatus();
|
||||
|
||||
const dataStatus = await event_getAllByStatusId({
|
||||
page: 1,
|
||||
statusId: statusId,
|
||||
});
|
||||
// const dataStatus = await event_getAllByStatusId({
|
||||
// page: 1,
|
||||
// statusId: statusId,
|
||||
// });
|
||||
|
||||
return (
|
||||
<>
|
||||
<Event_StatusPage
|
||||
statusId={statusId}
|
||||
dataStatus={dataStatus}
|
||||
listStatus={listStatus}
|
||||
/>
|
||||
<Event_StatusPage />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ export default function ComponentEvent_BoxListStatus({
|
||||
<Text c={MainColor.white} align="right" fz={"sm"} lineClamp={1}>
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
dateStyle: "medium",
|
||||
}).format(data.tanggal)}
|
||||
}).format(new Date(data.tanggal))}
|
||||
</Text>
|
||||
</Group>
|
||||
|
||||
|
||||
127
src/app_modules/event/component/button/api_fetch_event.ts
Normal file
127
src/app_modules/event/component/button/api_fetch_event.ts
Normal file
@@ -0,0 +1,127 @@
|
||||
export { apiGetEventByStatus, apiGetKontribusiEvent, apiGetRiwayatEvent };
|
||||
|
||||
const apiGetEventByStatus = async ({
|
||||
status,
|
||||
page,
|
||||
}: {
|
||||
status: string;
|
||||
page: string;
|
||||
}) => {
|
||||
try {
|
||||
// Fetch token from cookie
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) {
|
||||
console.error("No token found");
|
||||
return null;
|
||||
}
|
||||
|
||||
// Send PUT request to update portfolio logo
|
||||
const isPage = `?page=${page}`;
|
||||
const response = await fetch(`/api/event/status/${status}${isPage}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
|
||||
// Check if the response is OK
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json().catch(() => null);
|
||||
console.error(
|
||||
"Error updating portfolio logo:",
|
||||
errorData?.message || "Unknown error"
|
||||
);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
console.error("Error updating portfolio medsos:", error);
|
||||
throw error; // Re-throw the error to handle it in the calling function
|
||||
}
|
||||
};
|
||||
|
||||
const apiGetKontribusiEvent = async ({ page }: { page: string }) => {
|
||||
try {
|
||||
// Fetch token from cookie
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) {
|
||||
console.error("No token found");
|
||||
return null;
|
||||
}
|
||||
|
||||
// Send PUT request to update portfolio logo
|
||||
const isPage = `?page=${page}`;
|
||||
const response = await fetch(`/api/event/kontribusi${isPage}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
|
||||
// Check if the response is OK
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json().catch(() => null);
|
||||
console.error(
|
||||
"Error updating portfolio logo:",
|
||||
errorData?.message || "Unknown error"
|
||||
);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
console.error("Error updating portfolio medsos:", error);
|
||||
throw error; // Re-throw the error to handle it in the calling function
|
||||
}
|
||||
};
|
||||
|
||||
const apiGetRiwayatEvent = async ({
|
||||
name,
|
||||
page,
|
||||
}: {
|
||||
name: string;
|
||||
page: string;
|
||||
}) => {
|
||||
try {
|
||||
// Fetch token from cookie
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) {
|
||||
console.error("No token found");
|
||||
return null;
|
||||
}
|
||||
|
||||
// Send PUT request to update portfolio logo
|
||||
const isPage = `?page=${page}`;
|
||||
const response = await fetch(`/api/event/riwayat/${name}${isPage}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
|
||||
// Check if the response is OK
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json().catch(() => null);
|
||||
console.error(
|
||||
"Error updating portfolio logo:",
|
||||
errorData?.message || "Unknown error"
|
||||
);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
console.error("Error updating portfolio medsos:", error);
|
||||
throw error; // Re-throw the error to handle it in the calling function
|
||||
}
|
||||
};
|
||||
@@ -1,21 +1,19 @@
|
||||
import { IRealtimeData } from "@/lib/global_state";
|
||||
import { RouterEvent } from "@/lib/router_hipmi/router_event";
|
||||
import { MainColor } from "@/app_modules/_global/color";
|
||||
import {
|
||||
ComponentGlobal_NotifikasiBerhasil,
|
||||
ComponentGlobal_NotifikasiGagal,
|
||||
ComponentGlobal_NotifikasiPeringatan,
|
||||
} from "@/app_modules/_global/notif_global";
|
||||
import { notifikasiToAdmin_funCreate } from "@/app_modules/notifikasi/fun";
|
||||
import { IRealtimeData } from "@/lib/global_state";
|
||||
import { RouterEvent } from "@/lib/router_hipmi/router_event";
|
||||
import { Button } from "@mantine/core";
|
||||
import { useAtom } from "jotai";
|
||||
import moment from "moment";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { WibuRealtime } from "wibu-pkg";
|
||||
import { Event_funCreate } from "../../fun/create/fun_create";
|
||||
import { gs_event_hotMenu } from "../../global_state";
|
||||
import { event_checkStatus } from "../../fun/get/fun_check_status_by_id";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
|
||||
export default function Event_ComponentCreateButton({
|
||||
value,
|
||||
@@ -31,42 +29,47 @@ export default function Event_ComponentCreateButton({
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
|
||||
async function onSave() {
|
||||
try {
|
||||
setLoading(true);
|
||||
const res = await Event_funCreate(value);
|
||||
|
||||
const res = await Event_funCreate(value);
|
||||
if (res.status === 201) {
|
||||
const dataNotifikasi: IRealtimeData = {
|
||||
appId: res.data?.id as any,
|
||||
status: res.data?.EventMaster_Status?.name as any,
|
||||
userId: res.data?.authorId as any,
|
||||
pesan: res.data?.title as any,
|
||||
kategoriApp: "EVENT",
|
||||
title: "Event baru",
|
||||
};
|
||||
|
||||
if (res.status === 201) {
|
||||
const dataNotifikasi: IRealtimeData = {
|
||||
appId: res.data?.id as any,
|
||||
status: res.data?.EventMaster_Status?.name as any,
|
||||
userId: res.data?.authorId as any,
|
||||
pesan: res.data?.title as any,
|
||||
kategoriApp: "EVENT",
|
||||
title: "Event baru",
|
||||
};
|
||||
|
||||
const notif = await notifikasiToAdmin_funCreate({
|
||||
data: dataNotifikasi as any,
|
||||
});
|
||||
|
||||
if (notif.status === 201) {
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "ADMIN",
|
||||
const notif = await notifikasiToAdmin_funCreate({
|
||||
data: dataNotifikasi as any,
|
||||
});
|
||||
|
||||
WibuRealtime.setData({
|
||||
type: "trigger",
|
||||
pushNotificationTo: "ADMIN",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
if (notif.status === 201) {
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "ADMIN",
|
||||
});
|
||||
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
setHotMenu(1);
|
||||
setLoading(true);
|
||||
router.push(RouterEvent.status({ id: "2" }), { scroll: false });
|
||||
WibuRealtime.setData({
|
||||
type: "trigger",
|
||||
pushNotificationTo: "ADMIN",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
setHotMenu(1);
|
||||
router.push(RouterEvent.status({ id: "2" }), { scroll: false });
|
||||
}
|
||||
} else {
|
||||
setLoading(false);
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
} catch (error) {
|
||||
setLoading(false);
|
||||
clientLogger.error("Error create event", error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,13 +19,6 @@ export function ComponentEvent_CardRiwayat({ data }: { data: MODEL_EVENT }) {
|
||||
<>
|
||||
<ComponentGlobal_CardStyles marginBottom={"15px"}>
|
||||
<Stack>
|
||||
{/* <ComponentGlobal_AuthorNameOnHeader
|
||||
profileId={data.Author?.Profile?.id}
|
||||
imagesId={data.Author?.Profile?.imagesId}
|
||||
authorName={data.Author?.Profile?.name}
|
||||
isPembatas={true}
|
||||
/> */}
|
||||
|
||||
<ComponentGlobal_AvatarAndUsername
|
||||
profile={data.Author?.Profile as any}
|
||||
/>
|
||||
@@ -45,7 +38,7 @@ export function ComponentEvent_CardRiwayat({ data }: { data: MODEL_EVENT }) {
|
||||
<Text align="right" fz={"sm"} lineClamp={1}>
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
dateStyle: "medium",
|
||||
}).format(data.tanggal)}
|
||||
}).format(new Date(data.tanggal))}
|
||||
</Text>
|
||||
</Group>
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { RouterEvent } from "@/lib/router_hipmi/router_event";
|
||||
import { AccentColor, MainColor } from "@/app_modules/_global/color";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
||||
import { ActionIcon, Flex, Loader, Paper, Text } from "@mantine/core";
|
||||
|
||||
12
src/app_modules/event/component/list_tab_riwayat.ts
Normal file
12
src/app_modules/event/component/list_tab_riwayat.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
export const listTabsRiwayatEvent = [
|
||||
{
|
||||
id: "1",
|
||||
label: "Semua Riwayat",
|
||||
value: "semua",
|
||||
},
|
||||
{
|
||||
id: "2",
|
||||
label: "Riwayat Saya",
|
||||
value: "saya",
|
||||
},
|
||||
];
|
||||
@@ -1,26 +1,14 @@
|
||||
"use client";
|
||||
|
||||
import { Stack } from "@mantine/core";
|
||||
import { useParams, useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import ComponentEvent_DetailMainData from "../../component/detail/detail_main";
|
||||
import ComponentEvent_ListPeserta from "../../component/detail/list_peserta";
|
||||
|
||||
export default function Event_DetailRiwayat({
|
||||
totalPeserta,
|
||||
}: {
|
||||
totalPeserta: number;
|
||||
}) {
|
||||
const params = useParams<{ id: string }>();
|
||||
const eventId = params.id;
|
||||
const router = useRouter();
|
||||
const [total, setTotal] = useState(totalPeserta);
|
||||
|
||||
export default function Event_DetailRiwayat() {
|
||||
return (
|
||||
<>
|
||||
<Stack spacing={"lg"} py={"md"}>
|
||||
<ComponentEvent_DetailMainData />
|
||||
<ComponentEvent_ListPeserta eventId={eventId} total={total} />
|
||||
{/* <ComponentEvent_ListPeserta eventId={eventId} /> */}
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -6,33 +6,40 @@ import { revalidatePath } from "next/cache";
|
||||
import _ from "lodash";
|
||||
|
||||
export async function Event_funCreate(req: MODEL_EVENT) {
|
||||
const res = await prisma.event.create({
|
||||
data: {
|
||||
title: _.startCase(req.title),
|
||||
lokasi: req.lokasi,
|
||||
deskripsi: req.deskripsi,
|
||||
eventMaster_TipeAcaraId: req.eventMaster_TipeAcaraId,
|
||||
tanggal: req.tanggal,
|
||||
tanggalSelesai: req.tanggalSelesai,
|
||||
authorId: req.authorId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
EventMaster_Status: {
|
||||
select: {
|
||||
name: true,
|
||||
},
|
||||
try {
|
||||
const res = await prisma.event.create({
|
||||
data: {
|
||||
title: _.startCase(req.title),
|
||||
lokasi: req.lokasi,
|
||||
deskripsi: req.deskripsi,
|
||||
eventMaster_TipeAcaraId: req.eventMaster_TipeAcaraId,
|
||||
tanggal: req.tanggal,
|
||||
tanggalSelesai: req.tanggalSelesai,
|
||||
authorId: req.authorId,
|
||||
},
|
||||
authorId: true,
|
||||
},
|
||||
});
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
EventMaster_Status: {
|
||||
select: {
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
authorId: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!res) return { status: 400, message: "Gagal Disimpan" };
|
||||
revalidatePath("/dev/event/main/status_page");
|
||||
return {
|
||||
data: res,
|
||||
status: 201,
|
||||
message: "Berhasil Disimpan",
|
||||
};
|
||||
if (!res) return { status: 400, message: "Gagal disimpan" };
|
||||
revalidatePath("/dev/event/main/status_page");
|
||||
return {
|
||||
data: res,
|
||||
status: 201,
|
||||
message: "Berhasil disimpan",
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
status: 500,
|
||||
message: "Error create event",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,25 +2,69 @@
|
||||
|
||||
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
|
||||
import ComponentGlobal_Loader from "@/app_modules/_global/component/loader";
|
||||
import {
|
||||
Box,
|
||||
Center
|
||||
} from "@mantine/core";
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import { Box, Center, Stack } from "@mantine/core";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import _ from "lodash";
|
||||
import { ScrollOnly } from "next-scroll-loader";
|
||||
import { useState } from "react";
|
||||
import { ComponentEvent_CardKontributor } from "../../component/card_view/card_kontributor";
|
||||
import { event_getListKontibusiByUserId } from "../../fun/get/get_list_kontribusi_by_user_id";
|
||||
import { MODEL_EVENT_PESERTA } from "../../_lib/interface";
|
||||
import {
|
||||
apiGetKontribusiEvent
|
||||
} from "../../component/button/api_fetch_event";
|
||||
import { ComponentEvent_CardKontributor } from "../../component/card_view/card_kontributor";
|
||||
|
||||
export default function Event_Kontribusi({
|
||||
listKontribusi,
|
||||
}: {
|
||||
listKontribusi: MODEL_EVENT_PESERTA[];
|
||||
}) {
|
||||
const [data, setData] = useState(listKontribusi);
|
||||
export default function Event_Kontribusi() {
|
||||
const [data, setData] = useState<MODEL_EVENT_PESERTA[] | null>(null);
|
||||
const [activePage, setActivePage] = useState(1);
|
||||
|
||||
useShallowEffect(() => {
|
||||
handleLoadData();
|
||||
}, []);
|
||||
|
||||
const handleLoadData = async () => {
|
||||
try {
|
||||
const response = await apiGetKontribusiEvent({
|
||||
page: `${activePage}`,
|
||||
});
|
||||
if (response.success) {
|
||||
setData(response.data);
|
||||
} else {
|
||||
setData(null);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error get kontribusi event", error);
|
||||
setData(null);
|
||||
}
|
||||
};
|
||||
|
||||
const hanldeMoreData = async () => {
|
||||
try {
|
||||
const nextPage = activePage + 1;
|
||||
const response = await apiGetKontribusiEvent({
|
||||
page: `${nextPage}`,
|
||||
});
|
||||
if (response.success) {
|
||||
setActivePage(nextPage);
|
||||
return response.data;
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error get kontribusi event", error);
|
||||
setData(null);
|
||||
}
|
||||
};
|
||||
|
||||
if (!data)
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<CustomSkeleton height={200} width={"100%"} />
|
||||
<CustomSkeleton height={200} width={"100%"} />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
|
||||
return (
|
||||
<Box>
|
||||
{_.isEmpty(data) ? (
|
||||
@@ -35,16 +79,8 @@ export default function Event_Kontribusi({
|
||||
</Center>
|
||||
)}
|
||||
data={data}
|
||||
setData={setData}
|
||||
moreData={async () => {
|
||||
const loadData = await event_getListKontibusiByUserId({
|
||||
page: activePage + 1,
|
||||
});
|
||||
|
||||
setActivePage((val) => val + 1);
|
||||
|
||||
return loadData;
|
||||
}}
|
||||
setData={setData as any}
|
||||
moreData={hanldeMoreData}
|
||||
>
|
||||
{(item) => <ComponentEvent_CardKontributor data={item} />}
|
||||
</ScrollOnly>
|
||||
|
||||
@@ -1,55 +1,28 @@
|
||||
"use client";
|
||||
|
||||
import { Stack, Tabs } from "@mantine/core";
|
||||
import { RouterEvent } from "@/lib/router_hipmi/router_event";
|
||||
import {
|
||||
AccentColor,
|
||||
MainColor,
|
||||
MainColor
|
||||
} from "@/app_modules/_global/color/color_pallet";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { MODEL_EVENT } from "../../_lib/interface";
|
||||
import Event_RiwayatSaya from "./saya";
|
||||
import Event_SemuaRiwayat from "./semua";
|
||||
import { RouterEvent } from "@/lib/router_hipmi/router_event";
|
||||
import { Stack, Tabs } from "@mantine/core";
|
||||
import { useParams, useRouter } from "next/navigation";
|
||||
import { listTabsRiwayatEvent } from "../../component/list_tab_riwayat";
|
||||
import Event_ViewRiwayat from "./view_riwayat";
|
||||
|
||||
export default function Event_Riwayat({
|
||||
statusId,
|
||||
dataSemuaRiwayat,
|
||||
dataRiwayatSaya,
|
||||
}: {
|
||||
statusId: string;
|
||||
dataSemuaRiwayat?: MODEL_EVENT[];
|
||||
dataRiwayatSaya?: MODEL_EVENT[];
|
||||
}) {
|
||||
export default function Event_Riwayat() {
|
||||
const router = useRouter();
|
||||
const [changeStatus, setChangeStatus] = useState(statusId);
|
||||
|
||||
const listTabs = [
|
||||
{
|
||||
id: "1",
|
||||
label: "Semua Riwayat",
|
||||
value: "Semua",
|
||||
},
|
||||
{
|
||||
id: "2",
|
||||
label: "Riwayat Saya",
|
||||
value: "Saya",
|
||||
},
|
||||
];
|
||||
|
||||
async function onChangeStatus({ statusId }: { statusId: string }) {
|
||||
router.push(RouterEvent.riwayat({ id: statusId }));
|
||||
}
|
||||
const param = useParams<{ id: string }>();
|
||||
const statusId = param.id;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Tabs
|
||||
variant="pills"
|
||||
radius={"xl"}
|
||||
value={changeStatus}
|
||||
defaultValue={statusId}
|
||||
value={statusId}
|
||||
onTabChange={(val: any) => {
|
||||
setChangeStatus(val);
|
||||
onChangeStatus({ statusId: val });
|
||||
router.replace(RouterEvent.riwayat({ id: val }));
|
||||
}}
|
||||
styles={{
|
||||
tabsList: {
|
||||
@@ -62,32 +35,24 @@ export default function Event_Riwayat({
|
||||
>
|
||||
<Stack>
|
||||
<Tabs.List grow>
|
||||
{listTabs.map((e) => (
|
||||
{listTabsRiwayatEvent.map((e) => (
|
||||
<Tabs.Tab
|
||||
key={e.id}
|
||||
value={e.id}
|
||||
fw={"bold"}
|
||||
c={"black"}
|
||||
style={{
|
||||
transition: "0.5s",
|
||||
backgroundColor:
|
||||
changeStatus === e.id ? MainColor.yellow : MainColor.white,
|
||||
border:
|
||||
changeStatus === e.id
|
||||
? `1px solid ${AccentColor.yellow}`
|
||||
: `1px solid ${MainColor.white}`,
|
||||
statusId === e.id ? MainColor.yellow : MainColor.white,
|
||||
color: MainColor.darkblue,
|
||||
}}
|
||||
>
|
||||
{e.label}
|
||||
</Tabs.Tab>
|
||||
))}
|
||||
</Tabs.List>
|
||||
{statusId == "1" && (
|
||||
<Event_SemuaRiwayat listData={dataSemuaRiwayat as any} />
|
||||
)}
|
||||
{statusId == "2" && (
|
||||
<Event_RiwayatSaya listData={dataRiwayatSaya as any} />
|
||||
)}
|
||||
|
||||
<Event_ViewRiwayat />
|
||||
</Stack>
|
||||
</Tabs>
|
||||
</>
|
||||
|
||||
94
src/app_modules/event/main/riwayat/view_riwayat.tsx
Normal file
94
src/app_modules/event/main/riwayat/view_riwayat.tsx
Normal file
@@ -0,0 +1,94 @@
|
||||
"use client";
|
||||
|
||||
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import { Box, Center, Loader, Stack } from "@mantine/core";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import _ from "lodash";
|
||||
import { ScrollOnly } from "next-scroll-loader";
|
||||
import { useParams } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { MODEL_EVENT } from "../../_lib/interface";
|
||||
import {
|
||||
apiGetRiwayatEvent
|
||||
} from "../../component/button/api_fetch_event";
|
||||
import { ComponentEvent_CardRiwayat } from "../../component/card_view/card_riwayat";
|
||||
import { listTabsRiwayatEvent } from "../../component/list_tab_riwayat";
|
||||
|
||||
export default function Event_ViewRiwayat() {
|
||||
const param = useParams<{ id: string }>();
|
||||
const [data, setData] = useState<MODEL_EVENT[] | null>(null);
|
||||
const [activePage, setActivePage] = useState(1);
|
||||
|
||||
useShallowEffect(() => {
|
||||
handleLoadData();
|
||||
}, []);
|
||||
|
||||
const handleLoadData = async () => {
|
||||
try {
|
||||
const cek = listTabsRiwayatEvent.find((e) => e.id === param.id);
|
||||
const response = await apiGetRiwayatEvent({
|
||||
name: cek?.value as string,
|
||||
page: `${activePage}`,
|
||||
});
|
||||
if (response.success) {
|
||||
setData(response.data);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error get job", error);
|
||||
}
|
||||
};
|
||||
|
||||
const hanldeMoreData = async () => {
|
||||
try {
|
||||
const cek = listTabsRiwayatEvent.find((e) => e.id === param.id);
|
||||
const nextPage = activePage + 1;
|
||||
const response = await apiGetRiwayatEvent({
|
||||
name: cek?.value as string,
|
||||
page: `${activePage}`,
|
||||
});
|
||||
if (response.success) {
|
||||
setActivePage(nextPage);
|
||||
return response.data;
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error get job", error);
|
||||
}
|
||||
};
|
||||
|
||||
if (!data)
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<CustomSkeleton height={100} width={"100%"} />
|
||||
<CustomSkeleton height={100} width={"100%"} />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
{_.isEmpty(data) ? (
|
||||
<ComponentGlobal_IsEmptyData />
|
||||
) : (
|
||||
// --- Main component --- //
|
||||
<Box>
|
||||
<ScrollOnly
|
||||
height="77vh"
|
||||
renderLoading={() => (
|
||||
<Center mt={"lg"}>
|
||||
<Loader color={"yellow"} />
|
||||
</Center>
|
||||
)}
|
||||
data={data}
|
||||
setData={setData as any}
|
||||
moreData={hanldeMoreData}
|
||||
>
|
||||
{(item) => <ComponentEvent_CardRiwayat data={item} />}
|
||||
</ScrollOnly>
|
||||
</Box>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -7,28 +7,23 @@ import {
|
||||
} from "@/app_modules/_global/color/color_pallet";
|
||||
import { MODEL_NEW_DEFAULT_MASTER } from "@/app_modules/model_global/interface";
|
||||
import { Box, Stack, Tabs } from "@mantine/core";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useParams, useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import Event_StatusDraft from "./draft";
|
||||
import Event_StatusPublish from "./publish";
|
||||
import Event_StatusReject from "./reject";
|
||||
import Event_StatusReview from "./review";
|
||||
import { globalStatusApp } from "@/app_modules/_global/lib";
|
||||
import Event_ViewStatus from "./view_status";
|
||||
|
||||
export default function Event_StatusPage({
|
||||
statusId,
|
||||
dataStatus,
|
||||
listStatus,
|
||||
}: {
|
||||
statusId: string;
|
||||
dataStatus: any[];
|
||||
listStatus: MODEL_NEW_DEFAULT_MASTER[];
|
||||
}) {
|
||||
export default function Event_StatusPage() {
|
||||
// const [changeStatus, setChangeStatus] = useState(statusId);
|
||||
// async function onChangeStatus({ statusId }: { statusId: string }) {
|
||||
// router.replace(RouterEvent.status({ id: statusId }));
|
||||
// }
|
||||
const router = useRouter();
|
||||
const [changeStatus, setChangeStatus] = useState(statusId);
|
||||
|
||||
async function onChangeStatus({ statusId }: { statusId: string }) {
|
||||
router.replace(RouterEvent.status({ id: statusId }));
|
||||
}
|
||||
const param = useParams<{ id: string }>();
|
||||
const statusId = param.id;
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -36,10 +31,10 @@ export default function Event_StatusPage({
|
||||
variant="pills"
|
||||
radius="xl"
|
||||
mt={1}
|
||||
value={changeStatus}
|
||||
defaultValue={statusId}
|
||||
value={statusId}
|
||||
onTabChange={(val: any) => {
|
||||
setChangeStatus(val);
|
||||
onChangeStatus({ statusId: val });
|
||||
router.replace(RouterEvent.status({ id: val }));
|
||||
}}
|
||||
styles={{
|
||||
tabsList: {
|
||||
@@ -52,18 +47,21 @@ export default function Event_StatusPage({
|
||||
>
|
||||
<Stack>
|
||||
<Tabs.List grow>
|
||||
{listStatus.map((e) => (
|
||||
{globalStatusApp.map((e) => (
|
||||
<Tabs.Tab
|
||||
key={e.id}
|
||||
value={e.id}
|
||||
fw={"bold"}
|
||||
style={{
|
||||
transition: "0.5s",
|
||||
color: changeStatus === e.id ? MainColor.darkblue : MainColor.black,
|
||||
color:
|
||||
statusId === e.id
|
||||
? MainColor.darkblue
|
||||
: MainColor.black,
|
||||
backgroundColor:
|
||||
changeStatus === e.id ? MainColor.yellow : MainColor.white,
|
||||
statusId === e.id ? MainColor.yellow : MainColor.white,
|
||||
border:
|
||||
changeStatus === e.id
|
||||
statusId === e.id
|
||||
? `1px solid ${AccentColor.yellow}`
|
||||
: `1px solid ${MainColor.white}`,
|
||||
}}
|
||||
@@ -73,7 +71,9 @@ export default function Event_StatusPage({
|
||||
))}
|
||||
</Tabs.List>
|
||||
|
||||
<Box>
|
||||
<Event_ViewStatus/>
|
||||
|
||||
{/* <Box>
|
||||
{changeStatus === "1" && (
|
||||
<Event_StatusPublish listPublish={dataStatus} />
|
||||
)}
|
||||
@@ -86,7 +86,7 @@ export default function Event_StatusPage({
|
||||
{changeStatus === "4" && (
|
||||
<Event_StatusReject listReject={dataStatus} />
|
||||
)}
|
||||
</Box>
|
||||
</Box> */}
|
||||
</Stack>
|
||||
</Tabs>
|
||||
</>
|
||||
|
||||
111
src/app_modules/event/main/status_page/view_status.tsx
Normal file
111
src/app_modules/event/main/status_page/view_status.tsx
Normal file
@@ -0,0 +1,111 @@
|
||||
"use client";
|
||||
|
||||
import { RouterEvent } from "@/lib/router_hipmi/router_event";
|
||||
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
|
||||
import ComponentGlobal_Loader from "@/app_modules/_global/component/loader";
|
||||
import { Box, Center, Stack } from "@mantine/core";
|
||||
import _ from "lodash";
|
||||
import { ScrollOnly } from "next-scroll-loader";
|
||||
import { useState } from "react";
|
||||
import ComponentEvent_BoxListStatus from "../../component/box_list_status";
|
||||
import { event_getAllByStatusId } from "../../fun";
|
||||
import { MODEL_EVENT } from "../../_lib/interface";
|
||||
import { useParams } from "next/navigation";
|
||||
import { globalStatusApp } from "@/app_modules/_global/lib";
|
||||
import { apiGetJobByStatus } from "@/app_modules/job/component/api_fetch_job";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
import { apiGetEventByStatus } from "../../component/button/api_fetch_event";
|
||||
|
||||
export default function Event_ViewStatus() {
|
||||
const param = useParams<{ id: string }>();
|
||||
const [data, setData] = useState<any[] | null>(null);
|
||||
const [activePage, setActivePage] = useState(1);
|
||||
|
||||
useShallowEffect(() => {
|
||||
handleLoadData();
|
||||
}, []);
|
||||
|
||||
const handleLoadData = async () => {
|
||||
try {
|
||||
const cek = globalStatusApp.find((e) => e.id === param.id);
|
||||
const response = await apiGetEventByStatus({
|
||||
status: cek?.name as string,
|
||||
page: `${activePage}`,
|
||||
});
|
||||
if (response.success) {
|
||||
setData(response.data);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error get job", error);
|
||||
}
|
||||
};
|
||||
|
||||
const hanldeMoreData = async () => {
|
||||
try {
|
||||
const cek = globalStatusApp.find((e) => e.id === param.id);
|
||||
const nextPage = activePage + 1;
|
||||
const response = await apiGetEventByStatus({
|
||||
status: cek?.name as string,
|
||||
page: `${nextPage}`,
|
||||
});
|
||||
if (response.success) {
|
||||
setActivePage(nextPage);
|
||||
return response.data;
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error get job", error);
|
||||
}
|
||||
};
|
||||
|
||||
if (!data)
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<CustomSkeleton height={100} width={"100%"} />
|
||||
<CustomSkeleton height={100} width={"100%"} />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
{_.isEmpty(data) ? (
|
||||
<ComponentGlobal_IsEmptyData />
|
||||
) : (
|
||||
// --- Main component --- //
|
||||
<Box>
|
||||
<ScrollOnly
|
||||
height="75vh"
|
||||
renderLoading={() => (
|
||||
<Center mt={"lg"}>
|
||||
<ComponentGlobal_Loader size={25} />
|
||||
</Center>
|
||||
)}
|
||||
data={data}
|
||||
setData={setData as any}
|
||||
moreData={hanldeMoreData}
|
||||
>
|
||||
{(item) => (
|
||||
<ComponentEvent_BoxListStatus
|
||||
data={item}
|
||||
path={
|
||||
param.id == "1"
|
||||
? RouterEvent.detail_publish
|
||||
: param.id == "2"
|
||||
? RouterEvent.detail_review
|
||||
: param.id == "3"
|
||||
? RouterEvent.detail_draft
|
||||
: param.id == "4"
|
||||
? RouterEvent.detail_reject
|
||||
: ""
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</ScrollOnly>
|
||||
</Box>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -10,7 +10,7 @@ export const apiGetUserSearch = async ({
|
||||
|
||||
const isPage = page ? `?page=${page}` : "";
|
||||
const isSearch = search ? `&search=${search}` : "";
|
||||
console.log("page", page);
|
||||
|
||||
const response = await fetch(`/api/user${isPage}${isSearch}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
|
||||
@@ -29,7 +29,7 @@ const middlewareConfig: MiddlewareConfig = {
|
||||
"/api/logs/*",
|
||||
"/api/auth/*",
|
||||
"/api/origin-url",
|
||||
"/api/event/*",
|
||||
// "/api/event/*",
|
||||
|
||||
// ADMIN API
|
||||
// >> buat dibawah sini <<
|
||||
@@ -120,6 +120,33 @@ export const middleware = async (req: NextRequest) => {
|
||||
return setCorsHeaders(response);
|
||||
}
|
||||
|
||||
// Handle API requests
|
||||
if (pathname.startsWith(apiPath)) {
|
||||
|
||||
if (!token) {
|
||||
return setCorsHeaders(unauthorizedResponse());
|
||||
}
|
||||
|
||||
try {
|
||||
const validationResponse = await fetch(
|
||||
new URL(validationApiRoute, req.url),
|
||||
{
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (!validationResponse.ok) {
|
||||
throw new Error("Failed to validate API request");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error validating API request:", error);
|
||||
return setCorsHeaders(unauthorizedResponse());
|
||||
}
|
||||
}
|
||||
|
||||
// Handle /dev routes that require active status
|
||||
if (pathname.startsWith("/dev")) {
|
||||
try {
|
||||
@@ -153,32 +180,6 @@ export const middleware = async (req: NextRequest) => {
|
||||
}
|
||||
}
|
||||
|
||||
// Handle API requests
|
||||
if (pathname.startsWith(apiPath)) {
|
||||
if (!token) {
|
||||
return setCorsHeaders(unauthorizedResponse());
|
||||
}
|
||||
|
||||
try {
|
||||
const validationResponse = await fetch(
|
||||
new URL(validationApiRoute, req.url),
|
||||
{
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (!validationResponse.ok) {
|
||||
throw new Error("Failed to validate API request");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error validating API request:", error);
|
||||
return setCorsHeaders(unauthorizedResponse());
|
||||
}
|
||||
}
|
||||
|
||||
const response = NextResponse.next();
|
||||
// Ensure token is preserved in cookie
|
||||
if (token) {
|
||||
|
||||
Reference in New Issue
Block a user