diff --git a/src/app/api/admin/collaboration/[id]/report/route.ts b/src/app/api/admin/collaboration/[id]/report/route.ts
new file mode 100644
index 00000000..9520aac0
--- /dev/null
+++ b/src/app/api/admin/collaboration/[id]/report/route.ts
@@ -0,0 +1,57 @@
+import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
+import backendLogger from "@/util/backendLogger";
+import { NextResponse } from "next/server";
+import prisma from "@/lib/prisma";
+import { revalidatePath } from "next/cache";
+import { RouterAdminColab } from "@/lib/router_admin/router_admin_colab";
+
+export async function GET(req: Request, { params }: { params: { id: string, report: string } }) {
+ try {
+ const { id } = params
+ const userLoginId = await funGetUserIdByToken();
+ const data = await prisma.projectCollaboration.update({
+ where: {
+ id: params.id
+ },
+ data: {
+ isActive: false,
+ isReject: true,
+ report: params.report
+ },
+ select: {
+ userId: true,
+ }
+ })
+ if (!data) return { status: 400, message: "Gagal update project" };
+
+ const updateReport = await prisma.projectCollaboration_Notifikasi.create({
+ data: {
+ projectCollaborationId: params.id,
+ adminId: userLoginId as string,
+ userId: data.userId as any,
+ note: "Project Anda Telah Direport Admin",
+ },
+ });
+
+ if (!updateReport) return { status: 400, message: "Gagal update notifikasi" };
+
+ revalidatePath(RouterAdminColab.table_publish);
+
+ return NextResponse.json({
+ success: true,
+ message: "Project berhasil direport",
+ data: updateReport,
+ },
+ { status: 200 }
+ )
+ } catch (error) {
+ backendLogger.error("Error get data collaboration report >>", error);
+ return NextResponse.json({
+ success: false,
+ message: "Error get data collaboration report",
+ reason: (error as Error).message
+ },
+ { status: 500 }
+ )
+ }
+}
\ No newline at end of file
diff --git a/src/app/api/admin/collaboration/[id]/route.ts b/src/app/api/admin/collaboration/[id]/route.ts
new file mode 100644
index 00000000..3a912a16
--- /dev/null
+++ b/src/app/api/admin/collaboration/[id]/route.ts
@@ -0,0 +1,66 @@
+import prisma from "@/lib/prisma";
+import backendLogger from "@/util/backendLogger";
+import { NextResponse } from "next/server";
+
+export async function GET(req: Request, { params }: { params: { id: string } }) {
+ try {
+ const { id } = params;
+ const data = await prisma.projectCollaboration.findUnique({
+ where: {
+ id: id
+ },
+ select: {
+ id: true,
+ isActive: true,
+ title: true,
+ lokasi: true,
+ purpose: true,
+ benefit: true,
+ createdAt: true,
+ Author: {
+ select: {
+ id: true,
+ username: true,
+ },
+ },
+ ProjectCollaborationMaster_Industri: true,
+ ProjectCollaboration_Partisipasi: {
+ where: {
+ User: {
+ active: true,
+ },
+ },
+ select: {
+ id: true,
+ User: {
+ select: {
+ id: true,
+ Profile: {
+ select: {
+ name: true,
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ });
+ return NextResponse.json({
+ success: true,
+ message: "Success get collaboration",
+ data: data
+ },
+ { status: 200 }
+ )
+ } catch (error) {
+ backendLogger.error("Error get collaboration >>", error);
+ return NextResponse.json({
+ success: false,
+ message: "Error get collaboration",
+ reason: (error as Error).message
+ },
+ { status: 500 }
+ )
+ }
+}
\ No newline at end of file
diff --git a/src/app/api/admin/collaboration/status/[name]/route.ts b/src/app/api/admin/collaboration/status/publish/route.ts
similarity index 96%
rename from src/app/api/admin/collaboration/status/[name]/route.ts
rename to src/app/api/admin/collaboration/status/publish/route.ts
index e61ab5d6..3bf71a30 100644
--- a/src/app/api/admin/collaboration/status/[name]/route.ts
+++ b/src/app/api/admin/collaboration/status/publish/route.ts
@@ -3,20 +3,15 @@ import backendLogger from "@/util/backendLogger";
import _ from "lodash";
import { NextResponse } from "next/server";
-export async function GET(request: Request, { params }:
- { params: { name: string } }
-) {
+export async function GET(request: Request) {
-
- const { name } = params;
const { searchParams } = new URL(request.url);
const page = searchParams.get("page");
const takeData = 10;
const skipData = Number(page) * takeData - takeData;
-
+
try {
let fixData;
- const fixStatus = _.startCase(name);
if (!page) {
fixData = await prisma.projectCollaboration.findMany({
@@ -30,6 +25,7 @@ export async function GET(request: Request, { params }:
active: true,
},
+
},
select: {
id: true,
diff --git a/src/app/api/admin/collaboration/status/reject/route.ts b/src/app/api/admin/collaboration/status/reject/route.ts
new file mode 100644
index 00000000..7d43e265
--- /dev/null
+++ b/src/app/api/admin/collaboration/status/reject/route.ts
@@ -0,0 +1,143 @@
+import { prisma } from "@/lib";
+import backendLogger from "@/util/backendLogger";
+import _ from "lodash";
+import { NextResponse } from "next/server";
+
+export async function GET(request: Request) {
+
+ const { searchParams } = new URL(request.url);
+ const page = searchParams.get("page");
+ const takeData = 10;
+ const skipData = Number(page) * takeData - takeData;
+
+ try {
+ let fixData;
+
+
+ if (!page) {
+ fixData = await prisma.projectCollaboration.findMany({
+ orderBy: {
+ createdAt: "desc",
+ },
+ where: {
+ isActive: false,
+ isReject: true,
+ Author: {
+ active: true,
+ },
+
+
+ },
+ select: {
+ id: true,
+ createdAt: true,
+ isActive: true,
+ title: true,
+ Author: {
+ select: {
+ id: true,
+ username: true,
+ Profile: true,
+ },
+ },
+ projectCollaborationMaster_IndustriId: true,
+ ProjectCollaborationMaster_Industri: true,
+ ProjectCollaboration_Partisipasi: {
+ where: {
+ User: {
+ active: true,
+ },
+ },
+ // select: {
+ // User: {
+ // select: {
+ // id: true,
+ // username: true,
+ // Profile: true,
+ // },
+ // },
+ // },
+ },
+ },
+ });
+ } else {
+ const data = await prisma.projectCollaboration.findMany({
+ skip: skipData,
+ take: takeData,
+ orderBy: {
+ createdAt: "desc",
+ },
+ where: {
+ isActive: false,
+ isReject: true,
+ Author: {
+ active: true,
+ },
+ },
+ select: {
+ id: true,
+ createdAt: true,
+ isActive: true,
+ title: true,
+ Author: {
+ select: {
+ id: true,
+ username: true,
+ Profile: true,
+ },
+ },
+ projectCollaborationMaster_IndustriId: true,
+ ProjectCollaborationMaster_Industri: true,
+ ProjectCollaboration_Partisipasi: {
+ where: {
+ User: {
+ active: true,
+ },
+ },
+ // select: {
+ // User: {
+ // select: {
+ // id: true,
+ // username: true,
+ // Profile: true,
+ // },
+ // },
+ // },
+ },
+ },
+ });
+
+ const nCount = await prisma.projectCollaboration.count({
+ where: {
+ isActive: false,
+ isReject: true,
+ Author: {
+ active: true,
+ },
+ },
+ });
+
+ fixData = {
+ data: data,
+ nPage: _.ceil(nCount / takeData),
+ }
+ }
+
+ return NextResponse.json({
+ success: true,
+ message: "Success get data collaboration dashboard",
+ data: fixData,
+ },
+ { status: 200 }
+ );
+ } catch (error) {
+ backendLogger.error("Error get data collaboration dashboard >>", error);
+ return NextResponse.json({
+ success: false,
+ message: "Error get data collaboration dashboard",
+ reason: (error as Error).message
+ },
+ { status: 500 }
+ )
+ }
+}
\ No newline at end of file
diff --git a/src/app/dev/admin/colab/detail/publish/[id]/page.tsx b/src/app/dev/admin/colab/detail/publish/[id]/page.tsx
new file mode 100644
index 00000000..aad0ff7a
--- /dev/null
+++ b/src/app/dev/admin/colab/detail/publish/[id]/page.tsx
@@ -0,0 +1,12 @@
+import DetailPublish from '@/app_modules/admin/colab/detail/detail_publish';
+import React from 'react';
+
+function Page() {
+ return (
+ <>
+
+ >
+ );
+}
+
+export default Page;
diff --git a/src/app/dev/admin/colab/sub-menu/publish/page.tsx b/src/app/dev/admin/colab/sub-menu/publish/page.tsx
index 902b50c3..b177e938 100644
--- a/src/app/dev/admin/colab/sub-menu/publish/page.tsx
+++ b/src/app/dev/admin/colab/sub-menu/publish/page.tsx
@@ -2,11 +2,9 @@ import { AdminColab_TablePublish } from "@/app_modules/admin/colab";
import adminColab_getListAllPublish from "@/app_modules/admin/colab/fun/get/get_list_all_publish";
export default async function Page() {
- const listData = await adminColab_getListAllPublish({ page: 1 });
-
return (
<>
-
+
>
);
}
diff --git a/src/app/dev/admin/colab/sub-menu/reject/page.tsx b/src/app/dev/admin/colab/sub-menu/reject/page.tsx
index 11e5c047..898b9f62 100644
--- a/src/app/dev/admin/colab/sub-menu/reject/page.tsx
+++ b/src/app/dev/admin/colab/sub-menu/reject/page.tsx
@@ -2,11 +2,11 @@ import { AdminColab_TableRejected } from "@/app_modules/admin/colab";
import adminColab_getListAllRejected from "@/app_modules/admin/colab/fun/get/get_list_all_reject";
export default async function Page() {
- const listReject = await adminColab_getListAllRejected({page: 1})
+
return (
<>
-
+
>
);
}
\ No newline at end of file
diff --git a/src/app/dev/admin/investasi/detail/publish/[id]/page.tsx b/src/app/dev/admin/investasi/detail/publish/[id]/page.tsx
index 7d8582cd..53c5ac52 100644
--- a/src/app/dev/admin/investasi/detail/publish/[id]/page.tsx
+++ b/src/app/dev/admin/investasi/detail/publish/[id]/page.tsx
@@ -6,13 +6,8 @@ import {
} from "@/app_modules/admin/investasi/fun";
import getOneInvestasiById from "@/app_modules/investasi/fun/get_one_investasi_by_id";
-export default async function Page({ params }: { params: { id: string } }) {
- const investasiId = params.id;
- const statusTransaksi = await adminInvestasi_getStatusInvestasi();
- const dataTransaksi = await adminInvestasi_funGetAllTransaksiById({
- investasiId,
- page: 1,
- });
+export default async function Page() {
+
// export default async function Page({ params }: { params: { id: string } }) {
// const investasiId = params.id;
// const dataInvestasi = await getOneInvestasiById(investasiId);
@@ -24,8 +19,7 @@ export default async function Page({ params }: { params: { id: string } }) {
return (
<>
-
>
);
diff --git a/src/app_modules/admin/colab/detail/detail_group.tsx b/src/app_modules/admin/colab/detail/detail_group.tsx
new file mode 100644
index 00000000..320640de
--- /dev/null
+++ b/src/app_modules/admin/colab/detail/detail_group.tsx
@@ -0,0 +1,11 @@
+import React from 'react';
+
+function DetailGroup() {
+ return (
+
+ DetailGroup
+
+ );
+}
+
+export default DetailGroup;
diff --git a/src/app_modules/admin/colab/detail/detail_publish.tsx b/src/app_modules/admin/colab/detail/detail_publish.tsx
new file mode 100644
index 00000000..e738bbf9
--- /dev/null
+++ b/src/app_modules/admin/colab/detail/detail_publish.tsx
@@ -0,0 +1,173 @@
+'use client';
+import React, { useState } from 'react';
+import AdminGlobal_ComponentBackButton from '../../_admin_global/back_button';
+import { Button, Flex, Grid, Group, Modal, Paper, Stack, Text, Textarea, Title } from '@mantine/core';
+import { useParams } from 'next/navigation';
+import { MODEL_COLLABORATION } from '@/app_modules/colab/model/interface';
+import { useShallowEffect } from '@mantine/hooks';
+import { clientLogger } from '@/util/clientLogger';
+import { apiGetAdminCollaborationById } from '../lib/api_fetch_admin_collaboration';
+import { AdminColor } from '@/app_modules/_global/color/color_pallet';
+import CustomSkeleton from '@/app_modules/components/CustomSkeleton';
+import { ComponentGlobal_NotifikasiPeringatan } from '@/app_modules/_global/notif_global';
+import { IconCheck } from '@tabler/icons-react';
+
+function DetailPublish() {
+ const params = useParams<{ id: string }>();
+ const [data, setData] = useState(null);
+ const [loading, setLoading] = useState(false);
+ const [openReject, setOpenReject] = useState(false);
+
+ useShallowEffect(() => {
+ loadInitialData();
+ }, [])
+
+ const loadInitialData = async () => {
+ try {
+ const response = await apiGetAdminCollaborationById({
+ id: params.id,
+ })
+
+ if (response?.success && response?.data) {
+ setData(response.data);
+ }
+
+ } catch (error) {
+ clientLogger.error("Invalid data format recieved:", error);
+ setData(null);
+ }
+ }
+
+ async function onReject() {
+ try {
+ const response = await apiGetAdminCollaborationById({
+ id: params.id,
+ })
+
+ if (response?.success && response?.data) {
+ setOpenReject(true)
+ setData(response.data);
+ setLoading(false)
+ }
+ } catch (error) {
+ ComponentGlobal_NotifikasiPeringatan("Gagal Load");
+ clientLogger.error("Invalid data format recieved:", error);
+ setData(null);
+ }
+ }
+
+ return (
+ <>
+
+
+
+
+
+ {!data ? () : (
+
+ Detail Publish
+
+
+
+ Username:
+
+
+ {data?.Author?.username}
+
+
+
+
+ Title:
+
+
+ @{data?.title}
+
+
+
+
+ Industri:
+
+
+ + {data?.ProjectCollaborationMaster_Industri.name}
+
+
+
+
+ Jumlah Partisipan:
+
+
+ {data?.ProjectCollaboration_Partisipasi.length}
+
+
+
+
+ Lokasi:
+
+
+ {data?.lokasi}
+
+
+
+
+ Tujuan Proyek:
+
+
+ {data?.purpose}
+
+
+
+
+ Keuntungan:
+
+
+ {data?.benefit}
+
+
+
+
+ )}
+
+
+ {/* Reject Project */}
+ setOpenReject(false)}
+ centered
+ withCloseButton={false}
+ size={"lg"}
+ >
+
+
+
+ Apakah anda yakin ingin mereport project{" "}
+
+ {data?.title}
+
+ ?
+ {" "}
+
+
+
+ >
+ );
+}
+
+export default DetailPublish;
+
diff --git a/src/app_modules/admin/colab/lib/api_fetch_admin_collaboration.ts b/src/app_modules/admin/colab/lib/api_fetch_admin_collaboration.ts
index 4390515b..33306ebe 100644
--- a/src/app_modules/admin/colab/lib/api_fetch_admin_collaboration.ts
+++ b/src/app_modules/admin/colab/lib/api_fetch_admin_collaboration.ts
@@ -1,7 +1,9 @@
export {
apiGetAdminCollaborationStatusCountDashboard,
- apiGetAdminCollaborationStatusById,
- apiGetAdminCollaborationRoomById
+ apiGetAdminCollaborationPublish,
+ apiGetAdminCollaborationReject,
+ apiGetAdminCollaborationRoomById,
+ apiGetAdminCollaborationById
}
const apiGetAdminCollaborationStatusCountDashboard = async ({
@@ -25,8 +27,7 @@ const apiGetAdminCollaborationStatusCountDashboard = async ({
// console.log("Ini Response", await response.json());
return await response.json().catch(() => null);
}
-const apiGetAdminCollaborationStatusById = async ({ name, page}: {
- name: "Publish" | "Reject",
+const apiGetAdminCollaborationPublish = async ({ page }: {
page: string,
}) => {
@@ -35,7 +36,28 @@ const apiGetAdminCollaborationStatusById = async ({ name, page}: {
if (!token) return await token.json().catch(() => null);
const isPage = page ? `?page=${page}` : "";
- const response = await fetch(`/api/admin/collaboration/${name}${isPage}`, {
+ const response = await fetch(`/api/admin/collaboration/status/publish/${isPage}`, {
+ headers: {
+ "Content-Type": "application/json",
+ Accept: "application/json",
+ "Access-Control-Allow-Origin": "*",
+ Authorization: `Bearer ${token}`,
+ }
+ })
+
+ return await response.json().catch(() => null);
+}
+
+const apiGetAdminCollaborationReject = async ({ page }: {
+ page: string,
+
+}) => {
+
+ const { token } = await fetch("/api/get-cookie").then((res) => res.json());
+ if (!token) return await token.json().catch(() => null);
+
+ const isPage = page ? `?page=${page}` : "";
+ const response = await fetch(`/api/admin/collaboration/status/reject/${isPage}`, {
headers: {
"Content-Type": "application/json",
Accept: "application/json",
@@ -68,3 +90,19 @@ const apiGetAdminCollaborationRoomById = async ({ page, search }: {
return await response.json().catch(() => null);
}
+const apiGetAdminCollaborationById = async ({id} : {id: string}) => {
+ const { token } = await fetch("/api/get-cookie").then((res) => res.json());
+ if (!token) return await token.json().catch(() => null);
+
+ const response = await fetch(`/api/admin/collaboration/${id}`, {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ Accept: "application/json",
+ "Access-Control-Allow-Origin": "*",
+ Authorization: `Bearer ${token}`,
+ }
+ })
+ return await response.json().catch(() => null);
+}
+
diff --git a/src/app_modules/admin/colab/sub_menu/publish.tsx b/src/app_modules/admin/colab/sub_menu/publish.tsx
index 93af3c22..cfa20feb 100644
--- a/src/app_modules/admin/colab/sub_menu/publish.tsx
+++ b/src/app_modules/admin/colab/sub_menu/publish.tsx
@@ -31,179 +31,144 @@ import { IconBan, IconCheck, IconEye } from "@tabler/icons-react";
import adminColab_funReportProjectById from "../fun/edit/fun_report_project_by_id";
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
+import { useRouter } from "next/navigation";
-export default function AdminColab_TablePublish({
- listData,
-}: {
- listData: any;
-}) {
+import { clientLogger } from "@/util/clientLogger";
+import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
+import { apiGetAdminCollaborationPublish } from "../lib/api_fetch_admin_collaboration";
+import { RouterAdminColab } from "@/lib/router_admin/router_admin_colab";
+
+export default function AdminColab_TablePublish() {
return (
<>
-
+
{/* {JSON.stringify(listData.nPage, null, 2)} */}
>
);
}
-function TableMenu({ listData }: { listData: any }) {
- const [data, setData] = useState(listData.data);
- const [isNPage, setNPage] = useState(listData.nPage);
+function TableMenu() {
+ const router = useRouter();
+ const [data, setData] = useState(null);
+ const [isNPage, setNPage] = useState(1);
const [activePage, setActivePage] = useState(1);
+ const [idData, setIdData] = useState("");
+ const [isLoading, setLoading] = useState(false);
- const [idProject, setIdProject] = useState("");
- const [openDetail, setOpenDetail] = useState(false);
- const [loadingDetail, setLoadingDetail] = useState(false);
- const [detailData, setDetailData] = useState();
+ useShallowEffect(() => {
+ loadInitialData();
+ }, [activePage]);
- const [openReject, setOpenReject] = useState(false);
- const [report, setReport] = useState("");
- const [loadingReject, setLoadingReject] = useState(false);
- const [loadingReport, setLoadingReport] = useState(false);
+ const loadInitialData = async () => {
+ try {
+ const response = await apiGetAdminCollaborationPublish({
+ page: `${activePage}`,
+ })
+ console.log("Ini Response", response)
- // PAGINATION dan No awal data di tampilkan
- let noAwal = activePage * 5 - 4;
- async function onLoad(pindahPage: any) {
- const load = await adminColab_getListAllPublish({ page: pindahPage });
- setActivePage(pindahPage);
- setData(load.data as any);
- setNPage(load.nPage);
+ if (response?.success && response?.data?.data) {
+ setData(response.data.data);
+ setNPage(response.data.nPage || 1);
+ } else {
+ console.error("Invalid data format recieved", response);
+ setData([])
+ }
+ } catch (error) {
+ clientLogger.error("Invalid data table publish", error);
+ setData([]);
+ }
}
- // Table Body
- const tableRow = data.map((e, i) => (
-
- |
- {noAwal++}
- |
-
-
- {e?.Author?.Profile?.name}
-
- |
-
-
-
-
- {e?.title}
+ const onPageCLick = (page: number) => {
+ setActivePage(page);
+ }
+
+ const renderTableBody = () => {
+ if (!Array.isArray(data) || data.length === 0) {
+ return (
+
+ |
+
+ Tidak ada data
-
-
- |
-
-
- {e?.ProjectCollaborationMaster_Industri.name}
-
- |
-
-
- {e?.ProjectCollaboration_Partisipasi.length}
-
- |
-
-
-
+ |
+
+ )
+ }
+
+ return data.map((e, i) => (
+
+ |
+
+ {e?.Author?.Profile?.name}
+
+ |
+
+
+
+
+ {e?.title}
+
+
+
+ |
+
+
+ {e?.ProjectCollaborationMaster_Industri.name}
+
+ |
+
+
+ {e?.ProjectCollaboration_Partisipasi.length}
+
+ |
+
+
}
loaderPosition="center"
radius={"xl"}
color="green"
onClick={() => {
- getDetailData(e.id);
+ setLoading(true);
+ setIdData(e?.id);
+ router.push(RouterAdminColab.detail_publish + `${e?.id}`);
}}
>
Detail
- }
- loaderPosition="center"
- radius={"xl"}
- color="red"
- onClick={() => {
- onRejected(e.id);
- }}
- >
- Reject
-
-
-
- |
-
- ));
-
- // Menampilkan Detail Data
- async function getDetailData(colabId: any) {
- setLoadingDetail(true);
- setIdProject(colabId);
-
- await adminColab_getOneByColabId({ id: colabId }).then((res) => {
- if (res.status === 200) {
- setDetailData(res.data as any);
- setOpenDetail(true);
- setLoadingDetail(false);
- } else {
- ComponentGlobal_NotifikasiPeringatan("Gagal Load");
- }
- });
+
+ |
+
+ ));
}
- // Menampilkan Data Title yang akan di REJECT
- async function onRejected(colabId: string) {
- setLoadingReject(true);
- setIdProject(colabId);
+ // async function onReport() {
+ // if (report === "")
+ // return ComponentGlobal_NotifikasiPeringatan("Lengkapi Alasan Report");
- await adminColab_getOneByColabId({ id: colabId }).then((res) => {
- if (res.status === 200) {
- const selectedData = _.omit(res.data, [
- "Author",
- "ProjectCollaborationMaster_Industri",
- "ProjectCollaboration_Partisipasi",
- "benefit",
- "createdAt",
- "purpose",
- "lokasi",
- ]);
+ // await adminColab_funReportProjectById({
+ // colabId: idData,
+ // report: report,
+ // }).then(async (res) => {
+ // if (res.status === 200) {
+ // const newData = await adminColab_getListAllPublish({
+ // page: activePage,
+ // });
- setDetailData(selectedData as any);
- setOpenReject(true);
- setLoadingReject(false);
- } else {
- ComponentGlobal_NotifikasiPeringatan("Gagal Load");
- }
- });
- }
-
- // Update status report pada project
- async function onReport() {
- if (report === "")
- return ComponentGlobal_NotifikasiPeringatan("Lengkapi Alasan Report");
-
- await adminColab_funReportProjectById({
- colabId: idProject,
- report: report,
- }).then(async (res) => {
- if (res.status === 200) {
- const newData = await adminColab_getListAllPublish({
- page: activePage,
- });
-
- setActivePage(activePage);
- setData(newData.data as any);
- setNPage(newData.nPage);
- setOpenReject(false);
- ComponentGlobal_NotifikasiBerhasil(res.message);
- } else {
- ComponentGlobal_NotifikasiPeringatan(res.message);
- }
- });
- }
+ // setActivePage(activePage);
+ // setData(newData.data as any);
+ // setNPage(newData.nPage);
+ // setOpenReject(false);
+ // ComponentGlobal_NotifikasiBerhasil(res.message);
+ // } else {
+ // ComponentGlobal_NotifikasiPeringatan(res.message);
+ // }
+ // });
+ // }
return (
<>
@@ -217,101 +182,52 @@ function TableMenu({ listData }: { listData: any }) {
>
Publish
-
-
-
-
-
-
- |
- No
- |
-
- Username
- |
-
- Title
- |
-
- Industri
- |
-
- Jumlah Partisipan
- |
-
- Aksi
- |
-
-
- {tableRow}
-
-
- {
- onLoad(val);
- }}
- />
-
-
+ {!data ? (
+
+ ) : (
+
+
+
+
+
+
+ |
+ Username
+ |
+
+ Title
+ |
+
+ Industri
+ |
+
+ Jumlah Partisipan
+ |
+
+ Aksi
+ |
+
+
+ {renderTableBody()}
+
+
+ {
+ onPageCLick(val);
+ }}
+ />
+
+
+ )}
-
- {/* Detail Data */}
- setOpenDetail(false)}
- centered
- withCloseButton={false}
- size={"lg"}
- >
-
-
-
-
-
- {/* Reject Project */}
- setOpenReject(false)}
- centered
- withCloseButton={false}
- size={"lg"}
- >
-
-
-
- Apakah anda yakin ingin mereport project{" "}
-
- {detailData?.title}
-
- ?
- {" "}
-
-
-
>
);
}
diff --git a/src/app_modules/admin/colab/sub_menu/publish.txt b/src/app_modules/admin/colab/sub_menu/publish.txt
new file mode 100644
index 00000000..80a6b327
--- /dev/null
+++ b/src/app_modules/admin/colab/sub_menu/publish.txt
@@ -0,0 +1,317 @@
+"use client";
+
+import {
+ Stack,
+ Group,
+ Title,
+ Paper,
+ ScrollArea,
+ Table,
+ Center,
+ Text,
+ Badge,
+ Spoiler,
+ Pagination,
+ Button,
+ Modal,
+ TextInput,
+ Textarea,
+ Box,
+} from "@mantine/core";
+import ComponentAdminGlobal_HeaderTamplate from "../../_admin_global/header_tamplate";
+import { MODEL_COLLABORATION } from "@/app_modules/colab/model/interface";
+import { useState } from "react";
+import { useDisclosure, useShallowEffect } from "@mantine/hooks";
+import adminColab_getListAllPublish from "../fun/get/get_list_all_publish";
+import ComponentAdminColab_DetailData from "../component/detail_data";
+import adminColab_getOneByColabId from "../fun/get/get_one_by_colab_id";
+import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
+import _ from "lodash";
+import { IconBan, IconCheck, IconEye } from "@tabler/icons-react";
+import adminColab_funReportProjectById from "../fun/edit/fun_report_project_by_id";
+import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
+import { AdminColor } from "@/app_modules/_global/color/color_pallet";
+
+export default function AdminColab_TablePublish({
+ listData,
+}: {
+ listData: any;
+}) {
+ return (
+ <>
+
+
+
+ {/* {JSON.stringify(listData.nPage, null, 2)} */}
+
+ >
+ );
+}
+function TableMenu({ listData }: { listData: any }) {
+ const [data, setData] = useState(listData.data);
+ const [isNPage, setNPage] = useState(listData.nPage);
+ const [activePage, setActivePage] = useState(1);
+
+ const [idProject, setIdProject] = useState("");
+ const [openDetail, setOpenDetail] = useState(false);
+ const [loadingDetail, setLoadingDetail] = useState(false);
+ const [detailData, setDetailData] = useState();
+
+ const [openReject, setOpenReject] = useState(false);
+ const [report, setReport] = useState("");
+ const [loadingReject, setLoadingReject] = useState(false);
+ const [loadingReport, setLoadingReport] = useState(false);
+
+ // PAGINATION dan No awal data di tampilkan
+ let noAwal = activePage * 5 - 4;
+ async function onLoad(pindahPage: any) {
+ const load = await adminColab_getListAllPublish({ page: pindahPage });
+ setActivePage(pindahPage);
+ setData(load.data as any);
+ setNPage(load.nPage);
+ }
+
+ // Table Body
+ const tableRow = data.map((e, i) => (
+
+ |
+ {noAwal++}
+ |
+
+
+ {e?.Author?.Profile?.name}
+
+ |
+
+
+
+
+ {e?.title}
+
+
+
+ |
+
+
+ {e?.ProjectCollaborationMaster_Industri.name}
+
+ |
+
+
+ {e?.ProjectCollaboration_Partisipasi.length}
+
+ |
+
+
+
+ }
+ loaderPosition="center"
+ radius={"xl"}
+ color="green"
+ onClick={() => {
+ getDetailData(e.id);
+ }}
+ >
+ Detail
+
+ }
+ loaderPosition="center"
+ radius={"xl"}
+ color="red"
+ onClick={() => {
+ onRejected(e.id);
+ }}
+ >
+ Reject
+
+
+
+ |
+
+ ));
+
+ // Menampilkan Detail Data
+ async function getDetailData(colabId: any) {
+ setLoadingDetail(true);
+ setIdProject(colabId);
+
+ await adminColab_getOneByColabId({ id: colabId }).then((res) => {
+ if (res.status === 200) {
+ setDetailData(res.data as any);
+ setOpenDetail(true);
+ setLoadingDetail(false);
+ } else {
+ ComponentGlobal_NotifikasiPeringatan("Gagal Load");
+ }
+ });
+ }
+
+ // Menampilkan Data Title yang akan di REJECT
+ async function onRejected(colabId: string) {
+ setLoadingReject(true);
+ setIdProject(colabId);
+
+ await adminColab_getOneByColabId({ id: colabId }).then((res) => {
+ if (res.status === 200) {
+ const selectedData = _.omit(res.data, [
+ "Author",
+ "ProjectCollaborationMaster_Industri",
+ "ProjectCollaboration_Partisipasi",
+ "benefit",
+ "createdAt",
+ "purpose",
+ "lokasi",
+ ]);
+
+ setDetailData(selectedData as any);
+ setOpenReject(true);
+ setLoadingReject(false);
+ } else {
+ ComponentGlobal_NotifikasiPeringatan("Gagal Load");
+ }
+ });
+ }
+
+ // Update status report pada project
+ async function onReport() {
+ if (report === "")
+ return ComponentGlobal_NotifikasiPeringatan("Lengkapi Alasan Report");
+
+ await adminColab_funReportProjectById({
+ colabId: idProject,
+ report: report,
+ }).then(async (res) => {
+ if (res.status === 200) {
+ const newData = await adminColab_getListAllPublish({
+ page: activePage,
+ });
+
+ setActivePage(activePage);
+ setData(newData.data as any);
+ setNPage(newData.nPage);
+ setOpenReject(false);
+ ComponentGlobal_NotifikasiBerhasil(res.message);
+ } else {
+ ComponentGlobal_NotifikasiPeringatan(res.message);
+ }
+ });
+ }
+
+ return (
+ <>
+
+
+ Publish
+
+
+
+
+
+
+
+ |
+ No
+ |
+
+ Username
+ |
+
+ Title
+ |
+
+ Industri
+ |
+
+ Jumlah Partisipan
+ |
+
+ Aksi
+ |
+
+
+ {tableRow}
+
+
+ {
+ onLoad(val);
+ }}
+ />
+
+
+
+
+ {/* Detail Data */}
+ setOpenDetail(false)}
+ centered
+ withCloseButton={false}
+ size={"lg"}
+ >
+
+
+
+
+
+ {/* Reject Project */}
+ setOpenReject(false)}
+ centered
+ withCloseButton={false}
+ size={"lg"}
+ >
+
+
+
+ Apakah anda yakin ingin mereport project{" "}
+
+ {detailData?.title}
+
+ ?
+ {" "}
+
+
+
+ >
+ );
+}
\ No newline at end of file
diff --git a/src/app_modules/admin/colab/sub_menu/reject.tsx b/src/app_modules/admin/colab/sub_menu/reject.tsx
index 50f77bf9..fa0fd568 100644
--- a/src/app_modules/admin/colab/sub_menu/reject.tsx
+++ b/src/app_modules/admin/colab/sub_menu/reject.tsx
@@ -13,118 +13,138 @@ import {
Spoiler,
Box,
Pagination,
+ Button,
} from "@mantine/core";
import ComponentAdminGlobal_HeaderTamplate from "../../_admin_global/header_tamplate";
import { useState } from "react";
import { MODEL_COLLABORATION } from "@/app_modules/colab/model/interface";
import adminColab_getListAllRejected from "../fun/get/get_list_all_reject";
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
+import { clientLogger } from "@/util/clientLogger";
-export default function AdminColab_TableRejected({
- listReject,
-}: {
- listReject: any;
-}) {
+import { useShallowEffect } from "@mantine/hooks";
+import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
+import { IconEye } from "@tabler/icons-react";
+import { apiGetAdminCollaborationReject } from "../lib/api_fetch_admin_collaboration";
+
+export default function AdminColab_TableRejected() {
return (
<>
-
+
>
);
}
-function TableMenu({ listReject }: { listReject: any }) {
- const [data, setData] = useState(listReject.data);
- const [isNPage, setNPage] = useState(listReject.nPage);
+function TableMenu() {
+ const [data, setData] = useState(null);
+ const [isNPage, setNPage] = useState(1);
const [activePage, setActivePage] = useState(1);
+ const [loading, setLoading] = useState(false);
+ const [idData, setIdData] = useState("");
- let noAwal = activePage * 5 - 4;
- async function onLoad(pindahPage: any) {
- const load = await adminColab_getListAllRejected({ page: pindahPage });
- setActivePage(pindahPage);
- setData(load.data as any);
- setNPage(load.nPage);
+ useShallowEffect(() => {
+ loadInitialData()
+ }, [activePage])
+ const loadInitialData = async () => {
+ try {
+ const response = await apiGetAdminCollaborationReject({
+ page: `${activePage}`,
+ })
+ console.log("Ini Response", response)
+ if (response?.success && response?.data?.data) {
+ setData(response.data.data);
+ setNPage(response.data.nPage || 1);
+ } else {
+ console.error("Invalid data format recieved", response);
+ setData([])
+ }
+
+ } catch (error) {
+ clientLogger.error("Error get data table reject", error);
+ setData([]);
+ }
}
- const tableRow = data?.map((e, i) => (
-
- |
- {noAwal++}
- |
-
-
- {e?.Author?.Profile?.name}
-
- |
-
-
-
-
- {e?.title}
-
-
-
- |
-
-
- {e?.ProjectCollaborationMaster_Industri.name}
-
- |
-
-
- {e?.ProjectCollaboration_Partisipasi.length}
-
- |
-
-
-
-
-
- {e?.report}
-
-
-
-
+ const onPageClick = (page: number) => {
+ setActivePage(page);
+ }
- {/*
+ const renderTableBody = () => {
+ if (!Array.isArray(data) || data.length === 0) {
+ return (
+
+ |
+
+ Tidak ada data
+
+ |
+
+ )
+ }
+
+ return data.map((e, i) => (
+
+ |
+
+ {e?.Author?.Profile?.name}
+
+ |
+
+
+
+
+ {e?.title}
+
+
+
+ |
+
+
+ {e?.ProjectCollaborationMaster_Industri.name}
+
+ |
+
+
+ {e?.ProjectCollaboration_Partisipasi.length}
+
+ |
+
+
+
+
+
+ {e?.report}
+
+
+
+
+ |
+
+
}
loaderPosition="center"
radius={"xl"}
color="green"
onClick={() => {
- getDetailData(e.id);
+ setLoading(true);
+ setIdData(e.id);
}}
>
Detail
- }
- loaderPosition="center"
- radius={"xl"}
- color="red"
- onClick={() => {
- onRejected(e.id);
- }}
- >
- Reject
-
- */}
- |
-
- ));
-
+
+ |
+
+ ));
+ }
return (
<>
@@ -136,51 +156,55 @@ function TableMenu({ listReject }: { listReject: any }) {
>
Reject
-
-
-
-
-
-
- |
- No
- |
-
- Username
- |
-
- Title
- |
-
- Industri
- |
-
- Jumlah Partisipan
- |
-
- Report
- |
-
-
- {tableRow}
-
-
- {
- onLoad(val);
- }}
- />
-
-
+ {!data ? (
+
+ ) : (
+
+
+
+
+
+
+ |
+ Username
+ |
+
+ Title
+ |
+
+ Industri
+ |
+
+ Jumlah Partisipan
+ |
+
+ Report
+ |
+
+ Aksi
+ |
+
+
+ {renderTableBody()}
+
+
+ {
+ onPageClick(val);
+ }}
+ />
+
+
+ )}
>
);
-}
+}
\ No newline at end of file
diff --git a/src/app_modules/admin/colab/sub_menu/reject.txt b/src/app_modules/admin/colab/sub_menu/reject.txt
new file mode 100644
index 00000000..a1047a6b
--- /dev/null
+++ b/src/app_modules/admin/colab/sub_menu/reject.txt
@@ -0,0 +1,186 @@
+"use client";
+
+import {
+ Stack,
+ Group,
+ Title,
+ Paper,
+ ScrollArea,
+ Table,
+ Center,
+ Text,
+ Badge,
+ Spoiler,
+ Box,
+ Pagination,
+} from "@mantine/core";
+import ComponentAdminGlobal_HeaderTamplate from "../../_admin_global/header_tamplate";
+import { useState } from "react";
+import { MODEL_COLLABORATION } from "@/app_modules/colab/model/interface";
+import adminColab_getListAllRejected from "../fun/get/get_list_all_reject";
+import { AdminColor } from "@/app_modules/_global/color/color_pallet";
+
+export default function AdminColab_TableRejected({
+ listReject,
+}: {
+ listReject: any;
+}) {
+ return (
+ <>
+
+
+
+
+ >
+ );
+}
+function TableMenu({ listReject }: { listReject: any }) {
+ const [data, setData] = useState(listReject.data);
+ const [isNPage, setNPage] = useState(listReject.nPage);
+ const [activePage, setActivePage] = useState(1);
+
+ let noAwal = activePage * 5 - 4;
+ async function onLoad(pindahPage: any) {
+ const load = await adminColab_getListAllRejected({ page: pindahPage });
+ setActivePage(pindahPage);
+ setData(load.data as any);
+ setNPage(load.nPage);
+ }
+
+ const tableRow = data?.map((e, i) => (
+
+ |
+ {noAwal++}
+ |
+
+
+ {e?.Author?.Profile?.name}
+
+ |
+
+
+
+
+ {e?.title}
+
+
+
+ |
+
+
+ {e?.ProjectCollaborationMaster_Industri.name}
+
+ |
+
+
+ {e?.ProjectCollaboration_Partisipasi.length}
+
+ |
+
+
+
+
+
+ {e?.report}
+
+
+
+
+
+ {/*
+ }
+ loaderPosition="center"
+ radius={"xl"}
+ color="green"
+ onClick={() => {
+ getDetailData(e.id);
+ }}
+ >
+ Detail
+
+ }
+ loaderPosition="center"
+ radius={"xl"}
+ color="red"
+ onClick={() => {
+ onRejected(e.id);
+ }}
+ >
+ Reject
+
+ */}
+ |
+
+ ));
+
+ return (
+ <>
+
+
+ Reject
+
+
+
+
+
+
+
+ |
+ No
+ |
+
+ Username
+ |
+
+ Title
+ |
+
+ Industri
+ |
+
+ Jumlah Partisipan
+ |
+
+ Report
+ |
+
+
+ {tableRow}
+
+
+ {
+ onLoad(val);
+ }}
+ />
+
+
+
+ >
+ );
+}
\ No newline at end of file
diff --git a/src/app_modules/admin/investasi/detail/detail_publish.tsx b/src/app_modules/admin/investasi/detail/detail_publish.tsx
index b562a346..8a13feb0 100644
--- a/src/app_modules/admin/investasi/detail/detail_publish.tsx
+++ b/src/app_modules/admin/investasi/detail/detail_publish.tsx
@@ -17,13 +17,7 @@ import { apiGetAdminInvestasiById } from "../_lib/api_fetch_admin_investasi";
import { clientLogger } from "@/util/clientLogger";
import { useShallowEffect } from "@mantine/hooks";
-export function AdminInvestasi_DetailPublish({
- dataTransaksi,
- statusTransaksi,
-}: {
- dataTransaksi: any[];
- statusTransaksi: any[];
- }) {
+export function AdminInvestasi_DetailPublish() {
const params = useParams<{ id: string }>();
const [data, setData] = useState(null);
const [selectPage, setSelectPage] = useAtom(gs_admin_invetasi_menu_publish);
diff --git a/src/app_modules/admin/job/_view/view_table_review.tsx b/src/app_modules/admin/job/_view/view_table_review.tsx
index a5a2437c..eb0eb4f6 100644
--- a/src/app_modules/admin/job/_view/view_table_review.tsx
+++ b/src/app_modules/admin/job/_view/view_table_review.tsx
@@ -132,7 +132,7 @@ export default function AdminJob_ViewTavleReview() {
|
-
+
{e.imageId ? (
|