Merge branch 'join' of https://github.com/bipproduction/hipmi into bagas/7-mar-25
This commit is contained in:
66
src/app/api/admin/collaboration/[id]/route.ts
Normal file
66
src/app/api/admin/collaboration/[id]/route.ts
Normal file
@@ -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 }
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
143
src/app/api/admin/collaboration/status/reject/route.ts
Normal file
143
src/app/api/admin/collaboration/status/reject/route.ts
Normal file
@@ -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 }
|
||||
)
|
||||
}
|
||||
}
|
||||
12
src/app/dev/admin/colab/detail/publish/[id]/page.tsx
Normal file
12
src/app/dev/admin/colab/detail/publish/[id]/page.tsx
Normal file
@@ -0,0 +1,12 @@
|
||||
import DetailPublish from '@/app_modules/admin/colab/detail/detail_publish';
|
||||
import React from 'react';
|
||||
|
||||
function Page() {
|
||||
return (
|
||||
<>
|
||||
<DetailPublish/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default Page;
|
||||
@@ -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 (
|
||||
<>
|
||||
<AdminColab_TablePublish listData={listData} />
|
||||
<AdminColab_TablePublish />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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 (
|
||||
<>
|
||||
<AdminColab_TableRejected listReject={listReject as any} />
|
||||
<AdminColab_TableRejected />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -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 (
|
||||
<>
|
||||
<AdminInvestasi_DetailPublish dataTransaksi={dataTransaksi as any}
|
||||
statusTransaksi={statusTransaksi as any}
|
||||
<AdminInvestasi_DetailPublish
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
11
src/app_modules/admin/colab/detail/detail_group.tsx
Normal file
11
src/app_modules/admin/colab/detail/detail_group.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
import React from 'react';
|
||||
|
||||
function DetailGroup() {
|
||||
return (
|
||||
<div>
|
||||
DetailGroup
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default DetailGroup;
|
||||
173
src/app_modules/admin/colab/detail/detail_publish.tsx
Normal file
173
src/app_modules/admin/colab/detail/detail_publish.tsx
Normal file
@@ -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<MODEL_COLLABORATION | null>(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 (
|
||||
<>
|
||||
<Stack>
|
||||
<Flex justify={"space-between"}>
|
||||
<AdminGlobal_ComponentBackButton />
|
||||
<Button radius={"xl"} bg={"red"} color='white' onClick={onReject}>
|
||||
Reject
|
||||
</Button>
|
||||
</Flex>
|
||||
{!data ? (<CustomSkeleton height={"50vh"} width={"100%"} />) : (
|
||||
<Paper bg={AdminColor.softBlue} p={"md"}>
|
||||
<Title pb={10} c={AdminColor.white} order={3}>Detail Publish</Title>
|
||||
<Stack spacing={"xs"}>
|
||||
<Grid>
|
||||
<Grid.Col span={6}>
|
||||
<Text c={AdminColor.white} fw={"bold"}>Username:</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={6}>
|
||||
<Text c={AdminColor.white}>{data?.Author?.username}</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
<Grid>
|
||||
<Grid.Col span={6}>
|
||||
<Text c={AdminColor.white} fw={"bold"}>Title:</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={6}>
|
||||
<Text c={AdminColor.white}>@{data?.title}</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
<Grid>
|
||||
<Grid.Col span={6}>
|
||||
<Text c={AdminColor.white} fw={"bold"}>Industri:</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={6}>
|
||||
<Text c={AdminColor.white}>+ {data?.ProjectCollaborationMaster_Industri.name}</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
<Grid>
|
||||
<Grid.Col span={6}>
|
||||
<Text c={AdminColor.white} fw={"bold"}>Jumlah Partisipan:</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={6}>
|
||||
<Text c={AdminColor.white}>{data?.ProjectCollaboration_Partisipasi.length}</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
<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>
|
||||
|
||||
{/* Reject Project */}
|
||||
<Modal
|
||||
styles={{ body: { backgroundColor: AdminColor.softBlue } }}
|
||||
opened={openReject}
|
||||
onClose={() => setOpenReject(false)}
|
||||
centered
|
||||
withCloseButton={false}
|
||||
size={"lg"}
|
||||
>
|
||||
<Paper bg={AdminColor.softBlue} p={"md"}>
|
||||
<Stack>
|
||||
<Text c={AdminColor.white}>
|
||||
Apakah anda yakin ingin mereport project{" "}
|
||||
<Text c={AdminColor.white} span inherit fw={"bold"}>
|
||||
{data?.title}
|
||||
</Text>
|
||||
?
|
||||
</Text>{" "}
|
||||
<Textarea
|
||||
minRows={2}
|
||||
placeholder="Ketik alasan report.."
|
||||
// onChange={(val) => setReport(val.currentTarget.value)}
|
||||
/>
|
||||
<Group position="right">
|
||||
<Button
|
||||
leftIcon={<IconCheck />}
|
||||
radius={"xl"}
|
||||
// onClick={() => onReport()}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Paper>
|
||||
</Modal>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default DetailPublish;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 (
|
||||
<>
|
||||
<Stack>
|
||||
<ComponentAdminGlobal_HeaderTamplate name="Project Collaboration" />
|
||||
<TableMenu listData={listData} />
|
||||
<TableMenu />
|
||||
{/* <pre>{JSON.stringify(listData.nPage, null, 2)}</pre> */}
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
function TableMenu({ listData }: { listData: any }) {
|
||||
const [data, setData] = useState<MODEL_COLLABORATION[]>(listData.data);
|
||||
const [isNPage, setNPage] = useState(listData.nPage);
|
||||
function TableMenu() {
|
||||
const router = useRouter();
|
||||
const [data, setData] = useState<MODEL_COLLABORATION[] | null>(null);
|
||||
const [isNPage, setNPage] = useState<number>(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<MODEL_COLLABORATION>();
|
||||
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) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>{noAwal++}</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>
|
||||
<Text lineClamp={1}>{e?.Author?.Profile?.name}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>
|
||||
<Box>
|
||||
<Center c={AdminColor.white}>
|
||||
<Text lineClamp={1}>{e?.title}</Text>
|
||||
const onPageCLick = (page: number) => {
|
||||
setActivePage(page);
|
||||
}
|
||||
|
||||
const renderTableBody = () => {
|
||||
if (!Array.isArray(data) || data.length === 0) {
|
||||
return (
|
||||
<tr>
|
||||
<td colSpan={12}>
|
||||
<Center>
|
||||
<Text color="gray">Tidak ada data</Text>
|
||||
</Center>
|
||||
</Box>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>
|
||||
<Text>{e?.ProjectCollaborationMaster_Industri.name}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>
|
||||
<Text>{e?.ProjectCollaboration_Partisipasi.length}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center>
|
||||
<Stack>
|
||||
</td>
|
||||
</tr>
|
||||
)
|
||||
}
|
||||
|
||||
return data.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>
|
||||
<Text lineClamp={1}>{e?.Author?.Profile?.name}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>
|
||||
<Box>
|
||||
<Center c={AdminColor.white}>
|
||||
<Text lineClamp={1}>{e?.title}</Text>
|
||||
</Center>
|
||||
</Box>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>
|
||||
<Text>{e?.ProjectCollaborationMaster_Industri.name}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>
|
||||
<Text>{e?.ProjectCollaboration_Partisipasi.length}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center>
|
||||
<Button
|
||||
loading={
|
||||
idProject === e?.id ? (loadingDetail ? true : false) : false
|
||||
}
|
||||
loading={isLoading && e?.id == idData ? true : false}
|
||||
leftIcon={<IconEye />}
|
||||
loaderPosition="center"
|
||||
radius={"xl"}
|
||||
color="green"
|
||||
onClick={() => {
|
||||
getDetailData(e.id);
|
||||
setLoading(true);
|
||||
setIdData(e?.id);
|
||||
router.push(RouterAdminColab.detail_publish + `${e?.id}`);
|
||||
}}
|
||||
>
|
||||
Detail
|
||||
</Button>
|
||||
<Button
|
||||
loading={
|
||||
idProject === e?.id ? (loadingReject ? true : false) : false
|
||||
}
|
||||
leftIcon={<IconBan />}
|
||||
loaderPosition="center"
|
||||
radius={"xl"}
|
||||
color="red"
|
||||
onClick={() => {
|
||||
onRejected(e.id);
|
||||
}}
|
||||
>
|
||||
Reject
|
||||
</Button>
|
||||
</Stack>
|
||||
</Center>
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
|
||||
// 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");
|
||||
}
|
||||
});
|
||||
</Center>
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
}
|
||||
|
||||
// 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 }) {
|
||||
>
|
||||
<Title order={4}>Publish</Title>
|
||||
</Group>
|
||||
<Paper p={"md"} bg={AdminColor.softBlue} >
|
||||
<Stack>
|
||||
<ScrollArea h={"65vh"}>
|
||||
<Table
|
||||
verticalSpacing={"xs"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>No</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Username</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Title</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Industri</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Jumlah Partisipan</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Aksi</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{tableRow}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
<Pagination
|
||||
position="center"
|
||||
total={isNPage}
|
||||
value={activePage}
|
||||
onChange={(val) => {
|
||||
onLoad(val);
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
</Paper>
|
||||
{!data ? (
|
||||
<CustomSkeleton height={"80vh"} width={"100%"} />
|
||||
) : (
|
||||
<Paper p={"md"} bg={AdminColor.softBlue} >
|
||||
<Stack>
|
||||
<ScrollArea h={"65vh"}>
|
||||
<Table
|
||||
verticalSpacing={"xs"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Username</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Title</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Industri</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Jumlah Partisipan</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Aksi</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{renderTableBody()}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
<Pagination
|
||||
position="center"
|
||||
total={isNPage}
|
||||
value={activePage}
|
||||
onChange={(val) => {
|
||||
onPageCLick(val);
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
</Paper>
|
||||
)}
|
||||
</Stack>
|
||||
|
||||
{/* Detail Data */}
|
||||
<Modal
|
||||
styles={{body: { backgroundColor: AdminColor.softBlue}}}
|
||||
opened={openDetail}
|
||||
onClose={() => setOpenDetail(false)}
|
||||
centered
|
||||
withCloseButton={false}
|
||||
size={"lg"}
|
||||
>
|
||||
<Paper p={"md"} bg={AdminColor.softBlue}>
|
||||
<ComponentAdminColab_DetailData data={detailData as any} />
|
||||
</Paper>
|
||||
</Modal>
|
||||
|
||||
{/* Reject Project */}
|
||||
<Modal
|
||||
styles={{body: { backgroundColor: AdminColor.softBlue}}}
|
||||
opened={openReject}
|
||||
onClose={() => setOpenReject(false)}
|
||||
centered
|
||||
withCloseButton={false}
|
||||
size={"lg"}
|
||||
>
|
||||
<Paper bg={AdminColor.softBlue} p={"md"}>
|
||||
<Stack>
|
||||
<Text c={AdminColor.white}>
|
||||
Apakah anda yakin ingin mereport project{" "}
|
||||
<Text c={AdminColor.white} span inherit fw={"bold"}>
|
||||
{detailData?.title}
|
||||
</Text>
|
||||
?
|
||||
</Text>{" "}
|
||||
<Textarea
|
||||
minRows={2}
|
||||
placeholder="Ketik alasan report.."
|
||||
onChange={(val) => setReport(val.currentTarget.value)}
|
||||
/>
|
||||
<Group position="right">
|
||||
<Button
|
||||
leftIcon={<IconCheck />}
|
||||
radius={"xl"}
|
||||
onClick={() => onReport()}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Paper>
|
||||
</Modal>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
317
src/app_modules/admin/colab/sub_menu/publish.txt
Normal file
317
src/app_modules/admin/colab/sub_menu/publish.txt
Normal file
@@ -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 (
|
||||
<>
|
||||
<Stack>
|
||||
<ComponentAdminGlobal_HeaderTamplate name="Project Collaboration" />
|
||||
<TableMenu listData={listData} />
|
||||
{/* <pre>{JSON.stringify(listData.nPage, null, 2)}</pre> */}
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
function TableMenu({ listData }: { listData: any }) {
|
||||
const [data, setData] = useState<MODEL_COLLABORATION[]>(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<MODEL_COLLABORATION>();
|
||||
|
||||
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) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>{noAwal++}</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>
|
||||
<Text lineClamp={1}>{e?.Author?.Profile?.name}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>
|
||||
<Box>
|
||||
<Center c={AdminColor.white}>
|
||||
<Text lineClamp={1}>{e?.title}</Text>
|
||||
</Center>
|
||||
</Box>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>
|
||||
<Text>{e?.ProjectCollaborationMaster_Industri.name}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>
|
||||
<Text>{e?.ProjectCollaboration_Partisipasi.length}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center>
|
||||
<Stack>
|
||||
<Button
|
||||
loading={
|
||||
idProject === e?.id ? (loadingDetail ? true : false) : false
|
||||
}
|
||||
leftIcon={<IconEye />}
|
||||
loaderPosition="center"
|
||||
radius={"xl"}
|
||||
color="green"
|
||||
onClick={() => {
|
||||
getDetailData(e.id);
|
||||
}}
|
||||
>
|
||||
Detail
|
||||
</Button>
|
||||
<Button
|
||||
loading={
|
||||
idProject === e?.id ? (loadingReject ? true : false) : false
|
||||
}
|
||||
leftIcon={<IconBan />}
|
||||
loaderPosition="center"
|
||||
radius={"xl"}
|
||||
color="red"
|
||||
onClick={() => {
|
||||
onRejected(e.id);
|
||||
}}
|
||||
>
|
||||
Reject
|
||||
</Button>
|
||||
</Stack>
|
||||
</Center>
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
|
||||
// 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 (
|
||||
<>
|
||||
<Stack spacing={"xs"}>
|
||||
<Group
|
||||
position="apart"
|
||||
bg={AdminColor.softBlue}
|
||||
p={"xs"}
|
||||
style={{ borderRadius: "6px" }}
|
||||
c={AdminColor.white}
|
||||
>
|
||||
<Title order={4}>Publish</Title>
|
||||
</Group>
|
||||
<Paper p={"md"} bg={AdminColor.softBlue} >
|
||||
<Stack>
|
||||
<ScrollArea h={"65vh"}>
|
||||
<Table
|
||||
verticalSpacing={"xs"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>No</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Username</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Title</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Industri</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Jumlah Partisipan</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Aksi</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{tableRow}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
<Pagination
|
||||
position="center"
|
||||
total={isNPage}
|
||||
value={activePage}
|
||||
onChange={(val) => {
|
||||
onLoad(val);
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
</Paper>
|
||||
</Stack>
|
||||
|
||||
{/* Detail Data */}
|
||||
<Modal
|
||||
styles={{body: { backgroundColor: AdminColor.softBlue}}}
|
||||
opened={openDetail}
|
||||
onClose={() => setOpenDetail(false)}
|
||||
centered
|
||||
withCloseButton={false}
|
||||
size={"lg"}
|
||||
>
|
||||
<Paper p={"md"} bg={AdminColor.softBlue}>
|
||||
<ComponentAdminColab_DetailData data={detailData as any} />
|
||||
</Paper>
|
||||
</Modal>
|
||||
|
||||
{/* Reject Project */}
|
||||
<Modal
|
||||
styles={{body: { backgroundColor: AdminColor.softBlue}}}
|
||||
opened={openReject}
|
||||
onClose={() => setOpenReject(false)}
|
||||
centered
|
||||
withCloseButton={false}
|
||||
size={"lg"}
|
||||
>
|
||||
<Paper bg={AdminColor.softBlue} p={"md"}>
|
||||
<Stack>
|
||||
<Text c={AdminColor.white}>
|
||||
Apakah anda yakin ingin mereport project{" "}
|
||||
<Text c={AdminColor.white} span inherit fw={"bold"}>
|
||||
{detailData?.title}
|
||||
</Text>
|
||||
?
|
||||
</Text>{" "}
|
||||
<Textarea
|
||||
minRows={2}
|
||||
placeholder="Ketik alasan report.."
|
||||
onChange={(val) => setReport(val.currentTarget.value)}
|
||||
/>
|
||||
<Group position="right">
|
||||
<Button
|
||||
leftIcon={<IconCheck />}
|
||||
radius={"xl"}
|
||||
onClick={() => onReport()}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Paper>
|
||||
</Modal>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -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 (
|
||||
<>
|
||||
<Stack>
|
||||
<ComponentAdminGlobal_HeaderTamplate name="Project Collaboration" />
|
||||
<TableMenu listReject={listReject} />
|
||||
<TableMenu />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
function TableMenu({ listReject }: { listReject: any }) {
|
||||
const [data, setData] = useState<MODEL_COLLABORATION[]>(listReject.data);
|
||||
const [isNPage, setNPage] = useState(listReject.nPage);
|
||||
function TableMenu() {
|
||||
const [data, setData] = useState<MODEL_COLLABORATION[] | null>(null);
|
||||
const [isNPage, setNPage] = useState<number>(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) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>{noAwal++}</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>
|
||||
<Text lineClamp={1}>{e?.Author?.Profile?.name}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>
|
||||
<Box>
|
||||
<Center c={AdminColor.white}>
|
||||
<Text lineClamp={1}>{e?.title}</Text>
|
||||
</Center>
|
||||
</Box>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>
|
||||
<Text>{e?.ProjectCollaborationMaster_Industri.name}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>
|
||||
<Text>{e?.ProjectCollaboration_Partisipasi.length}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center>
|
||||
<Box w={400}>
|
||||
<Center>
|
||||
<Spoiler
|
||||
hideLabel={"sembunyikan"}
|
||||
maxHeight={50}
|
||||
showLabel="tampilkan"
|
||||
>
|
||||
{e?.report}
|
||||
</Spoiler>
|
||||
</Center>
|
||||
</Box>
|
||||
</Center>
|
||||
const onPageClick = (page: number) => {
|
||||
setActivePage(page);
|
||||
}
|
||||
|
||||
{/* <Stack>
|
||||
const renderTableBody = () => {
|
||||
if (!Array.isArray(data) || data.length === 0) {
|
||||
return (
|
||||
<tr>
|
||||
<td colSpan={12}>
|
||||
<Center>
|
||||
<Text color="gray">Tidak ada data</Text>
|
||||
</Center>
|
||||
</td>
|
||||
</tr>
|
||||
)
|
||||
}
|
||||
|
||||
return data.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>
|
||||
<Text lineClamp={1}>{e?.Author?.Profile?.name}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>
|
||||
<Box>
|
||||
<Center c={AdminColor.white}>
|
||||
<Text lineClamp={1}>{e?.title}</Text>
|
||||
</Center>
|
||||
</Box>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>
|
||||
<Text>{e?.ProjectCollaborationMaster_Industri.name}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>
|
||||
<Text>{e?.ProjectCollaboration_Partisipasi.length}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center>
|
||||
<Box w={300}>
|
||||
<Center c={AdminColor.white}>
|
||||
<Spoiler
|
||||
hideLabel={"sembunyikan"}
|
||||
maxHeight={50}
|
||||
showLabel="tampilkan"
|
||||
>
|
||||
{e?.report}
|
||||
</Spoiler>
|
||||
</Center>
|
||||
</Box>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center>
|
||||
<Button
|
||||
loading={
|
||||
idProject === e?.id ? (loadingDetail ? true : false) : false
|
||||
}
|
||||
loading={loading && e?.id == idData ? true : false}
|
||||
leftIcon={<IconEye />}
|
||||
loaderPosition="center"
|
||||
radius={"xl"}
|
||||
color="green"
|
||||
onClick={() => {
|
||||
getDetailData(e.id);
|
||||
setLoading(true);
|
||||
setIdData(e.id);
|
||||
}}
|
||||
>
|
||||
Detail
|
||||
</Button>
|
||||
<Button
|
||||
loading={
|
||||
idProject === e?.id ? (loadingReject ? true : false) : false
|
||||
}
|
||||
leftIcon={<IconBan />}
|
||||
loaderPosition="center"
|
||||
radius={"xl"}
|
||||
color="red"
|
||||
onClick={() => {
|
||||
onRejected(e.id);
|
||||
}}
|
||||
>
|
||||
Reject
|
||||
</Button>
|
||||
</Stack> */}
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
|
||||
</Center>
|
||||
</td>
|
||||
</tr >
|
||||
));
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<Stack spacing={"xs"}>
|
||||
@@ -136,51 +156,55 @@ function TableMenu({ listReject }: { listReject: any }) {
|
||||
>
|
||||
<Title c={AdminColor.white} order={4}>Reject</Title>
|
||||
</Group>
|
||||
<Paper p={"md"} bg={AdminColor.softBlue}>
|
||||
<Stack>
|
||||
<ScrollArea h={"65vh"}>
|
||||
<Table
|
||||
verticalSpacing={"lg"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>No</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Username</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Title</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Industri</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Jumlah Partisipan</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Report</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{tableRow}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
<Pagination
|
||||
position="center"
|
||||
total={isNPage}
|
||||
value={activePage}
|
||||
onChange={(val) => {
|
||||
onLoad(val);
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
</Paper>
|
||||
{!data ? (
|
||||
<CustomSkeleton height={"80vh"} width={"100%"} />
|
||||
) : (
|
||||
<Paper p={"md"} bg={AdminColor.softBlue}>
|
||||
<Stack>
|
||||
<ScrollArea h={"65vh"}>
|
||||
<Table
|
||||
verticalSpacing={"lg"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Username</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Title</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Industri</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Jumlah Partisipan</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Report</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Aksi</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{renderTableBody()}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
<Pagination
|
||||
position="center"
|
||||
total={isNPage}
|
||||
value={activePage}
|
||||
onChange={(val) => {
|
||||
onPageClick(val);
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
</Paper>
|
||||
)}
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
186
src/app_modules/admin/colab/sub_menu/reject.txt
Normal file
186
src/app_modules/admin/colab/sub_menu/reject.txt
Normal file
@@ -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 (
|
||||
<>
|
||||
<Stack>
|
||||
<ComponentAdminGlobal_HeaderTamplate name="Project Collaboration" />
|
||||
<TableMenu listReject={listReject} />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
function TableMenu({ listReject }: { listReject: any }) {
|
||||
const [data, setData] = useState<MODEL_COLLABORATION[]>(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) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>{noAwal++}</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>
|
||||
<Text lineClamp={1}>{e?.Author?.Profile?.name}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>
|
||||
<Box>
|
||||
<Center c={AdminColor.white}>
|
||||
<Text lineClamp={1}>{e?.title}</Text>
|
||||
</Center>
|
||||
</Box>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>
|
||||
<Text>{e?.ProjectCollaborationMaster_Industri.name}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>
|
||||
<Text>{e?.ProjectCollaboration_Partisipasi.length}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center>
|
||||
<Box w={400}>
|
||||
<Center>
|
||||
<Spoiler
|
||||
hideLabel={"sembunyikan"}
|
||||
maxHeight={50}
|
||||
showLabel="tampilkan"
|
||||
>
|
||||
{e?.report}
|
||||
</Spoiler>
|
||||
</Center>
|
||||
</Box>
|
||||
</Center>
|
||||
|
||||
{/* <Stack>
|
||||
<Button
|
||||
loading={
|
||||
idProject === e?.id ? (loadingDetail ? true : false) : false
|
||||
}
|
||||
leftIcon={<IconEye />}
|
||||
loaderPosition="center"
|
||||
radius={"xl"}
|
||||
color="green"
|
||||
onClick={() => {
|
||||
getDetailData(e.id);
|
||||
}}
|
||||
>
|
||||
Detail
|
||||
</Button>
|
||||
<Button
|
||||
loading={
|
||||
idProject === e?.id ? (loadingReject ? true : false) : false
|
||||
}
|
||||
leftIcon={<IconBan />}
|
||||
loaderPosition="center"
|
||||
radius={"xl"}
|
||||
color="red"
|
||||
onClick={() => {
|
||||
onRejected(e.id);
|
||||
}}
|
||||
>
|
||||
Reject
|
||||
</Button>
|
||||
</Stack> */}
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack spacing={"xs"}>
|
||||
<Group
|
||||
position="apart"
|
||||
bg={AdminColor.softBlue}
|
||||
p={"xs"}
|
||||
style={{ borderRadius: "6px" }}
|
||||
>
|
||||
<Title c={AdminColor.white} order={4}>Reject</Title>
|
||||
</Group>
|
||||
<Paper p={"md"} bg={AdminColor.softBlue}>
|
||||
<Stack>
|
||||
<ScrollArea h={"65vh"}>
|
||||
<Table
|
||||
verticalSpacing={"lg"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>No</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Username</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Title</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Industri</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Jumlah Partisipan</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Report</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{tableRow}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
<Pagination
|
||||
position="center"
|
||||
total={isNPage}
|
||||
value={activePage}
|
||||
onChange={(val) => {
|
||||
onLoad(val);
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
</Paper>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -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<MODEL_INVESTASI | null>(null);
|
||||
const [selectPage, setSelectPage] = useAtom(gs_admin_invetasi_menu_publish);
|
||||
|
||||
@@ -132,7 +132,7 @@ export default function AdminJob_ViewTavleReview() {
|
||||
<td>
|
||||
<Spoiler
|
||||
c={AdminColor.white}
|
||||
w={200}
|
||||
w={150}
|
||||
maxHeight={50}
|
||||
hideLabel="sembunyikan"
|
||||
showLabel="tampilkan"
|
||||
@@ -141,7 +141,7 @@ export default function AdminJob_ViewTavleReview() {
|
||||
</Spoiler>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Center w={150}>
|
||||
{e.imageId ? (
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
@@ -170,7 +170,7 @@ export default function AdminJob_ViewTavleReview() {
|
||||
<Spoiler
|
||||
style={{ color: AdminColor.white }}
|
||||
hideLabel="sembunyikan"
|
||||
w={400}
|
||||
w={250}
|
||||
maxHeight={50}
|
||||
showLabel="tampilkan"
|
||||
>
|
||||
@@ -226,6 +226,7 @@ export default function AdminJob_ViewTavleReview() {
|
||||
return (
|
||||
<>
|
||||
<Modal
|
||||
styles={{ header: { backgroundColor: AdminColor.softBlue }, body: { backgroundColor: AdminColor.softBlue}, title: { color: AdminColor.white } }}
|
||||
title={"Apakah anda yakin ingin mempublish job ini?"}
|
||||
withCloseButton={false}
|
||||
opened={publish}
|
||||
@@ -261,6 +262,7 @@ export default function AdminJob_ViewTavleReview() {
|
||||
</Modal>
|
||||
|
||||
<Modal
|
||||
styles={{ header: { backgroundColor: AdminColor.softBlue }, body: { backgroundColor: AdminColor.softBlue}, title: { color: AdminColor.white } }}
|
||||
opened={reject}
|
||||
onClose={() => {
|
||||
setReject(false);
|
||||
@@ -276,7 +278,7 @@ export default function AdminJob_ViewTavleReview() {
|
||||
maxRows={5}
|
||||
maxLength={300}
|
||||
autosize
|
||||
label={<Text fw={"bold"}>Alasan Penolakan</Text>}
|
||||
label={<Text c={AdminColor.white} fw={"bold"}>Alasan Penolakan</Text>}
|
||||
placeholder="Masukkan alasan penolakan lowongan ini"
|
||||
onChange={(val) => setCatatan(val.currentTarget.value)}
|
||||
/>
|
||||
|
||||
@@ -3,4 +3,5 @@ export const RouterAdminColab = {
|
||||
table_publish: "/dev/admin/colab/sub-menu/publish",
|
||||
table_group: "/dev/admin/colab/sub-menu/group",
|
||||
table_reject: "/dev/admin/colab/sub-menu/reject",
|
||||
detail_publish: "/dev/admin/colab/detail/publish/",
|
||||
};
|
||||
|
||||
@@ -34,6 +34,10 @@ export const RouterAdminDonasi_OLD = {
|
||||
pencairan_dana: "/dev/admin/donasi/pencairan_dana/",
|
||||
};
|
||||
|
||||
export const RouterColab = {
|
||||
// detail
|
||||
detail_publish: "/dev/admin/colab/detail/publish/",
|
||||
}
|
||||
|
||||
|
||||
export const RouterAdminAward = {
|
||||
|
||||
@@ -36,6 +36,7 @@ const middlewareConfig: MiddlewareConfig = {
|
||||
// >> buat dibawah sini <<
|
||||
"/api/admin/donasi/*",
|
||||
"/api/admin/investasi/*",
|
||||
"/api/admin/collaboration/*",
|
||||
|
||||
|
||||
// Akses awal
|
||||
|
||||
Reference in New Issue
Block a user