Fix: Event
Deskripsi: - Fix database event - Fix style detal
This commit is contained in:
@@ -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])
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -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 (
|
||||
<>
|
||||
<Home_UserNonActive />
|
||||
|
||||
@@ -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({
|
||||
<Text>{e.EventMaster_TipeAcara.name}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Center w={200}>
|
||||
{e.tanggal.toLocaleString("id-ID", { dateStyle: "full" })}
|
||||
<Text align="center">
|
||||
{" "}
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
dateStyle: "full",
|
||||
}).format(e?.tanggal)}
|
||||
,{" "}
|
||||
<Text span inherit>
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
timeStyle: "short",
|
||||
}).format(e?.tanggal)}
|
||||
</Text>
|
||||
</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
{e.tanggal.toLocaleTimeString([], {
|
||||
timeStyle: "short",
|
||||
hourCycle: "h24",
|
||||
})}
|
||||
<Text align="center">
|
||||
{" "}
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
dateStyle: "full",
|
||||
}).format(e?.tanggalSelesai)}
|
||||
,{" "}
|
||||
<Text span inherit>
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
timeStyle: "short",
|
||||
}).format(e?.tanggalSelesai)}
|
||||
</Text>
|
||||
</Text>
|
||||
</Center>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Center w={400}>
|
||||
<Spoiler hideLabel="sembunyikan" maxHeight={50} showLabel="tampilkan">
|
||||
@@ -246,7 +283,12 @@ export default function AdminEvent_ComponentTableReview({
|
||||
color={"green"}
|
||||
leftIcon={<IconCircleCheck />}
|
||||
radius={"xl"}
|
||||
onClick={() => onPublish(e.id, e.tanggal)}
|
||||
onClick={() =>
|
||||
onPublish({
|
||||
eventId: e.id,
|
||||
tanggalSelesai: e.tanggalSelesai,
|
||||
})
|
||||
}
|
||||
>
|
||||
Publish
|
||||
</Button>
|
||||
@@ -254,9 +296,17 @@ export default function AdminEvent_ComponentTableReview({
|
||||
color={"red"}
|
||||
leftIcon={<IconBan />}
|
||||
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({
|
||||
<Center>Tipe Acara</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Tanggal</Center>
|
||||
<Center>Tanggal & Waktu Mulai</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Jam</Center>
|
||||
<Center>Tanggal & Waktu Selesai</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Deskripsi</Center>
|
||||
|
||||
@@ -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 }) {
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={e.id === eventId && loading ? true : false}
|
||||
color={"green"}
|
||||
leftIcon={<IconCircleCheck />}
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
setEventId(e.id);
|
||||
setLoading(true);
|
||||
router.push(RouterAdminEvent.detail_peserta + e.id);
|
||||
}}
|
||||
>
|
||||
@@ -112,19 +106,40 @@ function DetailRiwayat({ listRiwayat }: { listRiwayat: any }) {
|
||||
<Text>{e.EventMaster_TipeAcara.name}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Center w={200}>
|
||||
{e.tanggal.toLocaleString("id-ID", { dateStyle: "full" })}
|
||||
<Text align="center">
|
||||
{" "}
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
dateStyle: "full",
|
||||
}).format(e?.tanggal)}
|
||||
,{" "}
|
||||
<Text span inherit>
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
timeStyle: "short",
|
||||
}).format(e?.tanggal)}
|
||||
</Text>
|
||||
</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
{e.tanggal.toLocaleTimeString([], {
|
||||
timeStyle: "short",
|
||||
hourCycle: "h24",
|
||||
})}
|
||||
<Text align="center">
|
||||
{" "}
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
dateStyle: "full",
|
||||
}).format(e?.tanggalSelesai)}
|
||||
,{" "}
|
||||
<Text span inherit>
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
timeStyle: "short",
|
||||
}).format(e?.tanggalSelesai)}
|
||||
</Text>
|
||||
</Text>
|
||||
</Center>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Center w={400}>
|
||||
<Spoiler hideLabel="sembunyikan" maxHeight={50} showLabel="tampilkan">
|
||||
@@ -183,10 +198,10 @@ function DetailRiwayat({ listRiwayat }: { listRiwayat: any }) {
|
||||
<Center>Tipe Acara</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Tanggal</Center>
|
||||
<Center>Tanggal & Waktu Mulai</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Jam</Center>
|
||||
<Center>Tanggal & Waktu Selesai</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Deskripsi</Center>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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",
|
||||
|
||||
@@ -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) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Text>{e?.Author?.username}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Text lineClamp={2}>{e.title}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Text>{e.lokasi}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Text>{e.EventMaster_TipeAcara.name}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
{e.tanggal.toLocaleString("id-ID", { dateStyle: "full" })}
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
{e.tanggal.toLocaleTimeString([], {
|
||||
timeStyle: "short",
|
||||
hourCycle: "h24",
|
||||
})}
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={400}>
|
||||
<Spoiler hideLabel="sembunyikan" maxHeight={50} showLabel="tampilkan">
|
||||
{e.deskripsi}
|
||||
</Spoiler>
|
||||
</Center>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Button
|
||||
loading={e.id === eventId ? (loading === true ? true : false) : false}
|
||||
color={"green"}
|
||||
leftIcon={<IconCircleCheck />}
|
||||
radius={"xl"}
|
||||
onClick={async () => {
|
||||
router.push(RouterAdminEvent.detail_peserta + e.id);
|
||||
}}
|
||||
>
|
||||
Lihat Peserta
|
||||
</Button>
|
||||
const TableRows = _.isEmpty(data) ? (
|
||||
<tr>
|
||||
<td colSpan={12}>
|
||||
<Center>Belum Ada Data</Center>
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
) : (
|
||||
data.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Text>{e?.Author?.username}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Text lineClamp={2}>{e.title}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Text>{e.lokasi}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Text>{e.EventMaster_TipeAcara.name}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Text align="center">
|
||||
{" "}
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
dateStyle: "full",
|
||||
}).format(e?.tanggal)}
|
||||
,{" "}
|
||||
<Text span inherit>
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
timeStyle: "short",
|
||||
}).format(e?.tanggal)}
|
||||
</Text>
|
||||
</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Text align="center">
|
||||
{" "}
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
dateStyle: "full",
|
||||
}).format(e?.tanggalSelesai)}
|
||||
,{" "}
|
||||
<Text span inherit>
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
timeStyle: "short",
|
||||
}).format(e?.tanggalSelesai)}
|
||||
</Text>
|
||||
</Text>
|
||||
</Center>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Center w={400}>
|
||||
<Spoiler
|
||||
hideLabel="sembunyikan"
|
||||
maxHeight={50}
|
||||
showLabel="tampilkan"
|
||||
>
|
||||
{e.deskripsi}
|
||||
</Spoiler>
|
||||
</Center>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={
|
||||
e.id === eventId ? (loading === true ? true : false) : false
|
||||
}
|
||||
color={"green"}
|
||||
leftIcon={<IconCircleCheck />}
|
||||
radius={"xl"}
|
||||
onClick={async () => {
|
||||
setEventId(e.id);
|
||||
setLoading(true);
|
||||
router.push(RouterAdminEvent.detail_peserta + e.id);
|
||||
}}
|
||||
>
|
||||
Lihat Peserta
|
||||
</Button>
|
||||
</td>
|
||||
</tr>
|
||||
))
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -182,10 +211,10 @@ function TableStatus({ listPublish }: { listPublish: any }) {
|
||||
<Center>Tipe Acara</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Tanggal</Center>
|
||||
<Center>Tanggal & Waktu Mulai</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Jam</Center>
|
||||
<Center>Tanggal & Waktu Selesai</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Deskripsi</Center>
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
Spoiler,
|
||||
Stack,
|
||||
Table,
|
||||
Text,
|
||||
Textarea,
|
||||
TextInput,
|
||||
Title,
|
||||
@@ -106,19 +107,40 @@ function TableStatus({ listReject }: { listReject: any }) {
|
||||
<td>
|
||||
<Center w={200}>{e.EventMaster_TipeAcara.name}</Center>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Center w={200}>
|
||||
{e.tanggal.toLocaleString("id-ID", { dateStyle: "full" })}
|
||||
<Text align="center">
|
||||
{" "}
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
dateStyle: "full",
|
||||
}).format(e?.tanggal)}
|
||||
,{" "}
|
||||
<Text span inherit>
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
timeStyle: "short",
|
||||
}).format(e?.tanggal)}
|
||||
</Text>
|
||||
</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={100}>
|
||||
{e.tanggal.toLocaleTimeString([], {
|
||||
timeStyle: "short",
|
||||
hourCycle: "h24",
|
||||
})}
|
||||
<Center w={200}>
|
||||
<Text align="center">
|
||||
{" "}
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
dateStyle: "full",
|
||||
}).format(e?.tanggalSelesai)}
|
||||
,{" "}
|
||||
<Text span inherit>
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
timeStyle: "short",
|
||||
}).format(e?.tanggalSelesai)}
|
||||
</Text>
|
||||
</Text>
|
||||
</Center>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Center w={500}>
|
||||
<Spoiler hideLabel="sembunyikan" maxHeight={50} showLabel="tampilkan">
|
||||
@@ -197,10 +219,10 @@ function TableStatus({ listReject }: { listReject: any }) {
|
||||
<Center>Tipe Acara</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Tanggal</Center>
|
||||
<Center>Tanggal & Waktu Mulai</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Jam</Center>
|
||||
<Center>Tanggal & Waktu Selesai</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Cacatan</Center>
|
||||
|
||||
@@ -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}</>;
|
||||
}
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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 (
|
||||
<>
|
||||
<ComponentGlobal_CardStyles marginBottom={"16px"}>
|
||||
<Stack px={"sm"} spacing={"lg"}>
|
||||
<Stack px={"sm"} spacing={"xl"}>
|
||||
<Title lineClamp={2} align="center" w={"100%"} order={4}>
|
||||
{data ? data?.title : null}
|
||||
</Title>
|
||||
<Grid>
|
||||
<Grid.Col span={4}>
|
||||
<Text fw={"bold"} fz={"sm"}>
|
||||
Lokasi
|
||||
</Text>
|
||||
<Text fw={"bold"}>Lokasi</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={1}>:</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
@@ -37,37 +27,59 @@ export default function ComponentEvent_DetailData({
|
||||
</Grid>
|
||||
<Grid>
|
||||
<Grid.Col span={4}>
|
||||
<Text fw={"bold"} fz={"sm"}>
|
||||
Tipe Acara
|
||||
</Text>
|
||||
<Text fw={"bold"}>Tipe Acara</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={1}>:</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text>{data ? data.EventMaster_TipeAcara?.name : null}</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
<Grid>
|
||||
<Grid.Col span={4}>
|
||||
<Text fw={"bold"} fz={"sm"}>
|
||||
Tanggal
|
||||
</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={1}>:</Grid.Col>
|
||||
<Grid.Col span={"auto"}>{hari ? hari : ""}</Grid.Col>
|
||||
</Grid>
|
||||
<Grid>
|
||||
<Grid.Col span={4}>
|
||||
<Text fw={"bold"} fz={"sm"}>
|
||||
Jam
|
||||
</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={1}>:</Grid.Col>
|
||||
<Grid.Col span={"auto"}>{jam ? jam : ""}</Grid.Col>
|
||||
</Grid>
|
||||
<Stack spacing={"xs"}>
|
||||
<Text fw={"bold"}>Tanggal & Waktu</Text>
|
||||
<Grid>
|
||||
<Grid.Col span={4}>
|
||||
<Text fw={"bold"}>Mulai</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={1}>:</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text>
|
||||
{" "}
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
dateStyle: "full",
|
||||
}).format(data?.tanggal)}
|
||||
,{" "}
|
||||
<Text span inherit>
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
timeStyle: "short",
|
||||
}).format(data?.tanggal)}
|
||||
</Text>
|
||||
</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
<Grid>
|
||||
<Grid.Col span={4}>
|
||||
<Text fw={"bold"}>Selesai</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={1}>:</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text>
|
||||
{" "}
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
dateStyle: "full",
|
||||
}).format(data?.tanggalSelesai)}
|
||||
,{" "}
|
||||
<Text span inherit>
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
timeStyle: "short",
|
||||
}).format(data?.tanggalSelesai)}
|
||||
</Text>
|
||||
</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</Stack>
|
||||
|
||||
<Stack spacing={2}>
|
||||
<Text fw={"bold"} fz={"sm"}>
|
||||
Deskripsi
|
||||
</Text>
|
||||
<Text fw={"bold"}>Deskripsi</Text>
|
||||
<Text>{data ? data?.deskripsi : null}</Text>
|
||||
</Stack>
|
||||
</Stack>
|
||||
|
||||
@@ -28,15 +28,13 @@ export default function ComponentEvent_DetailMainData({
|
||||
profile={data?.Author?.Profile as any}
|
||||
/>
|
||||
|
||||
<Stack>
|
||||
<Stack spacing={"xl"}>
|
||||
<Title align="center" order={4}>
|
||||
{data ? data.title : null}
|
||||
</Title>
|
||||
<Grid>
|
||||
<Grid.Col span={4}>
|
||||
<Text fw={"bold"} fz={"sm"}>
|
||||
Lokasi
|
||||
</Text>
|
||||
<Text fw={"bold"}>Lokasi</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={1}>:</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
@@ -45,37 +43,60 @@ export default function ComponentEvent_DetailMainData({
|
||||
</Grid>
|
||||
<Grid>
|
||||
<Grid.Col span={4}>
|
||||
<Text fw={"bold"} fz={"sm"}>
|
||||
Tipe Acara
|
||||
</Text>
|
||||
<Text fw={"bold"}>Tipe Acara</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={1}>:</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text>{data ? data.EventMaster_TipeAcara.name : null}</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
<Grid>
|
||||
<Grid.Col span={4}>
|
||||
<Text fw={"bold"} fz={"sm"}>
|
||||
Tanggal
|
||||
</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={1}>:</Grid.Col>
|
||||
<Grid.Col span={"auto"}>{hari}</Grid.Col>
|
||||
</Grid>
|
||||
<Grid>
|
||||
<Grid.Col span={4}>
|
||||
<Text fw={"bold"} fz={"sm"}>
|
||||
Jam
|
||||
</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={1}>:</Grid.Col>
|
||||
<Grid.Col span={"auto"}>{jam}</Grid.Col>
|
||||
</Grid>
|
||||
|
||||
<Stack spacing={"xs"}>
|
||||
<Text fw={"bold"}>Tanggal & Waktu</Text>
|
||||
<Grid>
|
||||
<Grid.Col span={4}>
|
||||
<Text fw={"bold"}>Mulai</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={1}>:</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text>
|
||||
{" "}
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
dateStyle: "full",
|
||||
}).format(data?.tanggal)}
|
||||
,{" "}
|
||||
<Text span inherit>
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
timeStyle: "short",
|
||||
}).format(data?.tanggal)}
|
||||
</Text>
|
||||
</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
<Grid>
|
||||
<Grid.Col span={4}>
|
||||
<Text fw={"bold"}>Selesai</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={1}>:</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text>
|
||||
{" "}
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
dateStyle: "full",
|
||||
}).format(data?.tanggalSelesai)}
|
||||
,{" "}
|
||||
<Text span inherit>
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
timeStyle: "short",
|
||||
}).format(data?.tanggalSelesai)}
|
||||
</Text>
|
||||
</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</Stack>
|
||||
|
||||
<Stack spacing={2}>
|
||||
<Text fw={"bold"} fz={"sm"}>
|
||||
Deskripsi
|
||||
</Text>
|
||||
<Text fw={"bold"}>Deskripsi</Text>
|
||||
<Text>{data ? data?.deskripsi : null}</Text>
|
||||
</Stack>
|
||||
</Stack>
|
||||
|
||||
@@ -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({
|
||||
});
|
||||
}}
|
||||
/>
|
||||
|
||||
|
||||
<DateTimePicker
|
||||
styles={{
|
||||
label: {
|
||||
@@ -98,10 +111,10 @@ export default function Event_Create({
|
||||
return moment(date).diff(Date.now(), "days") < 0;
|
||||
}}
|
||||
withAsterisk
|
||||
label="Tanggal & Waktu "
|
||||
placeholder="Masukan tangal dan waktu acara"
|
||||
label="Tanggal & Waktu Mulai"
|
||||
placeholder="Masukan tangal dan waktu"
|
||||
error={
|
||||
isTime ? (
|
||||
isTimeStart ? (
|
||||
<ComponentEvent_ErrorMaximalInput text="Invalid Time !" />
|
||||
) : (
|
||||
""
|
||||
@@ -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({
|
||||
}}
|
||||
/>
|
||||
|
||||
<DateTimePicker
|
||||
styles={{
|
||||
label: {
|
||||
color: "white",
|
||||
},
|
||||
}}
|
||||
excludeDate={(date) => {
|
||||
return moment(date).diff(Date.now(), "days") < 0;
|
||||
}}
|
||||
withAsterisk
|
||||
label="Tanggal & Waktu Berakhir"
|
||||
placeholder="Masukan tangal dan waktu "
|
||||
error={
|
||||
isTimeEnd ? (
|
||||
<ComponentEvent_ErrorMaximalInput text="Invalid Time !" />
|
||||
) : diffTimeEnd - 1 < diffTimeStart && diffTimeEnd != 0 ? (
|
||||
<ComponentEvent_ErrorMaximalInput text="Invalid Time !" />
|
||||
) : (
|
||||
""
|
||||
)
|
||||
}
|
||||
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,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
|
||||
<Stack spacing={5}>
|
||||
<Textarea
|
||||
styles={{
|
||||
@@ -147,7 +208,11 @@ export default function Event_Create({
|
||||
/>
|
||||
</Stack>
|
||||
|
||||
<Event_ComponentCreateButton value={value} />
|
||||
<Event_ComponentCreateButton
|
||||
value={value}
|
||||
diffTimeStart={diffTimeStart}
|
||||
diffTimeEnd={diffTimeEnd}
|
||||
/>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -46,7 +46,7 @@ export default function Event_DetailDraft({
|
||||
""
|
||||
)}
|
||||
<ComponentEvent_DetailData data={data} />
|
||||
<ButtonAction eventId={data.id} tanggal={data.tanggal} />
|
||||
<ButtonAction eventId={data.id} tanggalSelesai={data.tanggalSelesai} />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
@@ -54,10 +54,10 @@ export default function Event_DetailDraft({
|
||||
|
||||
function ButtonAction({
|
||||
eventId,
|
||||
tanggal,
|
||||
tanggalSelesai,
|
||||
}: {
|
||||
eventId: string;
|
||||
tanggal?: any;
|
||||
tanggalSelesai?: any;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [isLoadingDelete, setLoadingDelete] = useState(false);
|
||||
@@ -77,20 +77,16 @@ function ButtonAction({
|
||||
}
|
||||
|
||||
async function onAjukan() {
|
||||
if (moment(tanggal.toISOString().toString()).diff(moment(), "minutes") < 0)
|
||||
if (
|
||||
moment(tanggalSelesai.toISOString().toString()).diff(
|
||||
moment(),
|
||||
"minutes"
|
||||
) < 0
|
||||
)
|
||||
return ComponentGlobal_NotifikasiPeringatan("Waktu acara telah lewat");
|
||||
|
||||
const res = await Event_funEditStatusById("2", eventId);
|
||||
if (res.status === 200) {
|
||||
// const dataNotif: any = {
|
||||
// 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: "Mengajukan review",
|
||||
// };
|
||||
|
||||
const dataNotifikasi: IRealtimeData = {
|
||||
appId: res.data?.id as any,
|
||||
status: res.data?.EventMaster_Status?.name as any,
|
||||
|
||||
@@ -13,6 +13,10 @@ import { useState } from "react";
|
||||
import ComponentEvent_DetailData from "../../component/detail/detail_data";
|
||||
import { Event_funEditStatusById } from "../../fun/edit/fun_edit_status_by_id";
|
||||
import { MODEL_EVENT } from "../../model/interface";
|
||||
import { IRealtimeData } from "@/app/lib/global_state";
|
||||
import { WibuRealtime } from "wibu-pkg";
|
||||
import { event_checkStatus } from "../../fun/get/fun_check_status_by_id";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
||||
|
||||
export default function Event_DetailReview({
|
||||
dataEvent,
|
||||
@@ -35,11 +39,7 @@ function ButtonAction({ eventId }: { eventId: string }) {
|
||||
const [openModal, setOpenModal] = useState(false);
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
radius={"xl"}
|
||||
color={"orange"}
|
||||
onClick={() => setOpenModal(true)}
|
||||
>
|
||||
<Button radius={"xl"} color={"orange"} onClick={() => setOpenModal(true)}>
|
||||
Batalkan Review
|
||||
</Button>
|
||||
|
||||
@@ -73,34 +73,44 @@ async function onClick(
|
||||
eventId: string,
|
||||
setLoading: any
|
||||
) {
|
||||
const res = await Event_funEditStatusById("3", eventId);
|
||||
if (res.status === 200) {
|
||||
const dataNotif: any = {
|
||||
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: "Membatalkan review",
|
||||
};
|
||||
const checkStatus = await event_checkStatus({ id: eventId });
|
||||
|
||||
const notif = await notifikasiToAdmin_funCreate({
|
||||
data: dataNotif as any,
|
||||
});
|
||||
if (checkStatus) {
|
||||
const res = await Event_funEditStatusById("3", eventId);
|
||||
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: "Membatalkan review",
|
||||
};
|
||||
|
||||
if (notif.status === 201) {
|
||||
mqtt_client.publish(
|
||||
"ADMIN",
|
||||
JSON.stringify({
|
||||
count: 1,
|
||||
})
|
||||
);
|
||||
const notif = await notifikasiToAdmin_funCreate({
|
||||
data: dataNotifikasi as any,
|
||||
});
|
||||
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message, 1500);
|
||||
setLoading(true);
|
||||
router.replace(RouterEvent.status({ id: "3" }));
|
||||
if (notif.status === 201) {
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "ADMIN",
|
||||
});
|
||||
|
||||
WibuRealtime.setData({
|
||||
type: "trigger",
|
||||
pushNotificationTo: "ADMIN",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message, 1500);
|
||||
setLoading(true);
|
||||
router.replace(RouterEvent.status({ id: "3" }));
|
||||
}
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
ComponentGlobal_NotifikasiPeringatan("Event telah direview admin");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,20 @@
|
||||
"use client";
|
||||
|
||||
import { MainColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import ComponentGlobal_ErrorInput from "@/app_modules/_global/component/error_input";
|
||||
import ComponentGlobal_InputCountDown from "@/app_modules/_global/component/input_countdown";
|
||||
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 { MODEL_DEFAULT_MASTER_OLD } from "@/app_modules/model_global/interface";
|
||||
import { Button, Select, Stack, TextInput, Textarea } from "@mantine/core";
|
||||
import {
|
||||
Button,
|
||||
Select,
|
||||
Stack,
|
||||
Text,
|
||||
TextInput,
|
||||
Textarea,
|
||||
} from "@mantine/core";
|
||||
import { DateTimePicker } from "@mantine/dates";
|
||||
import _ from "lodash";
|
||||
import moment from "moment";
|
||||
@@ -15,7 +23,7 @@ import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { Event_funEditById } from "../fun/edit/fun_edit_by_id";
|
||||
import { MODEL_EVENT } from "../model/interface";
|
||||
import { MainColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import ComponentEvent_ErrorMaximalInput from "../component/error_maksimal_input";
|
||||
|
||||
export default function Event_Edit({
|
||||
dataEvent,
|
||||
@@ -30,10 +38,11 @@ export default function Event_Edit({
|
||||
const [value, setValue] = useState(dataEvent);
|
||||
const [tipe, setTipe] = useState(listTipeAcara);
|
||||
|
||||
// Masimal karakter state
|
||||
const [maxTitle, setMaxTitle] = useState("");
|
||||
const [maxLokasi, setMaxLokasi] = useState("");
|
||||
const [maxDeskripsi, setMaxDeskripsi] = useState("");
|
||||
const [isTimeStart, setIsTimeStart] = useState(false);
|
||||
const [diffTimeStart, setDiffTimeStart] = useState(0);
|
||||
const [isTimeEnd, setIsTimeEnd] = useState(false);
|
||||
const [diffTimeEnd, setDiffTimeEnd] = useState(0);
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* <pre>{JSON.stringify(value, null, 2)}</pre> */}
|
||||
@@ -57,7 +66,6 @@ export default function Event_Edit({
|
||||
)
|
||||
}
|
||||
onChange={(val) => {
|
||||
setMaxTitle(val.target.value);
|
||||
setValue({
|
||||
...value,
|
||||
title: val.target.value,
|
||||
@@ -108,13 +116,23 @@ export default function Event_Edit({
|
||||
)
|
||||
}
|
||||
onChange={(val) => {
|
||||
setMaxLokasi(val.target.value);
|
||||
setValue({
|
||||
...value,
|
||||
lokasi: val.target.value,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* <Text c={"green"}>{JSON.stringify(diffTimeStart, null, 2)}</Text>
|
||||
<Text c={"red"}>{JSON.stringify(diffTimeEnd, null, 2)}</Text>
|
||||
<Text c={"yellow"}>
|
||||
{JSON.stringify(
|
||||
moment(value.tanggal.toISOString().toString()),
|
||||
null,
|
||||
2
|
||||
)}
|
||||
</Text> */}
|
||||
|
||||
<DateTimePicker
|
||||
styles={{
|
||||
label: {
|
||||
@@ -125,20 +143,27 @@ export default function Event_Edit({
|
||||
return moment(date).diff(Date.now(), "days") < 0;
|
||||
}}
|
||||
withAsterisk
|
||||
label="Tanggal & Waktu "
|
||||
placeholder="Masukan tangal dan waktu acara"
|
||||
label="Tanggal & Waktu Mulai"
|
||||
placeholder="Masukan tangal dan waktu"
|
||||
value={value.tanggal}
|
||||
error={
|
||||
moment(value.tanggal.toISOString().toString()).diff(
|
||||
moment(),
|
||||
"minutes"
|
||||
) < 0 ? (
|
||||
<ComponentGlobal_ErrorInput text="Invalid Time" />
|
||||
isTimeStart ? (
|
||||
<ComponentEvent_ErrorMaximalInput text="Invalid Time !" />
|
||||
) : (
|
||||
""
|
||||
)
|
||||
}
|
||||
onChange={(val) => {
|
||||
const diffTime = moment(val?.toISOString().toString()).diff(
|
||||
moment(),
|
||||
"minutes"
|
||||
);
|
||||
setDiffTimeStart(diffTime);
|
||||
|
||||
moment(val?.toISOString().toString()).diff(moment(), "minutes") < 0
|
||||
? setIsTimeStart(true)
|
||||
: setIsTimeStart(false);
|
||||
|
||||
setValue({
|
||||
...(value as any),
|
||||
tanggal: val,
|
||||
@@ -146,6 +171,47 @@ export default function Event_Edit({
|
||||
}}
|
||||
/>
|
||||
|
||||
<DateTimePicker
|
||||
styles={{
|
||||
label: {
|
||||
color: "white",
|
||||
},
|
||||
}}
|
||||
excludeDate={(date) => {
|
||||
return moment(date).diff(Date.now(), "days") < 0;
|
||||
}}
|
||||
withAsterisk
|
||||
label="Tanggal & Waktu Berakhir"
|
||||
placeholder="Masukan tangal dan waktu"
|
||||
value={value.tanggalSelesai}
|
||||
error={
|
||||
isTimeEnd ? (
|
||||
<ComponentEvent_ErrorMaximalInput text="Invalid Time !" />
|
||||
) : moment(value.tanggalSelesai?.toISOString().toString()) <
|
||||
moment(value.tanggal.toISOString().toString()) ? (
|
||||
<ComponentGlobal_ErrorInput text="Invalid Time !" />
|
||||
) : (
|
||||
""
|
||||
)
|
||||
}
|
||||
onChange={(val) => {
|
||||
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 as any),
|
||||
tanggalSelesai: val,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
|
||||
<Stack spacing={5}>
|
||||
<Textarea
|
||||
styles={{
|
||||
@@ -167,7 +233,6 @@ export default function Event_Edit({
|
||||
)
|
||||
}
|
||||
onChange={(val) => {
|
||||
setMaxDeskripsi(val.target.value);
|
||||
setValue({
|
||||
...value,
|
||||
deskripsi: val.target.value,
|
||||
@@ -189,9 +254,8 @@ export default function Event_Edit({
|
||||
value.lokasi === "" ||
|
||||
value.deskripsi === "" ||
|
||||
value.eventMaster_TipeAcaraId === 0 ||
|
||||
value.tanggal.toISOString.toString() ===
|
||||
"function Date() { [native code] }" ||
|
||||
moment(value.tanggal).diff(moment(), "minutes") < 0
|
||||
moment(value.tanggalSelesai?.toISOString().toString()) <
|
||||
moment(value.tanggal.toISOString().toString())
|
||||
}
|
||||
loaderPosition="center"
|
||||
loading={isLoading ? true : false}
|
||||
|
||||
@@ -3,15 +3,17 @@
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { MODEL_EVENT } from "../../model/interface";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import _ from "lodash";
|
||||
|
||||
export async function Event_funCreate(req: MODEL_EVENT) {
|
||||
const res = await prisma.event.create({
|
||||
data: {
|
||||
title: req.title,
|
||||
title: _.startCase(req.title),
|
||||
lokasi: req.lokasi,
|
||||
deskripsi: req.deskripsi,
|
||||
eventMaster_TipeAcaraId: req.eventMaster_TipeAcaraId,
|
||||
tanggal: req.tanggal,
|
||||
tanggalSelesai: req.tanggalSelesai,
|
||||
authorId: req.authorId,
|
||||
},
|
||||
select: {
|
||||
@@ -20,10 +22,10 @@ export async function Event_funCreate(req: MODEL_EVENT) {
|
||||
EventMaster_Status: {
|
||||
select: {
|
||||
name: true,
|
||||
}
|
||||
},
|
||||
},
|
||||
authorId: true,
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
if (!res) return { status: 400, message: "Gagal Disimpan" };
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { MODEL_EVENT } from "../../model/interface";
|
||||
import _ from "lodash";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { RouterEvent } from "@/app/lib/router_hipmi/router_event";
|
||||
import { MODEL_EVENT } from "../../model/interface";
|
||||
|
||||
export async function Event_funEditById(data: MODEL_EVENT) {
|
||||
const updt = await prisma.event.update({
|
||||
@@ -11,10 +11,11 @@ export async function Event_funEditById(data: MODEL_EVENT) {
|
||||
id: data.id,
|
||||
},
|
||||
data: {
|
||||
title: data.title,
|
||||
title: _.startCase(data.title),
|
||||
lokasi: data.lokasi,
|
||||
deskripsi: data.deskripsi,
|
||||
tanggal: data.tanggal,
|
||||
tanggalSelesai: data.tanggalSelesai,
|
||||
eventMaster_TipeAcaraId: data.EventMaster_TipeAcara.id as any,
|
||||
},
|
||||
});
|
||||
|
||||
14
src/app_modules/event/fun/get/fun_check_status_by_id.ts
Normal file
14
src/app_modules/event/fun/get/fun_check_status_by_id.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
"use server";
|
||||
|
||||
import { prisma } from "@/app/lib";
|
||||
|
||||
export async function event_checkStatus({ id }: { id: string }) {
|
||||
const checkStatus = await prisma.event.findFirst({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
});
|
||||
|
||||
if (checkStatus?.eventMaster_StatusId == "2") return true;
|
||||
return false;
|
||||
}
|
||||
@@ -2,14 +2,42 @@
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import _ from "lodash";
|
||||
import moment from "moment";
|
||||
|
||||
export async function event_getListAllPublish({ page }: { page: number }) {
|
||||
const allData = await prisma.event.findMany({
|
||||
where: {
|
||||
active: true,
|
||||
eventMaster_StatusId: "1",
|
||||
isArsip: false,
|
||||
},
|
||||
});
|
||||
|
||||
for (let i of allData) {
|
||||
if (moment(i.tanggalSelesai).diff(moment(), "minutes") < 0) {
|
||||
const updateArsip = await prisma.event.update({
|
||||
where: {
|
||||
id: i.id,
|
||||
},
|
||||
data: {
|
||||
isArsip: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!updateArsip) {
|
||||
console.log("gagal update arsip");
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
const data = await prisma.event.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
|
||||
orderBy: [
|
||||
{
|
||||
tanggal: "asc",
|
||||
@@ -18,9 +46,7 @@ export async function event_getListAllPublish({ page }: { page: number }) {
|
||||
where: {
|
||||
active: true,
|
||||
eventMaster_StatusId: "1",
|
||||
tanggal: {
|
||||
gte: new Date(),
|
||||
},
|
||||
isArsip: false,
|
||||
},
|
||||
include: {
|
||||
Author: {
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
|
||||
export async function Event_getListByStatusId(
|
||||
statusId: string,
|
||||
authorId: string
|
||||
) {
|
||||
if (statusId === "1") {
|
||||
const data = await prisma.event.findMany({
|
||||
orderBy: {
|
||||
tanggal: "desc",
|
||||
},
|
||||
where: {
|
||||
active: true,
|
||||
eventMaster_StatusId: "1",
|
||||
authorId: authorId,
|
||||
tanggal: {
|
||||
gte: new Date(),
|
||||
},
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
deskripsi: true,
|
||||
tanggal: true,
|
||||
},
|
||||
});
|
||||
return data;
|
||||
}
|
||||
if (statusId === "2") {
|
||||
const data = await prisma.event.findMany({
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
active: true,
|
||||
eventMaster_StatusId: "2",
|
||||
authorId: authorId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
deskripsi: true,
|
||||
tanggal: true,
|
||||
},
|
||||
});
|
||||
return data;
|
||||
}
|
||||
if (statusId === "3") {
|
||||
const data = await prisma.event.findMany({
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
active: true,
|
||||
eventMaster_StatusId: "3",
|
||||
authorId: authorId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
deskripsi: true,
|
||||
tanggal: true,
|
||||
},
|
||||
});
|
||||
return data;
|
||||
}
|
||||
if (statusId === "4") {
|
||||
const data = await prisma.event.findMany({
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
active: true,
|
||||
eventMaster_StatusId: "4",
|
||||
authorId: authorId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
deskripsi: true,
|
||||
tanggal: true,
|
||||
},
|
||||
});
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -8,25 +8,13 @@ export async function event_getOneById(eventId: string) {
|
||||
where: {
|
||||
id: eventId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
lokasi: true,
|
||||
tanggal: true,
|
||||
deskripsi: true,
|
||||
active: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
catatan: true,
|
||||
authorId: true,
|
||||
include: {
|
||||
Author: {
|
||||
include: {
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
eventMaster_StatusId: true,
|
||||
EventMaster_Status: true,
|
||||
eventMaster_TipeAcaraId: true,
|
||||
EventMaster_TipeAcara: true,
|
||||
// Event_Peserta: true,
|
||||
},
|
||||
|
||||
@@ -18,9 +18,7 @@ export async function event_getListRiwayatSaya({ page }: { page: number }) {
|
||||
where: {
|
||||
authorId: userLoginId,
|
||||
eventMaster_StatusId: "1",
|
||||
tanggal: {
|
||||
lte: new Date(),
|
||||
},
|
||||
isArsip: true,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import _ from "lodash";
|
||||
|
||||
export async function event_getListSemuaRiwayat({page}: {page: number}) {
|
||||
|
||||
export async function event_getListSemuaRiwayat({ page }: { page: number }) {
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
@@ -16,9 +15,7 @@ export async function event_getListSemuaRiwayat({page}: {page: number}) {
|
||||
},
|
||||
where: {
|
||||
eventMaster_StatusId: "1",
|
||||
tanggal: {
|
||||
lte: new Date(),
|
||||
},
|
||||
isArsip: true,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
|
||||
@@ -26,9 +26,7 @@ export async function event_getAllByStatusId({
|
||||
active: true,
|
||||
eventMaster_StatusId: "1",
|
||||
authorId: userLoginId,
|
||||
tanggal: {
|
||||
gte: new Date(),
|
||||
},
|
||||
isArsip: false,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
|
||||
@@ -19,9 +19,7 @@ export async function event_funGetAllStatusPublish({ page }: { page: number }) {
|
||||
active: true,
|
||||
eventMaster_StatusId: "1",
|
||||
authorId: userLoginId,
|
||||
tanggal: {
|
||||
gte: new Date(),
|
||||
},
|
||||
isArsip: false,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
|
||||
@@ -10,7 +10,7 @@ import { useShallowEffect } from "@mantine/hooks";
|
||||
import { useAtom } from "jotai";
|
||||
import _ from "lodash";
|
||||
import { ScrollOnly } from "next-scroll-loader";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useState } from "react";
|
||||
import { ComponentEvent_CardBeranda } from "../component/card_view/card_beranda";
|
||||
import { event_getListAllPublish } from "../fun/get/get_list_all_publish";
|
||||
import { MODEL_EVENT } from "../model/interface";
|
||||
|
||||
@@ -8,7 +8,7 @@ import _ from "lodash";
|
||||
import { ScrollOnly } from "next-scroll-loader";
|
||||
import { useState } from "react";
|
||||
import ComponentEvent_BoxListStatus from "../../component/box_list_status";
|
||||
import { event_funGetAllStatusPublish } from "../../fun/get/status/get_all_status_publish";
|
||||
import { event_getAllByStatusId } from "../../fun";
|
||||
import { MODEL_EVENT } from "../../model/interface";
|
||||
|
||||
export default function Event_StatusPublish({
|
||||
@@ -36,8 +36,9 @@ export default function Event_StatusPublish({
|
||||
data={data}
|
||||
setData={setData}
|
||||
moreData={async () => {
|
||||
const loadData = await event_funGetAllStatusPublish({
|
||||
const loadData = await event_getAllByStatusId({
|
||||
page: activePage + 1,
|
||||
statusId: "1"
|
||||
});
|
||||
setActivePage((val) => val + 1);
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ export interface MODEL_EVENT {
|
||||
title: string;
|
||||
lokasi: string;
|
||||
tanggal: Date;
|
||||
tanggalSelesai: Date;
|
||||
isArsip: boolean;
|
||||
deskripsi: string;
|
||||
active: boolean;
|
||||
createdAt: Date;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { UIGlobal_LayoutDefault } from "@/app_modules/_global/ui";
|
||||
import { Logout } from "@/app_modules/auth";
|
||||
import Component_Logout from "@/app_modules/auth/logout/view";
|
||||
import { Center, Group, Skeleton, Stack, Text, Title } from "@mantine/core";
|
||||
@@ -38,15 +39,17 @@ export default function Home_UserNotActive() {
|
||||
);
|
||||
return (
|
||||
<>
|
||||
<Center h={"100vh"}>
|
||||
<Stack align="center">
|
||||
{customLOader}
|
||||
<Title order={4} c={"gray"}>
|
||||
Tunggu Konfirmasi Admin !
|
||||
</Title>
|
||||
<Component_Logout />
|
||||
</Stack>
|
||||
</Center>
|
||||
<UIGlobal_LayoutDefault>
|
||||
<Center h={"100vh"}>
|
||||
<Stack align="center">
|
||||
{customLOader}
|
||||
<Title order={4} c={"gray"}>
|
||||
Tunggu Konfirmasi Admin !
|
||||
</Title>
|
||||
<Component_Logout />
|
||||
</Stack>
|
||||
</Center>
|
||||
</UIGlobal_LayoutDefault>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user