diff --git a/src/app/api/admin/collaboration/[id]/route.ts b/src/app/api/admin/collaboration/[id]/route.ts index 3a912a16..47fb3f77 100644 --- a/src/app/api/admin/collaboration/[id]/route.ts +++ b/src/app/api/admin/collaboration/[id]/route.ts @@ -2,65 +2,71 @@ 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 +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, + report: true, + Author: { + select: { + id: true, + username: true, + }, + }, + ProjectCollaborationMaster_Industri: true, + ProjectCollaboration_Partisipasi: { + where: { + User: { + active: true, }, - select: { + }, + select: { + id: true, + User: { + 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, - }, - }, - }, - }, - }, + 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 + }, + }); + 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 } + ); + } +} diff --git a/src/app/api/admin/collaboration/dashboard/[name]/route.ts b/src/app/api/admin/collaboration/dashboard/[name]/route.ts index ec8780c9..0e1dda84 100644 --- a/src/app/api/admin/collaboration/dashboard/[name]/route.ts +++ b/src/app/api/admin/collaboration/dashboard/[name]/route.ts @@ -13,9 +13,13 @@ export async function GET(request: Request, { params }: { if (fixStatus === "Publish") { fixData = await prisma.projectCollaboration.count({ - where: { - isActive: true, + where: { + isActive: true, + isReject: false, + Author: { + active: true, }, + }, }); } else if (fixStatus === "Reject") { diff --git a/src/app/api/admin/collaboration/group/[id]/route.ts b/src/app/api/admin/collaboration/group/[id]/route.ts new file mode 100644 index 00000000..435bc2c9 --- /dev/null +++ b/src/app/api/admin/collaboration/group/[id]/route.ts @@ -0,0 +1,73 @@ +import backendLogger from "@/util/backendLogger"; +import { NextResponse } from "next/server"; + +export async function GET( + request: Request, + { params }: { params: { id: string } } +) { + try { + const { id } = params; + + const data = await prisma.projectCollaboration_RoomChat.findUnique({ + where: { + id: id, + }, + select: { + id: true, + name: true, + ProjectCollaboration: { + select: { + id: true, + isActive: true, + title: true, + lokasi: true, + purpose: true, + benefit: true, + createdAt: true, + ProjectCollaborationMaster_Industri: true, + Author: true + }, + }, + ProjectCollaboration_AnggotaRoomChat: { + select: { + User: { + select: { + username: true, + id: true, + Profile: { + select: { + id: true, + name: true, + }, + }, + }, + }, + }, + }, + }, + }); + + return NextResponse.json( + { + success: true, + message: "Success get data collaboration group", + data: data, + }, + { + status: 200, + } + ); + } catch (error) { + backendLogger.error("Error get data collaboration group", error); + return NextResponse.json( + { + success: false, + message: "Error get data collaboration group", + error: (error as Error).message, + }, + { + status: 500, + } + ); + } +} diff --git a/src/app/api/admin/collaboration/status/publish/route.ts b/src/app/api/admin/collaboration/status/publish/route.ts index 3bf71a30..cf04c496 100644 --- a/src/app/api/admin/collaboration/status/publish/route.ts +++ b/src/app/api/admin/collaboration/status/publish/route.ts @@ -4,139 +4,138 @@ 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; - const { searchParams } = new URL(request.url); - const page = searchParams.get("page"); - const takeData = 10; - const skipData = Number(page) * takeData - takeData; - - try { - let fixData; + try { + let fixData; - if (!page) { - fixData = await prisma.projectCollaboration.findMany({ - orderBy: { - createdAt: "desc", - }, - where: { - isActive: true, - isReject: false, - 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: true, - isReject: false, - 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: true, - isReject: false, - Author: { - active: true, - }, - }, - }); - - fixData = { - data: data, - nPage: _.ceil(nCount / takeData), - } - } - - return NextResponse.json({ - success: true, - message: "Success get data collaboration dashboard", - data: fixData, + if (!page) { + fixData = await prisma.projectCollaboration.findMany({ + orderBy: { + createdAt: "desc", }, - { 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 + where: { + isActive: true, + isReject: false, + Author: { + active: true, + }, }, - { status: 500 } - ) + 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: true, + isReject: false, + 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: true, + isReject: false, + Author: { + active: true, + }, + }, + }); + + fixData = { + data: data, + nPage: _.ceil(nCount / takeData), + }; } -} \ No newline at end of file + + 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 } + ); + } +} diff --git a/src/app/dev/admin/colab/detail/group/[id]/page.tsx b/src/app/dev/admin/colab/detail/group/[id]/page.tsx new file mode 100644 index 00000000..1e03a6ff --- /dev/null +++ b/src/app/dev/admin/colab/detail/group/[id]/page.tsx @@ -0,0 +1,11 @@ +import DetailGroup from "@/app_modules/admin/colab/detail/detail_group"; + +async function Page() { + return ( + <> + + + ); +} + +export default Page; diff --git a/src/app/dev/admin/colab/detail/publish/[id]/page.tsx b/src/app/dev/admin/colab/detail/publish/[id]/page.tsx index aad0ff7a..9004c86c 100644 --- a/src/app/dev/admin/colab/detail/publish/[id]/page.tsx +++ b/src/app/dev/admin/colab/detail/publish/[id]/page.tsx @@ -1,5 +1,4 @@ import DetailPublish from '@/app_modules/admin/colab/detail/detail_publish'; -import React from 'react'; function Page() { return ( diff --git a/src/app/dev/admin/colab/detail/reject/[id]/page.tsx b/src/app/dev/admin/colab/detail/reject/[id]/page.tsx new file mode 100644 index 00000000..a81cf94e --- /dev/null +++ b/src/app/dev/admin/colab/detail/reject/[id]/page.tsx @@ -0,0 +1,11 @@ +import DetailReject from "@/app_modules/admin/colab/detail/detail_reject"; + +async function Page() { + return ( + <> + + + ); +} + +export default Page; diff --git a/src/app_modules/admin/_admin_global/_component/button/detail_button.tsx b/src/app_modules/admin/_admin_global/_component/button/detail_button.tsx index db0d770c..2a6ebda6 100644 --- a/src/app_modules/admin/_admin_global/_component/button/detail_button.tsx +++ b/src/app_modules/admin/_admin_global/_component/button/detail_button.tsx @@ -18,7 +18,7 @@ export default function Admin_DetailButton({ path }: { path: string }) { leftIcon={} onClick={() => { setLoading(true); - router.push(path); + router.push(path || ""); }} > Detail diff --git a/src/app_modules/admin/colab/dashboard/index.tsx b/src/app_modules/admin/colab/dashboard/index.tsx index e8c75d52..af537ca3 100644 --- a/src/app_modules/admin/colab/dashboard/index.tsx +++ b/src/app_modules/admin/colab/dashboard/index.tsx @@ -1,10 +1,26 @@ "use client"; -import { Stack, SimpleGrid, Paper, Group, Title, Text, Flex, ThemeIcon } from "@mantine/core"; +import { + Stack, + SimpleGrid, + Paper, + Group, + Title, + Text, + Flex, + ThemeIcon, +} from "@mantine/core"; import { useRouter } from "next/navigation"; import ComponentAdminGlobal_HeaderTamplate from "../../_admin_global/header_tamplate"; -import { IconAlertTriangle, IconMessage2, IconUpload } from "@tabler/icons-react"; -import { AccentColor, AdminColor } from "@/app_modules/_global/color/color_pallet"; +import { + IconAlertTriangle, + IconMessage2, + IconUpload, +} from "@tabler/icons-react"; +import { + AccentColor, + AdminColor, +} from "@/app_modules/_global/color/color_pallet"; import { useState } from "react"; import { clientLogger } from "@/util/clientLogger"; import { apiGetAdminCollaborationStatusCountDashboard } from "../lib/api_fetch_admin_collaboration"; @@ -18,10 +34,8 @@ export default function AdminColab_Dashboard() { const [countReject, setCountReject] = useState(null); const router = useRouter(); - - useShallowEffect(() => { - handlerLoadData() + handlerLoadData(); }, []); async function handlerLoadData() { @@ -30,18 +44,18 @@ export default function AdminColab_Dashboard() { global_limit(() => onLoadCountPublish()), global_limit(() => onLoadCountRoom()), global_limit(() => onLoadCountReject()), - ] + ]; const result = await Promise.all(listLoadData); } catch (error) { - clientLogger.error("Error handler load data", error) + clientLogger.error("Error handler load data", error); } } async function onLoadCountPublish() { try { const response = await apiGetAdminCollaborationStatusCountDashboard({ name: "Publish", - }) - if (response) { + }); + if (response) { setCountPublish(response.data); } } catch (error) { @@ -49,14 +63,11 @@ export default function AdminColab_Dashboard() { } } - async function onLoadCountRoom() { try { - const response = await apiGetAdminCollaborationStatusCountDashboard( - { - name: "Room", - } - ) + const response = await apiGetAdminCollaborationStatusCountDashboard({ + name: "Room", + }); if (response) { setCountRoom(response.data); } @@ -69,7 +80,7 @@ export default function AdminColab_Dashboard() { try { const response = await apiGetAdminCollaborationStatusCountDashboard({ name: "Reject", - }) + }); if (response) { setCountReject(response.data); } @@ -82,47 +93,44 @@ export default function AdminColab_Dashboard() { { id: 1, name: "Publish", - jumlah: countPublish - == null ? ( - - ) : countPublish ? ( - countPublish - ) : ( - "-" - ) - , + jumlah: + countPublish == null ? ( + + ) : countPublish ? ( + countPublish + ) : ( + "-" + ), color: "green", - icon: + icon: , }, { id: 2, name: "Group Chat", - jumlah: countRoom - == null ? ( - - ) : countRoom ? ( - countRoom - ) : ( - "-" - ) - , + jumlah: + countRoom == null ? ( + + ) : countRoom ? ( + countRoom + ) : ( + "-" + ), color: "orange", - icon: + icon: , }, { id: 3, name: "Reject", - jumlah: countReject - == null ? ( - - ) : countReject ? ( - countReject - ) : ( - "-" - ) - , + jumlah: + countReject == null ? ( + + ) : countReject ? ( + countReject + ) : ( + "-" + ), color: "red", - icon: + icon: , }, ]; return ( @@ -145,13 +153,16 @@ export default function AdminColab_Dashboard() { shadow="md" radius="md" p="md" - // sx={{ borderColor: e.color, borderStyle: "solid" }} + // sx={{ borderColor: e.color, borderStyle: "solid" }} > - - {e.name} + + {e.name} + - {e.jumlah ? e.jumlah : 0} + + {e.jumlah ? e.jumlah : 0} + - ))} @@ -169,7 +179,6 @@ export default function AdminColab_Dashboard() { ); } -function apiGetAdminCollaborationStatuCountDashboard(arg0: { name: string; }) { +function apiGetAdminCollaborationStatuCountDashboard(arg0: { name: string }) { throw new Error("Function not implemented."); } - diff --git a/src/app_modules/admin/colab/detail/detail_group.tsx b/src/app_modules/admin/colab/detail/detail_group.tsx index 320640de..c4f95ea2 100644 --- a/src/app_modules/admin/colab/detail/detail_group.tsx +++ b/src/app_modules/admin/colab/detail/detail_group.tsx @@ -1,10 +1,176 @@ -import React from 'react'; +"use client"; + +import { AdminColor } from "@/app_modules/_global/color/color_pallet"; +import { MODEL_COLLABORATION_ROOM_CHAT } from "@/app_modules/colab/model/interface"; +import CustomSkeleton from "@/app_modules/components/CustomSkeleton"; +import { clientLogger } from "@/util/clientLogger"; +import { + Grid, + Group, + Paper, + ScrollArea, + SimpleGrid, + Stack, + Text, + Title, +} from "@mantine/core"; +import { useShallowEffect } from "@mantine/hooks"; +import { useParams } from "next/navigation"; +import { useState } from "react"; +import AdminGlobal_ComponentBackButton from "../../_admin_global/back_button"; +import ComponentAdminGlobal_HeaderTamplate from "../../_admin_global/header_tamplate"; +import { apiGetAdminCollaborationGroupById } from "../lib/api_fetch_admin_collaboration"; +import { Admin_ComponentBoxStyle } from "../../_admin_global/_component/comp_admin_boxstyle"; +import { IconCaretRight } from "@tabler/icons-react"; function DetailGroup() { + const params = useParams<{ id: string }>(); + const [data, setData] = useState(null); + const [loading, setLoading] = useState(false); + + useShallowEffect(() => { + loadInitialData(); + }, []); + + const loadInitialData = async () => { + try { + const response = await apiGetAdminCollaborationGroupById({ + id: params.id, + }); + + if (response?.success && response?.data) { + setData(response.data); + } + } catch (error) { + clientLogger.error("Invalid data format recieved:", error); + setData(null); + } + }; + + const listData = [ + { + label: "Admin", + value: data?.ProjectCollaboration?.Author?.username, + }, + { + label: "Judul", + value: data?.ProjectCollaboration?.title, + }, + { + label: "Industri", + value: + data?.ProjectCollaboration?.ProjectCollaborationMaster_Industri?.name, + }, + { + label: "Jumlah Partisipan", + value: data?.ProjectCollaboration_AnggotaRoomChat.length, + }, + { + label: "Lokasi", + value: data?.ProjectCollaboration?.lokasi, + }, + { + label: "Tujuan", + value: data?.ProjectCollaboration?.purpose, + }, + { + label: "Keuntungan", + value: data?.ProjectCollaboration?.benefit, + }, + ]; + return ( -
- DetailGroup -
+ + + + + + + {!data ? ( + + ) : ( + + + + {listData.map((e, i) => ( + + + + {e.label} + + + : + + {e.value} + + + ))} + + {/* + + */} + + + + )} + + + + {!data ? ( + + ) : ( + + + + Anggota + + + + {data.ProjectCollaboration_AnggotaRoomChat.map((e, i) => ( + + + + + + Username + : + {e.User.username} + + + + Name + : + {e.User.Profile.name} + + + + ))} + + + + )} + + + ); } diff --git a/src/app_modules/admin/colab/detail/detail_publish.tsx b/src/app_modules/admin/colab/detail/detail_publish.tsx index e738bbf9..b377f571 100644 --- a/src/app_modules/admin/colab/detail/detail_publish.tsx +++ b/src/app_modules/admin/colab/detail/detail_publish.tsx @@ -1,133 +1,155 @@ -'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'; +"use client"; + +import React, { useState } from "react"; +import AdminGlobal_ComponentBackButton from "../../_admin_global/back_button"; +import { + Button, + Flex, + Grid, + Group, + Modal, + Paper, + SimpleGrid, + Stack, + Text, + Textarea, + Title, +} from "@mantine/core"; +import { useParams, useRouter } 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, IconFlag2Off } from "@tabler/icons-react"; +import ComponentAdminGlobal_HeaderTamplate from "../../_admin_global/header_tamplate"; +import adminColab_funReportProjectById from "../fun/edit/fun_report_project_by_id"; +import { Admin_ComponentBoxStyle } from "../../_admin_global/_component/comp_admin_boxstyle"; function DetailPublish() { + const router = useRouter(); const params = useParams<{ id: string }>(); const [data, setData] = useState(null); const [loading, setLoading] = useState(false); const [openReject, setOpenReject] = useState(false); + const [report, setReport] = useState(""); 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, - }) + setLoading(true) + const response = await adminColab_funReportProjectById({ + colabId: params.id, + report: report, + }); - if (response?.success && response?.data) { - setOpenReject(true) - setData(response.data); - setLoading(false) + if (response.status == 200) { + setLoading(false); + router.back(); } } catch (error) { + setLoading(false); ComponentGlobal_NotifikasiPeringatan("Gagal Load"); - clientLogger.error("Invalid data format recieved:", error); - setData(null); + clientLogger.error("Invalid report collaboration", error); } } + const listData = [ + { + label: "Username", + value: data?.Author.username, + }, + { + label: "Judul", + value: data?.title, + }, + { + label: "Industri", + value: data?.ProjectCollaborationMaster_Industri.name, + }, + { + label: "Jumlah Partisipan", + value: data?.ProjectCollaboration_Partisipasi.length, + }, + { + label: "Lokasi", + value: data?.lokasi, + }, + { + label: "Tujuan", + value: data?.purpose, + }, + { + label: "Keuntungan", + value: data?.benefit, + }, + ]; + 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} - - - - - )} + + + + {!data ? ( + + ) : ( + + + {listData.map((e, i) => ( + + + + {e.label} + + + : + + {e.value} + + + ))} + + + + + + + )} + {/* Reject Project */} @@ -137,7 +159,7 @@ function DetailPublish() { onClose={() => setOpenReject(false)} centered withCloseButton={false} - size={"lg"} + size={"md"} > @@ -149,16 +171,21 @@ function DetailPublish() { ? {" "}