Fix: Event
Deskripsi: - Perbaikan route status event - Perbaikan route riwayat event ## No Issue
This commit is contained in:
@@ -14,7 +14,7 @@ import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import ComponentEvent_ErrorMaximalInput from "../component/error_maksimal_input";
|
||||
import { Event_funCreate } from "../fun/create/fun_create";
|
||||
import { gs_event_hotMenu, gs_event_status } from "../global_state";
|
||||
import { gs_event_hotMenu } from "../global_state";
|
||||
import { MainColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import mqtt_client from "@/util/mqtt_client";
|
||||
import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin";
|
||||
@@ -27,7 +27,6 @@ export default function Event_Create({
|
||||
authorId: string;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [tabsStatus, setTabsStatus] = useAtom(gs_event_status);
|
||||
const [listTipe, setListTipe] = useState(listTipeAcara);
|
||||
const [hotMenu, setHotMenu] = useAtom(gs_event_hotMenu);
|
||||
const [isTime, setIsTime] = useState(false);
|
||||
@@ -177,7 +176,7 @@ export default function Event_Create({
|
||||
radius={"xl"}
|
||||
mt={"xl"}
|
||||
onClick={() => {
|
||||
onSave(router, setTabsStatus, value, setHotMenu, setLoading);
|
||||
onSave(router, value, setHotMenu, setLoading);
|
||||
}}
|
||||
bg={MainColor.yellow}
|
||||
color="yellow"
|
||||
@@ -191,7 +190,6 @@ export default function Event_Create({
|
||||
|
||||
async function onSave(
|
||||
router: AppRouterInstance,
|
||||
setTabsStatus: any,
|
||||
value: any,
|
||||
setHotMenu: any,
|
||||
setLoading: any
|
||||
@@ -231,10 +229,9 @@ async function onSave(
|
||||
);
|
||||
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
setTabsStatus("Review");
|
||||
setHotMenu(1);
|
||||
setLoading(true);
|
||||
router.push(RouterEvent.status_page);
|
||||
router.push(RouterEvent.status({ id: "2" }), { scroll: false });
|
||||
}
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
"use client";
|
||||
|
||||
import { Button, Group, Stack } from "@mantine/core";
|
||||
import ComponentEvent_DetailData from "../../component/detail/detail_data";
|
||||
import { RouterEvent } from "@/app/lib/router_hipmi/router_event";
|
||||
import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
||||
import UIGlobal_Modal from "@/app_modules/_global/ui/ui_modal";
|
||||
import { useAtom } from "jotai";
|
||||
import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin";
|
||||
import mqtt_client from "@/util/mqtt_client";
|
||||
import { Button, Group, Stack } from "@mantine/core";
|
||||
import moment from "moment";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import ComponentEvent_DetailData from "../../component/detail/detail_data";
|
||||
import { Event_funDeleteById } from "../../fun/delete/fun_delete";
|
||||
import { Event_funEditStatusById } from "../../fun/edit/fun_edit_status_by_id";
|
||||
import { gs_event_status } from "../../global_state";
|
||||
import { MODEL_EVENT } from "../../model/interface";
|
||||
import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin";
|
||||
import mqtt_client from "@/util/mqtt_client";
|
||||
|
||||
export default function Event_DetailDraft({
|
||||
dataEvent,
|
||||
}: {
|
||||
dataEvent: MODEL_EVENT;
|
||||
}) {
|
||||
const [data, setData] = useState(dataEvent);
|
||||
return (
|
||||
<>
|
||||
{/* <pre>{JSON.stringify(dataEvent.catatan)}</pre> */}
|
||||
{/* <pre>{JSON.stringify(dataEvent.tanggal)}</pre> */}
|
||||
<Stack spacing={"lg"}>
|
||||
{dataEvent?.catatan ? (
|
||||
<ComponentGlobal_BoxInformation
|
||||
@@ -35,33 +35,35 @@ export default function Event_DetailDraft({
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
<ComponentEvent_DetailData data={dataEvent} />
|
||||
<ButtonAction eventId={dataEvent?.id} tanggal={dataEvent.tanggal} />
|
||||
<ComponentEvent_DetailData data={data} />
|
||||
<ButtonAction eventId={data.id} tanggal={data.tanggal} />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function ButtonAction({ eventId, tanggal }: { eventId: string; tanggal: any }) {
|
||||
function ButtonAction({
|
||||
eventId,
|
||||
tanggal,
|
||||
}: {
|
||||
eventId: string;
|
||||
tanggal?: any;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [isLoadingDelete, setLoadingDelete] = useState(false);
|
||||
const [isLoadingAjukan, setLoadingAjukan] = useState(false);
|
||||
const [tabsStatus, setTabsStatus] = useAtom(gs_event_status);
|
||||
const [openModal1, setOpenModal1] = useState(false);
|
||||
const [openModal2, setOpenModal2] = useState(false);
|
||||
|
||||
async function onDelete() {
|
||||
await Event_funDeleteById(eventId).then((res) => {
|
||||
if (res.status === 200) {
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
|
||||
setLoadingDelete(true);
|
||||
setTabsStatus("Draft");
|
||||
close();
|
||||
router.back();
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
});
|
||||
const res = await Event_funDeleteById(eventId);
|
||||
if (res.status === 200) {
|
||||
router.back();
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
|
||||
setLoadingDelete(true);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function onAjukan() {
|
||||
@@ -91,9 +93,8 @@ function ButtonAction({ eventId, tanggal }: { eventId: string; tanggal: any }) {
|
||||
})
|
||||
);
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
|
||||
setTabsStatus("Review");
|
||||
setLoadingAjukan(true);
|
||||
router.back();
|
||||
router.replace(RouterEvent.status({ id: "2" }));
|
||||
}
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
|
||||
@@ -1,77 +1,38 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Grid,
|
||||
Group,
|
||||
Modal,
|
||||
Paper,
|
||||
SimpleGrid,
|
||||
Stack,
|
||||
Text,
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
import ComponentEvent_DetailData from "../../component/detail/detail_data";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useAtom } from "jotai";
|
||||
import { gs_event_status } from "../../global_state";
|
||||
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||
import { useDisclosure } from "@mantine/hooks";
|
||||
import { MODEL_EVENT } from "../../model/interface";
|
||||
import { Event_funEditStatusById } from "../../fun/edit/fun_edit_status_by_id";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||
import ComponentEvent_CatatanReject from "../../component/catatan_reject";
|
||||
import { Event_funDeleteById } from "../../fun/delete/fun_delete";
|
||||
import { RouterEvent } from "@/app/lib/router_hipmi/router_event";
|
||||
import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information";
|
||||
import { useState } from "react";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||
import UIGlobal_Modal from "@/app_modules/_global/ui/ui_modal";
|
||||
import { Button, SimpleGrid, Stack } from "@mantine/core";
|
||||
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import ComponentEvent_DetailData from "../../component/detail/detail_data";
|
||||
import { Event_funDeleteById } from "../../fun/delete/fun_delete";
|
||||
import { Event_funEditStatusById } from "../../fun/edit/fun_edit_status_by_id";
|
||||
import { MODEL_EVENT } from "../../model/interface";
|
||||
|
||||
export default function Event_DetailReject({
|
||||
dataEvent,
|
||||
}: {
|
||||
dataEvent: MODEL_EVENT;
|
||||
}) {
|
||||
const [data, setData] = useState(dataEvent);
|
||||
return (
|
||||
<>
|
||||
<Stack spacing={"lg"}>
|
||||
<ComponentGlobal_BoxInformation
|
||||
isReport
|
||||
informasi={dataEvent.catatan}
|
||||
/>
|
||||
<ComponentEvent_DetailData data={dataEvent} />
|
||||
<ButtonAction eventId={dataEvent?.id} />
|
||||
<ComponentGlobal_BoxInformation isReport informasi={data.catatan} />
|
||||
<ComponentEvent_DetailData data={data} />
|
||||
<ButtonAction eventId={data.id} />
|
||||
</Stack>
|
||||
|
||||
{/* <Modal opened={opened} onClose={close} centered withCloseButton={false}>
|
||||
<Stack>
|
||||
<Title order={6}>Yakin akan menghapus event ini?</Title>
|
||||
<Group position="center">
|
||||
<Button radius={"xl"} onClick={close}>
|
||||
Batal
|
||||
</Button>
|
||||
<Button
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
onDelete(router, dataEvent.id, close);
|
||||
close();
|
||||
router.back();
|
||||
}}
|
||||
color="red"
|
||||
>
|
||||
Hapus
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Modal> */}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function ButtonAction({ eventId }: { eventId: string }) {
|
||||
const router = useRouter();
|
||||
const [tabsStatus, setTabsStatus] = useAtom(gs_event_status);
|
||||
const [openModal1, setOpenModal1] = useState(false);
|
||||
const [openModal2, setOpenModal2] = useState(false);
|
||||
|
||||
@@ -113,7 +74,7 @@ function ButtonAction({ eventId }: { eventId: string }) {
|
||||
radius={"xl"}
|
||||
color={"yellow"}
|
||||
onClick={() => {
|
||||
onUpdate(router, setTabsStatus, eventId);
|
||||
onUpdate(router, eventId);
|
||||
setOpenModal1(false);
|
||||
}}
|
||||
>
|
||||
@@ -137,9 +98,8 @@ function ButtonAction({ eventId }: { eventId: string }) {
|
||||
radius={"xl"}
|
||||
color={"red"}
|
||||
onClick={() => {
|
||||
onDelete(router, eventId, close);
|
||||
onDelete(router, eventId);
|
||||
setOpenModal2(false);
|
||||
|
||||
}}
|
||||
>
|
||||
Hapus
|
||||
@@ -150,32 +110,23 @@ function ButtonAction({ eventId }: { eventId: string }) {
|
||||
);
|
||||
}
|
||||
|
||||
async function onUpdate(
|
||||
router: AppRouterInstance,
|
||||
setTabsStatus: any,
|
||||
eventId: string
|
||||
) {
|
||||
async function onUpdate(router: AppRouterInstance, eventId: string) {
|
||||
await Event_funEditStatusById("3", eventId).then((res) => {
|
||||
if (res.status === 200) {
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
setTabsStatus("Draft");
|
||||
router.back();
|
||||
router.push(RouterEvent.status({ id: "3" }));
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function onDelete(
|
||||
router: AppRouterInstance,
|
||||
eventId: string,
|
||||
close: any
|
||||
) {
|
||||
await Event_funDeleteById(eventId).then((res) => {
|
||||
if (res.status === 200) {
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
});
|
||||
async function onDelete(router: AppRouterInstance, eventId: string) {
|
||||
const res = await Event_funDeleteById(eventId);
|
||||
if (res.status === 200) {
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
|
||||
router.back();
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
"use client";
|
||||
|
||||
import { RouterEvent } from "@/app/lib/router_hipmi/router_event";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||
import UIGlobal_Modal from "@/app_modules/_global/ui/ui_modal";
|
||||
import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin";
|
||||
import mqtt_client from "@/util/mqtt_client";
|
||||
import { Button, Stack } from "@mantine/core";
|
||||
import { useAtom } from "jotai";
|
||||
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import ComponentEvent_DetailData from "../../component/detail/detail_data";
|
||||
import { Event_funEditStatusById } from "../../fun/edit/fun_edit_status_by_id";
|
||||
import { gs_event_status } from "../../global_state";
|
||||
import { MODEL_EVENT } from "../../model/interface";
|
||||
|
||||
export default function Event_DetailReview({
|
||||
@@ -32,14 +31,11 @@ export default function Event_DetailReview({
|
||||
|
||||
function ButtonAction({ eventId }: { eventId: string }) {
|
||||
const router = useRouter();
|
||||
const [tabsStatus, setTabsStatus] = useAtom(gs_event_status);
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
const [openModal, setOpenModal] = useState(false);
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={isLoading ? true : false}
|
||||
radius={"xl"}
|
||||
color={"orange"}
|
||||
onClick={() => setOpenModal(true)}
|
||||
@@ -58,9 +54,11 @@ function ButtonAction({ eventId }: { eventId: string }) {
|
||||
}
|
||||
buttonKanan={
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={isLoading}
|
||||
radius={"xl"}
|
||||
color={"orange"}
|
||||
onClick={() => onClick(router, setTabsStatus, eventId, setLoading)}
|
||||
onClick={() => onClick(router, eventId, setLoading)}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
@@ -72,7 +70,6 @@ function ButtonAction({ eventId }: { eventId: string }) {
|
||||
|
||||
async function onClick(
|
||||
router: AppRouterInstance,
|
||||
setTabsStatus: any,
|
||||
eventId: string,
|
||||
setLoading: any
|
||||
) {
|
||||
@@ -100,9 +97,8 @@ async function onClick(
|
||||
);
|
||||
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message, 1500);
|
||||
setTabsStatus("Draft");
|
||||
setLoading(true);
|
||||
router.back();
|
||||
router.replace(RouterEvent.status({ id: "3" }));
|
||||
}
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { RouterEvent } from "@/app/lib/router_hipmi/router_event";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export async function Event_funDeleteById(eventId: string) {
|
||||
console.log(eventId);
|
||||
const del = await prisma.event.delete({
|
||||
where: {
|
||||
id: eventId,
|
||||
@@ -11,17 +13,9 @@ export async function Event_funDeleteById(eventId: string) {
|
||||
});
|
||||
if (!del) return { status: 400, message: "Gagal hapus data" };
|
||||
|
||||
// const delTemporary = await prisma.event.update({
|
||||
// where: {
|
||||
// id: eventId,
|
||||
// },
|
||||
// data: {
|
||||
// active: false,
|
||||
// },
|
||||
// });
|
||||
// if (!delTemporary) return { status: 400, message: "Gagal hapus data" };
|
||||
revalidatePath("/dev/event/main/status/3");
|
||||
revalidatePath("/dev/event/main/status/4");
|
||||
|
||||
revalidatePath("/dev/event/main/status_page");
|
||||
return {
|
||||
status: 200,
|
||||
message: "Hapus data berhasil",
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { MODEL_EVENT } from "../../model/interface";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { RouterEvent } from "@/app/lib/router_hipmi/router_event";
|
||||
|
||||
export async function Event_funEditById(data: MODEL_EVENT) {
|
||||
const updt = await prisma.event.update({
|
||||
@@ -19,7 +20,7 @@ export async function Event_funEditById(data: MODEL_EVENT) {
|
||||
});
|
||||
|
||||
if (!updt) return { status: 400, message: "Update Gagal" };
|
||||
revalidatePath("/dev/event/detail/event");
|
||||
revalidatePath(RouterEvent.detail_draft + data.id);
|
||||
return {
|
||||
status: 200,
|
||||
message: "Berhasil Update",
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
"use server";
|
||||
|
||||
import { prisma } from "@/app/lib";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export async function event_getAllByStatusId({
|
||||
page,
|
||||
statusId,
|
||||
}: {
|
||||
page: number;
|
||||
statusId: string;
|
||||
}) {
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
const data = await prisma.event.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
active: true,
|
||||
eventMaster_StatusId: statusId,
|
||||
authorId: userLoginId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
deskripsi: true,
|
||||
tanggal: true,
|
||||
},
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
5
src/app_modules/event/fun/index.ts
Normal file
5
src/app_modules/event/fun/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { event_getAllByStatusId } from "./get/status/get_all_by_status_id";
|
||||
import { event_getMasterStatus } from "./master/get_status_event";
|
||||
|
||||
export { event_getAllByStatusId };
|
||||
export { event_getMasterStatus };
|
||||
9
src/app_modules/event/fun/master/get_status_event.ts
Normal file
9
src/app_modules/event/fun/master/get_status_event.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
"use server";
|
||||
|
||||
import { prisma } from "@/app/lib";
|
||||
|
||||
export async function event_getMasterStatus() {
|
||||
const data = await prisma.eventMaster_Status.findMany({});
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -11,9 +11,3 @@ export const gs_event_hotMenu = atomWithStorage("gs_event_hotMenu", 0)
|
||||
* @type string
|
||||
*/
|
||||
export const gs_event_status = atomWithStorage<string | any>("gs_status_event", "Publish")
|
||||
|
||||
/**
|
||||
* @param riwayat | "Semua", "Saya"
|
||||
* @type string
|
||||
*/
|
||||
export const gs_event_riwayat = atomWithStorage<string | any>("gs_event_riwayat", "Semua")
|
||||
@@ -6,17 +6,12 @@ import { MainColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
||||
import UIGlobal_LayoutHeaderTamplate from "@/app_modules/_global/ui/ui_header_tamplate";
|
||||
import UIGlobal_LayoutTamplate from "@/app_modules/_global/ui/ui_layout_tamplate";
|
||||
import {
|
||||
ActionIcon,
|
||||
SimpleGrid,
|
||||
Stack,
|
||||
Text
|
||||
} from "@mantine/core";
|
||||
import { ActionIcon, SimpleGrid, Stack, Text } from "@mantine/core";
|
||||
import {
|
||||
IconCalendarEvent,
|
||||
IconHistory,
|
||||
IconHome,
|
||||
IconTimelineEventText
|
||||
IconTimelineEventText,
|
||||
} from "@tabler/icons-react";
|
||||
import { useAtom } from "jotai";
|
||||
import { useRouter } from "next/navigation";
|
||||
@@ -42,7 +37,7 @@ export default function LayoutEvent_Main({
|
||||
{
|
||||
id: "2",
|
||||
name: "Status",
|
||||
path: RouterEvent.status_page,
|
||||
path: RouterEvent.status({ id: "1" }),
|
||||
icon: <IconTimelineEventText />,
|
||||
},
|
||||
{
|
||||
@@ -54,7 +49,7 @@ export default function LayoutEvent_Main({
|
||||
{
|
||||
id: "4",
|
||||
name: "Riwayat",
|
||||
path: RouterEvent.riwayat,
|
||||
path: RouterEvent.riwayat({ id: "1" }),
|
||||
icon: <IconHistory />,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -1,48 +1,57 @@
|
||||
"use client";
|
||||
|
||||
import { Stack, Tabs } from "@mantine/core";
|
||||
|
||||
import { AccentColor, MainColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import { useAtom } from "jotai";
|
||||
import { RouterEvent } from "@/app/lib/router_hipmi/router_event";
|
||||
import {
|
||||
AccentColor,
|
||||
MainColor,
|
||||
} from "@/app_modules/_global/color/color_pallet";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { gs_event_riwayat } from "../../global_state";
|
||||
import { useState } from "react";
|
||||
import { MODEL_EVENT } from "../../model/interface";
|
||||
import Event_RiwayatSaya from "./saya";
|
||||
import Event_SemuaRiwayat from "./semua";
|
||||
|
||||
export default function Event_Riwayat({
|
||||
statusId,
|
||||
dataSemuaRiwayat,
|
||||
dataRiwayatSaya
|
||||
dataRiwayatSaya,
|
||||
}: {
|
||||
dataSemuaRiwayat: MODEL_EVENT[];
|
||||
dataRiwayatSaya: MODEL_EVENT[]
|
||||
statusId: string;
|
||||
dataSemuaRiwayat?: MODEL_EVENT[];
|
||||
dataRiwayatSaya?: MODEL_EVENT[];
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [tabsRiwayat, setTabsRiwayat] = useAtom(gs_event_riwayat)
|
||||
// const [tabsRiwayat, setTabsRiwayat] = useAtom(gs_event_riwayat)
|
||||
const [changeStatus, setChangeStatus] = useState(statusId);
|
||||
|
||||
const listTabs = [
|
||||
{
|
||||
id: 1,
|
||||
id: "1",
|
||||
label: "Semua Riwayat",
|
||||
value: "Semua",
|
||||
path: <Event_SemuaRiwayat listData={dataSemuaRiwayat as any} />,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
id: "2",
|
||||
label: "Riwayat Saya",
|
||||
value: "Saya",
|
||||
path: <Event_RiwayatSaya listData={dataRiwayatSaya as any} />,
|
||||
},
|
||||
];
|
||||
|
||||
async function onChangeStatus({ statusId }: { statusId: string }) {
|
||||
router.push(RouterEvent.riwayat({ id: statusId }));
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Tabs
|
||||
defaultValue={"Semua"}
|
||||
variant="pills"
|
||||
radius={"xl"}
|
||||
onTabChange={setTabsRiwayat}
|
||||
value={tabsRiwayat}
|
||||
value={changeStatus}
|
||||
onTabChange={(val: any) => {
|
||||
setChangeStatus(val);
|
||||
onChangeStatus({ statusId: val });
|
||||
}}
|
||||
styles={{
|
||||
tabsList: {
|
||||
backgroundColor: MainColor.darkblue,
|
||||
@@ -57,15 +66,15 @@ export default function Event_Riwayat({
|
||||
{listTabs.map((e) => (
|
||||
<Tabs.Tab
|
||||
key={e.id}
|
||||
value={e.value}
|
||||
value={e.id}
|
||||
fw={"bold"}
|
||||
c={"black"}
|
||||
style={{
|
||||
transition: "0.5s",
|
||||
backgroundColor:
|
||||
tabsRiwayat === e.value ? MainColor.yellow : "white",
|
||||
changeStatus === e.id ? MainColor.yellow : "white",
|
||||
border:
|
||||
tabsRiwayat === e.value
|
||||
changeStatus === e.id
|
||||
? `1px solid ${AccentColor.yellow}`
|
||||
: `1px solid white`,
|
||||
}}
|
||||
@@ -74,11 +83,12 @@ export default function Event_Riwayat({
|
||||
</Tabs.Tab>
|
||||
))}
|
||||
</Tabs.List>
|
||||
{listTabs.map((e) => (
|
||||
<Tabs.Panel key={e.id} value={e.value}>
|
||||
{e.path}
|
||||
</Tabs.Panel>
|
||||
))}
|
||||
{statusId == "1" && (
|
||||
<Event_SemuaRiwayat listData={dataSemuaRiwayat as any} />
|
||||
)}
|
||||
{statusId == "2" && (
|
||||
<Event_RiwayatSaya listData={dataRiwayatSaya as any} />
|
||||
)}
|
||||
</Stack>
|
||||
</Tabs>
|
||||
</>
|
||||
|
||||
@@ -9,7 +9,7 @@ import { useState } from "react";
|
||||
import { ComponentEvent_CardRiwayat } from "../../component/card_view/card_riwayat";
|
||||
import { event_getListSemuaRiwayat } from "../../fun/get/riwayat/get_list_semua_riwayat";
|
||||
import { MODEL_EVENT } from "../../model/interface";
|
||||
import { event_getListRiwayatSaya } from "../../fun/get/get_list_riwayat_saya";
|
||||
import { event_getListRiwayatSaya } from "../../fun/get/riwayat/get_list_riwayat_saya";
|
||||
|
||||
export default function Event_RiwayatSaya({
|
||||
listData,
|
||||
|
||||
@@ -1,64 +1,47 @@
|
||||
"use client";
|
||||
|
||||
import { Stack, Tabs } from "@mantine/core";
|
||||
import { useAtom } from "jotai";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { gs_event_status } from "../../global_state";
|
||||
import Event_StatusDraft from "./draft";
|
||||
import Event_StatusPublish from "./publish";
|
||||
import Event_StatusReject from "./reject";
|
||||
import Event_StatusReview from "./review";
|
||||
import { RouterEvent } from "@/app/lib/router_hipmi/router_event";
|
||||
import {
|
||||
AccentColor,
|
||||
MainColor,
|
||||
} from "@/app_modules/_global/color/color_pallet";
|
||||
import { MODEL_NEW_DEFAULT_MASTER } from "@/app_modules/model_global/interface";
|
||||
import { Box, Stack, Tabs } from "@mantine/core";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import Event_StatusDraft from "./draft";
|
||||
import Event_StatusPublish from "./publish";
|
||||
import Event_StatusReject from "./reject";
|
||||
import Event_StatusReview from "./review";
|
||||
|
||||
export default function Event_StatusPage({
|
||||
authorId,
|
||||
listPublish,
|
||||
listReview,
|
||||
listDraft,
|
||||
listReject,
|
||||
statusId,
|
||||
dataStatus,
|
||||
listStatus,
|
||||
}: {
|
||||
authorId: string;
|
||||
listPublish: any;
|
||||
listReview: any;
|
||||
listDraft: any;
|
||||
listReject: any;
|
||||
statusId: string;
|
||||
dataStatus: any[];
|
||||
listStatus: MODEL_NEW_DEFAULT_MASTER[];
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [tabsStatus, setTabsStatus] = useAtom(gs_event_status);
|
||||
const listTabs = [
|
||||
{
|
||||
id: 1,
|
||||
path: <Event_StatusPublish listPublish={listPublish} />,
|
||||
value: "Publish",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
path: <Event_StatusReview listReview={listReview} />,
|
||||
value: "Review",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
path: <Event_StatusDraft listDraft={listDraft} />,
|
||||
value: "Draft",
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
path: <Event_StatusReject listReject={listReject} />,
|
||||
value: "Reject",
|
||||
},
|
||||
];
|
||||
const [changeStatus, setChangeStatus] = useState(statusId);
|
||||
|
||||
async function onChangeStatus({ statusId }: { statusId: string }) {
|
||||
router.push(RouterEvent.status({ id: statusId }));
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Tabs
|
||||
variant="pills"
|
||||
radius="xl"
|
||||
mt={1}
|
||||
defaultValue="Publish"
|
||||
value={tabsStatus}
|
||||
onTabChange={setTabsStatus}
|
||||
// defaultValue={"1"}
|
||||
value={changeStatus}
|
||||
onTabChange={(val: any) => {
|
||||
setChangeStatus(val);
|
||||
onChangeStatus({ statusId: val });
|
||||
}}
|
||||
styles={{
|
||||
tabsList: {
|
||||
backgroundColor: MainColor.darkblue,
|
||||
@@ -70,33 +53,95 @@ export default function Event_StatusPage({
|
||||
>
|
||||
<Stack>
|
||||
<Tabs.List grow>
|
||||
{listTabs.map((e) => (
|
||||
{listStatus.map((e) => (
|
||||
<Tabs.Tab
|
||||
key={e.id}
|
||||
value={e.value}
|
||||
value={e.id}
|
||||
fw={"bold"}
|
||||
c={"black"}
|
||||
style={{
|
||||
transition: "0.5s",
|
||||
backgroundColor:
|
||||
tabsStatus === e.value ? MainColor.yellow : "white",
|
||||
changeStatus === e.id ? MainColor.yellow : "white",
|
||||
border:
|
||||
tabsStatus === e.value
|
||||
changeStatus === e.id
|
||||
? `1px solid ${AccentColor.yellow}`
|
||||
: `1px solid white`,
|
||||
}}
|
||||
>
|
||||
{e.value}
|
||||
{e.name}
|
||||
</Tabs.Tab>
|
||||
))}
|
||||
</Tabs.List>
|
||||
{listTabs.map((e) => (
|
||||
<Tabs.Panel key={e.id} value={e.value}>
|
||||
{e.path}
|
||||
</Tabs.Panel>
|
||||
))}
|
||||
|
||||
<Box>
|
||||
{changeStatus === "1" && (
|
||||
<Event_StatusPublish listPublish={dataStatus} />
|
||||
)}
|
||||
{changeStatus === "2" && (
|
||||
<Event_StatusReview listReview={dataStatus} />
|
||||
)}
|
||||
{changeStatus === "3" && (
|
||||
<Event_StatusDraft listDraft={dataStatus} />
|
||||
)}
|
||||
{changeStatus === "4" && (
|
||||
<Event_StatusReject listReject={dataStatus} />
|
||||
)}
|
||||
</Box>
|
||||
</Stack>
|
||||
</Tabs>
|
||||
</>
|
||||
);
|
||||
|
||||
// return (
|
||||
// <>
|
||||
// <Tabs
|
||||
// variant="pills"
|
||||
// radius="xl"
|
||||
// mt={1}
|
||||
// defaultValue={changeStatus}
|
||||
// value={changeStatus}
|
||||
// onTabChange={(val: any) => {
|
||||
// console.log(val);
|
||||
// }}
|
||||
// styles={{
|
||||
// tabsList: {
|
||||
// backgroundColor: MainColor.darkblue,
|
||||
// position: "sticky",
|
||||
// top: 0,
|
||||
// zIndex: 99,
|
||||
// },
|
||||
// }}
|
||||
// >
|
||||
// <Stack>
|
||||
// <Tabs.List grow>
|
||||
// {listStatus.map((e) => (
|
||||
// <Tabs.Tab
|
||||
// key={e.id}
|
||||
// value={e.name}
|
||||
// fw={"bold"}
|
||||
// c={"black"}
|
||||
// // style={{
|
||||
// // transition: "0.5s",
|
||||
// // backgroundColor:
|
||||
// // tabsStatus === e.name ? MainColor.yellow : "white",
|
||||
// // border:
|
||||
// // tabsStatus === e.name
|
||||
// // ? `1px solid ${AccentColor.yellow}`
|
||||
// // : `1px solid white`,
|
||||
// // }}
|
||||
// >
|
||||
// {e.name}
|
||||
// </Tabs.Tab>
|
||||
// ))}
|
||||
// </Tabs.List>
|
||||
// {/* {listTabs.map((e) => (
|
||||
// <Tabs.Panel key={e.id} value={e.value}>
|
||||
// {e.path}
|
||||
// </Tabs.Panel>
|
||||
// ))} */}
|
||||
// </Stack>
|
||||
// </Tabs>
|
||||
// </>
|
||||
// );
|
||||
}
|
||||
|
||||
@@ -1,27 +1,18 @@
|
||||
"use client";
|
||||
|
||||
import { RouterEvent } from "@/app/lib/router_hipmi/router_event";
|
||||
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
|
||||
import {
|
||||
Box,
|
||||
Center,
|
||||
Group,
|
||||
Loader,
|
||||
Paper,
|
||||
Stack,
|
||||
Text,
|
||||
Title,
|
||||
Loader
|
||||
} from "@mantine/core";
|
||||
import moment from "moment";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { MODEL_EVENT } from "../../model/interface";
|
||||
import ComponentEvent_BoxListStatus from "../../component/box_list_status";
|
||||
import _ from "lodash";
|
||||
import ComponentEvent_IsEmptyData from "../../component/is_empty_data";
|
||||
import { event_getAllReject } from "../../fun/get/status/get_all_reject";
|
||||
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
|
||||
import { ScrollOnly } from "next-scroll-loader";
|
||||
import { useState } from "react";
|
||||
import { event_getAllReview } from "../../fun/get/status/get_all_review";
|
||||
import ComponentEvent_BoxListStatus from "../../component/box_list_status";
|
||||
import { event_getAllReject } from "../../fun/get/status/get_all_reject";
|
||||
import { MODEL_EVENT } from "../../model/interface";
|
||||
|
||||
export default function Event_StatusReject({
|
||||
listReject,
|
||||
|
||||
@@ -12,10 +12,8 @@ import { MODEL_EVENT } from "../../model/interface";
|
||||
|
||||
export default function Event_StatusReview({
|
||||
listReview,
|
||||
|
||||
}: {
|
||||
listReview: MODEL_EVENT[];
|
||||
|
||||
}) {
|
||||
const [data, setData] = useState(listReview);
|
||||
const [activePage, setActivePage] = useState(1);
|
||||
|
||||
@@ -6,18 +6,16 @@ import { useShallowEffect } from "@mantine/hooks";
|
||||
import { IconPresentation } from "@tabler/icons-react";
|
||||
import { useAtom } from "jotai";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { gs_event_hotMenu, gs_event_status } from "../global_state";
|
||||
import { gs_event_hotMenu } from "../global_state";
|
||||
|
||||
export default function Event_SplashScreen() {
|
||||
const router = useRouter();
|
||||
const [hotMenu, setHotMenu] = useAtom(gs_event_hotMenu);
|
||||
const [tabsStatus, setTabsStatus] = useAtom(gs_event_status);
|
||||
|
||||
useShallowEffect(() => {
|
||||
setTimeout(() => {
|
||||
router.replace(RouterEvent.beranda);
|
||||
setHotMenu(0);
|
||||
setTabsStatus("Publish");
|
||||
}, 1000);
|
||||
}, []);
|
||||
return (
|
||||
|
||||
@@ -11,7 +11,7 @@ export function redirectEventPage({
|
||||
router: AppRouterInstance;
|
||||
onSetPage: (val: any) => void;
|
||||
}) {
|
||||
const path = RouterEvent.status_page;
|
||||
const path = RouterEvent.status({id: ""});
|
||||
|
||||
if (data.status === "Publish") {
|
||||
onSetPage({
|
||||
|
||||
Reference in New Issue
Block a user