fix admin evnet
- fix detail review
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { AdminEvent_TableReject } from "@/app_modules/admin/event";
|
||||
import { adminEvent_funGetListReject } from "@/app_modules/admin/event/fun";
|
||||
|
||||
export default async function Page() {
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import { Modal } from "@mantine/core";
|
||||
import { reject } from "lodash";
|
||||
|
||||
export function Admin_ComponentModal({
|
||||
children,
|
||||
opened,
|
||||
onClose,
|
||||
title,
|
||||
size,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
opened: boolean;
|
||||
onClose: () => void;
|
||||
size?: "sm" | "md" | "lg" | "xl";
|
||||
title: string
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<Modal
|
||||
styles={{
|
||||
header: { backgroundColor: AdminColor.softBlue },
|
||||
body: { backgroundColor: AdminColor.softBlue },
|
||||
title: { color: AdminColor.white },
|
||||
}}
|
||||
opened={opened}
|
||||
onClose={onClose}
|
||||
withCloseButton={false}
|
||||
size={size ? size : "sm"}
|
||||
centered
|
||||
title={title}
|
||||
>
|
||||
{children}
|
||||
</Modal>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
import ComponentAdminGlobal_IsEmptyData from "../../_admin_global/is_empty_data";
|
||||
import { AdminEvent_ViewDetailPublish } from "../_view/view_detail_publish";
|
||||
import { AdminEvent_ViewDetailReview } from "../_view/view_detail_review";
|
||||
import { AdminEvent_ViewDetailReject } from "../_view/view_detail_reject";
|
||||
|
||||
export function AdminEvent_UiNewDetail() {
|
||||
const params = useParams<{ id: string }>();
|
||||
@@ -55,11 +56,11 @@ export function AdminEvent_UiNewDetail() {
|
||||
) : !data ? (
|
||||
<ComponentAdminGlobal_IsEmptyData />
|
||||
) : data.EventMaster_Status.name === "Publish" ? (
|
||||
<AdminEvent_ViewDetailPublish data={data}/>
|
||||
<AdminEvent_ViewDetailPublish data={data} />
|
||||
) : data.EventMaster_Status.name === "Review" ? (
|
||||
<AdminEvent_ViewDetailReview data={data}/>
|
||||
<AdminEvent_ViewDetailReview data={data} />
|
||||
) : data.EventMaster_Status.name === "Reject" ? (
|
||||
"Detail Reject"
|
||||
<AdminEvent_ViewDetailReject data={data} />
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
|
||||
28
src/app_modules/admin/event/_view/view_detail_reject.tsx
Normal file
28
src/app_modules/admin/event/_view/view_detail_reject.tsx
Normal file
@@ -0,0 +1,28 @@
|
||||
import { MODEL_EVENT } from "@/app_modules/event/_lib/interface";
|
||||
import { Button, Group, Stack } from "@mantine/core";
|
||||
import { IconPencilPlus } from "@tabler/icons-react";
|
||||
import { Admin_ComponentBoxStyle } from "../../_admin_global/_component/comp_admin_boxstyle";
|
||||
import AdminEvent_ComponentDetailData from "../_component/comp_detail_data";
|
||||
|
||||
export function AdminEvent_ViewDetailReject({ data }: { data: MODEL_EVENT }) {
|
||||
return (
|
||||
<>
|
||||
<Admin_ComponentBoxStyle>
|
||||
<Stack>
|
||||
<AdminEvent_ComponentDetailData data={data} />
|
||||
|
||||
<Group mt={100} spacing={"xl"} position="center">
|
||||
<Button
|
||||
color={"red"}
|
||||
leftIcon={<IconPencilPlus />}
|
||||
radius={"xl"}
|
||||
// onClick={openReject}
|
||||
>
|
||||
Tambah catatan
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Admin_ComponentBoxStyle>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,16 +1,144 @@
|
||||
import {
|
||||
ComponentGlobal_NotifikasiBerhasil,
|
||||
ComponentGlobal_NotifikasiGagal,
|
||||
ComponentGlobal_NotifikasiPeringatan,
|
||||
} from "@/app_modules/_global/notif_global";
|
||||
import { MODEL_EVENT } from "@/app_modules/event/_lib/interface";
|
||||
import { IRealtimeData } from "@/lib/global_state";
|
||||
import { Button, Group, Stack, Textarea } from "@mantine/core";
|
||||
import { useDisclosure } from "@mantine/hooks";
|
||||
import { IconBan, IconCircleCheck } from "@tabler/icons-react";
|
||||
import { useAtom } from "jotai";
|
||||
import { gs_admin_event_menu_publish } from "../_lib/global_state";
|
||||
import { Stack, Group, Button } from "@mantine/core";
|
||||
import AdminGlobal_ComponentBackButton from "../../_admin_global/back_button";
|
||||
import AdminEvent_ComponentDetailPublish from "../_component/comp_detail_publish";
|
||||
import { AdminEvent_ViewDetailPeserta } from "./view_detail_peserta";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { WibuRealtime } from "wibu-pkg";
|
||||
import { Admin_ComponentBoxStyle } from "../../_admin_global/_component/comp_admin_boxstyle";
|
||||
import AdminEvent_ComponentDetailData from "../_component/comp_detail_data";
|
||||
import { Admin_ComponentModal } from "../../_admin_global/_component/comp_admin_modal";
|
||||
import { ComponentAdminGlobal_NotifikasiPeringatan } from "../../_admin_global/admin_notifikasi/notifikasi_peringatan";
|
||||
import adminNotifikasi_funCreateToUser from "../../notifikasi/fun/create/fun_create_notif_user";
|
||||
import AdminEvent_ComponentDetailData from "../_component/comp_detail_data";
|
||||
import { AdminEvent_funEditCatatanById } from "../fun/edit/fun_edit_status_reject_by_id";
|
||||
import { event_checkStatus } from "@/app_modules/event/fun/get/fun_check_status_by_id";
|
||||
import moment from "moment";
|
||||
import { ComponentAdminGlobal_NotifikasiBerhasil } from "../../_admin_global/admin_notifikasi/notifikasi_berhasil";
|
||||
import { ComponentAdminGlobal_NotifikasiGagal } from "../../_admin_global/admin_notifikasi/notifikasi_gagal";
|
||||
import { AdminEvent_funEditStatusPublishById } from "../fun/edit/fun_edit_status_publish_by_id";
|
||||
|
||||
export function AdminEvent_ViewDetailReview({ data }: { data: MODEL_EVENT }) {
|
||||
const router = useRouter();
|
||||
const [openedReject, { open: openReject, close: closeReject }] =
|
||||
useDisclosure();
|
||||
const [openedPublish, { open: openPublish, close: closePublish }] =
|
||||
useDisclosure();
|
||||
const [catatan, setCatatan] = useState("");
|
||||
const [isLoadingReject, setLoadingReject] = useState(false);
|
||||
const [isLoadingPublish, setLoadingPublish] = useState(false);
|
||||
|
||||
async function handleReject() {
|
||||
if (catatan === "")
|
||||
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Catatan");
|
||||
|
||||
try {
|
||||
const body = {
|
||||
id: data.id,
|
||||
catatan: catatan,
|
||||
};
|
||||
|
||||
setLoadingReject(true);
|
||||
const res = await AdminEvent_funEditCatatanById(body as any, "4");
|
||||
if (res.status === 200) {
|
||||
const dataNotifikasi: IRealtimeData = {
|
||||
appId: res.data?.id as any,
|
||||
status: res.data?.EventMaster_Status?.name as any,
|
||||
userId: res.data?.authorId as any,
|
||||
pesan: res.data?.title as any,
|
||||
kategoriApp: "EVENT",
|
||||
title: "Event reject",
|
||||
};
|
||||
|
||||
const notif = await adminNotifikasi_funCreateToUser({
|
||||
data: dataNotifikasi as any,
|
||||
});
|
||||
|
||||
if (notif.status === 201) {
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "USER",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
}
|
||||
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
closeReject();
|
||||
router.back();
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("Error reject event", error);
|
||||
} finally {
|
||||
setLoadingReject(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function handlePublish() {
|
||||
try {
|
||||
setLoadingPublish(true);
|
||||
const checkStatus = await event_checkStatus({ id: data.id });
|
||||
|
||||
if (checkStatus) {
|
||||
if (moment(data.tanggal).diff(Date.now(), "minutes") < 0)
|
||||
return ComponentGlobal_NotifikasiPeringatan(
|
||||
"Waktu acara telah lewat, Report untuk memberitahu user !"
|
||||
);
|
||||
|
||||
const res = await AdminEvent_funEditStatusPublishById(data.id, "1");
|
||||
if (res.status === 200) {
|
||||
const dataNotifikasi: IRealtimeData = {
|
||||
appId: res.data?.id as any,
|
||||
status: res.data?.EventMaster_Status?.name as any,
|
||||
userId: res.data?.authorId as any,
|
||||
pesan: res.data?.title as any,
|
||||
kategoriApp: "EVENT",
|
||||
title: "Event publish",
|
||||
};
|
||||
|
||||
const notif = await adminNotifikasi_funCreateToUser({
|
||||
data: dataNotifikasi as any,
|
||||
});
|
||||
|
||||
if (notif.status === 201) {
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "USER",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
|
||||
WibuRealtime.setData({
|
||||
type: "trigger",
|
||||
pushNotificationTo: "USER",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
}
|
||||
closePublish();
|
||||
ComponentAdminGlobal_NotifikasiBerhasil("Berhasil update status");
|
||||
router.back();
|
||||
} else {
|
||||
closePublish();
|
||||
ComponentAdminGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
} else {
|
||||
closePublish();
|
||||
ComponentAdminGlobal_NotifikasiPeringatan(
|
||||
"Review di batalkan oleh user, reload halaman review !"
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("Error publish event", error);
|
||||
} finally {
|
||||
setLoadingPublish(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Admin_ComponentBoxStyle>
|
||||
@@ -22,10 +150,7 @@ export function AdminEvent_ViewDetailReview({ data }: { data: MODEL_EVENT }) {
|
||||
color={"green"}
|
||||
leftIcon={<IconCircleCheck />}
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
// setPublish(true);
|
||||
ComponentAdminGlobal_NotifikasiPeringatan("On Progress");
|
||||
}}
|
||||
onClick={openPublish}
|
||||
>
|
||||
Publish
|
||||
</Button>
|
||||
@@ -34,16 +159,75 @@ export function AdminEvent_ViewDetailReview({ data }: { data: MODEL_EVENT }) {
|
||||
color={"red"}
|
||||
leftIcon={<IconBan />}
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
// setReject(true);
|
||||
ComponentAdminGlobal_NotifikasiPeringatan("On Progress");
|
||||
}}
|
||||
onClick={openReject}
|
||||
>
|
||||
Reject
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Admin_ComponentBoxStyle>
|
||||
|
||||
{/* MODAL REJECT */}
|
||||
<Admin_ComponentModal
|
||||
title="Masukan Alasan Penolakan"
|
||||
opened={openedReject}
|
||||
onClose={closeReject}
|
||||
>
|
||||
<Stack>
|
||||
<Textarea
|
||||
minRows={2}
|
||||
maxRows={5}
|
||||
maxLength={300}
|
||||
autosize
|
||||
placeholder="Contoh: Karena deskripsi kurang lengkap, dll"
|
||||
onChange={(val) => {
|
||||
setCatatan(val.target.value);
|
||||
}}
|
||||
/>
|
||||
<Group position="right">
|
||||
<Button radius={"xl"} onClick={closeReject}>
|
||||
Batal
|
||||
</Button>
|
||||
<Button
|
||||
loading={isLoadingReject}
|
||||
loaderPosition="center"
|
||||
color="green"
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
handleReject();
|
||||
}}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Admin_ComponentModal>
|
||||
|
||||
{/* MODAL PUBLISH */}
|
||||
<Admin_ComponentModal
|
||||
title="Anda Yakin Ingin Mempublish Event Ini ?"
|
||||
opened={openedPublish}
|
||||
onClose={closePublish}
|
||||
>
|
||||
<Stack>
|
||||
<Group position="center">
|
||||
<Button radius={"xl"} onClick={closePublish}>
|
||||
Batal
|
||||
</Button>
|
||||
<Button
|
||||
loading={isLoadingPublish}
|
||||
loaderPosition="center"
|
||||
color="green"
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
handlePublish();
|
||||
}}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Admin_ComponentModal>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ function TableStatus() {
|
||||
<td>
|
||||
<Center c={AdminColor.white}>
|
||||
<Box w={100}>
|
||||
<Text lineClamp={1}>{e?.Author?.username} dasdsasdasdsa sadasd</Text>
|
||||
<Text lineClamp={1}>{e?.Author?.username}</Text>
|
||||
</Box>
|
||||
</Center>
|
||||
</td>
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
"use client";
|
||||
|
||||
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||
import { apiGetDataEventByStatus } from "@/app_modules/admin/event/_lib/api_fecth_admin_event";
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
import { MODEL_EVENT } from "@/app_modules/event/_lib/interface";
|
||||
import { RouterAdminEvent } from "@/lib/router_admin/router_admin_event";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Center,
|
||||
Group,
|
||||
@@ -8,30 +17,20 @@ import {
|
||||
Pagination,
|
||||
Paper,
|
||||
ScrollArea,
|
||||
Spoiler,
|
||||
Stack,
|
||||
Table,
|
||||
Text,
|
||||
Textarea,
|
||||
TextInput,
|
||||
Title,
|
||||
TextInput
|
||||
} from "@mantine/core";
|
||||
import { IconPencilPlus, IconSearch } from "@tabler/icons-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useDisclosure, useShallowEffect } from "@mantine/hooks";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||
import { MODEL_EVENT } from "@/app_modules/event/_lib/interface";
|
||||
import { IconSearch } from "@tabler/icons-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import ComponentAdminGlobal_HeaderTamplate from "../../_admin_global/header_tamplate";
|
||||
import { adminEvent_funGetListReject } from "../fun";
|
||||
import { AdminEvent_funEditCatatanById } from "../fun/edit/fun_edit_status_reject_by_id";
|
||||
import { ComponentAdminGlobal_TitlePage } from "../../_admin_global/_component";
|
||||
import { MainColor } from "@/app_modules/_global/color";
|
||||
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import { apiGetDataEventByStatus } from "@/app_modules/admin/event/_lib/api_fecth_admin_event";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
import Admin_DetailButton from "../../_admin_global/_component/button/detail_button";
|
||||
import ComponentAdminGlobal_HeaderTamplate from "../../_admin_global/header_tamplate";
|
||||
import { AdminEvent_funEditCatatanById } from "../fun/edit/fun_edit_status_reject_by_id";
|
||||
|
||||
export default function AdminEvent_TableReject() {
|
||||
return (
|
||||
@@ -137,20 +136,22 @@ function TableStatus() {
|
||||
return data.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center c={AdminColor.white} w={200}>{e?.Author?.username}</Center>
|
||||
<Center c={AdminColor.white}>
|
||||
<Box w={100}>
|
||||
<Text lineClamp={1}>{e?.Author?.username}</Text>
|
||||
</Box>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white} w={200}>{e.title}</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white} w={200}>{e.lokasi}</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white} w={200}>{e.EventMaster_TipeAcara.name}</Center>
|
||||
<Center c={AdminColor.white}>
|
||||
<Box w={100}>
|
||||
<Text lineClamp={2}>{e.title}</Text>
|
||||
</Box>
|
||||
</Center>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Center c={AdminColor.white} w={200}>
|
||||
<Center c={AdminColor.white}>
|
||||
<Text align="center">
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
dateStyle: "full",
|
||||
@@ -165,7 +166,7 @@ function TableStatus() {
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white} w={200}>
|
||||
<Center c={AdminColor.white}>
|
||||
<Text align="center">
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
dateStyle: "full",
|
||||
@@ -180,7 +181,7 @@ function TableStatus() {
|
||||
</Center>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
{/* <td>
|
||||
<Center c={AdminColor.white} w={500}>
|
||||
<Spoiler
|
||||
hideLabel="sembunyikan"
|
||||
@@ -202,10 +203,10 @@ function TableStatus() {
|
||||
{e.catatan}
|
||||
</Spoiler>
|
||||
</Center>
|
||||
</td>
|
||||
</td> */}
|
||||
|
||||
<td>
|
||||
<Button
|
||||
{/* <Button
|
||||
color={"red"}
|
||||
leftIcon={<IconPencilPlus />}
|
||||
radius={"xl"}
|
||||
@@ -216,7 +217,12 @@ function TableStatus() {
|
||||
}}
|
||||
>
|
||||
Tambah Catatan
|
||||
</Button>
|
||||
</Button> */}
|
||||
<Center>
|
||||
<Admin_DetailButton
|
||||
path={RouterAdminEvent.new_detail({ id: e.id })}
|
||||
/>
|
||||
</Center>{" "}
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
@@ -246,13 +252,7 @@ function TableStatus() {
|
||||
) : (
|
||||
<Paper p={"md"} bg={AdminColor.softBlue} h={"80vh"}>
|
||||
<ScrollArea w={"100%"} h={"90%"}>
|
||||
<Table
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={1500}
|
||||
|
||||
>
|
||||
<Table verticalSpacing={"md"} horizontalSpacing={"md"} p={"md"}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@@ -261,24 +261,18 @@ function TableStatus() {
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Judul</Center>
|
||||
</th>
|
||||
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Lokasi</Center>
|
||||
<Center c={AdminColor.white}>
|
||||
Tanggal & Waktu Mulai
|
||||
</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Tipe Acara</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Tanggal & Waktu Mulai</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Tanggal & Waktu Selesai</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Cacatan</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Deskripsi</Center>
|
||||
<Center c={AdminColor.white}>
|
||||
Tanggal & Waktu Selesai
|
||||
</Center>
|
||||
</th>
|
||||
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Aksi</Center>
|
||||
</th>
|
||||
|
||||
Reference in New Issue
Block a user