Merge branch 'join' into bagas/6-feb-25
This commit is contained in:
@@ -6,9 +6,11 @@ import { update } from "lodash";
|
||||
export default async function adminDonasi_funUpdatekategoriById({
|
||||
kategoriId,
|
||||
name,
|
||||
|
||||
}: {
|
||||
kategoriId: string;
|
||||
name: string;
|
||||
|
||||
}) {
|
||||
const updt = await prisma.donasiMaster_Kategori.update({
|
||||
where: {
|
||||
@@ -16,6 +18,7 @@ export default async function adminDonasi_funUpdatekategoriById({
|
||||
},
|
||||
data: {
|
||||
name: name,
|
||||
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
export {
|
||||
apiGetAdminDonasiStatusCountDashboard,
|
||||
apiGetAdminDonasiKategoriCountDashboard,
|
||||
apiGetAdminDonasiByStatus
|
||||
apiGetAdminDonasiByStatus,
|
||||
apiGetAdminDonasiKategori
|
||||
};
|
||||
const apiGetAdminDonasiStatusCountDashboard = async ({ name }:
|
||||
{ name: "Publish" | "Review" | "Reject" }) => {
|
||||
@@ -66,3 +67,20 @@ const apiGetAdminDonasiByStatus = async ({
|
||||
console.log("Ini response", response)
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
const apiGetAdminDonasiKategori = async () => {
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
|
||||
console.log("ini token", token)
|
||||
const response = await fetch(`/api/admin/donasi/kategori`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`
|
||||
|
||||
}
|
||||
})
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
@@ -32,25 +32,23 @@ import _ from "lodash";
|
||||
import { ComponentAdminGlobal_TitlePage } from "../../_admin_global/_component";
|
||||
import { AccentColor } from "@/app_modules/_global/color";
|
||||
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import { apiGetAdminDonasiKategori } from "../lib/api_fetch_admin_donasi";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
|
||||
export default function AdminDonasi_TableKategori({
|
||||
listKategori,
|
||||
}: {
|
||||
listKategori: MODEL_NEW_DEFAULT_MASTER[];
|
||||
}) {
|
||||
export default function AdminDonasi_TableKategori() {
|
||||
return (
|
||||
<>
|
||||
<Stack h={"100%"}>
|
||||
<ComponentAdminGlobal_HeaderTamplate name="Donasi" />
|
||||
<TableView list={listKategori} />
|
||||
<TableView />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function TableView({ list }: { list: MODEL_NEW_DEFAULT_MASTER[] }) {
|
||||
const [data, setData] = useState(list);
|
||||
|
||||
function TableView() {
|
||||
const [data, setData] = useState<MODEL_NEW_DEFAULT_MASTER[] | null>(null);
|
||||
const [create, setCreate] = useState("");
|
||||
const [isCreate, setIsCreate] = useState(false);
|
||||
|
||||
@@ -67,6 +65,22 @@ function TableView({ list }: { list: MODEL_NEW_DEFAULT_MASTER[] }) {
|
||||
});
|
||||
const [isChangeStatus, setIsChangeStatus] = useState(false);
|
||||
|
||||
useShallowEffect(() => {
|
||||
onLoadData();
|
||||
}, []);
|
||||
|
||||
async function onLoadData() {
|
||||
try {
|
||||
const response = await apiGetAdminDonasiKategori();
|
||||
if (response) {
|
||||
console.log("ini response", response)
|
||||
setData(response.data)
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error get kategori" , error)
|
||||
}
|
||||
}
|
||||
|
||||
async function onCreateNewKategori() {
|
||||
const tambahData = await adminDonasi_funCreateKategori({
|
||||
newKategori: create,
|
||||
@@ -114,49 +128,63 @@ function TableView({ list }: { list: MODEL_NEW_DEFAULT_MASTER[] }) {
|
||||
}
|
||||
}
|
||||
|
||||
const rowTable = data.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center c={AccentColor.white}>
|
||||
<Text>{e?.name}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center>
|
||||
<Switch
|
||||
color="orange"
|
||||
onLabel="ON"
|
||||
offLabel="OFF"
|
||||
checked={e?.active}
|
||||
onChange={(val) => {
|
||||
const status = val.currentTarget.checked;
|
||||
setIsChangeStatus(true);
|
||||
setUpdateStatus({
|
||||
kategoriId: e?.id,
|
||||
isActive: status as any,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Group position="center">
|
||||
<ActionIcon
|
||||
onClick={() => {
|
||||
setIsUpdate(true);
|
||||
setIsCreate(false);
|
||||
setUpdateKategori({
|
||||
kategoriId: e?.id,
|
||||
name: e?.name,
|
||||
});
|
||||
}}
|
||||
>
|
||||
<IconEdit color={AdminColor.green} />
|
||||
</ActionIcon>
|
||||
</Group>
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
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={AccentColor.white}>
|
||||
<Text>{e?.name}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center>
|
||||
<Switch
|
||||
color="orange"
|
||||
onLabel="ON"
|
||||
offLabel="OFF"
|
||||
checked={e?.active}
|
||||
onChange={(val) => {
|
||||
const status = val.currentTarget.checked;
|
||||
setIsChangeStatus(true);
|
||||
setUpdateStatus({
|
||||
kategoriId: e?.id,
|
||||
isActive: status as any,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Group position="center">
|
||||
<ActionIcon
|
||||
onClick={() => {
|
||||
setIsUpdate(true);
|
||||
setIsCreate(false);
|
||||
setUpdateKategori({
|
||||
kategoriId: e?.id,
|
||||
name: e?.name,
|
||||
});
|
||||
}}
|
||||
>
|
||||
<IconEdit color={AdminColor.green} />
|
||||
</ActionIcon>
|
||||
</Group>
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -167,16 +195,16 @@ function TableView({ list }: { list: MODEL_NEW_DEFAULT_MASTER[] }) {
|
||||
color={AdminColor.softBlue}
|
||||
component={
|
||||
<Button
|
||||
w={120}
|
||||
leftIcon={<IconCirclePlus />}
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
setIsCreate(true);
|
||||
setIsUpdate(false);
|
||||
}}
|
||||
>
|
||||
Tambah
|
||||
</Button>
|
||||
w={120}
|
||||
leftIcon={<IconCirclePlus />}
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
setIsCreate(true);
|
||||
setIsUpdate(false);
|
||||
}}
|
||||
>
|
||||
Tambah
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
{/* <Group
|
||||
@@ -208,7 +236,7 @@ function TableView({ list }: { list: MODEL_NEW_DEFAULT_MASTER[] }) {
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={"100%"}
|
||||
|
||||
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -223,7 +251,7 @@ function TableView({ list }: { list: MODEL_NEW_DEFAULT_MASTER[] }) {
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{rowTable}</tbody>
|
||||
<tbody>{renderTableBody()}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
{/* <Center mt={"xl"}>
|
||||
|
||||
@@ -24,6 +24,7 @@ import { useState } from "react";
|
||||
import ComponentAdminGlobal_HeaderTamplate from "../../_admin_global/header_tamplate";
|
||||
import { apiGetAdminEventRiwayat } from "@/app/dev/admin/event/_lib/api_fecth_admin_event";
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
|
||||
|
||||
export default function AdminEvent_Riwayat() {
|
||||
return (
|
||||
@@ -112,28 +113,28 @@ function DetailRiwayat() {
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Center c={AdminColor.white} w={200}>
|
||||
<Text>{e?.Author?.username}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Center c={AdminColor.white} w={200}>
|
||||
<Text lineClamp={2}>{e.title}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Center c={AdminColor.white} w={200}>
|
||||
<Text>{e.lokasi}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Center c={AdminColor.white} w={200}>
|
||||
<Text>{e.EventMaster_TipeAcara.name}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Center c={AdminColor.white} w={200}>
|
||||
<Text align="center">
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
dateStyle: "full",
|
||||
@@ -148,7 +149,7 @@ function DetailRiwayat() {
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Center c={AdminColor.white} w={200}>
|
||||
<Text align="center">
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
dateStyle: "full",
|
||||
@@ -164,7 +165,7 @@ function DetailRiwayat() {
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Center w={400}>
|
||||
<Center c={AdminColor.white} w={400}>
|
||||
<Spoiler
|
||||
hideLabel="sembunyikan"
|
||||
maxHeight={50}
|
||||
@@ -183,11 +184,11 @@ function DetailRiwayat() {
|
||||
<Stack spacing={"xs"} h={"100%"}>
|
||||
<Group
|
||||
position="apart"
|
||||
bg={"gray.4"}
|
||||
bg={AdminColor.softBlue}
|
||||
p={"xs"}
|
||||
style={{ borderRadius: "6px" }}
|
||||
>
|
||||
<Title order={4}>Riwayat</Title>
|
||||
<Title c={AdminColor.white} order={4}>Riwayat</Title>
|
||||
<TextInput
|
||||
icon={<IconSearch size={20} />}
|
||||
radius={"xl"}
|
||||
@@ -201,41 +202,40 @@ function DetailRiwayat() {
|
||||
{!data ? (
|
||||
<CustomSkeleton height={"80vh"} width="100%" />
|
||||
) : (
|
||||
<Paper p={"md"} withBorder shadow="lg" h={"80vh"}>
|
||||
<Paper p={"md"} bg={AdminColor.softBlue} h={"80vh"}>
|
||||
<ScrollArea w={"100%"} h={"90%"}>
|
||||
<Table
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={"100%"}
|
||||
striped
|
||||
highlightOnHover
|
||||
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center>Aksi</Center>
|
||||
<Center c={AdminColor.white}>Aksi</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Username</Center>
|
||||
<Center c={AdminColor.white}>Username</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Judul</Center>
|
||||
<Center c={AdminColor.white}>Judul</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Lokasi</Center>
|
||||
<Center c={AdminColor.white}>Lokasi</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Tipe Acara</Center>
|
||||
<Center c={AdminColor.white}>Tipe Acara</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Tanggal & Waktu Mulai</Center>
|
||||
<Center c={AdminColor.white}>Tanggal & Waktu Mulai</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Tanggal & Waktu Selesai</Center>
|
||||
<Center c={AdminColor.white}>Tanggal & Waktu Selesai</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Deskripsi</Center>
|
||||
<Center c={AdminColor.white}>Deskripsi</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@@ -28,6 +28,7 @@ import { AdminEvent_getListTipeAcara } from "../fun/get/get_list_tipe_acara";
|
||||
import { apiGetAdminEventTipeAcara } from "@/app/dev/admin/event/_lib/api_fecth_admin_event";
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
|
||||
|
||||
export default function AdminEvent_DetailTipeAcara() {
|
||||
return (
|
||||
@@ -92,11 +93,11 @@ function DetailTipeAcara() {
|
||||
|
||||
<Group
|
||||
position="apart"
|
||||
bg={"gray.4"}
|
||||
bg={AdminColor.softBlue}
|
||||
p={"xs"}
|
||||
style={{ borderRadius: "6px" }}
|
||||
>
|
||||
<Title order={4}>Tipe Acara</Title>
|
||||
<Title c={AdminColor.white} order={4}>Tipe Acara</Title>
|
||||
<Button
|
||||
leftIcon={<IconCirclePlus />}
|
||||
radius={"xl"}
|
||||
@@ -123,14 +124,14 @@ function DetailTipeAcara() {
|
||||
]}
|
||||
>
|
||||
<div>
|
||||
<Paper p={"md"} shadow="lg" withBorder>
|
||||
<Paper p={"md"} bg={AdminColor.softBlue}>
|
||||
<Stack>
|
||||
<Title order={3}>Tipe Acara Yang Tersedia </Title>
|
||||
<Title c={AdminColor.white} order={3}>Tipe Acara Yang Tersedia </Title>
|
||||
<Stack px={"md"}>
|
||||
{tipe.map((e, i) => (
|
||||
<Stack key={e.id} spacing={"xs"}>
|
||||
<Group position="apart">
|
||||
<Text>{e.name}</Text>
|
||||
<Text c={AdminColor.white}>{e.name}</Text>
|
||||
<Group>
|
||||
<ActionIcon
|
||||
variant="transparent"
|
||||
@@ -202,9 +203,10 @@ function DetailTipeAcara() {
|
||||
|
||||
<div>
|
||||
{openEditor ? (
|
||||
<Paper p={"sm"} shadow="lg" withBorder>
|
||||
<Paper p={"sm"} bg={AdminColor.softBlue}>
|
||||
<Stack>
|
||||
<TextInput
|
||||
styles={{ label: { color: AdminColor.white } }}
|
||||
value={edit?.name ? edit?.name : ""}
|
||||
label="Edit Tipe"
|
||||
placeholder="Contoh: Ramah Tamah, dll"
|
||||
|
||||
@@ -24,6 +24,7 @@ import { useState } from "react";
|
||||
import QRCode from "react-qr-code";
|
||||
import { ComponentAdminGlobal_TitlePage } from "../../_admin_global/_component";
|
||||
import ComponentAdminGlobal_HeaderTamplate from "../../_admin_global/header_tamplate";
|
||||
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
|
||||
|
||||
export default function AdminEvent_TablePublish() {
|
||||
return (
|
||||
@@ -135,28 +136,28 @@ function TableStatus() {
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Center c={AdminColor.white} w={200}>
|
||||
<Text>{e?.Author?.username}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Center c={AdminColor.white} w={200}>
|
||||
<Text lineClamp={2}>{e.title}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Center c={AdminColor.white} w={200}>
|
||||
<Text>{e.lokasi}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Center c={AdminColor.white} w={200}>
|
||||
<Text>{e.EventMaster_TipeAcara?.name}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Center c={AdminColor.white} w={200}>
|
||||
<Text align="center">
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
dateStyle: "full",
|
||||
@@ -171,7 +172,7 @@ function TableStatus() {
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Center c={AdminColor.white} w={200}>
|
||||
<Text align="center">
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
dateStyle: "full",
|
||||
@@ -187,7 +188,7 @@ function TableStatus() {
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Center w={400}>
|
||||
<Center c={AdminColor.white} w={400}>
|
||||
<Spoiler
|
||||
hideLabel="sembunyikan"
|
||||
maxHeight={50}
|
||||
@@ -222,7 +223,7 @@ function TableStatus() {
|
||||
<Stack spacing="xs" h="100%">
|
||||
<ComponentAdminGlobal_TitlePage
|
||||
name="Publish"
|
||||
color="green"
|
||||
color={AdminColor.softBlue}
|
||||
component={
|
||||
<TextInput
|
||||
disabled={!data}
|
||||
@@ -238,47 +239,45 @@ function TableStatus() {
|
||||
{!data ? (
|
||||
<CustomSkeleton height={"80vh"} width="100%" />
|
||||
) : (
|
||||
<Paper p="md" withBorder shadow="lg" h="80vh">
|
||||
<Paper p="md" bg={AdminColor.softBlue} h="80vh">
|
||||
<ScrollArea w="100%" h="90%">
|
||||
<Table
|
||||
verticalSpacing="md"
|
||||
horizontalSpacing="md"
|
||||
p="md"
|
||||
w={1500}
|
||||
striped
|
||||
highlightOnHover
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center>QR Code</Center>
|
||||
<Center c={AdminColor.white}>QR Code</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Download QR</Center>
|
||||
<Center c={AdminColor.white}>Download QR</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Username</Center>
|
||||
<Center c={AdminColor.white}>Username</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Judul</Center>
|
||||
<Center c={AdminColor.white}>Judul</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Lokasi</Center>
|
||||
<Center c={AdminColor.white}>Lokasi</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Tipe Acara</Center>
|
||||
<Center c={AdminColor.white}>Tipe Acara</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Tanggal & Waktu Mulai</Center>
|
||||
<Center c={AdminColor.white}>Tanggal & Waktu Mulai</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Tanggal & Waktu Selesai</Center>
|
||||
<Center c={AdminColor.white}>Tanggal & Waktu Selesai</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Deskripsi</Center>
|
||||
<Center c={AdminColor.white}>Deskripsi</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Aksi</Center>
|
||||
<Center c={AdminColor.white}>Aksi</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@@ -47,7 +47,7 @@ export default function AdminEvent_TableReject() {
|
||||
function TableStatus() {
|
||||
const router = useRouter();
|
||||
const [data, setData] = useState<MODEL_EVENT[] | null>(null);
|
||||
const [isNPage, setNPage] = useState(1);
|
||||
const [isNPage, setNPage] = useState<number>(1);
|
||||
const [activePage, setActivePage] = useState(1);
|
||||
const [isSearch, setSearch] = useState("");
|
||||
|
||||
|
||||
@@ -46,15 +46,14 @@ import adminJob_getListReview from "../fun/get/get_list_review";
|
||||
import { useAtom } from "jotai";
|
||||
import { AccentColor } from "@/app_modules/_global/color";
|
||||
import { AdminColor, MainColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import { apiGetAdminJobByStatus } from "../lib/api_fetch_admin_job";
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
|
||||
export default function AdminJob_ViewTavleReview({
|
||||
listReview,
|
||||
}: {
|
||||
listReview: any;
|
||||
}) {
|
||||
export default function AdminJob_ViewTavleReview() {
|
||||
const router = useRouter();
|
||||
const [data, setData] = useState<MODEL_JOB[]>(listReview.data);
|
||||
const [nPage, setNPage] = useState(listReview.nPage);
|
||||
const [data, setData] = useState<MODEL_JOB[] | null>(null);
|
||||
const [nPage, setNPage] = useState<number>(1);
|
||||
const [activePage, setActivePage] = useState(1);
|
||||
const [isSearch, setSearch] = useState("");
|
||||
const [publish, setPublish] = useState(false);
|
||||
@@ -70,153 +69,159 @@ export default function AdminJob_ViewTavleReview({
|
||||
const [isShowReload, setIsShowReload] = useState(false);
|
||||
|
||||
useShallowEffect(() => {
|
||||
if (isAdminJob_TriggerReview) {
|
||||
setIsShowReload(true);
|
||||
loadInitialData();
|
||||
}, [activePage, isSearch]);
|
||||
|
||||
|
||||
const loadInitialData = async () => {
|
||||
try {
|
||||
const response = await apiGetAdminJobByStatus({
|
||||
status: "Review",
|
||||
page: `${activePage}`,
|
||||
search: isSearch
|
||||
})
|
||||
|
||||
|
||||
if (response?.success && response?.data.data) {
|
||||
setData(response.data.data);
|
||||
setNPage(response.data.nPage || 1);
|
||||
} else {
|
||||
console.error("Invliad data format recieved", response)
|
||||
setData([]);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error get data table publish", error);
|
||||
setData([]);
|
||||
}
|
||||
}, [isAdminJob_TriggerReview, setIsShowReload]);
|
||||
|
||||
// useShallowEffect(() => {
|
||||
// onLoadData({
|
||||
// onSuccessLoad(val) {
|
||||
// setData(val.data);
|
||||
// setNPage(val.nPage);
|
||||
// },
|
||||
// });
|
||||
// }, [setData, setNPage]);
|
||||
// async function onLoadData({
|
||||
// onSuccessLoad,
|
||||
// }: {
|
||||
// onSuccessLoad: (val: any) => any;
|
||||
// }) {
|
||||
// const loadData = await adminJob_getListReview({ page: 1 });
|
||||
// onSuccessLoad(loadData);
|
||||
// }
|
||||
|
||||
}
|
||||
async function onLoadData() {
|
||||
const loadData = await adminJob_getListReview({ page: 1 });
|
||||
setData(loadData.data as any);
|
||||
setNPage(loadData.nPage);
|
||||
loadInitialData();
|
||||
setIsLoading(false);
|
||||
setIsShowReload(false);
|
||||
setIsAdminJob_TriggerReview(false);
|
||||
}
|
||||
|
||||
async function onSearch(s: string) {
|
||||
setSearch(s);
|
||||
const onSearch = async (searchTerm: string) => {
|
||||
setSearch(searchTerm);
|
||||
setActivePage(1);
|
||||
const loadData = await adminJob_getListReview({
|
||||
page: 1,
|
||||
search: s,
|
||||
});
|
||||
setData(loadData.data as any);
|
||||
setNPage(loadData.nPage);
|
||||
}
|
||||
|
||||
async function onPageClick(p: any) {
|
||||
setActivePage(p);
|
||||
const loadData = await adminJob_getListReview({
|
||||
search: isSearch,
|
||||
page: p,
|
||||
});
|
||||
setData(loadData.data as any);
|
||||
setNPage(loadData.nPage);
|
||||
const onPageClick = (page: number) => {
|
||||
setActivePage(page);
|
||||
}
|
||||
|
||||
const rowTable = data?.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center w={150}>
|
||||
<Text c={AdminColor.white}>{e?.Author?.username}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Spoiler
|
||||
w={200}
|
||||
maxHeight={50}
|
||||
hideLabel="sembunyikan"
|
||||
showLabel="tampilkan"
|
||||
>
|
||||
{e.title}
|
||||
</Spoiler>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
{e.imageId ? (
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={isLoading && jobId == e?.id}
|
||||
color="green"
|
||||
radius={"xl"}
|
||||
leftIcon={<IconPhotoCheck />}
|
||||
onClick={() => {
|
||||
setJobId(e?.id);
|
||||
setIsLoading(true);
|
||||
router.push(RouterAdminGlobal.preview_image({ id: e.imageId }));
|
||||
}}
|
||||
>
|
||||
Lihat
|
||||
</Button>
|
||||
) : (
|
||||
<Center w={150}>
|
||||
<Text c={AdminColor.white} fw={"bold"} fz={"xs"} fs={"italic"}>
|
||||
Tidak ada poster
|
||||
</Text>
|
||||
const renderTableBody = () => {
|
||||
if (!Array.isArray(data) || data.length === 0) {
|
||||
return (
|
||||
<tr>
|
||||
<td colSpan={12}>
|
||||
<Center>
|
||||
<Text color="gray">Tidak ada data</Text>
|
||||
</Center>
|
||||
)}
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Spoiler
|
||||
hideLabel="sembunyikan"
|
||||
w={400}
|
||||
maxHeight={50}
|
||||
showLabel="tampilkan"
|
||||
>
|
||||
<div dangerouslySetInnerHTML={{ __html: e.content }} />
|
||||
</Spoiler>
|
||||
</td>
|
||||
<td>
|
||||
<Spoiler
|
||||
hideLabel="sembunyikan"
|
||||
w={400}
|
||||
maxHeight={50}
|
||||
showLabel="tampilkan"
|
||||
>
|
||||
<div dangerouslySetInnerHTML={{ __html: e.deskripsi }} />
|
||||
</Spoiler>
|
||||
</td>
|
||||
<td>
|
||||
<Stack>
|
||||
<Stack align="center">
|
||||
<Button
|
||||
color={"green"}
|
||||
leftIcon={<IconCircleCheck />}
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
setJobId(e?.id);
|
||||
setPublish(true);
|
||||
}
|
||||
|
||||
}
|
||||
>
|
||||
Publish
|
||||
</Button>
|
||||
<Button
|
||||
color={"red"}
|
||||
leftIcon={<IconBan />}
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
setReject(true);
|
||||
setJobId(e.id);
|
||||
}}
|
||||
>
|
||||
Reject
|
||||
</Button>
|
||||
</td>
|
||||
</tr>
|
||||
)
|
||||
}
|
||||
return data.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center w={150}>
|
||||
<Text c={AdminColor.white}>{e?.Author?.username}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Spoiler
|
||||
c={AdminColor.white}
|
||||
w={200}
|
||||
maxHeight={50}
|
||||
hideLabel="sembunyikan"
|
||||
showLabel="tampilkan"
|
||||
>
|
||||
{e.title}
|
||||
</Spoiler>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
{e.imageId ? (
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={isLoading && jobId == e?.id}
|
||||
color="green"
|
||||
radius={"xl"}
|
||||
leftIcon={<IconPhotoCheck />}
|
||||
onClick={() => {
|
||||
setJobId(e?.id);
|
||||
setIsLoading(true);
|
||||
router.push(RouterAdminGlobal.preview_image({ id: e.imageId }));
|
||||
}}
|
||||
>
|
||||
Lihat
|
||||
</Button>
|
||||
) : (
|
||||
<Center w={150}>
|
||||
<Text c={AdminColor.white} fw={"bold"} fz={"xs"} fs={"italic"}>
|
||||
Tidak ada poster
|
||||
</Text>
|
||||
</Center>
|
||||
)}
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Spoiler
|
||||
style={{ color: AdminColor.white }}
|
||||
hideLabel="sembunyikan"
|
||||
w={400}
|
||||
maxHeight={50}
|
||||
showLabel="tampilkan"
|
||||
>
|
||||
<div dangerouslySetInnerHTML={{ __html: e.content }} />
|
||||
</Spoiler>
|
||||
</td>
|
||||
<td>
|
||||
<Spoiler
|
||||
style={{ color: AdminColor.white }}
|
||||
hideLabel="sembunyikan"
|
||||
w={400}
|
||||
maxHeight={50}
|
||||
showLabel="tampilkan"
|
||||
>
|
||||
<div dangerouslySetInnerHTML={{ __html: e.deskripsi }} />
|
||||
</Spoiler>
|
||||
</td>
|
||||
<td>
|
||||
<Stack>
|
||||
<Stack align="center">
|
||||
<Button
|
||||
color={"green"}
|
||||
leftIcon={<IconCircleCheck />}
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
setJobId(e?.id);
|
||||
setPublish(true);
|
||||
}
|
||||
|
||||
}
|
||||
>
|
||||
Publish
|
||||
</Button>
|
||||
<Button
|
||||
color={"red"}
|
||||
leftIcon={<IconBan />}
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
setReject(true);
|
||||
setJobId(e.id);
|
||||
}}
|
||||
>
|
||||
Reject
|
||||
</Button>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -306,7 +311,7 @@ export default function AdminJob_ViewTavleReview({
|
||||
</Group>
|
||||
</Stack>
|
||||
</Modal>
|
||||
|
||||
|
||||
|
||||
<Stack spacing={"xs"} h={"100%"}>
|
||||
<ComponentAdminGlobal_TitlePage
|
||||
@@ -323,76 +328,79 @@ export default function AdminJob_ViewTavleReview({
|
||||
/>
|
||||
}
|
||||
/>
|
||||
{!data ? (
|
||||
<CustomSkeleton height={"80vh"} width={"100%"} />
|
||||
) : (
|
||||
<Paper p={"md"} bg={AdminColor.softBlue} h={"80vh"}>
|
||||
{isShowReload && (
|
||||
<Paper bg={"red"} w={"50%"}>
|
||||
<Affix position={{ top: rem(200) }} w={"100%"}>
|
||||
<Center>
|
||||
<Button
|
||||
style={{
|
||||
transition: "0.5s",
|
||||
border: `1px solid ${AccentColor.skyblue}`,
|
||||
}}
|
||||
bg={AccentColor.blue}
|
||||
loaderPosition="center"
|
||||
loading={isLoading}
|
||||
radius={"xl"}
|
||||
opacity={0.8}
|
||||
onClick={() => onLoadData()}
|
||||
leftIcon={<IconRefresh />}
|
||||
>
|
||||
Update Data
|
||||
</Button>
|
||||
</Center>
|
||||
</Affix>
|
||||
</Paper>
|
||||
)}
|
||||
|
||||
<Paper p={"md"} bg={AdminColor.softBlue} h={"80vh"}>
|
||||
{isShowReload && (
|
||||
<Paper bg={"red"} w={"50%"}>
|
||||
<Affix position={{ top: rem(200) }} w={"100%"}>
|
||||
<Center>
|
||||
<Button
|
||||
style={{
|
||||
transition: "0.5s",
|
||||
border: `1px solid ${AccentColor.skyblue}`,
|
||||
}}
|
||||
bg={AccentColor.blue}
|
||||
loaderPosition="center"
|
||||
loading={isLoading}
|
||||
radius={"xl"}
|
||||
opacity={0.8}
|
||||
onClick={() => onLoadData()}
|
||||
leftIcon={<IconRefresh />}
|
||||
>
|
||||
Update Data
|
||||
</Button>
|
||||
</Center>
|
||||
</Affix>
|
||||
</Paper>
|
||||
)}
|
||||
<ScrollArea w={"100%"} h={"90%"}>
|
||||
<Table
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={"100%"}
|
||||
h={"100%"}
|
||||
|
||||
<ScrollArea w={"100%"} h={"90%"}>
|
||||
<Table
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={"100%"}
|
||||
h={"100%"}
|
||||
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Author</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Text c={AdminColor.white}>Judul</Text>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Poster</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Text c={AdminColor.white}>Syarat Ketentuan</Text>
|
||||
</th>
|
||||
<th>
|
||||
<Text c={AdminColor.white}>Deskripsi</Text>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Aksi</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{rowTable}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
<Center mt={"xl"}>
|
||||
<Pagination
|
||||
value={activePage}
|
||||
total={nPage}
|
||||
onChange={(val) => {
|
||||
onPageClick(val);
|
||||
}}
|
||||
/>
|
||||
</Center>
|
||||
</Paper>
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Author</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Text c={AdminColor.white}>Judul</Text>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Poster</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Text c={AdminColor.white}>Syarat Ketentuan</Text>
|
||||
</th>
|
||||
<th>
|
||||
<Text c={AdminColor.white}>Deskripsi</Text>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Aksi</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{renderTableBody()}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
<Center mt={"xl"}>
|
||||
<Pagination
|
||||
value={activePage}
|
||||
total={nPage}
|
||||
onChange={(val) => {
|
||||
onPageClick(val);
|
||||
}}
|
||||
/>
|
||||
</Center>
|
||||
</Paper>
|
||||
)}
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -17,135 +17,163 @@ import {
|
||||
Text,
|
||||
TextInput,
|
||||
} from "@mantine/core";
|
||||
import { IconPhotoCheck, IconSearch } from "@tabler/icons-react";
|
||||
import { IconPhotoCheck, IconSearch, IconSettingsSearch } from "@tabler/icons-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import adminJob_getListPublish from "../../fun/get/get_list_publish";
|
||||
import { RouterAdminGlobal } from "@/app/lib";
|
||||
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import { apiGetAdminJobByStatus } from "../../lib/api_fetch_admin_job";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
|
||||
export default function AdminJob_TablePublish({
|
||||
dataPublish,
|
||||
}: {
|
||||
dataPublish: any;
|
||||
}) {
|
||||
export default function AdminJob_TablePublish() {
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<ComponentAdminGlobal_HeaderTamplate name="Job Vacancy" />
|
||||
<TableStatus dataPublish={dataPublish} />
|
||||
<TableStatus />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function TableStatus({ dataPublish }: { dataPublish: any }) {
|
||||
function TableStatus() {
|
||||
const router = useRouter();
|
||||
|
||||
const [data, setData] = useState<MODEL_JOB[]>(dataPublish.data);
|
||||
const [nPage, setNPage] = useState(dataPublish.nPage);
|
||||
const [data, setData] = useState<MODEL_JOB[] | null>(null);
|
||||
const [nPage, setNPage] = useState<number>(1);
|
||||
const [activePage, setActivePage] = useState(1);
|
||||
const [isSearch, setSearch] = useState("");
|
||||
const [isLoadingShowImage, setLoadingShowImage] = useState(false);
|
||||
const [dataId, setDataId] = useState("");
|
||||
|
||||
async function onSearch(s: string) {
|
||||
setSearch(s);
|
||||
useShallowEffect(() => {
|
||||
loadInitialData();
|
||||
}, [activePage, isSearch])
|
||||
|
||||
const loadInitialData = async () => {
|
||||
try {
|
||||
const response = await apiGetAdminJobByStatus({
|
||||
status: "Publish",
|
||||
page: `${activePage}`,
|
||||
search: isSearch
|
||||
})
|
||||
|
||||
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 format recieved:", error)
|
||||
setData([])
|
||||
}
|
||||
}
|
||||
const onSearch = async (searchTerm: string) => {
|
||||
setSearch(searchTerm);
|
||||
setActivePage(1);
|
||||
const loadData = await adminJob_getListPublish({
|
||||
page: 1,
|
||||
search: s,
|
||||
});
|
||||
setData(loadData.data as any);
|
||||
setNPage(loadData.nPage);
|
||||
}
|
||||
|
||||
async function onPageClick(p: any) {
|
||||
setActivePage(p);
|
||||
const loadData = await adminJob_getListPublish({
|
||||
search: isSearch,
|
||||
page: p,
|
||||
});
|
||||
setData(loadData.data as any);
|
||||
setNPage(loadData.nPage);
|
||||
const onPageClick = (page: number) => {
|
||||
setActivePage(page);
|
||||
}
|
||||
|
||||
const TableRows = data?.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center w={150}>
|
||||
<Text c={AdminColor.white}>{e?.Author?.username}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={150}>
|
||||
<Text>
|
||||
{e?.isArsip ? (
|
||||
<Badge variant="light">Arsip</Badge>
|
||||
) : (
|
||||
<Badge color="green">Publish</Badge>
|
||||
)}
|
||||
</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Spoiler
|
||||
w={300}
|
||||
maxHeight={50}
|
||||
hideLabel="sembunyikan"
|
||||
showLabel="tampilkan"
|
||||
>
|
||||
{e.title}
|
||||
</Spoiler>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
{e.imageId ? (
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={isLoadingShowImage && e.id === dataId}
|
||||
color="green"
|
||||
radius={"xl"}
|
||||
leftIcon={<IconPhotoCheck />}
|
||||
onClick={() => {
|
||||
setLoadingShowImage(true);
|
||||
setDataId(e.id);
|
||||
router.push(RouterAdminGlobal.preview_image({ id: e.imageId }));
|
||||
}}
|
||||
>
|
||||
Lihat
|
||||
</Button>
|
||||
) : (
|
||||
<Center w={200}>
|
||||
<Text c={AdminColor.white} fw={"bold"} fz={"xs"} fs={"italic"}>
|
||||
Tidak ada poster
|
||||
</Text>
|
||||
const renderTableBody = () => {
|
||||
if (!Array.isArray(data) || data.length === 0) {
|
||||
return (
|
||||
<tr>
|
||||
<td colSpan={12}>
|
||||
<Center>
|
||||
<Text color="gray">Tidak ada data</Text>
|
||||
</Center>
|
||||
)}
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Spoiler
|
||||
hideLabel="sembunyikan"
|
||||
w={400}
|
||||
maxHeight={50}
|
||||
showLabel="tampilkan"
|
||||
>
|
||||
<div dangerouslySetInnerHTML={{ __html: e.content }} />
|
||||
</Spoiler>
|
||||
</td>
|
||||
<td>
|
||||
<Spoiler
|
||||
hideLabel="sembunyikan"
|
||||
w={400}
|
||||
maxHeight={50}
|
||||
showLabel="tampilkan"
|
||||
>
|
||||
<div dangerouslySetInnerHTML={{ __html: e.deskripsi }} />
|
||||
</Spoiler>
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
</td>
|
||||
</tr>
|
||||
)
|
||||
}
|
||||
return data?.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center w={150}>
|
||||
<Text c={AdminColor.white}>{e?.Author?.username}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={150}>
|
||||
<Text>
|
||||
{e?.isArsip ? (
|
||||
<Badge variant="light">Arsip</Badge>
|
||||
) : (
|
||||
<Badge color="green">Publish</Badge>
|
||||
)}
|
||||
</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Spoiler
|
||||
c={AdminColor.white}
|
||||
w={300}
|
||||
maxHeight={50}
|
||||
hideLabel="sembunyikan"
|
||||
showLabel="tampilkan"
|
||||
>
|
||||
{e.title}
|
||||
</Spoiler>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
{e.imageId ? (
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={isLoadingShowImage && e.id === dataId}
|
||||
color="green"
|
||||
radius={"xl"}
|
||||
leftIcon={<IconPhotoCheck />}
|
||||
onClick={() => {
|
||||
setLoadingShowImage(true);
|
||||
setDataId(e.id);
|
||||
router.push(RouterAdminGlobal.preview_image({ id: e.imageId }));
|
||||
}}
|
||||
>
|
||||
Lihat
|
||||
</Button>
|
||||
) : (
|
||||
<Center w={200}>
|
||||
<Text c={AdminColor.white} fw={"bold"} fz={"xs"} fs={"italic"}>
|
||||
Tidak ada poster
|
||||
</Text>
|
||||
</Center>
|
||||
)}
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Spoiler
|
||||
c={AdminColor.white}
|
||||
hideLabel="sembunyikan"
|
||||
w={400}
|
||||
maxHeight={50}
|
||||
showLabel="tampilkan"
|
||||
>
|
||||
<div dangerouslySetInnerHTML={{ __html: e.content }} />
|
||||
</Spoiler>
|
||||
</td>
|
||||
<td>
|
||||
<Spoiler
|
||||
c={AdminColor.white}
|
||||
hideLabel="sembunyikan"
|
||||
w={400}
|
||||
maxHeight={50}
|
||||
showLabel="tampilkan"
|
||||
>
|
||||
<div dangerouslySetInnerHTML={{ __html: e.deskripsi }} />
|
||||
</Spoiler>
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -165,52 +193,55 @@ function TableStatus({ dataPublish }: { dataPublish: any }) {
|
||||
/>
|
||||
}
|
||||
/>
|
||||
{!data ? (
|
||||
<CustomSkeleton height={"80vh"} width="100%" />
|
||||
) : (
|
||||
<Paper p={"md"} bg={AdminColor.softBlue} h={"80vh"}>
|
||||
<ScrollArea w={"100%"} h={"90%"}>
|
||||
<Table
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={"100%"}
|
||||
h={"100%"}
|
||||
|
||||
<Paper p={"md"} bg={AdminColor.softBlue} h={"80vh"}>
|
||||
<ScrollArea w={"100%"} h={"90%"}>
|
||||
<Table
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={"100%"}
|
||||
h={"100%"}
|
||||
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Author</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Status</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Text c={AdminColor.white}>Judul</Text>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Poster</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Text c={AdminColor.white}>Syarat Ketentuan</Text>
|
||||
</th>
|
||||
<th>
|
||||
<Text c={AdminColor.white}>Deskripsi</Text>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{TableRows}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
<Center mt={"xl"}>
|
||||
<Pagination
|
||||
value={activePage}
|
||||
total={nPage}
|
||||
onChange={(val) => {
|
||||
onPageClick(val);
|
||||
}}
|
||||
/>
|
||||
</Center>
|
||||
</Paper>
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Author</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Status</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Text c={AdminColor.white}>Judul</Text>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Poster</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Text c={AdminColor.white}>Syarat Ketentuan</Text>
|
||||
</th>
|
||||
<th>
|
||||
<Text c={AdminColor.white}>Deskripsi</Text>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{renderTableBody()}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
<Center mt={"xl"}>
|
||||
<Pagination
|
||||
value={activePage}
|
||||
total={nPage}
|
||||
onChange={(val) => {
|
||||
onPageClick(val);
|
||||
}}
|
||||
/>
|
||||
</Center>
|
||||
</Paper>
|
||||
)}
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -31,6 +31,9 @@ import { WibuRealtime } from "wibu-pkg";
|
||||
import { AdminJob_funEditCatatanById } from "../../fun/edit/fun_edit_catatan_by_id";
|
||||
import adminJob_getListReject from "../../fun/get/get_list_reject";
|
||||
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import { apiGetAdminJobByStatus } from "../../lib/api_fetch_admin_job";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
|
||||
export default function AdminJob_TableReject({
|
||||
dataReject,
|
||||
@@ -41,16 +44,16 @@ export default function AdminJob_TableReject({
|
||||
<>
|
||||
<Stack>
|
||||
<ComponentAdminGlobal_HeaderTamplate name="Job Vacancy" />
|
||||
<TableStatus listReject={dataReject} />
|
||||
<TableStatus />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function TableStatus({ listReject }: { listReject: any }) {
|
||||
function TableStatus() {
|
||||
const router = useRouter();
|
||||
const [data, setData] = useState<MODEL_JOB[]>(listReject.data);
|
||||
const [nPage, setNPage] = useState(listReject.nPage);
|
||||
const [data, setData] = useState<MODEL_JOB[] | null>(null);
|
||||
const [nPage, setNPage] = useState<number>(1);
|
||||
const [activePage, setActivePage] = useState(1);
|
||||
const [isSearch, setSearch] = useState("");
|
||||
|
||||
@@ -59,119 +62,148 @@ function TableStatus({ listReject }: { listReject: any }) {
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [catatan, setCatatan] = useState("");
|
||||
|
||||
async function onSearch(s: string) {
|
||||
setSearch(s);
|
||||
const loadData = await adminJob_getListReject({
|
||||
page: 1,
|
||||
search: s,
|
||||
});
|
||||
setData(loadData.data as any);
|
||||
setNPage(loadData.nPage);
|
||||
useShallowEffect(() => {
|
||||
loadInitialData();
|
||||
}, [activePage, isSearch]);
|
||||
const loadInitialData = async () => {
|
||||
try {
|
||||
const response = await apiGetAdminJobByStatus({
|
||||
status: "Reject",
|
||||
page: `${activePage}`,
|
||||
search: isSearch
|
||||
});
|
||||
|
||||
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 format recieced:", error);
|
||||
setData([])
|
||||
}
|
||||
}
|
||||
|
||||
const onSearch = async (searchTerm: string) => {
|
||||
setSearch(searchTerm);
|
||||
setActivePage(1);
|
||||
}
|
||||
|
||||
async function onPageClick(p: any) {
|
||||
setActivePage(p);
|
||||
const loadData = await adminJob_getListReject({
|
||||
search: isSearch,
|
||||
page: p,
|
||||
});
|
||||
setData(loadData.data as any);
|
||||
setNPage(loadData.nPage);
|
||||
const onPageClick = (page: number) => {
|
||||
setActivePage(page);
|
||||
}
|
||||
|
||||
const rowTable = data?.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center w={150}>
|
||||
<Text c={AdminColor.white}>{e?.Author?.username}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Spoiler
|
||||
w={200}
|
||||
maxHeight={50}
|
||||
hideLabel="sembunyikan"
|
||||
showLabel="tampilkan"
|
||||
>
|
||||
{e.title}
|
||||
</Spoiler>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={150}>
|
||||
{e.imageId ? (
|
||||
<Button
|
||||
loading={isLoading && e?.imageId === jobId}
|
||||
loaderPosition="center"
|
||||
color="green"
|
||||
radius={"xl"}
|
||||
leftIcon={<IconPhotoCheck />}
|
||||
onClick={() => {
|
||||
setJobId(e?.imageId);
|
||||
setIsLoading(true);
|
||||
router.push(RouterAdminJob.detail_poster + e?.imageId);
|
||||
}}
|
||||
>
|
||||
Lihat
|
||||
</Button>
|
||||
) : (
|
||||
<Center w={150}>
|
||||
<Text c={AdminColor.white} fw={"bold"} fz={"xs"} fs={"italic"}>
|
||||
Tidak ada poster
|
||||
</Text>
|
||||
const renderTableBody = () => {
|
||||
if (!Array.isArray(data) || data.length === 0) {
|
||||
return (
|
||||
<tr>
|
||||
<td colSpan={12}>
|
||||
<Center>
|
||||
<Text color="gray">Tidak ada data</Text>
|
||||
</Center>
|
||||
)}
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Spoiler
|
||||
w={400}
|
||||
maxHeight={50}
|
||||
hideLabel="sembunyikan"
|
||||
showLabel="tampilkan"
|
||||
>
|
||||
<div dangerouslySetInnerHTML={{ __html: e.content }} />
|
||||
</Spoiler>
|
||||
</td>
|
||||
<td>
|
||||
<Spoiler
|
||||
hideLabel="sembunyikan"
|
||||
w={400}
|
||||
maxHeight={50}
|
||||
showLabel="tampilkan"
|
||||
>
|
||||
<div dangerouslySetInnerHTML={{ __html: e.deskripsi }} />
|
||||
</Spoiler>
|
||||
</td>
|
||||
<td>
|
||||
<Spoiler
|
||||
hideLabel="sembunyikan"
|
||||
w={400}
|
||||
maxHeight={50}
|
||||
showLabel="tampilkan"
|
||||
>
|
||||
{e.catatan}
|
||||
</Spoiler>
|
||||
</td>
|
||||
<td>
|
||||
<Button
|
||||
color={"red"}
|
||||
leftIcon={<IconBan />}
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
setReject(true);
|
||||
setJobId(e.id);
|
||||
setCatatan(e.catatan);
|
||||
}}
|
||||
>
|
||||
<Stack spacing={0}>
|
||||
<Text fz={10}>Tambah</Text>
|
||||
<Text fz={10}>Catatan</Text>
|
||||
</Stack>
|
||||
</Button>
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
</td>
|
||||
</tr>
|
||||
)
|
||||
}
|
||||
return data?.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center w={150}>
|
||||
<Text c={AdminColor.white}>{e?.Author?.username}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Spoiler
|
||||
w={200}
|
||||
maxHeight={50}
|
||||
hideLabel="sembunyikan"
|
||||
showLabel="tampilkan"
|
||||
c={AdminColor.white}
|
||||
>
|
||||
{e.title}
|
||||
</Spoiler>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={150}>
|
||||
{e.imageId ? (
|
||||
<Button
|
||||
loading={isLoading && e?.imageId === jobId}
|
||||
loaderPosition="center"
|
||||
color="green"
|
||||
radius={"xl"}
|
||||
leftIcon={<IconPhotoCheck />}
|
||||
onClick={() => {
|
||||
setJobId(e?.imageId);
|
||||
setIsLoading(true);
|
||||
router.push(RouterAdminJob.detail_poster + e?.imageId);
|
||||
}}
|
||||
>
|
||||
Lihat
|
||||
</Button>
|
||||
) : (
|
||||
<Center w={150}>
|
||||
<Text c={AdminColor.white} fw={"bold"} fz={"xs"} fs={"italic"}>
|
||||
Tidak ada poster
|
||||
</Text>
|
||||
</Center>
|
||||
)}
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Spoiler
|
||||
c={AdminColor.white}
|
||||
w={400}
|
||||
maxHeight={50}
|
||||
hideLabel="sembunyikan"
|
||||
showLabel="tampilkan"
|
||||
>
|
||||
<div dangerouslySetInnerHTML={{ __html: e.content }} />
|
||||
</Spoiler>
|
||||
</td>
|
||||
<td>
|
||||
<Spoiler
|
||||
c={AdminColor.white}
|
||||
hideLabel="sembunyikan"
|
||||
w={400}
|
||||
maxHeight={50}
|
||||
showLabel="tampilkan"
|
||||
>
|
||||
<div dangerouslySetInnerHTML={{ __html: e.deskripsi }} />
|
||||
</Spoiler>
|
||||
</td>
|
||||
<td>
|
||||
<Spoiler
|
||||
c={AdminColor.white}
|
||||
hideLabel="sembunyikan"
|
||||
w={400}
|
||||
maxHeight={50}
|
||||
showLabel="tampilkan"
|
||||
>
|
||||
{e.catatan}
|
||||
</Spoiler>
|
||||
</td>
|
||||
<td>
|
||||
<Button
|
||||
color={"red"}
|
||||
leftIcon={<IconBan />}
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
setReject(true);
|
||||
setJobId(e.id);
|
||||
setCatatan(e.catatan);
|
||||
}}
|
||||
>
|
||||
<Stack spacing={0} c={AdminColor.white}>
|
||||
<Text fz={10}>Tambah</Text>
|
||||
<Text fz={10}>Catatan</Text>
|
||||
</Stack>
|
||||
</Button>
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -253,7 +285,7 @@ function TableStatus({ listReject }: { listReject: any }) {
|
||||
p={"md"}
|
||||
w={"100%"}
|
||||
h={"100%"}
|
||||
|
||||
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -280,7 +312,7 @@ function TableStatus({ listReject }: { listReject: any }) {
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{rowTable}</tbody>
|
||||
<tbody>{renderTableBody()}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
<Center mt={"xl"}>
|
||||
|
||||
@@ -4,16 +4,12 @@ import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/_admin_glob
|
||||
import { Stack } from "@mantine/core";
|
||||
import { AdminJob_ViewTavleReview } from "../../_view";
|
||||
|
||||
export default function AdminJob_TableReview({
|
||||
dataReview,
|
||||
}: {
|
||||
dataReview: any;
|
||||
}) {
|
||||
export default function AdminJob_TableReview() {
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<ComponentAdminGlobal_HeaderTamplate name="Job Vacancy" />
|
||||
<AdminJob_ViewTavleReview listReview={dataReview} />
|
||||
<AdminJob_ViewTavleReview />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
export {
|
||||
apiGetJobStatusCountDashboard,
|
||||
apiGetJobArsipCount
|
||||
apiGetAdminJobStatusCountDashboard as apiGetJobStatusCountDashboard ,
|
||||
apiGetAdminJobArsipCount as apiGetJobArsipCount,
|
||||
apiGetAdminJobByStatus
|
||||
}
|
||||
|
||||
const apiGetJobStatusCountDashboard = async ({ name }: {
|
||||
const apiGetAdminJobStatusCountDashboard = async ({ name }: {
|
||||
name: "Publish" | "Review" | "Reject";
|
||||
}) => {
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
@@ -21,7 +22,7 @@ const apiGetJobStatusCountDashboard = async ({ name }: {
|
||||
return await response.json().catch(() => null)
|
||||
}
|
||||
|
||||
const apiGetJobArsipCount = async () => {
|
||||
const apiGetAdminJobArsipCount = async () => {
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
|
||||
@@ -36,4 +37,31 @@ const apiGetJobArsipCount = async () => {
|
||||
});
|
||||
return await response.json().catch(() => null)
|
||||
|
||||
};
|
||||
};
|
||||
const apiGetAdminJobByStatus = async ({
|
||||
status,
|
||||
page,
|
||||
search
|
||||
}: {
|
||||
status: "Publish" | "Review" | "Reject";
|
||||
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/job/${status}${isPage}${isSearch}`,
|
||||
{
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`
|
||||
}
|
||||
}
|
||||
)
|
||||
return await response.json().catch(() => null)
|
||||
}
|
||||
@@ -85,7 +85,7 @@ export default function HomeViewNew() {
|
||||
<ActionIcon radius={"xl"} variant={"transparent"}>
|
||||
<IconUserSearch color={MainColor.white} />
|
||||
</ActionIcon>
|
||||
) : dataUser.profile === undefined ? (
|
||||
) : dataUser?.profile === undefined ? (
|
||||
<ActionIcon
|
||||
radius={"xl"}
|
||||
variant={"transparent"}
|
||||
@@ -112,7 +112,7 @@ export default function HomeViewNew() {
|
||||
<ActionIcon radius={"xl"} variant={"transparent"}>
|
||||
<IconBell color={MainColor.white} />
|
||||
</ActionIcon>
|
||||
) : dataUser.profile === undefined ? (
|
||||
) : dataUser?.profile === undefined ? (
|
||||
<ActionIcon
|
||||
radius={"xl"}
|
||||
variant={"transparent"}
|
||||
|
||||
Reference in New Issue
Block a user