Notifikas Job
# fix - Notifikasi to admin - Notifikasi to user - Perubahan tampilan admin ## No issue
This commit is contained in:
@@ -1,60 +1,98 @@
|
||||
"use client";
|
||||
|
||||
import { RouterJob } from "@/app/lib/router_hipmi/router_job";
|
||||
import { RouterAdminJob } from "@/app/lib/router_admin/router_admin_job";
|
||||
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/component_global/header_tamplate";
|
||||
import { MODEL_JOB } from "@/app_modules/job/model/interface";
|
||||
import {
|
||||
Avatar,
|
||||
Badge,
|
||||
Box,
|
||||
Button,
|
||||
Card,
|
||||
Center,
|
||||
Divider,
|
||||
Grid,
|
||||
Group,
|
||||
Image,
|
||||
Modal,
|
||||
Pagination,
|
||||
Paper,
|
||||
ScrollArea,
|
||||
Spoiler,
|
||||
Stack,
|
||||
Table,
|
||||
Text,
|
||||
Title,
|
||||
TextInput,
|
||||
Title
|
||||
} from "@mantine/core";
|
||||
import { useDisclosure } from "@mantine/hooks";
|
||||
import { IconBan, IconEyeCheck, IconEyeShare } from "@tabler/icons-react";
|
||||
import _ from "lodash";
|
||||
import {
|
||||
IconEyeCheck,
|
||||
IconSearch
|
||||
} from "@tabler/icons-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import adminJob_getListPublish from "../../fun/get/get_list_publish";
|
||||
import { IconPhotoCheck } from "@tabler/icons-react";
|
||||
|
||||
export default function AdminJob_TablePublish({
|
||||
dataVote,
|
||||
dataPublish,
|
||||
}: {
|
||||
dataVote?: any;
|
||||
dataPublish: any;
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<ComponentAdminGlobal_HeaderTamplate name="Job Vacancy: Table Publish" />
|
||||
<TableStatus listReview={dataVote} />
|
||||
<ComponentAdminGlobal_HeaderTamplate name="Job Vacancy" />
|
||||
<TableStatus dataPublish={dataPublish} />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function TableStatus({ listReview }: { listReview: MODEL_JOB[] }) {
|
||||
function TableStatus({ dataPublish }: { dataPublish: any }) {
|
||||
const router = useRouter();
|
||||
const [opened, { open, close }] = useDisclosure(false);
|
||||
const [data, setData] = useState(listReview);
|
||||
const [img, setImg] = useState("");
|
||||
|
||||
const [data, setData] = useState<MODEL_JOB[]>(dataPublish.data);
|
||||
const [nPage, setNPage] = useState(dataPublish.nPage);
|
||||
const [activePage, setActivePage] = useState(1);
|
||||
const [isSearch, setSearch] = useState("");
|
||||
|
||||
|
||||
async function onSearch(s: string) {
|
||||
setSearch(s);
|
||||
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 TableRows = data?.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center w={150}>
|
||||
<Text>{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={200}
|
||||
w={300}
|
||||
maxHeight={50}
|
||||
hideLabel="sembunyikan"
|
||||
showLabel="tampilkan"
|
||||
@@ -63,21 +101,20 @@ function TableStatus({ listReview }: { listReview: MODEL_JOB[] }) {
|
||||
</Spoiler>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={150}>
|
||||
<Center w={200}>
|
||||
{e.imagesId ? (
|
||||
<Button
|
||||
color="green"
|
||||
radius={"xl"}
|
||||
leftIcon={<IconEyeCheck />}
|
||||
leftIcon={<IconPhotoCheck />}
|
||||
onClick={() => {
|
||||
setImg(e.imagesId);
|
||||
open();
|
||||
router.push(RouterAdminJob.detail_poster + e?.imagesId);
|
||||
}}
|
||||
>
|
||||
Lihat
|
||||
</Button>
|
||||
) : (
|
||||
<Center w={150}>
|
||||
<Center w={200}>
|
||||
<Text fw={"bold"} fz={"xs"} fs={"italic"}>
|
||||
Tidak ada poster
|
||||
</Text>
|
||||
@@ -110,62 +147,78 @@ function TableStatus({ listReview }: { listReview: MODEL_JOB[] }) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Modal opened={opened} onClose={close} withCloseButton={false} centered>
|
||||
<Center>
|
||||
<Image
|
||||
alt="Foto"
|
||||
src={RouterJob.api_gambar + img}
|
||||
mah={500}
|
||||
maw={300}
|
||||
/>
|
||||
</Center>
|
||||
</Modal>
|
||||
|
||||
|
||||
<Box>
|
||||
<Box bg={"green.1"} p={"xs"}>
|
||||
<Title order={6} c={"green"}>
|
||||
PUBLISH
|
||||
<Stack spacing={"xs"} h={"100%"}>
|
||||
{/* <pre>{JSON.stringify(listUser, null, 2)}</pre> */}
|
||||
<Group
|
||||
position="apart"
|
||||
bg={"green.4"}
|
||||
p={"xs"}
|
||||
style={{ borderRadius: "6px" }}
|
||||
>
|
||||
<Title order={4} c={"white"}>
|
||||
Publish
|
||||
</Title>
|
||||
</Box>
|
||||
<ScrollArea w={"100%"}>
|
||||
<Table
|
||||
withBorder
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"xl"}
|
||||
p={"md"}
|
||||
striped
|
||||
highlightOnHover
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center>Judul</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Poster</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Syarat Ketentuan</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Deskripsi</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{TableRows}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
<Center>
|
||||
{_.isEmpty(TableRows) ? (
|
||||
<Center h={"50vh"}>
|
||||
<Title order={6}>Tidak Ada Data</Title>
|
||||
</Center>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
</Center>
|
||||
</Box>
|
||||
{/* <pre>{JSON.stringify(data, null, 2)}</pre> */}
|
||||
<TextInput
|
||||
icon={<IconSearch size={20} />}
|
||||
radius={"xl"}
|
||||
placeholder="Masukan judul"
|
||||
onChange={(val) => {
|
||||
onSearch(val.currentTarget.value);
|
||||
}}
|
||||
/>
|
||||
</Group>
|
||||
|
||||
<Paper p={"md"} withBorder shadow="lg" h={"80vh"}>
|
||||
<ScrollArea w={"100%"} h={"90%"}>
|
||||
<Table
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={1500}
|
||||
h={"100%"}
|
||||
striped
|
||||
highlightOnHover
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center>Author</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Status</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Text>Judul</Text>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Poster</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Text>Syarat Ketentuan</Text>
|
||||
</th>
|
||||
<th>
|
||||
<Text>Deskripsi</Text>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{TableRows}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
<Center mt={"xl"}>
|
||||
<Pagination
|
||||
value={activePage}
|
||||
total={nPage}
|
||||
onChange={(val) => {
|
||||
onPageClick(val);
|
||||
}}
|
||||
/>
|
||||
</Center>
|
||||
</Paper>
|
||||
</Stack>
|
||||
|
||||
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,60 +1,90 @@
|
||||
"use client";
|
||||
|
||||
import { RouterJob } from "@/app/lib/router_hipmi/router_job";
|
||||
import { RouterAdminJob } from "@/app/lib/router_admin/router_admin_job";
|
||||
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/component_global/header_tamplate";
|
||||
import ComponentGlobal_InputCountDown from "@/app_modules/component_global/input_countdown";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
|
||||
import { MODEL_JOB } from "@/app_modules/job/model/interface";
|
||||
import {
|
||||
Avatar,
|
||||
Badge,
|
||||
Box,
|
||||
Button,
|
||||
Card,
|
||||
Center,
|
||||
Divider,
|
||||
Grid,
|
||||
Group,
|
||||
Image,
|
||||
Modal,
|
||||
Pagination,
|
||||
Paper,
|
||||
ScrollArea,
|
||||
Spoiler,
|
||||
Stack,
|
||||
Table,
|
||||
Text,
|
||||
TextInput,
|
||||
Textarea,
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
import { useDisclosure } from "@mantine/hooks";
|
||||
import { IconBan, IconEyeCheck, IconEyeShare } from "@tabler/icons-react";
|
||||
import _ from "lodash";
|
||||
import { IconBan, IconPhotoCheck, IconSearch } from "@tabler/icons-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { AdminJob_funEditCatatanById } from "../../fun/edit/fun_edit_catatan_by_id";
|
||||
import adminJob_getListReject from "../../fun/get/get_list_reject";
|
||||
import { AdminJob_getListTableByStatusId } from "../../fun/get/get_list_table_by_status_id";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
|
||||
import mqtt_client from "@/util/mqtt_client";
|
||||
import adminNotifikasi_funCreateToUser from "@/app_modules/admin/notifikasi/fun/create/fun_create_notif_user";
|
||||
|
||||
export default function AdminJob_TableReject({ dataVote }: { dataVote?: any }) {
|
||||
export default function AdminJob_TableReject({
|
||||
dataReject,
|
||||
}: {
|
||||
dataReject: any;
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<ComponentAdminGlobal_HeaderTamplate name="Job Vacancy: Table Reject" />
|
||||
<TableStatus listReject={dataVote} />
|
||||
<ComponentAdminGlobal_HeaderTamplate name="Job Vacancy" />
|
||||
<TableStatus listReject={dataReject} />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function TableStatus({ listReject }: { listReject: MODEL_JOB[] }) {
|
||||
const [opened, { open, close }] = useDisclosure(false);
|
||||
const [data, setData] = useState(listReject);
|
||||
function TableStatus({ listReject }: { listReject: any }) {
|
||||
const router = useRouter();
|
||||
const [data, setData] = useState<MODEL_JOB[]>(listReject.data);
|
||||
const [nPage, setNPage] = useState(listReject.nPage);
|
||||
const [activePage, setActivePage] = useState(1);
|
||||
const [isSearch, setSearch] = useState("");
|
||||
|
||||
const [reject, setReject] = useState(false);
|
||||
const [img, setImg] = useState("");
|
||||
const [jobId, setJobId] = useState("");
|
||||
const [catatan, setCatatan] = useState("");
|
||||
|
||||
const TableRows = data?.map((e, i) => (
|
||||
async function onSearch(s: string) {
|
||||
setSearch(s);
|
||||
const loadData = await adminJob_getListReject({
|
||||
page: 1,
|
||||
search: s,
|
||||
});
|
||||
setData(loadData.data as any);
|
||||
setNPage(loadData.nPage);
|
||||
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 rowTable = data?.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center w={150}>
|
||||
<Text>{e?.Author?.username}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Spoiler
|
||||
w={200}
|
||||
@@ -71,10 +101,9 @@ function TableStatus({ listReject }: { listReject: MODEL_JOB[] }) {
|
||||
<Button
|
||||
color="green"
|
||||
radius={"xl"}
|
||||
leftIcon={<IconEyeCheck />}
|
||||
leftIcon={<IconPhotoCheck />}
|
||||
onClick={() => {
|
||||
setImg(e.imagesId);
|
||||
open();
|
||||
router.push(RouterAdminJob.detail_poster + e?.imagesId);
|
||||
}}
|
||||
>
|
||||
Lihat
|
||||
@@ -129,7 +158,10 @@ function TableStatus({ listReject }: { listReject: MODEL_JOB[] }) {
|
||||
setCatatan(e.catatan);
|
||||
}}
|
||||
>
|
||||
Reject
|
||||
<Stack spacing={0}>
|
||||
<Text fz={10}>Tambah</Text>
|
||||
<Text fz={10}>Catatan</Text>
|
||||
</Stack>
|
||||
</Button>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -137,42 +169,51 @@ function TableStatus({ listReject }: { listReject: MODEL_JOB[] }) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Modal opened={opened} onClose={close} withCloseButton={false} centered>
|
||||
<Center>
|
||||
<Image
|
||||
alt="Foto"
|
||||
src={RouterJob.api_gambar + img}
|
||||
mah={500}
|
||||
maw={300}
|
||||
/>
|
||||
</Center>
|
||||
</Modal>
|
||||
|
||||
<Modal
|
||||
opened={reject}
|
||||
onClose={() => {
|
||||
setReject(false);
|
||||
}}
|
||||
withCloseButton={false}
|
||||
size={"lg"}
|
||||
size={"sm"}
|
||||
centered
|
||||
>
|
||||
<Stack>
|
||||
<Textarea
|
||||
minRows={2}
|
||||
maxRows={5}
|
||||
maxLength={300}
|
||||
autosize
|
||||
label="Alasan Penolakan"
|
||||
placeholder="Masukkan alasan penolakan lowongan ini"
|
||||
value={catatan}
|
||||
onChange={(val) => setCatatan(val.currentTarget.value)}
|
||||
/>
|
||||
<Stack spacing={5}>
|
||||
<Textarea
|
||||
minRows={2}
|
||||
maxRows={5}
|
||||
maxLength={300}
|
||||
autosize
|
||||
label={<Text fw={"bold"}>Alasan Penolakan</Text>}
|
||||
placeholder="Masukkan alasan penolakan lowongan ini"
|
||||
value={catatan}
|
||||
onChange={(val) => setCatatan(val.currentTarget.value)}
|
||||
/>
|
||||
<ComponentGlobal_InputCountDown
|
||||
lengthInput={catatan.length}
|
||||
maxInput={300}
|
||||
/>
|
||||
</Stack>
|
||||
<Group position="right">
|
||||
<Button radius={"xl"} onClick={() => setReject(false)}>
|
||||
Batal
|
||||
</Button>
|
||||
<Button
|
||||
style={{
|
||||
transition: "0.5s",
|
||||
}}
|
||||
disabled={catatan === "" ? true : false}
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
onReject(jobId, catatan, setData);
|
||||
onReject({
|
||||
catatan: catatan,
|
||||
jobId: jobId,
|
||||
onSetData(val) {
|
||||
setData(val.data);
|
||||
setNPage(val.nPage);
|
||||
},
|
||||
});
|
||||
setReject(false);
|
||||
}}
|
||||
>
|
||||
@@ -182,70 +223,116 @@ function TableStatus({ listReject }: { listReject: MODEL_JOB[] }) {
|
||||
</Stack>
|
||||
</Modal>
|
||||
|
||||
<Box>
|
||||
<Box bg={"red.1"} p={"xs"}>
|
||||
<Title order={6} c={"red"}>
|
||||
REJECT
|
||||
<Stack spacing={"xs"} h={"100%"}>
|
||||
<Group
|
||||
position="apart"
|
||||
bg={"red.4"}
|
||||
p={"xs"}
|
||||
style={{ borderRadius: "6px" }}
|
||||
>
|
||||
<Title order={4} c={"white"}>
|
||||
Reject
|
||||
</Title>
|
||||
</Box>
|
||||
<ScrollArea w={"100%"}>
|
||||
<Table
|
||||
withBorder
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"xl"}
|
||||
p={"md"}
|
||||
striped
|
||||
highlightOnHover
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center>Judul</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Poster</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Syarat Ketentuan</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Deskripsi</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Catatan</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Aksi</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{TableRows}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
<Center>
|
||||
{_.isEmpty(TableRows) ? (
|
||||
<Center h={"50vh"}>
|
||||
<Title order={6}>Tidak Ada Data</Title>
|
||||
</Center>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
</Center>
|
||||
</Box>
|
||||
{/* <pre>{JSON.stringify(data, null, 2)}</pre> */}
|
||||
<TextInput
|
||||
icon={<IconSearch size={20} />}
|
||||
radius={"xl"}
|
||||
placeholder="Masukan judul"
|
||||
onChange={(val) => {
|
||||
onSearch(val.currentTarget.value);
|
||||
}}
|
||||
/>
|
||||
</Group>
|
||||
|
||||
<Paper p={"md"} withBorder shadow="lg" h={"80vh"}>
|
||||
<ScrollArea w={"100%"} h={"90%"}>
|
||||
<Table
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={1500}
|
||||
h={"100%"}
|
||||
striped
|
||||
highlightOnHover
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center>Author</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Text>Judul</Text>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Poster</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Text>Syarat Ketentuan</Text>
|
||||
</th>
|
||||
<th>
|
||||
<Text>Deskripsi</Text>
|
||||
</th>
|
||||
<th>
|
||||
<Text>Report</Text>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Aksi</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{rowTable}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
<Center mt={"xl"}>
|
||||
<Pagination
|
||||
value={activePage}
|
||||
total={nPage}
|
||||
onChange={(val) => {
|
||||
onPageClick(val);
|
||||
}}
|
||||
/>
|
||||
</Center>
|
||||
</Paper>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
async function onReject(jobId: string, catatan: string, setData: any) {
|
||||
await AdminJob_funEditCatatanById(jobId, catatan).then(async (res) => {
|
||||
if (res.status === 200) {
|
||||
await AdminJob_getListTableByStatusId("4").then((val) => {
|
||||
setData(val);
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
});
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
async function onReject({
|
||||
jobId,
|
||||
catatan,
|
||||
onSetData,
|
||||
}: {
|
||||
jobId: string;
|
||||
catatan: string;
|
||||
onSetData: (val: any) => void;
|
||||
}) {
|
||||
const reject = await AdminJob_funEditCatatanById(jobId, catatan);
|
||||
if (reject.status === 200) {
|
||||
const loadData = await adminJob_getListReject({ page: 1 });
|
||||
onSetData(loadData);
|
||||
|
||||
const dataNotif = {
|
||||
appId: reject.data?.id as any,
|
||||
status: reject.data?.MasterStatus?.name as any,
|
||||
userId: reject.data?.authorId as any,
|
||||
pesan: reject.data?.title as any,
|
||||
kategoriApp: "JOB",
|
||||
title: "Report tambahan",
|
||||
};
|
||||
|
||||
const notif = await adminNotifikasi_funCreateToUser({
|
||||
data: dataNotif as any,
|
||||
});
|
||||
|
||||
if (notif.status === 201) {
|
||||
mqtt_client.publish(
|
||||
"USER",
|
||||
JSON.stringify({ userId: reject?.data?.authorId, count: 1 })
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
ComponentGlobal_NotifikasiBerhasil(reject.message);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(reject.message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,62 +1,116 @@
|
||||
"use client";
|
||||
|
||||
import { RouterJob } from "@/app/lib/router_hipmi/router_job";
|
||||
import { RouterAdminJob } from "@/app/lib/router_admin/router_admin_job";
|
||||
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/component_global/header_tamplate";
|
||||
import adminNotifikasi_funCreateToUser from "@/app_modules/admin/notifikasi/fun/create/fun_create_notif_user";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
|
||||
import { MODEL_JOB } from "@/app_modules/job/model/interface";
|
||||
import mqtt_client from "@/util/mqtt_client";
|
||||
import {
|
||||
Avatar,
|
||||
Badge,
|
||||
Box,
|
||||
Button,
|
||||
Card,
|
||||
Center,
|
||||
Divider,
|
||||
Grid,
|
||||
Group,
|
||||
Image,
|
||||
Modal,
|
||||
Pagination,
|
||||
Paper,
|
||||
ScrollArea,
|
||||
Spoiler,
|
||||
Stack,
|
||||
Table,
|
||||
Text,
|
||||
TextInput,
|
||||
Textarea,
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
import { useDisclosure } from "@mantine/hooks";
|
||||
import { IconBan, IconEyeCheck, IconEyeShare } from "@tabler/icons-react";
|
||||
import _ from "lodash";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import {
|
||||
IconBan,
|
||||
IconEyeCheck,
|
||||
IconEyeShare,
|
||||
IconHandFinger,
|
||||
IconSearch,
|
||||
} from "@tabler/icons-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { AdminJob_funEditStatusPublishById } from "../../fun/edit/fun_edit_status_publish_by_id";
|
||||
import { AdminJob_getListTableByStatusId } from "../../fun/get/get_list_table_by_status_id";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
|
||||
import { AdminJob_funEditCatatanById } from "../../fun/edit/fun_edit_catatan_by_id";
|
||||
import { AdminJob_funEditStatusPublishById } from "../../fun/edit/fun_edit_status_publish_by_id";
|
||||
import adminJob_getListReview from "../../fun/get/get_list_review";
|
||||
import { IconPhotoCheck } from "@tabler/icons-react";
|
||||
import ComponentGlobal_InputCountDown from "@/app_modules/component_global/input_countdown";
|
||||
|
||||
export default function AdminJob_TableReview({ dataVote }: { dataVote?: any }) {
|
||||
export default function AdminJob_TableReview({
|
||||
dataReview,
|
||||
}: {
|
||||
dataReview: any;
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<ComponentAdminGlobal_HeaderTamplate name="Job Vacancy: Table Review" />
|
||||
<TableStatus listReview={dataVote} />
|
||||
<ComponentAdminGlobal_HeaderTamplate name="Job Vacancy" />
|
||||
<TableStatus listReview={dataReview} />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function TableStatus({ listReview }: { listReview: MODEL_JOB[] }) {
|
||||
function TableStatus({ listReview }: { listReview: any }) {
|
||||
const router = useRouter();
|
||||
const [opened, { open, close }] = useDisclosure(false);
|
||||
const [data, setData] = useState(listReview);
|
||||
const [data, setData] = useState<MODEL_JOB[]>(listReview.data);
|
||||
const [nPage, setNPage] = useState(listReview.nPage);
|
||||
const [activePage, setActivePage] = useState(1);
|
||||
const [isSearch, setSearch] = useState("");
|
||||
|
||||
const [reject, setReject] = useState(false);
|
||||
const [img, setImg] = useState("");
|
||||
const [jobId, setJobId] = useState("");
|
||||
const [catatan, setCatatan] = useState("");
|
||||
|
||||
const TableRows = data?.map((e, i) => (
|
||||
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 onSearch(s: string) {
|
||||
setSearch(s);
|
||||
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 rowTable = data?.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center w={150}>
|
||||
<Text>{e?.Author?.username}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Spoiler
|
||||
w={200}
|
||||
@@ -68,15 +122,14 @@ function TableStatus({ listReview }: { listReview: MODEL_JOB[] }) {
|
||||
</Spoiler>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={150}>
|
||||
<Center w={200}>
|
||||
{e.imagesId ? (
|
||||
<Button
|
||||
color="green"
|
||||
radius={"xl"}
|
||||
leftIcon={<IconEyeCheck />}
|
||||
leftIcon={<IconPhotoCheck />}
|
||||
onClick={() => {
|
||||
setImg(e.imagesId);
|
||||
open();
|
||||
router.push(RouterAdminJob.detail_poster + e?.imagesId);
|
||||
}}
|
||||
>
|
||||
Lihat
|
||||
@@ -117,7 +170,15 @@ function TableStatus({ listReview }: { listReview: MODEL_JOB[] }) {
|
||||
color={"green"}
|
||||
leftIcon={<IconEyeShare />}
|
||||
radius={"xl"}
|
||||
onClick={() => onPublish(e.id, setData)}
|
||||
onClick={() =>
|
||||
onPublish({
|
||||
jobId: e?.id,
|
||||
onLoadData(val: any) {
|
||||
setData(val.data);
|
||||
setNPage(val.nPage);
|
||||
},
|
||||
})
|
||||
}
|
||||
>
|
||||
Publish
|
||||
</Button>
|
||||
@@ -140,41 +201,48 @@ function TableStatus({ listReview }: { listReview: MODEL_JOB[] }) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Modal opened={opened} onClose={close} withCloseButton={false} centered>
|
||||
<Center>
|
||||
<Image
|
||||
alt="Foto"
|
||||
src={RouterJob.api_gambar + img}
|
||||
mah={500}
|
||||
maw={300}
|
||||
/>
|
||||
</Center>
|
||||
</Modal>
|
||||
|
||||
<Modal
|
||||
opened={reject}
|
||||
onClose={() => {
|
||||
setReject(false);
|
||||
}}
|
||||
withCloseButton={false}
|
||||
size={"lg"}
|
||||
size={"sm"}
|
||||
centered
|
||||
>
|
||||
<Stack>
|
||||
<Textarea
|
||||
minRows={2}
|
||||
maxRows={5}
|
||||
maxLength={300}
|
||||
autosize
|
||||
label="Alasan Penolakan"
|
||||
placeholder="Masukkan alasan penolakan lowongan ini"
|
||||
onChange={(val) => setCatatan(val.currentTarget.value)}
|
||||
/>
|
||||
<Stack spacing={5}>
|
||||
<Textarea
|
||||
minRows={2}
|
||||
maxRows={5}
|
||||
maxLength={300}
|
||||
autosize
|
||||
label={<Text fw={"bold"}>Alasan Penolakan</Text>}
|
||||
placeholder="Masukkan alasan penolakan lowongan ini"
|
||||
onChange={(val) => setCatatan(val.currentTarget.value)}
|
||||
/>
|
||||
<ComponentGlobal_InputCountDown
|
||||
maxInput={300}
|
||||
lengthInput={catatan.length}
|
||||
/>
|
||||
</Stack>
|
||||
<Group position="right">
|
||||
<Button radius={"xl"} onClick={() => setReject(false)}>
|
||||
Batal
|
||||
</Button>
|
||||
<Button
|
||||
style={{ transition: "0.5s" }}
|
||||
disabled={catatan === "" ? true : false}
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
onReject(jobId, catatan, setData);
|
||||
onReject({
|
||||
jobId: jobId,
|
||||
catatan: catatan,
|
||||
onLoadData(val) {
|
||||
setData(val.data);
|
||||
setNPage(val.nPage);
|
||||
},
|
||||
});
|
||||
setReject(false);
|
||||
}}
|
||||
>
|
||||
@@ -184,80 +252,151 @@ function TableStatus({ listReview }: { listReview: MODEL_JOB[] }) {
|
||||
</Stack>
|
||||
</Modal>
|
||||
|
||||
<Box>
|
||||
<Box bg={"orange.1"} p={"xs"}>
|
||||
<Title order={6} c={"orange"}>
|
||||
REVIEW
|
||||
<Stack spacing={"xs"} h={"100%"}>
|
||||
<Group
|
||||
position="apart"
|
||||
bg={"orange.4"}
|
||||
p={"xs"}
|
||||
style={{ borderRadius: "6px" }}
|
||||
>
|
||||
<Title order={4} c={"white"}>
|
||||
Review
|
||||
</Title>
|
||||
</Box>
|
||||
<ScrollArea w={"100%"}>
|
||||
<Table
|
||||
withBorder
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"xl"}
|
||||
p={"md"}
|
||||
striped
|
||||
highlightOnHover
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center>Judul</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Poster</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Syarat Ketentuan</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Deskripsi</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Aksi</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{TableRows}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
<Center>
|
||||
{_.isEmpty(TableRows) ? (
|
||||
<Center h={"50vh"}>
|
||||
<Title order={6}>Tidak Ada Data</Title>
|
||||
</Center>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
</Center>
|
||||
</Box>
|
||||
{/* <pre>{JSON.stringify(data, null, 2)}</pre> */}
|
||||
<TextInput
|
||||
icon={<IconSearch size={20} />}
|
||||
radius={"xl"}
|
||||
placeholder="Masukan judul"
|
||||
onChange={(val) => {
|
||||
onSearch(val.currentTarget.value);
|
||||
}}
|
||||
/>
|
||||
</Group>
|
||||
|
||||
<Paper p={"md"} withBorder shadow="lg" h={"80vh"}>
|
||||
<ScrollArea w={"100%"} h={"90%"}>
|
||||
<Table
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={1500}
|
||||
h={"100%"}
|
||||
striped
|
||||
highlightOnHover
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center>Author</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Text>Judul</Text>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Poster</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Text>Syarat Ketentuan</Text>
|
||||
</th>
|
||||
<th>
|
||||
<Text>Deskripsi</Text>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Aksi</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{rowTable}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
<Center mt={"xl"}>
|
||||
<Pagination
|
||||
value={activePage}
|
||||
total={nPage}
|
||||
onChange={(val) => {
|
||||
onPageClick(val);
|
||||
}}
|
||||
/>
|
||||
</Center>
|
||||
</Paper>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
async function onPublish(jobId: string, setData: any) {
|
||||
await AdminJob_funEditStatusPublishById(jobId).then(async (res) => {
|
||||
if (res.status === 200) {
|
||||
await AdminJob_getListTableByStatusId("2").then((res) => {
|
||||
setData(res);
|
||||
ComponentGlobal_NotifikasiBerhasil("Berhasil Update");
|
||||
});
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
async function onPublish({
|
||||
jobId,
|
||||
onLoadData,
|
||||
}: {
|
||||
jobId: string;
|
||||
onLoadData: (val: any) => void;
|
||||
}) {
|
||||
const publish = await AdminJob_funEditStatusPublishById(jobId);
|
||||
if (publish.status === 200) {
|
||||
const loadData = await adminJob_getListReview({ page: 1 });
|
||||
onLoadData(loadData);
|
||||
|
||||
const dataNotif = {
|
||||
appId: publish.data?.id as any,
|
||||
status: publish.data?.MasterStatus?.name as any,
|
||||
userId: publish.data?.authorId as any,
|
||||
pesan: publish.data?.title as any,
|
||||
kategoriApp: "JOB",
|
||||
title: "Job publish",
|
||||
};
|
||||
|
||||
const notif = await adminNotifikasi_funCreateToUser({
|
||||
data: dataNotif as any,
|
||||
});
|
||||
|
||||
if (notif.status === 201) {
|
||||
mqtt_client.publish(
|
||||
"USER",
|
||||
JSON.stringify({ userId: publish?.data?.authorId, count: 1 })
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
ComponentGlobal_NotifikasiBerhasil(publish.message);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(publish.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function onReject(jobId: string, catatan: string, setData: any) {
|
||||
await AdminJob_funEditCatatanById(jobId, catatan).then(async (res) => {
|
||||
if (res.status === 200) {
|
||||
await AdminJob_getListTableByStatusId("2").then((val) => {
|
||||
setData(val);
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
});
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
async function onReject({
|
||||
jobId,
|
||||
catatan,
|
||||
onLoadData,
|
||||
}: {
|
||||
jobId: string;
|
||||
catatan: string;
|
||||
onLoadData: (val: any) => void;
|
||||
}) {
|
||||
const reject = await AdminJob_funEditCatatanById(jobId, catatan);
|
||||
|
||||
if (reject.status === 200) {
|
||||
const loadData = await adminJob_getListReview({ page: 1 });
|
||||
onLoadData(loadData);
|
||||
ComponentGlobal_NotifikasiBerhasil(reject.message);
|
||||
|
||||
const dataNotif = {
|
||||
appId: reject.data?.id as any,
|
||||
status: reject.data?.MasterStatus?.name as any,
|
||||
userId: reject.data?.authorId as any,
|
||||
pesan: reject.data?.title as any,
|
||||
kategoriApp: "JOB",
|
||||
title: "Job anda ditolak !",
|
||||
};
|
||||
|
||||
const notif = await adminNotifikasi_funCreateToUser({
|
||||
data: dataNotif as any,
|
||||
});
|
||||
|
||||
if (notif.status === 201) {
|
||||
mqtt_client.publish(
|
||||
"USER",
|
||||
JSON.stringify({ userId: reject?.data?.authorId, count: 1 })
|
||||
);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(reject.message);
|
||||
}
|
||||
}
|
||||
|
||||
27
src/app_modules/admin/job/detail/detail_poster.tsx
Normal file
27
src/app_modules/admin/job/detail/detail_poster.tsx
Normal file
@@ -0,0 +1,27 @@
|
||||
"use client";
|
||||
|
||||
import { RouterJob } from "@/app/lib/router_hipmi/router_job";
|
||||
import { Center, Image, Stack } from "@mantine/core";
|
||||
import ComponentGlobalAdmin_BackButton from "../../component_global/back_button";
|
||||
|
||||
export default function AdminJob_DetailPoster({
|
||||
imageId,
|
||||
}: {
|
||||
imageId: string;
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<ComponentGlobalAdmin_BackButton />
|
||||
<Center>
|
||||
<Image
|
||||
alt="Foto"
|
||||
src={RouterJob.api_gambar + imageId}
|
||||
mah={500}
|
||||
maw={300}
|
||||
/>
|
||||
</Center>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -7,7 +7,7 @@ export async function AdminJob_funEditCatatanById(
|
||||
jobId: string,
|
||||
catatan: string
|
||||
) {
|
||||
const up = await prisma.job.update({
|
||||
const udpt = await prisma.job.update({
|
||||
where: {
|
||||
id: jobId,
|
||||
},
|
||||
@@ -15,9 +15,21 @@ export async function AdminJob_funEditCatatanById(
|
||||
masterStatusId: "4",
|
||||
catatan: catatan,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
authorId: true,
|
||||
MasterStatus: {
|
||||
select: {
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
title: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!up) return { status: 400, message: "Gagal reject" };
|
||||
|
||||
|
||||
if (!udpt) return { status: 400, message: "Gagal menambah catatan" };
|
||||
revalidatePath("/dev/admin/job/child/table_review");
|
||||
return { status: 200, message: "Berhasil reject" };
|
||||
return {data: udpt, status: 200, message: "Berhasil menambah catatan" };
|
||||
}
|
||||
|
||||
@@ -11,10 +11,20 @@ export async function AdminJob_funEditStatusPublishById(jobId: string) {
|
||||
data: {
|
||||
masterStatusId: "1",
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
authorId: true,
|
||||
MasterStatus: {
|
||||
select: {
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
title: true,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
if(!updt) return {status: 400, message: "Update Gagal"}
|
||||
revalidatePath("/dev/admin/job/child/table_review");
|
||||
return {status: 200, message: "Berhasil Update"}
|
||||
return {data: updt, status: 200, message: "Berhasil Update"}
|
||||
}
|
||||
|
||||
63
src/app_modules/admin/job/fun/get/get_list_publish.ts
Normal file
63
src/app_modules/admin/job/fun/get/get_list_publish.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { ceil } from "lodash";
|
||||
|
||||
export default async function adminJob_getListPublish({
|
||||
page,
|
||||
search,
|
||||
}: {
|
||||
page: number;
|
||||
search?: string;
|
||||
}) {
|
||||
let takeData = 5;
|
||||
let skipData = page * takeData - takeData;
|
||||
|
||||
const getData = await prisma.job.findMany({
|
||||
skip: skipData,
|
||||
take: takeData,
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
masterStatusId: "1",
|
||||
isActive: true,
|
||||
title: {
|
||||
contains: search,
|
||||
mode: "insensitive",
|
||||
},
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
isActive: true,
|
||||
isArsip: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
content: true,
|
||||
deskripsi: true,
|
||||
catatan: true,
|
||||
authorId: true,
|
||||
Author: true,
|
||||
imagesId: true,
|
||||
},
|
||||
});
|
||||
|
||||
const nCount = await prisma.job.count({
|
||||
where: {
|
||||
masterStatusId: "1",
|
||||
isActive: true,
|
||||
title: {
|
||||
contains: search,
|
||||
mode: "insensitive",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const allData = {
|
||||
data: getData,
|
||||
nPage: ceil(nCount / takeData),
|
||||
};
|
||||
|
||||
return allData;
|
||||
}
|
||||
62
src/app_modules/admin/job/fun/get/get_list_reject.ts
Normal file
62
src/app_modules/admin/job/fun/get/get_list_reject.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { ceil } from "lodash";
|
||||
|
||||
export default async function adminJob_getListReject({
|
||||
page,
|
||||
search,
|
||||
}: {
|
||||
page: number;
|
||||
search?: string;
|
||||
}) {
|
||||
let takeData = 5;
|
||||
let skipData = page * takeData - takeData;
|
||||
|
||||
const getData = await prisma.job.findMany({
|
||||
skip: skipData,
|
||||
take: takeData,
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
masterStatusId: "4",
|
||||
isActive: true,
|
||||
title: {
|
||||
contains: search,
|
||||
mode: "insensitive",
|
||||
},
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
isActive: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
content: true,
|
||||
deskripsi: true,
|
||||
catatan: true,
|
||||
authorId: true,
|
||||
Author: true,
|
||||
imagesId: true,
|
||||
},
|
||||
});
|
||||
|
||||
const nCount = await prisma.job.count({
|
||||
where: {
|
||||
masterStatusId: "4",
|
||||
isActive: true,
|
||||
title: {
|
||||
contains: search,
|
||||
mode: "insensitive",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const allData = {
|
||||
data: getData,
|
||||
nPage: ceil(nCount / takeData),
|
||||
};
|
||||
|
||||
return allData;
|
||||
}
|
||||
62
src/app_modules/admin/job/fun/get/get_list_review.ts
Normal file
62
src/app_modules/admin/job/fun/get/get_list_review.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { ceil } from "lodash";
|
||||
|
||||
export default async function adminJob_getListReview({
|
||||
page,
|
||||
search,
|
||||
}: {
|
||||
page: number;
|
||||
search?: string;
|
||||
}) {
|
||||
let takeData = 5;
|
||||
let skipData = page * takeData - takeData;
|
||||
|
||||
const getData = await prisma.job.findMany({
|
||||
skip: skipData,
|
||||
take: takeData,
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
masterStatusId: "2",
|
||||
isActive: true,
|
||||
title: {
|
||||
contains: search,
|
||||
mode: "insensitive",
|
||||
},
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
isActive: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
content: true,
|
||||
deskripsi: true,
|
||||
catatan: true,
|
||||
authorId: true,
|
||||
Author: true,
|
||||
imagesId: true,
|
||||
},
|
||||
});
|
||||
|
||||
const nCount = await prisma.job.count({
|
||||
where: {
|
||||
masterStatusId: "2",
|
||||
isActive: true,
|
||||
title: {
|
||||
contains: search,
|
||||
mode: "insensitive",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const allData = {
|
||||
data: getData,
|
||||
nPage: ceil(nCount / takeData),
|
||||
};
|
||||
|
||||
return allData;
|
||||
}
|
||||
@@ -2,5 +2,12 @@ import AdminJob_Main from "./main";
|
||||
import AdminJob_TablePublish from "./child/publish";
|
||||
import AdminJob_TableReview from "./child/review";
|
||||
import AdminJob_TableReject from "./child/reject";
|
||||
import AdminJob_DetailPoster from "./detail/detail_poster";
|
||||
|
||||
export { AdminJob_Main, AdminJob_TablePublish, AdminJob_TableReview, AdminJob_TableReject };
|
||||
export {
|
||||
AdminJob_Main,
|
||||
AdminJob_TablePublish,
|
||||
AdminJob_TableReview,
|
||||
AdminJob_TableReject,
|
||||
AdminJob_DetailPoster,
|
||||
};
|
||||
|
||||
@@ -23,24 +23,28 @@ export default function AdminJob_Main({
|
||||
name: "Publish",
|
||||
jumlah: countPublish,
|
||||
color: "green",
|
||||
text_color: "white",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "Review",
|
||||
jumlah: countReview,
|
||||
color: "orange",
|
||||
text_color: "white",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "Reject",
|
||||
jumlah: countReject,
|
||||
color: "red",
|
||||
text_color: "white",
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: "Arsip",
|
||||
jumlah: countArsip,
|
||||
color: "gray",
|
||||
text_color: "white",
|
||||
},
|
||||
];
|
||||
return (
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
"use client";
|
||||
|
||||
import mqtt_client from "@/util/mqtt_client";
|
||||
import {
|
||||
ActionIcon,
|
||||
AppShell,
|
||||
Badge,
|
||||
Box,
|
||||
Burger,
|
||||
Button,
|
||||
Card,
|
||||
Center,
|
||||
Divider,
|
||||
@@ -30,17 +30,15 @@ import {
|
||||
IconChecks,
|
||||
IconCircleDot,
|
||||
IconCircleDotFilled,
|
||||
IconDashboard,
|
||||
IconUserSquareRounded,
|
||||
} from "@tabler/icons-react";
|
||||
import { useAtom } from "jotai";
|
||||
import _ from "lodash";
|
||||
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
||||
import { useRouter } from "next/navigation";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { auth_Logout } from "../auth/fun/fun_logout";
|
||||
import { gs_kodeId } from "../auth/state/state";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "../component_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "../component_global/notif_global/notifikasi_peringatan";
|
||||
import { MODEL_USER } from "../home/model/interface";
|
||||
import { MODEL_NOTIFIKASI } from "../notifikasi/model/interface";
|
||||
import Admin_Logout from "./component_global/logout";
|
||||
import {
|
||||
gs_admin_hotMenu,
|
||||
@@ -48,16 +46,9 @@ import {
|
||||
gs_layout_admin_isNavbarOpen,
|
||||
} from "./global_state";
|
||||
import { listAdminPage } from "./list_page";
|
||||
import { MODEL_NOTIFIKASI } from "../notifikasi/model/interface";
|
||||
import { MODEL_USER } from "../home/model/interface";
|
||||
import { useHover, useShallowEffect, useToggle } from "@mantine/hooks";
|
||||
import moment from "moment";
|
||||
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
||||
import { RouterAdminJob } from "@/app/lib/router_admin/router_admin_job";
|
||||
import adminNotifikasi_funUpdateIsReadById from "./notifikasi/fun/update/fun_update_is_read_by_id";
|
||||
import adminNotifikasi_getByUserId from "./notifikasi/fun/get/get_notifikasi_by_user_id";
|
||||
import adminNotifikasi_countNotifikasi from "./notifikasi/fun/count/count_is_read";
|
||||
import mqtt_client from "@/util/mqtt_client";
|
||||
import adminNotifikasi_getByUserId from "./notifikasi/fun/get/get_notifikasi_by_user_id";
|
||||
import adminNotifikasi_funUpdateIsReadById from "./notifikasi/fun/update/fun_update_is_read_by_id";
|
||||
|
||||
export default function AdminLayout({
|
||||
children,
|
||||
@@ -322,7 +313,6 @@ export default function AdminLayout({
|
||||
<Text fw={"bold"} fz={"lg"}>
|
||||
Notifikasi
|
||||
</Text>
|
||||
{/* <Button compact radius={"xl"} fz={10}>Tandai terliha</Button> */}
|
||||
</Group>
|
||||
}
|
||||
opened={isNotif}
|
||||
@@ -364,7 +354,7 @@ function DrawerNotifikasi({
|
||||
}) {
|
||||
const router = useRouter();
|
||||
|
||||
if (_.isEmpty(data)){
|
||||
if (_.isEmpty(data)) {
|
||||
return (
|
||||
<>
|
||||
<Center>
|
||||
@@ -375,7 +365,6 @@ function DrawerNotifikasi({
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -383,6 +372,9 @@ function DrawerNotifikasi({
|
||||
<Stack>
|
||||
{data.map((e, i) => (
|
||||
<Card
|
||||
style={{
|
||||
transition: "0.5s",
|
||||
}}
|
||||
key={e?.id}
|
||||
// withBorder
|
||||
bg={e?.isRead ? "gray.1" : "gray.4"}
|
||||
@@ -391,9 +383,7 @@ function DrawerNotifikasi({
|
||||
borderStyle: "solid",
|
||||
borderWidth: "0.5px",
|
||||
":hover": {
|
||||
borderColor: "gray",
|
||||
borderStyle: "solid",
|
||||
borderWidth: "1.5px",
|
||||
backgroundColor: "#C1C2C5",
|
||||
},
|
||||
}}
|
||||
onClick={async () => {
|
||||
@@ -426,15 +416,31 @@ function DrawerNotifikasi({
|
||||
}}
|
||||
>
|
||||
<Card.Section p={"sm"}>
|
||||
<Group position="apart">
|
||||
<Text fw={"bold"} fz={"xs"}>
|
||||
# {e?.kategoriApp}
|
||||
</Text>
|
||||
{e?.status ? <Badge w={70}>{e?.status}</Badge> : ""}
|
||||
</Group>
|
||||
<Stack spacing={"xs"}>
|
||||
<Group position="apart">
|
||||
<Text fw={"bold"} fz={10}>
|
||||
# {e?.kategoriApp}
|
||||
</Text>
|
||||
{e?.status ? (
|
||||
<Badge fz={10} size="sm">
|
||||
{e?.status}
|
||||
</Badge>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
</Group>
|
||||
<Divider color="gray.3" />
|
||||
</Stack>
|
||||
</Card.Section>
|
||||
<Card.Section p={"sm"}>
|
||||
<Text lineClamp={2}>{e?.pesan}</Text>
|
||||
<Card.Section px={"sm"} pb={"sm"}>
|
||||
<Stack spacing={0}>
|
||||
<Text lineClamp={2} fw={"bold"} fz={"xs"}>
|
||||
{e?.title}
|
||||
</Text>
|
||||
<Text lineClamp={2} fz={"xs"}>
|
||||
{e?.pesan}
|
||||
</Text>
|
||||
</Stack>
|
||||
</Card.Section>
|
||||
<Card.Section p={"sm"}>
|
||||
<Group position="apart">
|
||||
@@ -487,10 +493,22 @@ async function findRouterJob({
|
||||
onToggleNavbar2: (val: any) => void;
|
||||
}) {
|
||||
const routeName = "/dev/admin/job/child/";
|
||||
router.push(routeName + _.lowerCase(data.status));
|
||||
onChangeNavbar2({
|
||||
id: 6,
|
||||
childId: 63,
|
||||
});
|
||||
|
||||
if (data.status === "Review") {
|
||||
router.push(routeName + _.lowerCase(data.status));
|
||||
onChangeNavbar2({
|
||||
id: 6,
|
||||
childId: 63,
|
||||
});
|
||||
}
|
||||
|
||||
if (data.status === "Draft") {
|
||||
router.push(routeName + "review");
|
||||
onChangeNavbar2({
|
||||
id: 6,
|
||||
childId: 63,
|
||||
});
|
||||
}
|
||||
|
||||
onToggleNavbar2(true);
|
||||
}
|
||||
|
||||
@@ -206,11 +206,11 @@ export const listAdminPage = [
|
||||
name: "Table Reject",
|
||||
path: RouterAdminJob.reject,
|
||||
},
|
||||
{
|
||||
id: 65,
|
||||
name: "Arsip",
|
||||
path: RouterAdminJob.arsip,
|
||||
},
|
||||
// {
|
||||
// id: 65,
|
||||
// name: "Arsip",
|
||||
// path: RouterAdminJob.arsip,
|
||||
// },
|
||||
],
|
||||
},
|
||||
|
||||
|
||||
@@ -4,12 +4,13 @@ import prisma from "@/app/lib/prisma";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export default async function adminNotifikasi_countNotifikasi() {
|
||||
const userId = await user_getOneUserId();
|
||||
const adminId = await user_getOneUserId();
|
||||
|
||||
const data = await prisma.notifikasi.findMany({
|
||||
where: {
|
||||
adminId: userId,
|
||||
adminId: adminId,
|
||||
isRead: false,
|
||||
userRoleId: "2",
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { MODEL_NOTIFIKASI } from "@/app_modules/notifikasi/model/interface";
|
||||
|
||||
export default async function adminNotifikasi_funCreateToUser({
|
||||
data,
|
||||
}: {
|
||||
data: MODEL_NOTIFIKASI;
|
||||
}) {
|
||||
const adminId = await user_getOneUserId();
|
||||
|
||||
const create = await prisma.notifikasi.create({
|
||||
data: {
|
||||
adminId: adminId,
|
||||
userId: data.userId,
|
||||
appId: data.appId,
|
||||
status: data.status,
|
||||
title: data.title,
|
||||
pesan: data.pesan,
|
||||
kategoriApp: data.kategoriApp,
|
||||
userRoleId: "1",
|
||||
},
|
||||
});
|
||||
|
||||
return { status: 201, message: "Berhasil mengirim notifikasi" };
|
||||
}
|
||||
@@ -2,13 +2,15 @@
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { NextRequest } from "next/server";
|
||||
|
||||
export default async function adminNotifikasi_getByUserId() {
|
||||
const adminId = await user_getOneUserId();
|
||||
|
||||
const data = await prisma.notifikasi.findMany({
|
||||
orderBy:{
|
||||
createdAt: "desc"
|
||||
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
where: {
|
||||
adminId: adminId,
|
||||
|
||||
@@ -1,5 +1,2 @@
|
||||
// test notif
|
||||
|
||||
import Notifikasi_MainView from "./main";
|
||||
|
||||
export { Notifikasi_MainView };
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import AppComponentGlobal_LayoutTamplate from "@/app_modules/component_global/component_layout_tamplate";
|
||||
import ComponentGlobal_HeaderTamplate from "@/app_modules/component_global/header_tamplate";
|
||||
import { Text } from "@mantine/core";
|
||||
|
||||
export default function Notifikasi_MainView() {
|
||||
return (
|
||||
<>
|
||||
<AppComponentGlobal_LayoutTamplate
|
||||
header={<ComponentGlobal_HeaderTamplate title="Notifikasi" />}
|
||||
>
|
||||
<MainView />
|
||||
</AppComponentGlobal_LayoutTamplate>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function MainView() {
|
||||
return (
|
||||
<>
|
||||
<Text>notif</Text>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user