From 45279cd37fb4b2a293012c9cb1a8d6e977d0edb3 Mon Sep 17 00:00:00 2001 From: Bagasbanuna02 Date: Fri, 29 Nov 2024 16:15:54 +0800 Subject: [PATCH 01/44] Fix: Event Deskripsi: - Fix database event - Fix style detal --- prisma/schema.prisma | 13 +- .../dev/admin/event/table/publish/page.tsx | 7 +- src/app/dev/layout.tsx | 19 +- src/app/dev/user-not-active/page.tsx | 11 -- .../admin/event/_view/view_table_review.tsx | 146 ++++++++++----- src/app_modules/admin/event/child/riwayat.tsx | 49 +++-- .../fun/count/fun_count_event_by_status_id.ts | 4 +- .../event/fun/count/fun_count_riwayat.ts | 4 +- .../event/fun/get/get_list_all_riwayat.ts | 8 +- .../fun/get/get_list_table_by_status_id.ts | 146 --------------- .../fun/get/status/fun_get_list_publish.ts | 31 ++- .../event/table_status/table_publish.tsx | 177 ++++++++++-------- .../admin/event/table_status/table_reject.tsx | 38 +++- .../check_cookies/layout_cek_cookies.tsx | 10 +- .../component/button/button_create_event.tsx | 16 +- .../event/component/detail/detail_data.tsx | 84 +++++---- .../event/component/detail/detail_main.tsx | 77 +++++--- src/app_modules/event/create/create.tsx | 81 +++++++- src/app_modules/event/detail/draft/index.tsx | 22 +-- src/app_modules/event/detail/review/index.tsx | 68 ++++--- src/app_modules/event/edit/index.tsx | 102 ++++++++-- .../event/fun/create/fun_create.ts | 8 +- .../event/fun/edit/fun_edit_by_id.ts | 7 +- .../event/fun/get/fun_check_status_by_id.ts | 14 ++ .../event/fun/get/get_list_all_publish.ts | 32 +++- .../fun/get/get_list_event_by_status_id.ts | 88 --------- .../event/fun/get/get_one_by_id.ts | 14 +- .../fun/get/riwayat/get_list_riwayat_saya.ts | 4 +- .../fun/get/riwayat/get_list_semua_riwayat.ts | 7 +- .../fun/get/status/get_all_by_status_id.tsx | 4 +- .../fun/get/status/get_all_status_publish.ts | 4 +- src/app_modules/event/main/beranda.tsx | 2 +- .../event/main/status_page/publish.tsx | 5 +- src/app_modules/event/model/interface.ts | 2 + .../home/user_non_active/index.tsx | 21 ++- src/{middleware.txt => middleware.ts} | 0 36 files changed, 714 insertions(+), 611 deletions(-) delete mode 100644 src/app_modules/admin/event/fun/get/get_list_table_by_status_id.ts create mode 100644 src/app_modules/event/fun/get/fun_check_status_by_id.ts delete mode 100644 src/app_modules/event/fun/get/get_list_event_by_status_id.ts rename src/{middleware.txt => middleware.ts} (100%) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index c946ba04..0d878e58 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -573,16 +573,19 @@ model Donasi_PencairanDana { // ========================================= EVENT ========================================= // model Event { - id String @id @default(cuid()) + id String @id @default(cuid()) title String lokasi String - tanggal DateTime + tanggal DateTime? deskripsi String - active Boolean @default(true) - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + active Boolean @default(true) + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt catatan String? + tanggalSelesai DateTime? + isArsip Boolean? @default(false) + Author User? @relation(fields: [authorId], references: [id]) authorId String? EventMaster_Status EventMaster_Status? @relation(fields: [eventMaster_StatusId], references: [id]) diff --git a/src/app/dev/admin/event/table/publish/page.tsx b/src/app/dev/admin/event/table/publish/page.tsx index 50fc6b34..a7c514dc 100644 --- a/src/app/dev/admin/event/table/publish/page.tsx +++ b/src/app/dev/admin/event/table/publish/page.tsx @@ -1,9 +1,8 @@ import { AdminEvent_TablePublish } from "@/app_modules/admin/event"; import { adminEvent_funGetListPublish } from "@/app_modules/admin/event/fun"; -import { AdminEvent_getListTableByStatusId } from "@/app_modules/admin/event/fun/get/get_list_table_by_status_id"; -export default async function Page() { - const listPublish = await adminEvent_funGetListPublish({page: 1}); +async function Page() { + const listPublish = await adminEvent_funGetListPublish({ page: 1 }); return ( <> @@ -11,3 +10,5 @@ export default async function Page() { ); } + +export default Page; diff --git a/src/app/dev/layout.tsx b/src/app/dev/layout.tsx index c568b5c5..65398635 100644 --- a/src/app/dev/layout.tsx +++ b/src/app/dev/layout.tsx @@ -1,12 +1,11 @@ -import { CheckCookies_UiLayout } from "@/app_modules/check_cookies"; -import { RealtimeProvider } from "../lib"; -import { funCheckCookies } from "@/app_modules/_global/fun/get/fun_check_cookies"; import { funGetUserIdByToken } from "@/app_modules/_global/fun/get"; +import { funCheckCookies } from "@/app_modules/_global/fun/get/fun_check_cookies"; +import { permanentRedirect, redirect } from "next/navigation"; +import { RealtimeProvider } from "../lib"; import { ServerEnv } from "../lib/server_env"; import { funGlobal_getUserById } from "@/app_modules/_global/fun/get/fun_get_user_by_id"; import { RouterHome } from "../lib/router_hipmi/router_home"; -import { RouterAdminDashboard } from "../lib/router_hipmi/router_admin"; -import { redirect } from "next/navigation"; +import { CheckCookies_UiLayout } from "@/app_modules/check_cookies"; export default async function Layout({ children, @@ -14,10 +13,14 @@ export default async function Layout({ children: React.ReactNode; }) { const checkCookies = await funCheckCookies(); - if (!checkCookies) return redirect("/"); - const userLoginId = await funGetUserIdByToken(); - const WIBU_REALTIME_TOKEN = process.env.NEXT_PUBLIC_WIBU_REALTIME_TOKEN; + if (!checkCookies) return redirect("/"); + + // const dataUser = await funGlobal_getUserById({ userId: userLoginId }); + // console.log(dataUser?.active, dataUser?.username, "ini di layout"); + + // if(dataUser?.active == false) return permanentRedirect(RouterHome.home_user_non_active); + // const WIBU_REALTIME_TOKEN = process.env.NEXT_PUBLIC_WIBU_REALTIME_TOKEN; // console.log(WIBU_REALTIME_TOKEN, "check cookies di layout dalam"); return ( diff --git a/src/app/dev/user-not-active/page.tsx b/src/app/dev/user-not-active/page.tsx index 5f29e41a..6b31051e 100644 --- a/src/app/dev/user-not-active/page.tsx +++ b/src/app/dev/user-not-active/page.tsx @@ -1,18 +1,7 @@ -import { RouterHome } from "@/app/lib/router_hipmi/router_home"; -import { funGetUserIdByToken } from "@/app_modules/_global/fun/get"; import { Home_UserNonActive } from "@/app_modules/home"; -import { user_getOneByUserId } from "@/app_modules/home/fun/get/get_one_user_by_id"; // import { redirect } from "next/navigation"; export default async function Page() { - const userLoginId = await funGetUserIdByToken(); - - const dataUser = await user_getOneByUserId(userLoginId as string); - - // if (dataUser?.active === true) { - // return redirect(RouterHome.main_home); - // } - return ( <> diff --git a/src/app_modules/admin/event/_view/view_table_review.tsx b/src/app_modules/admin/event/_view/view_table_review.tsx index c0dd35a6..4b9ab12c 100644 --- a/src/app_modules/admin/event/_view/view_table_review.tsx +++ b/src/app_modules/admin/event/_view/view_table_review.tsx @@ -45,6 +45,8 @@ import adminNotifikasi_funCreateToUser from "../../notifikasi/fun/create/fun_cre import { adminEvent_funGetListReview } from "../fun"; import { AdminEvent_funEditStatusPublishById } from "../fun/edit/fun_edit_status_publish_by_id"; 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 { ComponentAdminGlobal_NotifikasiPeringatan } from "../../_admin_global/admin_notifikasi/notifikasi_peringatan"; export default function AdminEvent_ComponentTableReview({ listData, @@ -104,51 +106,65 @@ export default function AdminEvent_ComponentTableReview({ setIsAdminTriggerReview(false); } - async function onPublish(eventId: string, tanggal: Date) { - if (moment(tanggal).diff(Date.now(), "minutes") < 0) - return ComponentGlobal_NotifikasiPeringatan( - "Waktu acara telah lewat, Report untuk memberitahu user !" - ); + async function onPublish({ + eventId, + tanggalSelesai, + }: { + eventId: string; + tanggalSelesai: Date; + }) { + const checkStatus = await event_checkStatus({ id: eventId }); - const res = await AdminEvent_funEditStatusPublishById(eventId, "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", - }; + if (checkStatus) { + if (moment(tanggalSelesai).diff(Date.now(), "minutes") < 0) + return ComponentGlobal_NotifikasiPeringatan( + "Waktu acara telah lewat, Report untuk memberitahu user !" + ); - const notif = await adminNotifikasi_funCreateToUser({ - data: dataNotifikasi as any, - }); + const res = await AdminEvent_funEditStatusPublishById(eventId, "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", + }; - if (notif.status === 201) { - WibuRealtime.setData({ - type: "notification", - pushNotificationTo: "USER", - dataMessage: dataNotifikasi, + const notif = await adminNotifikasi_funCreateToUser({ + data: dataNotifikasi as any, }); - WibuRealtime.setData({ - type: "trigger", - pushNotificationTo: "USER", - dataMessage: dataNotifikasi, + if (notif.status === 201) { + WibuRealtime.setData({ + type: "notification", + pushNotificationTo: "USER", + dataMessage: dataNotifikasi, + }); + + WibuRealtime.setData({ + type: "trigger", + pushNotificationTo: "USER", + dataMessage: dataNotifikasi, + }); + } + + const loadData = await adminEvent_funGetListReview({ + search: isSearch, + page: isActivePage, }); + setData(loadData.data as any); + setNPage(loadData.nPage); + + ComponentAdminGlobal_NotifikasiBerhasil("Berhasil update status"); + } else { + ComponentAdminGlobal_NotifikasiGagal(res.message); } - - const loadData = await adminEvent_funGetListReview({ - search: isSearch, - page: isActivePage, - }); - setData(loadData.data as any); - setNPage(loadData.nPage); - - ComponentAdminGlobal_NotifikasiBerhasil("Berhasil update status"); } else { - ComponentAdminGlobal_NotifikasiGagal(res.message); + ComponentAdminGlobal_NotifikasiPeringatan( + "Review di batalkan oleh user, reload halaman review !" + ); } } @@ -218,19 +234,40 @@ export default function AdminEvent_ComponentTableReview({ {e.EventMaster_TipeAcara.name} +
- {e.tanggal.toLocaleString("id-ID", { dateStyle: "full" })} + + {" "} + {new Intl.DateTimeFormat("id-ID", { + dateStyle: "full", + }).format(e?.tanggal)} + ,{" "} + + {new Intl.DateTimeFormat("id-ID", { + timeStyle: "short", + }).format(e?.tanggal)} + +
- {e.tanggal.toLocaleTimeString([], { - timeStyle: "short", - hourCycle: "h24", - })} + + {" "} + {new Intl.DateTimeFormat("id-ID", { + dateStyle: "full", + }).format(e?.tanggalSelesai)} + ,{" "} + + {new Intl.DateTimeFormat("id-ID", { + timeStyle: "short", + }).format(e?.tanggalSelesai)} + +
+
@@ -246,7 +283,12 @@ export default function AdminEvent_ComponentTableReview({ color={"green"} leftIcon={} radius={"xl"} - onClick={() => onPublish(e.id, e.tanggal)} + onClick={() => + onPublish({ + eventId: e.id, + tanggalSelesai: e.tanggalSelesai, + }) + } > Publish @@ -254,9 +296,17 @@ export default function AdminEvent_ComponentTableReview({ color={"red"} leftIcon={} radius={"xl"} - onClick={() => { - open(); - setEventId(e.id); + onClick={async () => { + const checkStatus = await event_checkStatus({ id: eventId }); + + if (checkStatus) { + open(); + setEventId(e.id); + } else { + ComponentAdminGlobal_NotifikasiPeringatan( + "Review di batalkan oleh user, muat kembali halaman ini !" + ); + } }} > Reject @@ -334,10 +384,10 @@ export default function AdminEvent_ComponentTableReview({
Tipe Acara
-
Tanggal
+
Tanggal & Waktu Mulai
-
Jam
+
Tanggal & Waktu Selesai
Deskripsi
diff --git a/src/app_modules/admin/event/child/riwayat.tsx b/src/app_modules/admin/event/child/riwayat.tsx index b7ab3385..1bee7757 100644 --- a/src/app_modules/admin/event/child/riwayat.tsx +++ b/src/app_modules/admin/event/child/riwayat.tsx @@ -1,19 +1,11 @@ "use client"; import { RouterAdminEvent } from "@/app/lib/router_admin/router_admin_event"; -import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog"; +import { MODEL_EVENT } from "@/app_modules/event/model/interface"; import { - MODEL_EVENT, - MODEL_EVENT_PESERTA, -} from "@/app_modules/event/model/interface"; -import { - Avatar, Button, Center, - Divider, - Grid, Group, - Modal, Pagination, Paper, ScrollArea, @@ -24,7 +16,6 @@ import { TextInput, Title, } from "@mantine/core"; -import { useDisclosure } from "@mantine/hooks"; import { IconCircleCheck, IconSearch } from "@tabler/icons-react"; import { useRouter } from "next/navigation"; import { useState } from "react"; @@ -80,11 +71,14 @@ function DetailRiwayat({ listRiwayat }: { listRiwayat: any }) {
+
- {e.tanggal.toLocaleString("id-ID", { dateStyle: "full" })} + + {" "} + {new Intl.DateTimeFormat("id-ID", { + dateStyle: "full", + }).format(e?.tanggal)} + ,{" "} + + {new Intl.DateTimeFormat("id-ID", { + timeStyle: "short", + }).format(e?.tanggal)} + +
- {e.tanggal.toLocaleTimeString([], { - timeStyle: "short", - hourCycle: "h24", - })} + + {" "} + {new Intl.DateTimeFormat("id-ID", { + dateStyle: "full", + }).format(e?.tanggalSelesai)} + ,{" "} + + {new Intl.DateTimeFormat("id-ID", { + timeStyle: "short", + }).format(e?.tanggalSelesai)} + +
+
@@ -183,10 +198,10 @@ function DetailRiwayat({ listRiwayat }: { listRiwayat: any }) {
Tipe Acara
-
Tanggal
+
Tanggal & Waktu Mulai
-
Jam
+
Tanggal & Waktu Selesai
Deskripsi
diff --git a/src/app_modules/admin/event/fun/count/fun_count_event_by_status_id.ts b/src/app_modules/admin/event/fun/count/fun_count_event_by_status_id.ts index bcb7c67f..0246c7ac 100644 --- a/src/app_modules/admin/event/fun/count/fun_count_event_by_status_id.ts +++ b/src/app_modules/admin/event/fun/count/fun_count_event_by_status_id.ts @@ -12,9 +12,7 @@ export default async function AdminEvent_funCountByStatusId(statusId: string) { const count = await prisma.event.count({ where: { eventMaster_StatusId: "1", - tanggal: { - gte: new Date - } + isArsip: false }, }); return count; diff --git a/src/app_modules/admin/event/fun/count/fun_count_riwayat.ts b/src/app_modules/admin/event/fun/count/fun_count_riwayat.ts index 58ec852b..76fb0a0c 100644 --- a/src/app_modules/admin/event/fun/count/fun_count_riwayat.ts +++ b/src/app_modules/admin/event/fun/count/fun_count_riwayat.ts @@ -6,9 +6,7 @@ export async function AdminEvent_funCountRiwayat() { const data = await prisma.event.count({ where: { eventMaster_StatusId: "1", - tanggal: { - lte: new Date(), - }, + isArsip: true, }, }); diff --git a/src/app_modules/admin/event/fun/get/get_list_all_riwayat.ts b/src/app_modules/admin/event/fun/get/get_list_all_riwayat.ts index 01bfa7b2..02551435 100644 --- a/src/app_modules/admin/event/fun/get/get_list_all_riwayat.ts +++ b/src/app_modules/admin/event/fun/get/get_list_all_riwayat.ts @@ -21,9 +21,7 @@ export async function adminEvent_funGetListAllRiwayat({ }, where: { eventMaster_StatusId: "1", - tanggal: { - lte: new Date(), - }, + isArsip: true, title: { contains: search, mode: "insensitive", @@ -49,9 +47,7 @@ export async function adminEvent_funGetListAllRiwayat({ const nCount = await prisma.event.count({ where: { eventMaster_StatusId: "1", - tanggal: { - lte: new Date(), - }, + isArsip: true, title: { contains: search, mode: "insensitive", diff --git a/src/app_modules/admin/event/fun/get/get_list_table_by_status_id.ts b/src/app_modules/admin/event/fun/get/get_list_table_by_status_id.ts deleted file mode 100644 index 56cb6cc5..00000000 --- a/src/app_modules/admin/event/fun/get/get_list_table_by_status_id.ts +++ /dev/null @@ -1,146 +0,0 @@ -"use server"; - -import prisma from "@/app/lib/prisma"; - -export async function AdminEvent_getListTableByStatusId(statudId: string) { - if (statudId === "1") { - const getPublish = await prisma.event.findMany({ - orderBy: { - tanggal: "desc", - }, - where: { - eventMaster_StatusId: "1", - tanggal: { - gte: new Date(), - }, - }, - select: { - id: true, - title: true, - lokasi: true, - tanggal: true, - deskripsi: true, - Author: { - select: { - id: true, - username: true, - Profile: { - select: { - name: true, - }, - }, - }, - }, - EventMaster_Status: { - select: { - id: true, - name: true, - }, - }, - EventMaster_TipeAcara: { - select: { - id: true, - name: true, - }, - }, - Event_Peserta: true, - }, - }); - return getPublish; - } - if (statudId === "2") { - const getReview = await prisma.event.findMany({ - orderBy: { - updatedAt: "desc", - }, - where: { - eventMaster_StatusId: "2", - active: true, - }, - select: { - id: true, - title: true, - lokasi: true, - tanggal: true, - deskripsi: true, - Author: { - select: { - id: true, - username: true, - Profile: { - select: { - name: true, - }, - }, - }, - }, - EventMaster_Status: { - select: { - id: true, - name: true, - }, - }, - EventMaster_TipeAcara: { - select: { - id: true, - name: true, - }, - }, - }, - }); - return getReview; - } - if (statudId === "3") { - const getDraft = await prisma.event.findMany({ - orderBy: { - updatedAt: "desc", - }, - where: { - eventMaster_StatusId: "3", - }, - }); - return getDraft; - } - if (statudId === "4") { - const getReject = await prisma.event.findMany({ - orderBy: { - updatedAt: "desc", - }, - where: { - eventMaster_StatusId: "4", - }, - select: { - id: true, - title: true, - lokasi: true, - tanggal: true, - deskripsi: true, - Author: { - select: { - id: true, - username: true, - Profile: { - select: { - name: true, - }, - }, - }, - }, - EventMaster_Status: { - select: { - id: true, - name: true, - }, - }, - EventMaster_TipeAcara: { - select: { - id: true, - name: true, - }, - }, - catatan: true, - }, - }); - return getReject; - } -} diff --git a/src/app_modules/admin/event/fun/get/status/fun_get_list_publish.ts b/src/app_modules/admin/event/fun/get/status/fun_get_list_publish.ts index 73c5475a..04eb5096 100644 --- a/src/app_modules/admin/event/fun/get/status/fun_get_list_publish.ts +++ b/src/app_modules/admin/event/fun/get/status/fun_get_list_publish.ts @@ -1,7 +1,9 @@ "use server"; import prisma from "@/app/lib/prisma"; +import { ComponentAdminGlobal_NotifikasiPeringatan } from "@/app_modules/admin/_admin_global/admin_notifikasi/notifikasi_peringatan"; import { ceil } from "lodash"; +import moment from "moment"; export async function adminEvent_funGetListPublish({ page, @@ -10,6 +12,27 @@ export async function adminEvent_funGetListPublish({ page: number; search?: string; }) { + const getAllData = await prisma.event.findMany({ + where: { + active: true, + eventMaster_StatusId: "1", + isArsip: false, + }, + }); + + for (let i of getAllData) { + if (moment(i.tanggalSelesai).diff(moment(), "minutes") < 0) { + await prisma.event.update({ + where: { + id: i.id, + }, + data: { + isArsip: true, + }, + }); + } + } + let takeData = 10; let skipData = page * takeData - takeData; @@ -21,9 +44,7 @@ export async function adminEvent_funGetListPublish({ }, where: { eventMaster_StatusId: "1", - tanggal: { - gte: new Date(), - }, + isArsip: false, title: { contains: search, mode: "insensitive", @@ -49,9 +70,7 @@ export async function adminEvent_funGetListPublish({ const nCount = await prisma.event.count({ where: { eventMaster_StatusId: "1", - tanggal: { - gte: new Date(), - }, + isArsip: false, title: { contains: search, mode: "insensitive", diff --git a/src/app_modules/admin/event/table_status/table_publish.tsx b/src/app_modules/admin/event/table_status/table_publish.tsx index cf2f2a09..eb3eb7c5 100644 --- a/src/app_modules/admin/event/table_status/table_publish.tsx +++ b/src/app_modules/admin/event/table_status/table_publish.tsx @@ -1,14 +1,13 @@ "use client"; +import { RouterAdminEvent } from "@/app/lib/router_admin/router_admin_event"; +import { + MODEL_EVENT +} from "@/app_modules/event/model/interface"; import { - Avatar, - Box, Button, Center, - Divider, - Grid, Group, - Modal, Pagination, Paper, ScrollArea, @@ -17,22 +16,14 @@ import { Table, Text, TextInput, - Title, + Title } from "@mantine/core"; -import { IconCircleCheck, IconEyeShare, IconSearch } from "@tabler/icons-react"; -import { useRouter } from "next/navigation"; -import { useDisclosure } from "@mantine/hooks"; -import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog"; -import { - MODEL_EVENT, - MODEL_EVENT_PESERTA, -} from "@/app_modules/event/model/interface"; +import { IconCircleCheck, IconSearch } from "@tabler/icons-react"; import _ from "lodash"; +import { useRouter } from "next/navigation"; import { useState } from "react"; import ComponentAdminGlobal_HeaderTamplate from "../../_admin_global/header_tamplate"; -import { adminEvent_getListPesertaById } from "../fun/get/get_list_peserta_by_id"; import { adminEvent_funGetListPublish } from "../fun"; -import { RouterAdminEvent } from "@/app/lib/router_admin/router_admin_event"; export default function AdminEvent_TablePublish({ listPublish, @@ -78,64 +69,102 @@ function TableStatus({ listPublish }: { listPublish: any }) { setNPage(loadData.nPage); } - const TableRows = data.map((e, i) => ( - - -
- {e?.Author?.username} -
- - -
- {e.title} -
- - -
- {e.lokasi} -
- - -
- {e.EventMaster_TipeAcara.name} -
- - -
- {e.tanggal.toLocaleString("id-ID", { dateStyle: "full" })} -
- - -
- {e.tanggal.toLocaleTimeString([], { - timeStyle: "short", - hourCycle: "h24", - })} -
- - -
- - {e.deskripsi} - -
- - - - + const TableRows = _.isEmpty(data) ? ( + + +
Belum Ada Data
- )); + ) : ( + data.map((e, i) => ( + + +
+ {e?.Author?.username} +
+ + +
+ {e.title} +
+ + +
+ {e.lokasi} +
+ + +
+ {e.EventMaster_TipeAcara.name} +
+ + + +
+ + {" "} + {new Intl.DateTimeFormat("id-ID", { + dateStyle: "full", + }).format(e?.tanggal)} + ,{" "} + + {new Intl.DateTimeFormat("id-ID", { + timeStyle: "short", + }).format(e?.tanggal)} + + +
+ + +
+ + {" "} + {new Intl.DateTimeFormat("id-ID", { + dateStyle: "full", + }).format(e?.tanggalSelesai)} + ,{" "} + + {new Intl.DateTimeFormat("id-ID", { + timeStyle: "short", + }).format(e?.tanggalSelesai)} + + +
+ + + +
+ + {e.deskripsi} + +
+ + + + + + + )) + ); return ( <> @@ -182,10 +211,10 @@ function TableStatus({ listPublish }: { listPublish: any }) {
Tipe Acara
-
Tanggal
+
Tanggal & Waktu Mulai
-
Jam
+
Tanggal & Waktu Selesai
Deskripsi
diff --git a/src/app_modules/admin/event/table_status/table_reject.tsx b/src/app_modules/admin/event/table_status/table_reject.tsx index 24e7f175..fd786fd1 100644 --- a/src/app_modules/admin/event/table_status/table_reject.tsx +++ b/src/app_modules/admin/event/table_status/table_reject.tsx @@ -11,6 +11,7 @@ import { Spoiler, Stack, Table, + Text, Textarea, TextInput, Title, @@ -106,19 +107,40 @@ function TableStatus({ listReject }: { listReject: any }) {
{e.EventMaster_TipeAcara.name}
+
- {e.tanggal.toLocaleString("id-ID", { dateStyle: "full" })} + + {" "} + {new Intl.DateTimeFormat("id-ID", { + dateStyle: "full", + }).format(e?.tanggal)} + ,{" "} + + {new Intl.DateTimeFormat("id-ID", { + timeStyle: "short", + }).format(e?.tanggal)} + +
-
- {e.tanggal.toLocaleTimeString([], { - timeStyle: "short", - hourCycle: "h24", - })} +
+ + {" "} + {new Intl.DateTimeFormat("id-ID", { + dateStyle: "full", + }).format(e?.tanggalSelesai)} + ,{" "} + + {new Intl.DateTimeFormat("id-ID", { + timeStyle: "short", + }).format(e?.tanggalSelesai)} + +
+
@@ -197,10 +219,10 @@ function TableStatus({ listReject }: { listReject: any }) {
Tipe Acara
-
Tanggal
+
Tanggal & Waktu Mulai
-
Jam
+
Tanggal & Waktu Selesai
Cacatan
diff --git a/src/app_modules/check_cookies/layout_cek_cookies.tsx b/src/app_modules/check_cookies/layout_cek_cookies.tsx index 753bfa17..b328354d 100644 --- a/src/app_modules/check_cookies/layout_cek_cookies.tsx +++ b/src/app_modules/check_cookies/layout_cek_cookies.tsx @@ -2,7 +2,7 @@ import { RouterAuth } from "@/app/lib/router_hipmi/router_auth"; import { useShallowEffect } from "@mantine/hooks"; -import { useRouter } from "next/navigation"; +import { redirect, useRouter } from "next/navigation"; import { MODEL_USER } from "../home/model/interface"; import { RouterHome } from "@/app/lib/router_hipmi/router_home"; import { RouterAdminDashboard } from "@/app/lib/router_hipmi/router_admin"; @@ -16,6 +16,12 @@ export function CheckCookies_UiLayout({ }) { const router = useRouter(); + // if (dataUser.active == false){ + // router.push(RouterHome.home_user_non_active, { scroll: false }); + // return children + // } + + // useShallowEffect(() => { // onCheckCookies(); // }, []); @@ -38,5 +44,5 @@ export function CheckCookies_UiLayout({ // router.push(RouterAdminDashboard.splash_admin, { scroll: false }); // } - return children; + return <>{children}; } diff --git a/src/app_modules/event/component/button/button_create_event.tsx b/src/app_modules/event/component/button/button_create_event.tsx index 2e796932..74d53096 100644 --- a/src/app_modules/event/component/button/button_create_event.tsx +++ b/src/app_modules/event/component/button/button_create_event.tsx @@ -4,6 +4,7 @@ import { MainColor } from "@/app_modules/_global/color"; import { ComponentGlobal_NotifikasiBerhasil, ComponentGlobal_NotifikasiGagal, + ComponentGlobal_NotifikasiPeringatan, } from "@/app_modules/_global/notif_global"; import { notifikasiToAdmin_funCreate } from "@/app_modules/notifikasi/fun"; import { Button } from "@mantine/core"; @@ -14,13 +15,23 @@ import { useState } from "react"; import { WibuRealtime } from "wibu-pkg"; import { Event_funCreate } from "../../fun/create/fun_create"; import { gs_event_hotMenu } from "../../global_state"; +import { event_checkStatus } from "../../fun/get/fun_check_status_by_id"; -export default function Event_ComponentCreateButton({ value }: { value: any }) { +export default function Event_ComponentCreateButton({ + value, + diffTimeStart, + diffTimeEnd, +}: { + value: any; + diffTimeStart: number; + diffTimeEnd: number; +}) { const router = useRouter(); const [hotMenu, setHotMenu] = useAtom(gs_event_hotMenu); const [isLoading, setLoading] = useState(false); async function onSave() { + const res = await Event_funCreate(value); if (res.status === 201) { @@ -71,7 +82,8 @@ export default function Event_ComponentCreateButton({ value }: { value: any }) { value.deskripsi === "" || value.eventMaster_TipeAcaraId === 0 || value.tanggal === "function Date() { [native code] }" || - moment(value.tanggal).diff(moment(), "minutes") < 0 + // moment(value.tanggal).diff(moment(), "minutes") < 0 + diffTimeEnd - 1 < diffTimeStart } loaderPosition="center" loading={isLoading ? true : false} diff --git a/src/app_modules/event/component/detail/detail_data.tsx b/src/app_modules/event/component/detail/detail_data.tsx index b82a96ee..3e72b9b9 100644 --- a/src/app_modules/event/component/detail/detail_data.tsx +++ b/src/app_modules/event/component/detail/detail_data.tsx @@ -9,26 +9,16 @@ export default function ComponentEvent_DetailData({ }: { data: MODEL_EVENT; }) { - const tgl = data.tanggal; - const hari = tgl.toLocaleString("id-ID", { dateStyle: "full" }); - - const jam = tgl.toLocaleTimeString([], { - timeStyle: "short", - hourCycle: "h24", - }); - return ( <> - + {data ? data?.title : null} - - Lokasi - + Lokasi : @@ -37,37 +27,59 @@ export default function ComponentEvent_DetailData({ - - Tipe Acara - + Tipe Acara : {data ? data.EventMaster_TipeAcara?.name : null} - - - - Tanggal - - - : - {hari ? hari : ""} - - - - - Jam - - - : - {jam ? jam : ""} - + + Tanggal & Waktu + + + Mulai + + : + + + {" "} + {new Intl.DateTimeFormat("id-ID", { + dateStyle: "full", + }).format(data?.tanggal)} + ,{" "} + + {new Intl.DateTimeFormat("id-ID", { + timeStyle: "short", + }).format(data?.tanggal)} + + + + + + + Selesai + + : + + + {" "} + {new Intl.DateTimeFormat("id-ID", { + dateStyle: "full", + }).format(data?.tanggalSelesai)} + ,{" "} + + {new Intl.DateTimeFormat("id-ID", { + timeStyle: "short", + }).format(data?.tanggalSelesai)} + + + + + + - - Deskripsi - + Deskripsi {data ? data?.deskripsi : null} diff --git a/src/app_modules/event/component/detail/detail_main.tsx b/src/app_modules/event/component/detail/detail_main.tsx index 3e7acb65..bfcdefea 100644 --- a/src/app_modules/event/component/detail/detail_main.tsx +++ b/src/app_modules/event/component/detail/detail_main.tsx @@ -28,15 +28,13 @@ export default function ComponentEvent_DetailMainData({ profile={data?.Author?.Profile as any} /> - + {data ? data.title : null} - - Lokasi - + Lokasi : @@ -45,37 +43,60 @@ export default function ComponentEvent_DetailMainData({ - - Tipe Acara - + Tipe Acara : {data ? data.EventMaster_TipeAcara.name : null} - - - - Tanggal - - - : - {hari} - - - - - Jam - - - : - {jam} - + + + Tanggal & Waktu + + + Mulai + + : + + + {" "} + {new Intl.DateTimeFormat("id-ID", { + dateStyle: "full", + }).format(data?.tanggal)} + ,{" "} + + {new Intl.DateTimeFormat("id-ID", { + timeStyle: "short", + }).format(data?.tanggal)} + + + + + + + Selesai + + : + + + {" "} + {new Intl.DateTimeFormat("id-ID", { + dateStyle: "full", + }).format(data?.tanggalSelesai)} + ,{" "} + + {new Intl.DateTimeFormat("id-ID", { + timeStyle: "short", + }).format(data?.tanggalSelesai)} + + + + + + - - Deskripsi - + Deskripsi {data ? data?.deskripsi : null} diff --git a/src/app_modules/event/create/create.tsx b/src/app_modules/event/create/create.tsx index 0331fe7f..a078cb80 100644 --- a/src/app_modules/event/create/create.tsx +++ b/src/app_modules/event/create/create.tsx @@ -2,7 +2,14 @@ import ComponentGlobal_InputCountDown from "@/app_modules/_global/component/input_countdown"; import { MODEL_DEFAULT_MASTER_OLD } from "@/app_modules/model_global/interface"; -import { Select, Stack, TextInput, Textarea } from "@mantine/core"; +import { + Button, + Select, + Stack, + Text, + TextInput, + Textarea, +} from "@mantine/core"; import { DateTimePicker } from "@mantine/dates"; import moment from "moment"; import { useState } from "react"; @@ -17,14 +24,18 @@ export default function Event_Create({ authorId: string; }) { const [listTipe, setListTipe] = useState(listTipeAcara); - const [isTime, setIsTime] = useState(false); + const [isTimeStart, setIsTimeStart] = useState(false); + const [diffTimeStart, setDiffTimeStart] = useState(0); + const [isTimeEnd, setIsTimeEnd] = useState(false); + const [diffTimeEnd, setDiffTimeEnd] = useState(0); const [value, setValue] = useState({ title: "", lokasi: "", deskripsi: "", tanggal: Date.toString(), + tanggalSelesai: Date.toString(), eventMaster_TipeAcaraId: 0, authorId: authorId, }); @@ -88,6 +99,8 @@ export default function Event_Create({ }); }} /> + + ) : ( "" @@ -111,9 +124,15 @@ export default function Event_Create({ // console.log( // moment(val?.toISOString().toString()).diff(moment(), "minutes" ) // ); + const diffTime = moment(val?.toISOString().toString()).diff( + moment(), + "minutes" + ); + setDiffTimeStart(diffTime); + moment(val?.toISOString().toString()).diff(moment(), "minutes") < 0 - ? setIsTime(true) - : setIsTime(false); + ? setIsTimeStart(true) + : setIsTimeStart(false); setValue({ ...value, @@ -122,6 +141,48 @@ export default function Event_Create({ }} /> + { + return moment(date).diff(Date.now(), "days") < 0; + }} + withAsterisk + label="Tanggal & Waktu Berakhir" + placeholder="Masukan tangal dan waktu " + error={ + isTimeEnd ? ( + + ) : diffTimeEnd - 1 < diffTimeStart && diffTimeEnd != 0 ? ( + + ) : ( + "" + ) + } + onChange={(val) => { + // console.log( + // moment(val?.toISOString().toString()).diff(moment(), "minutes" ) + // ); + const diffTime = moment(val?.toISOString().toString()).diff( + moment(), + "minutes" + ); + setDiffTimeEnd(diffTime); + + moment(val?.toISOString().toString()).diff(moment(), "minutes") < 0 + ? setIsTimeEnd(true) + : setIsTimeEnd(false); + + setValue({ + ...value, + tanggalSelesai: val as any, + }); + }} + /> +