fix admin collaboration

deskripsi:
- fix detail publish, detail group & detail reject
This commit is contained in:
2025-03-21 10:36:25 +08:00
parent 4de05506ae
commit 5a220528d2
17 changed files with 974 additions and 494 deletions

View File

@@ -2,65 +2,71 @@ import prisma from "@/lib/prisma";
import backendLogger from "@/util/backendLogger"; import backendLogger from "@/util/backendLogger";
import { NextResponse } from "next/server"; import { NextResponse } from "next/server";
export async function GET(req: Request, { params }: { params: { id: string } }) { export async function GET(
try { req: Request,
const { id } = params; { params }: { params: { id: string } }
const data = await prisma.projectCollaboration.findUnique({ ) {
where: { try {
id: id 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, id: true,
isActive: true, Profile: {
title: true, select: {
lokasi: true, name: 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) { return NextResponse.json(
backendLogger.error("Error get collaboration >>", error); {
return NextResponse.json({ success: true,
success: false, message: "Success get collaboration",
message: "Error get collaboration", data: data,
reason: (error as Error).message },
}, { status: 200 }
{ status: 500 } );
) } catch (error) {
} backendLogger.error("Error get collaboration >>", error);
} return NextResponse.json(
{
success: false,
message: "Error get collaboration",
reason: (error as Error).message,
},
{ status: 500 }
);
}
}

View File

@@ -13,9 +13,13 @@ export async function GET(request: Request, { params }: {
if (fixStatus === "Publish") { if (fixStatus === "Publish") {
fixData = await prisma.projectCollaboration.count({ fixData = await prisma.projectCollaboration.count({
where: { where: {
isActive: true, isActive: true,
isReject: false,
Author: {
active: true,
}, },
},
}); });
} else if (fixStatus === "Reject") { } else if (fixStatus === "Reject") {

View File

@@ -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,
}
);
}
}

View File

@@ -4,139 +4,138 @@ import _ from "lodash";
import { NextResponse } from "next/server"; import { NextResponse } from "next/server";
export async function GET(request: Request) { 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); try {
const page = searchParams.get("page"); let fixData;
const takeData = 10;
const skipData = Number(page) * takeData - takeData;
try {
let fixData;
if (!page) { if (!page) {
fixData = await prisma.projectCollaboration.findMany({ fixData = await prisma.projectCollaboration.findMany({
orderBy: { orderBy: {
createdAt: "desc", 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,
}, },
{ status: 200 } where: {
); isActive: true,
} catch (error) { isReject: false,
backendLogger.error("Error get data collaboration dashboard >>", error); Author: {
return NextResponse.json({ active: true,
success: false, },
message: "Error get data collaboration dashboard",
reason: (error as Error).message
}, },
{ 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),
};
} }
}
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 }
);
}
}

View File

@@ -0,0 +1,11 @@
import DetailGroup from "@/app_modules/admin/colab/detail/detail_group";
async function Page() {
return (
<>
<DetailGroup />
</>
);
}
export default Page;

View File

@@ -1,5 +1,4 @@
import DetailPublish from '@/app_modules/admin/colab/detail/detail_publish'; import DetailPublish from '@/app_modules/admin/colab/detail/detail_publish';
import React from 'react';
function Page() { function Page() {
return ( return (

View File

@@ -0,0 +1,11 @@
import DetailReject from "@/app_modules/admin/colab/detail/detail_reject";
async function Page() {
return (
<>
<DetailReject />
</>
);
}
export default Page;

View File

@@ -18,7 +18,7 @@ export default function Admin_DetailButton({ path }: { path: string }) {
leftIcon={<IconEye size={25} color={"white"} />} leftIcon={<IconEye size={25} color={"white"} />}
onClick={() => { onClick={() => {
setLoading(true); setLoading(true);
router.push(path); router.push(path || "");
}} }}
> >
Detail Detail

View File

@@ -1,10 +1,26 @@
"use client"; "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 { useRouter } from "next/navigation";
import ComponentAdminGlobal_HeaderTamplate from "../../_admin_global/header_tamplate"; import ComponentAdminGlobal_HeaderTamplate from "../../_admin_global/header_tamplate";
import { IconAlertTriangle, IconMessage2, IconUpload } from "@tabler/icons-react"; import {
import { AccentColor, AdminColor } from "@/app_modules/_global/color/color_pallet"; IconAlertTriangle,
IconMessage2,
IconUpload,
} from "@tabler/icons-react";
import {
AccentColor,
AdminColor,
} from "@/app_modules/_global/color/color_pallet";
import { useState } from "react"; import { useState } from "react";
import { clientLogger } from "@/util/clientLogger"; import { clientLogger } from "@/util/clientLogger";
import { apiGetAdminCollaborationStatusCountDashboard } from "../lib/api_fetch_admin_collaboration"; import { apiGetAdminCollaborationStatusCountDashboard } from "../lib/api_fetch_admin_collaboration";
@@ -18,10 +34,8 @@ export default function AdminColab_Dashboard() {
const [countReject, setCountReject] = useState<number | null>(null); const [countReject, setCountReject] = useState<number | null>(null);
const router = useRouter(); const router = useRouter();
useShallowEffect(() => { useShallowEffect(() => {
handlerLoadData() handlerLoadData();
}, []); }, []);
async function handlerLoadData() { async function handlerLoadData() {
@@ -30,18 +44,18 @@ export default function AdminColab_Dashboard() {
global_limit(() => onLoadCountPublish()), global_limit(() => onLoadCountPublish()),
global_limit(() => onLoadCountRoom()), global_limit(() => onLoadCountRoom()),
global_limit(() => onLoadCountReject()), global_limit(() => onLoadCountReject()),
] ];
const result = await Promise.all(listLoadData); const result = await Promise.all(listLoadData);
} catch (error) { } catch (error) {
clientLogger.error("Error handler load data", error) clientLogger.error("Error handler load data", error);
} }
} }
async function onLoadCountPublish() { async function onLoadCountPublish() {
try { try {
const response = await apiGetAdminCollaborationStatusCountDashboard({ const response = await apiGetAdminCollaborationStatusCountDashboard({
name: "Publish", name: "Publish",
}) });
if (response) { if (response) {
setCountPublish(response.data); setCountPublish(response.data);
} }
} catch (error) { } catch (error) {
@@ -49,14 +63,11 @@ export default function AdminColab_Dashboard() {
} }
} }
async function onLoadCountRoom() { async function onLoadCountRoom() {
try { try {
const response = await apiGetAdminCollaborationStatusCountDashboard( const response = await apiGetAdminCollaborationStatusCountDashboard({
{ name: "Room",
name: "Room", });
}
)
if (response) { if (response) {
setCountRoom(response.data); setCountRoom(response.data);
} }
@@ -69,7 +80,7 @@ export default function AdminColab_Dashboard() {
try { try {
const response = await apiGetAdminCollaborationStatusCountDashboard({ const response = await apiGetAdminCollaborationStatusCountDashboard({
name: "Reject", name: "Reject",
}) });
if (response) { if (response) {
setCountReject(response.data); setCountReject(response.data);
} }
@@ -82,47 +93,44 @@ export default function AdminColab_Dashboard() {
{ {
id: 1, id: 1,
name: "Publish", name: "Publish",
jumlah: countPublish jumlah:
== null ? ( countPublish == null ? (
<CustomSkeleton height={40} width={40} /> <CustomSkeleton height={40} width={40} />
) : countPublish ? ( ) : countPublish ? (
countPublish countPublish
) : ( ) : (
"-" "-"
) ),
,
color: "green", color: "green",
icon: <IconUpload size={18} color="#4CAF4F" /> icon: <IconUpload size={18} color="#4CAF4F" />,
}, },
{ {
id: 2, id: 2,
name: "Group Chat", name: "Group Chat",
jumlah: countRoom jumlah:
== null ? ( countRoom == null ? (
<CustomSkeleton height={40} width={40} /> <CustomSkeleton height={40} width={40} />
) : countRoom ? ( ) : countRoom ? (
countRoom countRoom
) : ( ) : (
"-" "-"
) ),
,
color: "orange", color: "orange",
icon: <IconMessage2 size={18} color="#FF9800" /> icon: <IconMessage2 size={18} color="#FF9800" />,
}, },
{ {
id: 3, id: 3,
name: "Reject", name: "Reject",
jumlah: countReject jumlah:
== null ? ( countReject == null ? (
<CustomSkeleton height={40} width={40} /> <CustomSkeleton height={40} width={40} />
) : countReject ? ( ) : countReject ? (
countReject countReject
) : ( ) : (
"-" "-"
) ),
,
color: "red", color: "red",
icon: <IconAlertTriangle size={18} color="#FF4B4C" /> icon: <IconAlertTriangle size={18} color="#FF4B4C" />,
}, },
]; ];
return ( return (
@@ -145,13 +153,16 @@ export default function AdminColab_Dashboard() {
shadow="md" shadow="md"
radius="md" radius="md"
p="md" p="md"
// sx={{ borderColor: e.color, borderStyle: "solid" }} // sx={{ borderColor: e.color, borderStyle: "solid" }}
> >
<Stack spacing={0}> <Stack spacing={0}>
<Text fw={"bold"} c={AccentColor.white}>{e.name}</Text> <Text fw={"bold"} c={AccentColor.white}>
{e.name}
</Text>
<Flex align={"center"} justify={"space-between"}> <Flex align={"center"} justify={"space-between"}>
<Title color={AccentColor.white}>{e.jumlah ? e.jumlah : 0}</Title> <Title color={AccentColor.white}>
{e.jumlah ? e.jumlah : 0}
</Title>
<ThemeIcon <ThemeIcon
radius={"xl"} radius={"xl"}
size={"md"} size={"md"}
@@ -161,7 +172,6 @@ export default function AdminColab_Dashboard() {
</ThemeIcon> </ThemeIcon>
</Flex> </Flex>
</Stack> </Stack>
</Paper> </Paper>
))} ))}
</SimpleGrid> </SimpleGrid>
@@ -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."); throw new Error("Function not implemented.");
} }

View File

@@ -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() { function DetailGroup() {
const params = useParams<{ id: string }>();
const [data, setData] = useState<MODEL_COLLABORATION_ROOM_CHAT | null>(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 ( return (
<div> <Stack>
DetailGroup <ComponentAdminGlobal_HeaderTamplate name={`Detail group`} />
</div> <AdminGlobal_ComponentBackButton />
<Grid>
<Grid.Col span={6}>
{!data ? (
<CustomSkeleton height={"50vh"} width={"100%"} />
) : (
<Admin_ComponentBoxStyle
style={{
height: 500,
}}
>
<ScrollArea h={450} scrollbarSize={"md"}>
<Stack spacing={"xs"}>
{listData.map((e, i) => (
<Grid c={"white"} key={i}>
<Grid.Col span={4}>
<Text c={AdminColor.white} fw={"bold"}>
{e.label}
</Text>
</Grid.Col>
<Grid.Col span={1}>:</Grid.Col>
<Grid.Col span={"auto"}>
<Text c={AdminColor.white}>{e.value}</Text>
</Grid.Col>
</Grid>
))}
{/* <Group position="center">
<Button
mt={"xl"}
radius={"xl"}
bg={"red"}
color="red"
onClick={() => {
setOpenReject(true);
}}
leftIcon={<IconFlag2Off size={20} color="white" />}
>
Reject
</Button>
</Group> */}
</Stack>
</ScrollArea>
</Admin_ComponentBoxStyle>
)}
</Grid.Col>
<Grid.Col span={6}>
{!data ? (
<CustomSkeleton height={"50vh"} width={"100%"} />
) : (
<Admin_ComponentBoxStyle
style={{
height: 500,
}}
>
<Stack>
<Title align="center" order={6}>
Anggota
</Title>
<ScrollArea h={400}>
{data.ProjectCollaboration_AnggotaRoomChat.map((e, i) => (
<Group key={i} align="flex-start" mb={"md"}>
<IconCaretRight />
<Stack spacing={0} w={"70%"}>
<Grid>
<Grid.Col span={3} fw={"bold"}>Username</Grid.Col>
<Grid.Col span={1}>:</Grid.Col>
<Grid.Col span={8}>{e.User.username}</Grid.Col>
</Grid>
<Grid>
<Grid.Col span={3} fw={"bold"}>Name</Grid.Col>
<Grid.Col span={1}>:</Grid.Col>
<Grid.Col span={8}>{e.User.Profile.name}</Grid.Col>
</Grid>
</Stack>
</Group>
))}
</ScrollArea>
</Stack>
</Admin_ComponentBoxStyle>
)}
</Grid.Col>
</Grid>
</Stack>
); );
} }

View File

@@ -1,133 +1,155 @@
'use client'; "use client";
import React, { useState } from 'react';
import AdminGlobal_ComponentBackButton from '../../_admin_global/back_button'; import React, { useState } from "react";
import { Button, Flex, Grid, Group, Modal, Paper, Stack, Text, Textarea, Title } from '@mantine/core'; import AdminGlobal_ComponentBackButton from "../../_admin_global/back_button";
import { useParams } from 'next/navigation'; import {
import { MODEL_COLLABORATION } from '@/app_modules/colab/model/interface'; Button,
import { useShallowEffect } from '@mantine/hooks'; Flex,
import { clientLogger } from '@/util/clientLogger'; Grid,
import { apiGetAdminCollaborationById } from '../lib/api_fetch_admin_collaboration'; Group,
import { AdminColor } from '@/app_modules/_global/color/color_pallet'; Modal,
import CustomSkeleton from '@/app_modules/components/CustomSkeleton'; Paper,
import { ComponentGlobal_NotifikasiPeringatan } from '@/app_modules/_global/notif_global'; SimpleGrid,
import { IconCheck } from '@tabler/icons-react'; 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() { function DetailPublish() {
const router = useRouter();
const params = useParams<{ id: string }>(); const params = useParams<{ id: string }>();
const [data, setData] = useState<MODEL_COLLABORATION | null>(null); const [data, setData] = useState<MODEL_COLLABORATION | null>(null);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [openReject, setOpenReject] = useState(false); const [openReject, setOpenReject] = useState(false);
const [report, setReport] = useState("");
useShallowEffect(() => { useShallowEffect(() => {
loadInitialData(); loadInitialData();
}, []) }, []);
const loadInitialData = async () => { const loadInitialData = async () => {
try { try {
const response = await apiGetAdminCollaborationById({ const response = await apiGetAdminCollaborationById({
id: params.id, id: params.id,
}) });
if (response?.success && response?.data) { if (response?.success && response?.data) {
setData(response.data); setData(response.data);
} }
} catch (error) { } catch (error) {
clientLogger.error("Invalid data format recieved:", error); clientLogger.error("Invalid data format recieved:", error);
setData(null); setData(null);
} }
} };
async function onReject() { async function onReject() {
try { try {
const response = await apiGetAdminCollaborationById({ setLoading(true)
id: params.id, const response = await adminColab_funReportProjectById({
}) colabId: params.id,
report: report,
});
if (response?.success && response?.data) { if (response.status == 200) {
setOpenReject(true) setLoading(false);
setData(response.data); router.back();
setLoading(false)
} }
} catch (error) { } catch (error) {
setLoading(false);
ComponentGlobal_NotifikasiPeringatan("Gagal Load"); ComponentGlobal_NotifikasiPeringatan("Gagal Load");
clientLogger.error("Invalid data format recieved:", error); clientLogger.error("Invalid report collaboration", error);
setData(null);
} }
} }
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 ( return (
<> <>
<Stack> <Stack>
<Flex justify={"space-between"}> <ComponentAdminGlobal_HeaderTamplate name={`Detail publish`} />
<AdminGlobal_ComponentBackButton /> <AdminGlobal_ComponentBackButton />
<Button radius={"xl"} bg={"red"} color='white' onClick={onReject}>
Reject
</Button> <SimpleGrid cols={2}>
</Flex> {!data ? (
{!data ? (<CustomSkeleton height={"50vh"} width={"100%"} />) : ( <CustomSkeleton height={"50vh"} width={"100%"} />
<Paper bg={AdminColor.softBlue} p={"md"}> ) : (
<Title pb={10} c={AdminColor.white} order={3}>Detail Publish</Title> <Admin_ComponentBoxStyle>
<Stack spacing={"xs"}> <Stack spacing={"xs"}>
<Grid> {listData.map((e, i) => (
<Grid.Col span={6}> <Grid c={"white"} key={i}>
<Text c={AdminColor.white} fw={"bold"}>Username:</Text> <Grid.Col span={4}>
</Grid.Col> <Text c={AdminColor.white} fw={"bold"}>
<Grid.Col span={6}> {e.label}
<Text c={AdminColor.white}>{data?.Author?.username}</Text> </Text>
</Grid.Col> </Grid.Col>
</Grid> <Grid.Col span={1}>:</Grid.Col>
<Grid> <Grid.Col span={"auto"}>
<Grid.Col span={6}> <Text c={AdminColor.white}>{e.value}</Text>
<Text c={AdminColor.white} fw={"bold"}>Title:</Text> </Grid.Col>
</Grid.Col> </Grid>
<Grid.Col span={6}> ))}
<Text c={AdminColor.white}>@{data?.title}</Text>
</Grid.Col> <Group position="center">
</Grid> <Button
<Grid> mt={"xl"}
<Grid.Col span={6}> radius={"xl"}
<Text c={AdminColor.white} fw={"bold"}>Industri:</Text> bg={"red"}
</Grid.Col> color="red"
<Grid.Col span={6}> onClick={() => {
<Text c={AdminColor.white}>+ {data?.ProjectCollaborationMaster_Industri.name}</Text> setOpenReject(true);
</Grid.Col> }}
</Grid> leftIcon={<IconFlag2Off size={20} color="white" />}
<Grid> >
<Grid.Col span={6}> Reject
<Text c={AdminColor.white} fw={"bold"}>Jumlah Partisipan:</Text> </Button>
</Grid.Col> </Group>
<Grid.Col span={6}> </Stack>
<Text c={AdminColor.white}>{data?.ProjectCollaboration_Partisipasi.length}</Text> </Admin_ComponentBoxStyle>
</Grid.Col> )}
</Grid> </SimpleGrid>
<Grid>
<Grid.Col span={6}>
<Text c={AdminColor.white} fw={"bold"}>Lokasi:</Text>
</Grid.Col>
<Grid.Col span={6}>
<Text c={AdminColor.white}>{data?.lokasi}</Text>
</Grid.Col>
</Grid>
<Grid>
<Grid.Col span={6}>
<Text c={AdminColor.white} fw={"bold"}>Tujuan Proyek:</Text>
</Grid.Col>
<Grid.Col span={6}>
<Text c={AdminColor.white}>{data?.purpose}</Text>
</Grid.Col>
</Grid>
<Grid>
<Grid.Col span={6}>
<Text c={AdminColor.white} fw={"bold"}>Keuntungan:</Text>
</Grid.Col>
<Grid.Col span={6}>
<Text c={AdminColor.white}>{data?.benefit}</Text>
</Grid.Col>
</Grid>
</Stack>
</Paper>
)}
</Stack> </Stack>
{/* Reject Project */} {/* Reject Project */}
@@ -137,7 +159,7 @@ function DetailPublish() {
onClose={() => setOpenReject(false)} onClose={() => setOpenReject(false)}
centered centered
withCloseButton={false} withCloseButton={false}
size={"lg"} size={"md"}
> >
<Paper bg={AdminColor.softBlue} p={"md"}> <Paper bg={AdminColor.softBlue} p={"md"}>
<Stack> <Stack>
@@ -149,16 +171,21 @@ function DetailPublish() {
? ?
</Text>{" "} </Text>{" "}
<Textarea <Textarea
minRows={2} minRows={3}
maxRows={5}
placeholder="Ketik alasan report.." placeholder="Ketik alasan report.."
// onChange={(val) => setReport(val.currentTarget.value)} onChange={(val) => setReport(val.currentTarget.value)}
/> />
<Group position="right"> <Group position="right">
<Button <Button
loading={loading}
loaderPosition="center"
leftIcon={<IconCheck />} leftIcon={<IconCheck />}
radius={"xl"} radius={"xl"}
// onClick={() => onReport()} onClick={() => {
> onReject();
}}
>
Simpan Simpan
</Button> </Button>
</Group> </Group>
@@ -170,4 +197,3 @@ function DetailPublish() {
} }
export default DetailPublish; export default DetailPublish;

View File

@@ -0,0 +1,147 @@
"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 DetailReject() {
const router = useRouter();
const params = useParams<{ id: string }>();
const [data, setData] = useState<MODEL_COLLABORATION | null>(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 {
// setLoading(true);
// const response = await adminColab_funReportProjectById({
// colabId: params.id,
// report: report,
// });
// if (response.status == 200) {
// setLoading(false);
// router.back();
// }
// } catch (error) {
// setLoading(false);
// ComponentGlobal_NotifikasiPeringatan("Gagal Load");
// 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,
},
{
label: "Catatan Report",
value: data?.report,
},
];
return (
<>
<Stack>
<ComponentAdminGlobal_HeaderTamplate name={`Detail reject`} />
<AdminGlobal_ComponentBackButton />
<SimpleGrid cols={2}>
{!data ? (
<CustomSkeleton height={"50vh"} width={"100%"} />
) : (
<Admin_ComponentBoxStyle>
<Stack spacing={"xs"}>
{listData.map((e, i) => (
<Grid c={"white"} key={i}>
<Grid.Col span={4}>
<Text c={AdminColor.white} fw={"bold"}>
{e.label}
</Text>
</Grid.Col>
<Grid.Col span={1}>:</Grid.Col>
<Grid.Col span={"auto"}>
<Text c={AdminColor.white}>{e.value}</Text>
</Grid.Col>
</Grid>
))}
</Stack>
</Admin_ComponentBoxStyle>
)}
</SimpleGrid>
</Stack>
</>
);
}
export default DetailReject;

View File

@@ -30,16 +30,16 @@ export default async function adminColab_funReportProjectById({
if (!projectUpdate) return { status: 400, message: "Gagal update project" }; if (!projectUpdate) return { status: 400, message: "Gagal update project" };
const updateReport = await prisma.projectCollaboration_Notifikasi.create({ // const updateReport = await prisma.projectCollaboration_Notifikasi.create({
data: { // data: {
projectCollaborationId: colabId, // projectCollaborationId: colabId,
adminId: userLoginId as string, // adminId: userLoginId as string,
userId: projectUpdate.userId as any, // userId: projectUpdate.userId as any,
note: "Project Anda Telah Direport Admin", // note: "Project Anda Telah Direport Admin",
}, // },
}); // });
if (!updateReport) return { status: 400, message: "Gagal update notifikasi" }; // if (!updateReport) return { status: 400, message: "Gagal update notifikasi" };
revalidatePath(RouterAdminColab.table_publish); revalidatePath(RouterAdminColab.table_publish);
return { status: 200, message: "Berhasil Update" }; return { status: 200, message: "Berhasil Update" };

View File

@@ -1,108 +1,151 @@
export { export {
apiGetAdminCollaborationStatusCountDashboard, apiGetAdminCollaborationStatusCountDashboard,
apiGetAdminCollaborationPublish, apiGetAdminCollaborationPublish,
apiGetAdminCollaborationReject, apiGetAdminCollaborationReject,
apiGetAdminCollaborationRoomById, apiGetAdminCollaborationRoomById,
apiGetAdminCollaborationById apiGetAdminCollaborationById,
apiGetAdminCollaborationGroupById,
} };
const apiGetAdminCollaborationStatusCountDashboard = async ({ const apiGetAdminCollaborationStatusCountDashboard = async ({
name name,
}: { }: {
name: "Publish" | "Reject" | "Room"; name: "Publish" | "Reject" | "Room";
}) => { }) => {
const { token } = await fetch("/api/get-cookie").then((res) => res.json()); const { token } = await fetch("/api/get-cookie").then((res) => res.json());
if (!token) return await token.json().catch(() => null); if (!token) return await token.json().catch(() => null);
// console.log("Ini Token", token); // console.log("Ini Token", token);
const response = await fetch(`/api/admin/collaboration/dashboard/${name}`, { const response = await fetch(`/api/admin/collaboration/dashboard/${name}`, {
method: "GET", method: "GET",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
Accept: "application/json", Accept: "application/json",
"Access-Control-Allow-Origin": "*", "Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`, Authorization: `Bearer ${token}`,
} },
}) });
// console.log("Ini Response", await response.json()); // console.log("Ini Response", await response.json());
return await response.json().catch(() => null); return await response.json().catch(() => null);
} };
const apiGetAdminCollaborationPublish = async ({ page }: { const apiGetAdminCollaborationPublish = async ({ page }: { page: string }) => {
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/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",
"Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`,
},
}
);
return await response.json().catch(() => null);
};
const apiGetAdminCollaborationRoomById = async ({
page,
search,
}: {
page: string;
search: 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 isSearch = search ? `&search=${search}` : "";
const response = await fetch(
`/api/admin/collaboration/group${isPage}${isSearch}`,
{
headers: {
"Content-Type": "application/json",
Accept: "application/json",
"Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`,
},
}
);
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);
};
const apiGetAdminCollaborationGroupById = async ({ id }: { id: string }) => {
try {
// Fetch token from cookie
const { token } = await fetch("/api/get-cookie").then((res) => res.json()); const { token } = await fetch("/api/get-cookie").then((res) => res.json());
if (!token) return await token.json().catch(() => null); if (!token) {
console.error("No token found");
const isPage = page ? `?page=${page}` : ""; return null;
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 response = await fetch(`/api/admin/collaboration/group/${id}`, {
} method: "GET",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
Authorization: `Bearer ${token}`,
},
});
const apiGetAdminCollaborationReject = async ({ page }: { // Check if the response is OK
page: string, if (!response.ok) {
const errorData = await response.json().catch(() => null);
}) => { console.error(
"Failed to get data collaboration group",
const { token } = await fetch("/api/get-cookie").then((res) => res.json()); response.statusText,
if (!token) return await token.json().catch(() => null); errorData
);
const isPage = page ? `?page=${page}` : ""; throw new Error(
const response = await fetch(`/api/admin/collaboration/status/reject/${isPage}`, { errorData?.message || "Failed to get data collaboration group"
headers: { );
"Content-Type": "application/json", }
Accept: "application/json",
"Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`,
}
})
return await response.json().catch(() => null); // Return the JSON response
}
const apiGetAdminCollaborationRoomById = async ({ page, search }: {
page: string,
search: 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 isSearch = search ? `&search=${search}` : "";
const response = await fetch(`/api/admin/collaboration/group${isPage}${isSearch}`, {
headers: {
"Content-Type": "application/json",
Accept: "application/json",
"Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`,
}
})
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);
}
const result = await response.json();
return result;
} catch (error) {
console.error("Error get data collaboration group", error);
throw error; // Re-throw the error to handle it in the calling function
}
};

View File

@@ -32,6 +32,7 @@ import adminColab_getListAllGroupChat from "../fun/get/get_list_all_group_chat";
import { ComponentAdminGlobal_TitlePage } from "../../_admin_global/_component"; import { ComponentAdminGlobal_TitlePage } from "../../_admin_global/_component";
import { AccentColor } from "@/app_modules/_global/color"; import { AccentColor } from "@/app_modules/_global/color";
import { AdminColor } from "@/app_modules/_global/color/color_pallet"; import { AdminColor } from "@/app_modules/_global/color/color_pallet";
import Admin_DetailButton from "../../_admin_global/_component/button/detail_button";
export default function AdminColab_TableGroup({ export default function AdminColab_TableGroup({
listGroup, listGroup,
@@ -114,7 +115,11 @@ function TableMenu({ listGroup }: { listGroup: any }) {
<td> <td>
<Center> <Center>
<Stack> <Stack>
<Button <Admin_DetailButton
path={`/dev/admin/colab/detail/group/${e.id}`}
/>
{/* <Button
loading={ loading={
idProject === e?.id ? (loadingDetail ? true : false) : false idProject === e?.id ? (loadingDetail ? true : false) : false
} }
@@ -126,8 +131,9 @@ function TableMenu({ listGroup }: { listGroup: any }) {
onDetailData(e?.id); onDetailData(e?.id);
}} }}
> >
Detail Detail 1
</Button> </Button> */}
{/* <Button {/* <Button
// loading={ // loading={
// idProject === e?.id ? (loadingReject ? true : false) : false // idProject === e?.id ? (loadingReject ? true : false) : false
@@ -154,19 +160,12 @@ function TableMenu({ listGroup }: { listGroup: any }) {
<ComponentAdminGlobal_TitlePage <ComponentAdminGlobal_TitlePage
name="Group Chat" name="Group Chat"
color={AdminColor.softBlue} color={AdminColor.softBlue}
component={ component={<></>}
<></>
}
/> />
<Paper p={"md"} bg={AdminColor.softBlue}> <Paper p={"md"} bg={AdminColor.softBlue}>
<Stack> <Stack>
<ScrollArea h={"65vh"}> <ScrollArea h={"65vh"}>
<Table <Table verticalSpacing={"xs"} horizontalSpacing={"md"} p={"md"}>
verticalSpacing={"xs"}
horizontalSpacing={"md"}
p={"md"}
>
<thead> <thead>
<tr> <tr>
<th> <th>
@@ -205,7 +204,7 @@ function TableMenu({ listGroup }: { listGroup: any }) {
</Stack> </Stack>
<Modal <Modal
styles={{ body: { backgroundColor: AccentColor.darkblue}}} styles={{ body: { backgroundColor: AccentColor.darkblue } }}
opened={openDetail} opened={openDetail}
onClose={() => setOpenDetail(false)} onClose={() => setOpenDetail(false)}
centered centered
@@ -224,7 +223,9 @@ function TableMenu({ listGroup }: { listGroup: any }) {
<ScrollArea h={"100%"}> <ScrollArea h={"100%"}>
<Stack> <Stack>
<Center> <Center>
<Title c={AdminColor.white} order={4}>Anggota</Title> <Title c={AdminColor.white} order={4}>
Anggota
</Title>
</Center> </Center>
<Stack> <Stack>
{detailData?.ProjectCollaboration_AnggotaRoomChat?.map( {detailData?.ProjectCollaboration_AnggotaRoomChat?.map(

View File

@@ -66,7 +66,6 @@ function TableMenu() {
const response = await apiGetAdminCollaborationPublish({ const response = await apiGetAdminCollaborationPublish({
page: `${activePage}`, page: `${activePage}`,
}) })
console.log("Ini Response", response)
if (response?.success && response?.data?.data) { if (response?.success && response?.data?.data) {
setData(response.data.data); setData(response.data.data);

View File

@@ -21,11 +21,11 @@ import { MODEL_COLLABORATION } from "@/app_modules/colab/model/interface";
import adminColab_getListAllRejected from "../fun/get/get_list_all_reject"; import adminColab_getListAllRejected from "../fun/get/get_list_all_reject";
import { AdminColor } from "@/app_modules/_global/color/color_pallet"; import { AdminColor } from "@/app_modules/_global/color/color_pallet";
import { clientLogger } from "@/util/clientLogger"; import { clientLogger } from "@/util/clientLogger";
import { useShallowEffect } from "@mantine/hooks"; import { useShallowEffect } from "@mantine/hooks";
import CustomSkeleton from "@/app_modules/components/CustomSkeleton"; import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
import { IconEye } from "@tabler/icons-react"; import { IconEye } from "@tabler/icons-react";
import { apiGetAdminCollaborationReject } from "../lib/api_fetch_admin_collaboration"; import { apiGetAdminCollaborationReject } from "../lib/api_fetch_admin_collaboration";
import Admin_DetailButton from "../../_admin_global/_component/button/detail_button";
export default function AdminColab_TableRejected() { export default function AdminColab_TableRejected() {
return ( return (
@@ -52,7 +52,7 @@ function TableMenu() {
const response = await apiGetAdminCollaborationReject({ const response = await apiGetAdminCollaborationReject({
page: `${activePage}`, page: `${activePage}`,
}) })
console.log("Ini Response", response)
if (response?.success && response?.data?.data) { if (response?.success && response?.data?.data) {
setData(response.data.data); setData(response.data.data);
setNPage(response.data.nPage || 1); setNPage(response.data.nPage || 1);
@@ -88,9 +88,10 @@ function TableMenu() {
<tr key={i}> <tr key={i}>
<td> <td>
<Center c={AdminColor.white}> <Center c={AdminColor.white}>
<Text lineClamp={1}>{e?.Author?.Profile?.name}</Text> <Text lineClamp={1}>{e?.Author.username}</Text>
</Center> </Center>
</td> </td>
<td> <td>
<Center c={AdminColor.white}> <Center c={AdminColor.white}>
<Box> <Box>
@@ -100,11 +101,13 @@ function TableMenu() {
</Box> </Box>
</Center> </Center>
</td> </td>
<td> <td>
<Center c={AdminColor.white}> <Center c={AdminColor.white}>
<Text>{e?.ProjectCollaborationMaster_Industri.name}</Text> <Text>{e?.ProjectCollaborationMaster_Industri.name}</Text>
</Center> </Center>
</td> </td>
<td> <td>
<Center c={AdminColor.white}> <Center c={AdminColor.white}>
<Text>{e?.ProjectCollaboration_Partisipasi.length}</Text> <Text>{e?.ProjectCollaboration_Partisipasi.length}</Text>
@@ -112,22 +115,7 @@ function TableMenu() {
</td> </td>
<td> <td>
<Center> <Center>
<Box w={300}> {/* <Button
<Center c={AdminColor.white}>
<Spoiler
hideLabel={"sembunyikan"}
maxHeight={50}
showLabel="tampilkan"
>
{e?.report}
</Spoiler>
</Center>
</Box>
</Center>
</td>
<td>
<Center>
<Button
loading={loading && e?.id == idData ? true : false} loading={loading && e?.id == idData ? true : false}
leftIcon={<IconEye />} leftIcon={<IconEye />}
loaderPosition="center" loaderPosition="center"
@@ -139,7 +127,8 @@ function TableMenu() {
}} }}
> >
Detail Detail
</Button> </Button> */}
<Admin_DetailButton path={`/dev/admin/colab/detail/reject/${e.id}`} />
</Center> </Center>
</td> </td>
</tr > </tr >
@@ -182,9 +171,6 @@ function TableMenu() {
<th> <th>
<Center c={AdminColor.white}>Jumlah Partisipan</Center> <Center c={AdminColor.white}>Jumlah Partisipan</Center>
</th> </th>
<th>
<Center c={AdminColor.white}>Report</Center>
</th>
<th> <th>
<Center c={AdminColor.white}>Aksi</Center> <Center c={AdminColor.white}>Aksi</Center>
</th> </th>