@@ -1,10 +1,9 @@
|
|||||||
/** @type {import('next').NextConfig} */
|
/** @type {import('next').NextConfig} */
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
reactStrictMode: false,
|
reactStrictMode: false,
|
||||||
experimental: {
|
experimental: {
|
||||||
serverActions: true
|
serverActions: true,
|
||||||
},
|
},
|
||||||
|
};
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = nextConfig
|
module.exports = nextConfig;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "bun --bun run next dev --experimental-https",
|
"dev": "bun --bun run next dev --experimental-https",
|
||||||
"build": "NODE_OPTIONS='--max-old-space-size=2048' bun --bun run next build",
|
"build": "NODE_OPTIONS='--max-old-space-size=2048' bun --bun run next build",
|
||||||
|
"build:dev": "bun --bun run next build",
|
||||||
"start": "bun --bun run next start",
|
"start": "bun --bun run next start",
|
||||||
"lint": "bun --bun run next lint",
|
"lint": "bun --bun run next lint",
|
||||||
"ver": "bunx commit-and-tag-version -- --prerelease"
|
"ver": "bunx commit-and-tag-version -- --prerelease"
|
||||||
@@ -94,4 +95,4 @@
|
|||||||
"wibu-pkg": "^1.0.3",
|
"wibu-pkg": "^1.0.3",
|
||||||
"yaml": "^2.3.2"
|
"yaml": "^2.3.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,5 +11,5 @@ export async function GET(req: Request) {
|
|||||||
userId: userId as string,
|
userId: userId as string,
|
||||||
});
|
});
|
||||||
|
|
||||||
return NextResponse.json({ res });
|
return NextResponse.json(res, { status: 200 });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
import { NextResponse } from "next/server";
|
|
||||||
|
|
||||||
export async function GET(params: Request) {
|
|
||||||
const { searchParams } = new URL(params.url);
|
|
||||||
const userId = searchParams.get("userId");
|
|
||||||
|
|
||||||
|
|
||||||
return NextResponse.json({ userId });
|
|
||||||
}
|
|
||||||
12
src/app/api/event/get-all/route.ts
Normal file
12
src/app/api/event/get-all/route.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { event_getListAllPublish } from "@/app_modules/event/fun/get/get_list_all_publish";
|
||||||
|
import { toNumber } from "lodash";
|
||||||
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
|
export async function GET(params: Request) {
|
||||||
|
const { searchParams } = new URL(params.url);
|
||||||
|
const page = searchParams.get("page");
|
||||||
|
|
||||||
|
const data = await event_getListAllPublish({ page: toNumber(page) });
|
||||||
|
|
||||||
|
return NextResponse.json({ data });
|
||||||
|
}
|
||||||
21
src/app/api/event/get-one-by-id/route.ts
Normal file
21
src/app/api/event/get-one-by-id/route.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { event_getOneById } from "@/app_modules/event/fun/get/get_one_by_id";
|
||||||
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
|
export async function GET(params: Request) {
|
||||||
|
const { searchParams } = new URL(params.url);
|
||||||
|
const eventId = searchParams.get("eventId");
|
||||||
|
|
||||||
|
const res = await event_getOneById(eventId as string);
|
||||||
|
|
||||||
|
if (!res) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ message: "Event Not Found", data: null },
|
||||||
|
{ status: 404 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NextResponse.json(
|
||||||
|
{ message: "Event Found", data: res },
|
||||||
|
{ status: 200 }
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
import { newFunGetUserId } from "@/app/lib/new_fun_user_id";
|
||||||
import { Event_Create } from "@/app_modules/event";
|
import { Event_Create } from "@/app_modules/event";
|
||||||
import { Event_getMasterTipeAcara } from "@/app_modules/event/fun/master/get_tipe_acara";
|
import { Event_getMasterTipeAcara } from "@/app_modules/event/fun/master/get_tipe_acara";
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
const userLoginId = await funGetUserIdByToken();
|
const userLoginId = await newFunGetUserId();
|
||||||
const listTipeAcara = await Event_getMasterTipeAcara();
|
const listTipeAcara = await Event_getMasterTipeAcara();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,33 +1,35 @@
|
|||||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||||
import Ui_Konfirmasi from "@/app_modules/event/_ui/konfirmasi";
|
import Ui_Konfirmasi from "@/app_modules/event/_ui/konfirmasi";
|
||||||
import {
|
import { event_funCheckPesertaByUserId } from "@/app_modules/event/fun";
|
||||||
event_funCheckKehadiran,
|
|
||||||
event_funCheckPesertaByUserId,
|
|
||||||
} from "@/app_modules/event/fun";
|
|
||||||
import { event_getOneById } from "@/app_modules/event/fun/get/get_one_by_id";
|
import { event_getOneById } from "@/app_modules/event/fun/get/get_one_by_id";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
export default async function Page({ params }: { params: { id: string } }) {
|
export default async function Page({
|
||||||
const eventId = params.id;
|
params,
|
||||||
const userLoginId = await funGetUserIdByToken();
|
}: {
|
||||||
const dataEvent = await event_getOneById(eventId);
|
params: Promise<{ id: string }>;
|
||||||
|
}) {
|
||||||
|
const eventId = (await params).id;
|
||||||
|
|
||||||
const checkPeserta = await event_funCheckPesertaByUserId({
|
|
||||||
eventId: eventId,
|
|
||||||
userId: userLoginId as string,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (dataEvent == null) return redirect("/dev/event/main/beranda");
|
// const userLoginId = await funGetUserIdByToken();
|
||||||
|
|
||||||
if (moment(dataEvent?.tanggal).diff(moment(), "minutes") > 0)
|
// const checkPeserta = await event_funCheckPesertaByUserId({
|
||||||
return redirect("/dev/event/main/beranda");
|
// eventId: eventId,
|
||||||
|
// userId: userLoginId as string,
|
||||||
|
// });
|
||||||
|
|
||||||
if (dataEvent?.isArsip)
|
// if (dataEvent == null) return redirect("/dev/event/main/beranda");
|
||||||
return redirect(`/dev/event/detail/riwayat/${dataEvent.id}`);
|
|
||||||
|
|
||||||
if (checkPeserta == false)
|
// if (moment(dataEvent?.tanggal).diff(moment(), "minutes") > 0)
|
||||||
return redirect(`/dev/event/detail/main/${eventId}`);
|
// return redirect("/dev/event/main/beranda");
|
||||||
|
|
||||||
|
// if (dataEvent?.isArsip)
|
||||||
|
// return redirect(`/dev/event/detail/riwayat/${dataEvent.id}`);
|
||||||
|
|
||||||
|
// if (checkPeserta == false)
|
||||||
|
// return redirect(`/dev/event/detail/main/${eventId}`);
|
||||||
|
|
||||||
// if (checkKehadiran) {
|
// if (checkKehadiran) {
|
||||||
// return redirect(`/dev/event/main/beranda`);
|
// return redirect(`/dev/event/main/beranda`);
|
||||||
@@ -35,10 +37,7 @@ export default async function Page({ params }: { params: { id: string } }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Ui_Konfirmasi
|
<Ui_Konfirmasi userLoginId={"" as string} eventId={eventId} />
|
||||||
dataEvent={dataEvent as any}
|
|
||||||
userLoginId={userLoginId as string}
|
|
||||||
/>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
import { Event_Beranda } from "@/app_modules/event";
|
import { Event_Beranda } from "@/app_modules/event";
|
||||||
import { event_getListAllPublish } from "@/app_modules/event/fun/get/get_list_all_publish";
|
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
const dataEvent = await event_getListAllPublish({ page: 1 });
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Event_Beranda dataEvent={dataEvent as any} />
|
<Event_Beranda />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,42 +1,21 @@
|
|||||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
|
||||||
import { funGlobal_getUserById } from "@/app_modules/_global/fun/get/fun_get_user_by_id";
|
|
||||||
import { redirect } from "next/navigation";
|
|
||||||
import { RealtimeProvider } from "../lib";
|
import { RealtimeProvider } from "../lib";
|
||||||
|
import { newFunGetUserId } from "../lib/new_fun_user_id";
|
||||||
import { ServerEnv } from "../lib/server_env";
|
import { ServerEnv } from "../lib/server_env";
|
||||||
import { RouterAdminDashboard } from "../lib/router_hipmi/router_admin";
|
|
||||||
import { funGlobal_checkActivationUseById } from "@/app_modules/_global/fun/get/fun_check_activation_use_by_id";
|
|
||||||
|
|
||||||
export default async function Layout({
|
export default async function Layout({
|
||||||
children,
|
children,
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}) {
|
}) {
|
||||||
// const userLoginId = await funGetUserIdByToken();
|
|
||||||
// const dataUser = await funGlobal_getUserById({
|
|
||||||
// userId: userLoginId as string,
|
|
||||||
// });
|
|
||||||
|
|
||||||
// if (dataUser?.masterUserRoleId != "1") return redirect("/dev/home");
|
|
||||||
|
|
||||||
// const activationUser = await funGlobal_checkActivationUseById({
|
|
||||||
// userId: userLoginId as string,
|
|
||||||
// });
|
|
||||||
|
|
||||||
// if (activationUser == false) return redirect("/waiting-room");
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<RealtimeProvider
|
<RealtimeProvider
|
||||||
userLoginId={"" as string}
|
|
||||||
WIBU_REALTIME_TOKEN={
|
WIBU_REALTIME_TOKEN={
|
||||||
ServerEnv.value?.NEXT_PUBLIC_WIBU_REALTIME_TOKEN as string
|
ServerEnv.value?.NEXT_PUBLIC_WIBU_REALTIME_TOKEN as string
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{children}
|
{children}
|
||||||
{/* <CheckCookies_UiLayout dataUser={dataUser as any}>
|
|
||||||
{children}
|
|
||||||
</CheckCookies_UiLayout> */}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
7
src/app/lib/api_user_router/route_api_event.ts
Normal file
7
src/app/lib/api_user_router/route_api_event.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export const API_RouteEvent = {
|
||||||
|
get_all: ({ page }: { page: number }) => `/api/event/get-all?page=${page}`,
|
||||||
|
get_one_by_id: ({ eventId }: { eventId: string }) =>
|
||||||
|
`/api/event/get-one-by-id?eventId=${eventId}`,
|
||||||
|
check_kehadiran: ({ eventId, userId }: { eventId: string; userId: string }) =>
|
||||||
|
`/api/event/check-kehadiran?eventId=${eventId}&userId=${userId}`,
|
||||||
|
};
|
||||||
21
src/app/lib/new_fun_user_id.ts
Normal file
21
src/app/lib/new_fun_user_id.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
"use server"
|
||||||
|
|
||||||
|
import _ from "lodash";
|
||||||
|
import { cookies } from "next/headers";
|
||||||
|
import { decrypt } from "../auth/_lib/decrypt";
|
||||||
|
|
||||||
|
export async function newFunGetUserId() {
|
||||||
|
const c = cookies().get(process.env.NEXT_PUBLIC_BASE_SESSION_KEY!);
|
||||||
|
|
||||||
|
if (!c || !c?.value || _.isEmpty(c?.value) || _.isUndefined(c?.value)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const token = c.value;
|
||||||
|
const dataUser = await decrypt({
|
||||||
|
token: token,
|
||||||
|
encodedKey: process.env.NEXT_PUBLIC_BASE_TOKEN_KEY!,
|
||||||
|
});
|
||||||
|
|
||||||
|
return dataUser?.id;
|
||||||
|
}
|
||||||
@@ -1,17 +1,26 @@
|
|||||||
import { PrismaClient } from '@prisma/client'
|
import { PrismaClient } from '@prisma/client';
|
||||||
|
|
||||||
const prismaClientSingleton = () => {
|
|
||||||
return new PrismaClient()
|
|
||||||
}
|
|
||||||
|
|
||||||
type PrismaClientSingleton = ReturnType<typeof prismaClientSingleton>
|
|
||||||
|
|
||||||
|
// Singleton PrismaClient untuk pengembangan
|
||||||
const globalForPrisma = globalThis as unknown as {
|
const globalForPrisma = globalThis as unknown as {
|
||||||
prisma: PrismaClientSingleton | undefined
|
__prisma__: PrismaClient | undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const prisma = globalForPrisma.__prisma__ ?? new PrismaClient({
|
||||||
|
// log: process.env.NODE_ENV === 'development' ? ['query', 'info', 'warn', 'error'] : [],
|
||||||
|
});
|
||||||
|
|
||||||
|
// Gunakan PrismaClient yang sama jika sudah ada
|
||||||
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
|
if (!globalForPrisma.__prisma__) {
|
||||||
|
console.log('PrismaClient initialized in development mode');
|
||||||
|
}
|
||||||
|
globalForPrisma.__prisma__ = prisma;
|
||||||
}
|
}
|
||||||
|
|
||||||
const prisma = globalForPrisma.prisma ?? prismaClientSingleton()
|
process.on('SIGINT', async () => {
|
||||||
|
console.log('Disconnecting PrismaClient...');
|
||||||
|
await prisma.$disconnect();
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
|
|
||||||
export default prisma
|
export default prisma;
|
||||||
|
|
||||||
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma
|
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ import {
|
|||||||
gs_votingTiggerBeranda,
|
gs_votingTiggerBeranda,
|
||||||
IRealtimeData,
|
IRealtimeData,
|
||||||
} from "./global_state";
|
} from "./global_state";
|
||||||
|
import { newFunGetUserId } from "./new_fun_user_id";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
|
||||||
|
|
||||||
// const WIBU_REALTIME_TOKEN: string | undefined =
|
// const WIBU_REALTIME_TOKEN: string | undefined =
|
||||||
// process.env.NEXT_PUBLIC_WIBU_REALTIME_TOKEN;
|
// process.env.NEXT_PUBLIC_WIBU_REALTIME_TOKEN;
|
||||||
@@ -32,13 +32,11 @@ export type TypeNotification = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default function RealtimeProvider({
|
export default function RealtimeProvider({
|
||||||
userLoginId,
|
|
||||||
WIBU_REALTIME_TOKEN,
|
WIBU_REALTIME_TOKEN,
|
||||||
}: {
|
}: {
|
||||||
userLoginId: string;
|
|
||||||
WIBU_REALTIME_TOKEN: string;
|
WIBU_REALTIME_TOKEN: string;
|
||||||
}) {
|
}) {
|
||||||
const [userId, setUserId] = useState("");
|
const [userLoginId, setUserLoginId] = useState("");
|
||||||
const [dataRealtime, setDataRealtime] = useAtom(gs_realtimeData);
|
const [dataRealtime, setDataRealtime] = useAtom(gs_realtimeData);
|
||||||
const [newAdminNtf, setNewAdminNtf] = useAtom(gs_admin_ntf);
|
const [newAdminNtf, setNewAdminNtf] = useAtom(gs_admin_ntf);
|
||||||
const [newUserNtf, setNewUserNtf] = useAtom(gs_user_ntf);
|
const [newUserNtf, setNewUserNtf] = useAtom(gs_user_ntf);
|
||||||
@@ -74,159 +72,146 @@ export default function RealtimeProvider({
|
|||||||
gs_donasiTriggerBeranda
|
gs_donasiTriggerBeranda
|
||||||
);
|
);
|
||||||
|
|
||||||
useShallowEffect(() => {
|
async function loadUserId() {
|
||||||
onLoadUser({
|
const userId = await newFunGetUserId();
|
||||||
onSetUser(val: string) {
|
|
||||||
|
|
||||||
if (val !== "" || val !== undefined) {
|
setUserLoginId(userId as string);
|
||||||
try {
|
|
||||||
WibuRealtime.init({
|
|
||||||
project: "hipmi",
|
|
||||||
WIBU_REALTIME_TOKEN: WIBU_REALTIME_TOKEN,
|
|
||||||
onData(data: TypeNotification) {
|
|
||||||
if (
|
|
||||||
data.type == "notification" &&
|
|
||||||
data.pushNotificationTo == "ADMIN"
|
|
||||||
) {
|
|
||||||
setNewAdminNtf((e) => e + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Notifikasi ke semua user , yang datanya di acc admin
|
|
||||||
if (
|
|
||||||
data.type == "notification" &&
|
|
||||||
data.pushNotificationTo == "USER" &&
|
|
||||||
data.dataMessage?.userId == userId
|
|
||||||
) {
|
|
||||||
setNewUserNtf((e) => e + 1);
|
|
||||||
setDataRealtime(data.dataMessage as any);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------- JOB ------------------------- //
|
|
||||||
if (
|
|
||||||
data.type == "trigger" &&
|
|
||||||
data.pushNotificationTo == "ADMIN" &&
|
|
||||||
data.dataMessage?.kategoriApp == "JOB"
|
|
||||||
) {
|
|
||||||
setIsAdminJob_TriggerReview(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
data.type == "trigger" &&
|
|
||||||
data.pushNotificationTo == "USER" &&
|
|
||||||
data.dataMessage?.kategoriApp == "JOB" &&
|
|
||||||
data.dataMessage.status == "Publish"
|
|
||||||
) {
|
|
||||||
setIsTriggerJobBeranda(true);
|
|
||||||
}
|
|
||||||
// ---------------------- JOB ------------------------- //
|
|
||||||
|
|
||||||
// ---------------------- EVENT ------------------------- //
|
|
||||||
if (
|
|
||||||
data.type == "trigger" &&
|
|
||||||
data.pushNotificationTo == "ADMIN" &&
|
|
||||||
data.dataMessage?.kategoriApp == "EVENT"
|
|
||||||
) {
|
|
||||||
setIsAdminEvent_TriggerReview(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
data.type == "trigger" &&
|
|
||||||
data.pushNotificationTo == "USER" &&
|
|
||||||
data.dataMessage?.kategoriApp == "EVENT" &&
|
|
||||||
data.dataMessage.status == "Publish"
|
|
||||||
) {
|
|
||||||
setIsTriggerEventBeranda(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
data.type == "notification" &&
|
|
||||||
data.pushNotificationTo == "USER" &&
|
|
||||||
data.dataMessage?.status == "Peserta Event" &&
|
|
||||||
userId !== data.dataMessage?.userId
|
|
||||||
) {
|
|
||||||
setNewUserNtf((e) => e + 1);
|
|
||||||
}
|
|
||||||
// ---------------------- EVENT ------------------------- //
|
|
||||||
|
|
||||||
// ---------------------- VOTING ------------------------- //
|
|
||||||
if (
|
|
||||||
data.type == "trigger" &&
|
|
||||||
data.pushNotificationTo == "ADMIN" &&
|
|
||||||
data.dataMessage?.kategoriApp == "VOTING"
|
|
||||||
) {
|
|
||||||
setIsAdminVoting_TriggerReview(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
data.type == "trigger" &&
|
|
||||||
data.pushNotificationTo == "USER" &&
|
|
||||||
data.dataMessage?.kategoriApp == "VOTING" &&
|
|
||||||
data.dataMessage.status == "Publish"
|
|
||||||
) {
|
|
||||||
setIsTriggerVotingBeranda(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
data.type == "notification" &&
|
|
||||||
data.pushNotificationTo == "USER" &&
|
|
||||||
data.dataMessage?.status == "Voting Masuk" &&
|
|
||||||
userId !== data.dataMessage?.userId
|
|
||||||
) {
|
|
||||||
setNewUserNtf((e) => e + 1);
|
|
||||||
}
|
|
||||||
// ---------------------- VOTING ------------------------- //
|
|
||||||
|
|
||||||
// ---------------------- DONASI ------------------------- //
|
|
||||||
if (
|
|
||||||
data.type == "trigger" &&
|
|
||||||
data.pushNotificationTo == "ADMIN" &&
|
|
||||||
data.dataMessage?.kategoriApp == "DONASI"
|
|
||||||
) {
|
|
||||||
setIsAdminDonasi_TriggerReview(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
data.type == "trigger" &&
|
|
||||||
data.pushNotificationTo == "USER" &&
|
|
||||||
data.dataMessage?.kategoriApp == "DONASI" &&
|
|
||||||
data.dataMessage.status == "Publish"
|
|
||||||
) {
|
|
||||||
setIsTriggerDonasiBeranda(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (
|
|
||||||
// data.type == "notification" &&
|
|
||||||
// data.pushNotificationTo == "ADMIN" &&
|
|
||||||
// data.dataMessage?.status == "Menunggu" &&
|
|
||||||
// userLoginId !== data.dataMessage?.userId
|
|
||||||
// ) {
|
|
||||||
// console.log("yes");
|
|
||||||
// }
|
|
||||||
|
|
||||||
// ---------------------- DONASI ------------------------- //
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}, [setUserId]);
|
|
||||||
|
|
||||||
async function onLoadUser({
|
|
||||||
onSetUser,
|
|
||||||
}: {
|
|
||||||
onSetUser: (val: string) => void;
|
|
||||||
}) {
|
|
||||||
const res = await fetch("/api/user", {
|
|
||||||
method: "GET",
|
|
||||||
});
|
|
||||||
const result = await res.json();
|
|
||||||
onSetUser(result.data.id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
loadUserId();
|
||||||
|
|
||||||
|
try {
|
||||||
|
WibuRealtime.init({
|
||||||
|
project: "hipmi",
|
||||||
|
WIBU_REALTIME_TOKEN: WIBU_REALTIME_TOKEN,
|
||||||
|
onData(data: TypeNotification) {
|
||||||
|
if (
|
||||||
|
data.type == "notification" &&
|
||||||
|
data.pushNotificationTo == "ADMIN"
|
||||||
|
) {
|
||||||
|
setNewAdminNtf((e) => e + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Notifikasi ke semua user , yang datanya di acc admin
|
||||||
|
if (
|
||||||
|
data.type == "notification" &&
|
||||||
|
data.pushNotificationTo == "USER" &&
|
||||||
|
data.dataMessage?.userId == userLoginId
|
||||||
|
) {
|
||||||
|
setNewUserNtf((e) => e + 1);
|
||||||
|
setDataRealtime(data.dataMessage as any);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------- JOB ------------------------- //
|
||||||
|
if (
|
||||||
|
data.type == "trigger" &&
|
||||||
|
data.pushNotificationTo == "ADMIN" &&
|
||||||
|
data.dataMessage?.kategoriApp == "JOB"
|
||||||
|
) {
|
||||||
|
setIsAdminJob_TriggerReview(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
data.type == "trigger" &&
|
||||||
|
data.pushNotificationTo == "USER" &&
|
||||||
|
data.dataMessage?.kategoriApp == "JOB" &&
|
||||||
|
data.dataMessage.status == "Publish"
|
||||||
|
) {
|
||||||
|
setIsTriggerJobBeranda(true);
|
||||||
|
}
|
||||||
|
// ---------------------- JOB ------------------------- //
|
||||||
|
|
||||||
|
// ---------------------- EVENT ------------------------- //
|
||||||
|
if (
|
||||||
|
data.type == "trigger" &&
|
||||||
|
data.pushNotificationTo == "ADMIN" &&
|
||||||
|
data.dataMessage?.kategoriApp == "EVENT"
|
||||||
|
) {
|
||||||
|
setIsAdminEvent_TriggerReview(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
data.type == "trigger" &&
|
||||||
|
data.pushNotificationTo == "USER" &&
|
||||||
|
data.dataMessage?.kategoriApp == "EVENT" &&
|
||||||
|
data.dataMessage.status == "Publish"
|
||||||
|
) {
|
||||||
|
setIsTriggerEventBeranda(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
data.type == "notification" &&
|
||||||
|
data.pushNotificationTo == "USER" &&
|
||||||
|
data.dataMessage?.status == "Peserta Event" &&
|
||||||
|
userLoginId !== data.dataMessage?.userId
|
||||||
|
) {
|
||||||
|
setNewUserNtf((e) => e + 1);
|
||||||
|
}
|
||||||
|
// ---------------------- EVENT ------------------------- //
|
||||||
|
|
||||||
|
// ---------------------- VOTING ------------------------- //
|
||||||
|
if (
|
||||||
|
data.type == "trigger" &&
|
||||||
|
data.pushNotificationTo == "ADMIN" &&
|
||||||
|
data.dataMessage?.kategoriApp == "VOTING"
|
||||||
|
) {
|
||||||
|
setIsAdminVoting_TriggerReview(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
data.type == "trigger" &&
|
||||||
|
data.pushNotificationTo == "USER" &&
|
||||||
|
data.dataMessage?.kategoriApp == "VOTING" &&
|
||||||
|
data.dataMessage.status == "Publish"
|
||||||
|
) {
|
||||||
|
setIsTriggerVotingBeranda(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
data.type == "notification" &&
|
||||||
|
data.pushNotificationTo == "USER" &&
|
||||||
|
data.dataMessage?.status == "Voting Masuk" &&
|
||||||
|
userLoginId !== data.dataMessage?.userId
|
||||||
|
) {
|
||||||
|
setNewUserNtf((e) => e + 1);
|
||||||
|
}
|
||||||
|
// ---------------------- VOTING ------------------------- //
|
||||||
|
|
||||||
|
// ---------------------- DONASI ------------------------- //
|
||||||
|
if (
|
||||||
|
data.type == "trigger" &&
|
||||||
|
data.pushNotificationTo == "ADMIN" &&
|
||||||
|
data.dataMessage?.kategoriApp == "DONASI"
|
||||||
|
) {
|
||||||
|
setIsAdminDonasi_TriggerReview(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
data.type == "trigger" &&
|
||||||
|
data.pushNotificationTo == "USER" &&
|
||||||
|
data.dataMessage?.kategoriApp == "DONASI" &&
|
||||||
|
data.dataMessage.status == "Publish"
|
||||||
|
) {
|
||||||
|
setIsTriggerDonasiBeranda(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (
|
||||||
|
// data.type == "notification" &&
|
||||||
|
// data.pushNotificationTo == "ADMIN" &&
|
||||||
|
// data.dataMessage?.status == "Menunggu" &&
|
||||||
|
// userLoginId !== data.dataMessage?.userId
|
||||||
|
// ) {
|
||||||
|
// console.log("yes");
|
||||||
|
// }
|
||||||
|
|
||||||
|
// ---------------------- DONASI ------------------------- //
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Error!:", error);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,15 +108,15 @@ export default function AdminEvent_ComponentTableReview({
|
|||||||
|
|
||||||
async function onPublish({
|
async function onPublish({
|
||||||
eventId,
|
eventId,
|
||||||
tanggalSelesai,
|
tanggal,
|
||||||
}: {
|
}: {
|
||||||
eventId: string;
|
eventId: string;
|
||||||
tanggalSelesai: Date;
|
tanggal: Date;
|
||||||
}) {
|
}) {
|
||||||
const checkStatus = await event_checkStatus({ id: eventId });
|
const checkStatus = await event_checkStatus({ id: eventId });
|
||||||
|
|
||||||
if (checkStatus) {
|
if (checkStatus) {
|
||||||
if (moment(tanggalSelesai).diff(Date.now(), "minutes") < 0)
|
if (moment(tanggal).diff(Date.now(), "minutes") < 0)
|
||||||
return ComponentGlobal_NotifikasiPeringatan(
|
return ComponentGlobal_NotifikasiPeringatan(
|
||||||
"Waktu acara telah lewat, Report untuk memberitahu user !"
|
"Waktu acara telah lewat, Report untuk memberitahu user !"
|
||||||
);
|
);
|
||||||
@@ -267,7 +267,7 @@ export default function AdminEvent_ComponentTableReview({
|
|||||||
</Text>
|
</Text>
|
||||||
</Center>
|
</Center>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<Center w={400}>
|
<Center w={400}>
|
||||||
<Spoiler hideLabel="sembunyikan" maxHeight={50} showLabel="tampilkan">
|
<Spoiler hideLabel="sembunyikan" maxHeight={50} showLabel="tampilkan">
|
||||||
@@ -286,7 +286,7 @@ export default function AdminEvent_ComponentTableReview({
|
|||||||
onClick={() =>
|
onClick={() =>
|
||||||
onPublish({
|
onPublish({
|
||||||
eventId: e.id,
|
eventId: e.id,
|
||||||
tanggalSelesai: e.tanggalSelesai,
|
tanggal: e.tanggal,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
@@ -297,7 +297,7 @@ export default function AdminEvent_ComponentTableReview({
|
|||||||
leftIcon={<IconBan />}
|
leftIcon={<IconBan />}
|
||||||
radius={"xl"}
|
radius={"xl"}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
const checkStatus = await event_checkStatus({ id: eventId });
|
const checkStatus = await event_checkStatus({ id: e.id });
|
||||||
|
|
||||||
if (checkStatus) {
|
if (checkStatus) {
|
||||||
open();
|
open();
|
||||||
|
|||||||
@@ -4,7 +4,17 @@ import {
|
|||||||
UIGlobal_LayoutDefault,
|
UIGlobal_LayoutDefault,
|
||||||
UIGlobal_LayoutTamplate,
|
UIGlobal_LayoutTamplate,
|
||||||
} from "@/app_modules/_global/ui";
|
} from "@/app_modules/_global/ui";
|
||||||
import { Button, Paper, Skeleton, Stack, Text, Title } from "@mantine/core";
|
import {
|
||||||
|
Button,
|
||||||
|
Card,
|
||||||
|
Center,
|
||||||
|
Group,
|
||||||
|
Paper,
|
||||||
|
Skeleton,
|
||||||
|
Stack,
|
||||||
|
Text,
|
||||||
|
Title,
|
||||||
|
} from "@mantine/core";
|
||||||
import { MODEL_EVENT } from "../model/interface";
|
import { MODEL_EVENT } from "../model/interface";
|
||||||
import { useShallowEffect } from "@mantine/hooks";
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
import { AccentColor, MainColor } from "@/app_modules/_global/color";
|
import { AccentColor, MainColor } from "@/app_modules/_global/color";
|
||||||
@@ -13,112 +23,328 @@ import {
|
|||||||
ComponentGlobal_NotifikasiBerhasil,
|
ComponentGlobal_NotifikasiBerhasil,
|
||||||
ComponentGlobal_NotifikasiGagal,
|
ComponentGlobal_NotifikasiGagal,
|
||||||
} from "@/app_modules/_global/notif_global";
|
} from "@/app_modules/_global/notif_global";
|
||||||
import { useRouter } from "next/navigation";
|
import { redirect, useRouter } from "next/navigation";
|
||||||
import { RouterEvent } from "@/app/lib/router_hipmi/router_event";
|
import { RouterEvent } from "@/app/lib/router_hipmi/router_event";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { API_RouteEvent } from "@/app/lib/api_user_router/route_api_event";
|
||||||
|
import { ComponentGlobal_CardStyles } from "@/app_modules/_global/component";
|
||||||
|
import moment from "moment";
|
||||||
|
import { gs_event_hotMenu } from "../global_state";
|
||||||
|
import { useAtom } from "jotai";
|
||||||
|
|
||||||
export default function Ui_Konfirmasi({
|
export default function Ui_Konfirmasi({
|
||||||
dataEvent,
|
|
||||||
userLoginId,
|
userLoginId,
|
||||||
|
eventId,
|
||||||
}: {
|
}: {
|
||||||
dataEvent: MODEL_EVENT;
|
|
||||||
userLoginId: string;
|
userLoginId: string;
|
||||||
|
eventId: string;
|
||||||
}) {
|
}) {
|
||||||
// console.log(dataEvent);
|
// console.log(dataEvent);
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [isLoading, setLoading] = useState(false);
|
const [data, setData] = useState<MODEL_EVENT | null>(null);
|
||||||
const [isPresent, setIsPresent] = useState<boolean | null>(null);
|
const [isPresent, setIsPresent] = useState<boolean | null>(null);
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
onLoadKehadiran({
|
onLoadData();
|
||||||
onChange(val) {
|
}, []);
|
||||||
setIsPresent(val);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}, [setIsPresent]);
|
|
||||||
|
|
||||||
async function onLoadKehadiran({
|
async function onLoadData() {
|
||||||
onChange,
|
const data = await fetch(
|
||||||
}: {
|
API_RouteEvent.get_one_by_id({ eventId: eventId })
|
||||||
onChange: (val: boolean) => void;
|
|
||||||
}) {
|
|
||||||
const res = await fetch(
|
|
||||||
`/api/event/check-kehadiran?userId=${userLoginId}&eventId=${dataEvent.id}`
|
|
||||||
);
|
);
|
||||||
const checkKehadiran = await res.json();
|
const res = await data.json();
|
||||||
|
console.log(res.data, "data event");
|
||||||
onChange(checkKehadiran.res);
|
setData(res.data);
|
||||||
}
|
|
||||||
async function onUpdateKonfirmasi() {
|
|
||||||
setLoading(true);
|
|
||||||
const res = await event_funUpdateKehadiran({
|
|
||||||
eventId: dataEvent.id,
|
|
||||||
userId: userLoginId,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (res.status === 200) {
|
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
|
|
||||||
router.push(RouterEvent.detail_main + dataEvent.id);
|
|
||||||
} else {
|
|
||||||
setLoading(false);
|
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(isPresent, "isPresent");
|
useShallowEffect(() => {
|
||||||
|
onLoadKehadiran();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
async function onLoadKehadiran() {
|
||||||
|
const res = await fetch(
|
||||||
|
API_RouteEvent.check_kehadiran({ eventId: eventId, userId: userLoginId })
|
||||||
|
);
|
||||||
|
const data = await res.json();
|
||||||
|
|
||||||
|
setIsPresent(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// console.log("kehadiran:", isPresent);
|
||||||
|
// console.log("data:", data);
|
||||||
|
|
||||||
|
if (data == null && isPresent == null) {
|
||||||
|
return <SkeletonIsDataNull />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data == null) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<DataNotFound />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (moment(data?.tanggal).diff(moment(), "minute") < 0) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<EventAlreadyDone title={data?.title} eventId={eventId} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isPresent && data) {
|
||||||
|
return <UserAlreadyConfirm title={data.title} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isPresent == false && data) {
|
||||||
|
return (
|
||||||
|
<UserNotConfirm
|
||||||
|
title={data.title}
|
||||||
|
eventId={eventId}
|
||||||
|
userLoginId={userLoginId}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// const tgl = moment(data?.tanggal).diff(moment(), "minute") < 0;
|
||||||
|
// return (
|
||||||
|
// <>
|
||||||
|
// <UIGlobal_LayoutDefault>
|
||||||
|
// <Stack h={"100vh"} justify="center" c={"white"}>
|
||||||
|
// {JSON.stringify(tgl)}
|
||||||
|
// </Stack>
|
||||||
|
// </UIGlobal_LayoutDefault>
|
||||||
|
// </>
|
||||||
|
// );
|
||||||
|
}
|
||||||
|
|
||||||
|
function DataNotFound() {
|
||||||
|
const router = useRouter();
|
||||||
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
const [hotMenu, setHotMenu] = useAtom(gs_event_hotMenu);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<UIGlobal_LayoutDefault>
|
<UIGlobal_LayoutDefault>
|
||||||
<Stack h={"100vh"} align="center" justify="center">
|
<Stack h={"100vh"} justify="center">
|
||||||
{isPresent == null ? (
|
<ComponentGlobal_CardStyles>
|
||||||
<Skeleton h={200} w={300} radius={"sm"} />
|
<Stack>
|
||||||
) : isPresent ? (
|
<Text fw={"bold"} align="center">
|
||||||
<Paper p={"md"} withBorder bg={AccentColor.softblue}>
|
Data Event Tidak Ditemukan
|
||||||
<Stack align="center" justify="center">
|
</Text>
|
||||||
<Text fw={"bold"} align="center">
|
|
||||||
Anda telah terkonfirmasi silahkan kembali ke beranda !
|
<Button
|
||||||
</Text>
|
loading={isLoading}
|
||||||
<Title order={3}>{dataEvent.title}</Title>
|
loaderPosition="center"
|
||||||
<Button
|
radius={"xl"}
|
||||||
loading={isLoading}
|
color="green"
|
||||||
loaderPosition="center"
|
c={"black"}
|
||||||
radius={"md"}
|
onClick={() => {
|
||||||
color="green"
|
setHotMenu(0);
|
||||||
c={"black"}
|
setLoading(true);
|
||||||
onClick={() => {
|
router.push(RouterEvent.beranda, { scroll: false });
|
||||||
router.push(RouterEvent.beranda, { scroll: false });
|
}}
|
||||||
}}
|
>
|
||||||
>
|
Kembali Ke Beranda
|
||||||
Beranda
|
</Button>
|
||||||
</Button>
|
</Stack>
|
||||||
</Stack>
|
</ComponentGlobal_CardStyles>
|
||||||
</Paper>
|
</Stack>
|
||||||
) : (
|
</UIGlobal_LayoutDefault>
|
||||||
<Paper p={"md"} withBorder bg={AccentColor.softblue}>
|
</>
|
||||||
<Stack align="center" justify="center">
|
);
|
||||||
<Text fw={"bold"} align="center">
|
}
|
||||||
Anda mengkonfirmasi bahwa anda telah datang & ikut menghadir
|
|
||||||
di event
|
function SkeletonIsDataNull() {
|
||||||
</Text>
|
return (
|
||||||
<Title order={3}>{dataEvent.title}</Title>
|
<>
|
||||||
<Button
|
<UIGlobal_LayoutDefault>
|
||||||
loading={isLoading}
|
<Stack h={"100vh"} justify="center">
|
||||||
loaderPosition="center"
|
<ComponentGlobal_CardStyles>
|
||||||
radius={"xs"}
|
<Stack>
|
||||||
bg={MainColor.yellow}
|
<Skeleton height={20} width={"100%"} radius={"xl"} />{" "}
|
||||||
color="yellow"
|
<Skeleton height={20} width={"100%"} radius={"xl"} />{" "}
|
||||||
c={"black"}
|
<Skeleton height={20} width={"100%"} radius={"xl"} />
|
||||||
onClick={() => {
|
<Center>
|
||||||
onUpdateKonfirmasi();
|
<Skeleton height={40} width={"40%"} radius={"sm"} />
|
||||||
}}
|
</Center>
|
||||||
>
|
</Stack>
|
||||||
YA
|
</ComponentGlobal_CardStyles>
|
||||||
</Button>
|
</Stack>
|
||||||
</Stack>
|
</UIGlobal_LayoutDefault>
|
||||||
</Paper>
|
</>
|
||||||
)}
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function EventAlreadyDone({
|
||||||
|
title,
|
||||||
|
eventId,
|
||||||
|
}: {
|
||||||
|
title: string;
|
||||||
|
eventId: string;
|
||||||
|
}) {
|
||||||
|
const router = useRouter();
|
||||||
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
const [isLoadingDetail, setLoadingDetail] = useState(false);
|
||||||
|
const [hotMenu, setHotMenu] = useAtom(gs_event_hotMenu);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<UIGlobal_LayoutDefault>
|
||||||
|
<Stack h={"100vh"} justify="center">
|
||||||
|
<ComponentGlobal_CardStyles>
|
||||||
|
<Stack align="center" justify="center">
|
||||||
|
<Text align="center">
|
||||||
|
Kami mohon maaf, Bapak/Ibu, acara{" "}
|
||||||
|
<Text inherit span fw={"bold"}>
|
||||||
|
{title}
|
||||||
|
</Text>{" "}
|
||||||
|
telah selesai, sehingga konfirmasi kehadiran sudah tidak dapat
|
||||||
|
dilakukan. Terima kasih atas perhatian dan minat Anda. Kami
|
||||||
|
berharap dapat bertemu di acara kami berikutnya. Terima kasih,
|
||||||
|
Bapak/Ibu, kehadiran Anda di acara.
|
||||||
|
</Text>
|
||||||
|
</Stack>
|
||||||
|
<Group grow mt={"lg"}>
|
||||||
|
<Button
|
||||||
|
loading={isLoading}
|
||||||
|
loaderPosition="center"
|
||||||
|
radius={"xl"}
|
||||||
|
color="green"
|
||||||
|
c={"black"}
|
||||||
|
onClick={() => {
|
||||||
|
setHotMenu(0);
|
||||||
|
setLoading(true);
|
||||||
|
router.push(RouterEvent.beranda, { scroll: false });
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Beranda
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
loading={isLoadingDetail}
|
||||||
|
loaderPosition="center"
|
||||||
|
radius={"xl"}
|
||||||
|
c={"black"}
|
||||||
|
onClick={() => {
|
||||||
|
setHotMenu(3);
|
||||||
|
setLoadingDetail(true);
|
||||||
|
router.push(RouterEvent.detail_riwayat + eventId, {
|
||||||
|
scroll: false,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Riwayat Event
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
|
</ComponentGlobal_CardStyles>
|
||||||
|
</Stack>
|
||||||
|
</UIGlobal_LayoutDefault>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function UserNotConfirm({
|
||||||
|
title,
|
||||||
|
eventId,
|
||||||
|
userLoginId,
|
||||||
|
}: {
|
||||||
|
title: string;
|
||||||
|
eventId: string;
|
||||||
|
userLoginId: string;
|
||||||
|
}) {
|
||||||
|
const router = useRouter();
|
||||||
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
async function onUpdateKonfirmasi() {
|
||||||
|
setLoading(true);
|
||||||
|
const res = await event_funUpdateKehadiran({
|
||||||
|
eventId: eventId,
|
||||||
|
userId: userLoginId,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (res.status === 200) {
|
||||||
|
ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
|
||||||
|
router.push(RouterEvent.detail_main + eventId);
|
||||||
|
} else {
|
||||||
|
setLoading(false);
|
||||||
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<UIGlobal_LayoutDefault>
|
||||||
|
<Stack h={"100vh"} justify="center">
|
||||||
|
<ComponentGlobal_CardStyles>
|
||||||
|
<Stack align="center" justify="center">
|
||||||
|
<Text align="center">
|
||||||
|
Terima kasih atas kehadiran Anda di acara{" "}
|
||||||
|
<Text inherit span fw={"bold"}>
|
||||||
|
{title}
|
||||||
|
</Text>{" "}
|
||||||
|
pada hari ini. Mohon untuk mengonfirmasi kehadiran Anda dengan
|
||||||
|
menekan tombol {"Hadir"} atau fitur konfirmasi yang tersedia di
|
||||||
|
bawah. Terima kasih dan selamat menikmati acara.
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
loading={isLoading}
|
||||||
|
loaderPosition="center"
|
||||||
|
radius={"xs"}
|
||||||
|
bg={MainColor.yellow}
|
||||||
|
color="yellow"
|
||||||
|
c={"black"}
|
||||||
|
onClick={() => {
|
||||||
|
onUpdateKonfirmasi();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
HADIR
|
||||||
|
</Button>
|
||||||
|
</Stack>
|
||||||
|
</ComponentGlobal_CardStyles>
|
||||||
|
</Stack>
|
||||||
|
</UIGlobal_LayoutDefault>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function UserAlreadyConfirm({ title }: { title: string }) {
|
||||||
|
const router = useRouter();
|
||||||
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
const [hotMenu, setHotMenu] = useAtom(gs_event_hotMenu);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<UIGlobal_LayoutDefault>
|
||||||
|
<Stack h={"100vh"} justify="center">
|
||||||
|
<ComponentGlobal_CardStyles>
|
||||||
|
<Stack align="center" justify="center">
|
||||||
|
<Text align="center">
|
||||||
|
Terima kasih, Bapak/Ibu, kehadiran Anda di acara{" "}
|
||||||
|
<Text inherit span fw={"bold"}>
|
||||||
|
{title}
|
||||||
|
</Text>{" "}
|
||||||
|
telah berhasil dikonfirmasi. Kami senang menyambut Anda dan
|
||||||
|
semoga acara ini memberikan manfaat yang maksimal. Selamat
|
||||||
|
mengikuti kegiatan.
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
loading={isLoading}
|
||||||
|
loaderPosition="center"
|
||||||
|
radius={"xl"}
|
||||||
|
color="green"
|
||||||
|
c={"black"}
|
||||||
|
onClick={() => {
|
||||||
|
setHotMenu(0);
|
||||||
|
setLoading(true);
|
||||||
|
router.push(RouterEvent.beranda, { scroll: false });
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Beranda
|
||||||
|
</Button>
|
||||||
|
</Stack>
|
||||||
|
</ComponentGlobal_CardStyles>
|
||||||
</Stack>
|
</Stack>
|
||||||
</UIGlobal_LayoutDefault>
|
</UIGlobal_LayoutDefault>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -34,11 +34,11 @@ export function ComponentEvent_CardBeranda({ data }: { data: any }) {
|
|||||||
<Title order={5} lineClamp={1}>
|
<Title order={5} lineClamp={1}>
|
||||||
{data.title}
|
{data.title}
|
||||||
</Title>
|
</Title>
|
||||||
<Text align="right" fz={"sm"} lineClamp={1}>
|
{/* <Text align="right" fz={"sm"} lineClamp={1}>
|
||||||
{new Intl.DateTimeFormat("id-ID", {
|
{new Intl.DateTimeFormat("id-ID", {
|
||||||
dateStyle: "medium",
|
dateStyle: "medium",
|
||||||
}).format(data.tanggal)}
|
}).format(data?.tanggal)}
|
||||||
</Text>
|
</Text> */}
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
<Text fz={"sm"} lineClamp={2}>
|
<Text fz={"sm"} lineClamp={2}>
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import Event_ComponentCreateButton from "./button/button_create_event";
|
import Event_ComponentCreateButton from "./button/button_create_event";
|
||||||
|
import Event_ComponentSkeletonBeranda from "./skeleton/comp_skeleton_beranda";
|
||||||
import { Event_ComponentSkeletonDetailData } from "./skeleton/comp_skeleton_detail_data";
|
import { Event_ComponentSkeletonDetailData } from "./skeleton/comp_skeleton_detail_data";
|
||||||
|
|
||||||
export { Event_ComponentSkeletonDetailData };
|
export { Event_ComponentSkeletonDetailData };
|
||||||
export { Event_ComponentCreateButton };
|
export { Event_ComponentCreateButton };
|
||||||
|
export { Event_ComponentSkeletonBeranda };
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import { AccentColor } from "@/app_modules/_global/color";
|
||||||
|
import { ComponentGlobal_CardStyles } from "@/app_modules/_global/component";
|
||||||
|
import { Grid, Group, Paper, Skeleton, Stack, Text } from "@mantine/core";
|
||||||
|
|
||||||
|
export default function Event_ComponentSkeletonBeranda() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{Array.from({ length: 10 }).map((_, index) => (
|
||||||
|
<ComponentGlobal_CardStyles key={index} marginBottom={"16px"}>
|
||||||
|
<Stack>
|
||||||
|
<Grid align="center">
|
||||||
|
<Grid.Col span={"content"}>
|
||||||
|
<Skeleton radius={"100%"} h={50} w={50} />
|
||||||
|
</Grid.Col>
|
||||||
|
<Grid.Col span={"auto"}>
|
||||||
|
<Skeleton h={20} w={"50%"} />
|
||||||
|
</Grid.Col>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<Stack>
|
||||||
|
<Skeleton h={20} w={"100%"} />
|
||||||
|
<Skeleton h={20} w={"100%"} />
|
||||||
|
</Stack>
|
||||||
|
</Stack>
|
||||||
|
</ComponentGlobal_CardStyles>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
Loader,
|
Loader,
|
||||||
rem,
|
rem,
|
||||||
Skeleton,
|
Skeleton,
|
||||||
|
Paper,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { useShallowEffect } from "@mantine/hooks";
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
import { useAtom } from "jotai";
|
import { useAtom } from "jotai";
|
||||||
@@ -22,12 +23,10 @@ import { useState } from "react";
|
|||||||
import { ComponentEvent_CardBeranda } from "../component/card_view/card_beranda";
|
import { ComponentEvent_CardBeranda } from "../component/card_view/card_beranda";
|
||||||
import { event_getListAllPublish } from "../fun/get/get_list_all_publish";
|
import { event_getListAllPublish } from "../fun/get/get_list_all_publish";
|
||||||
import { MODEL_EVENT } from "../model/interface";
|
import { MODEL_EVENT } from "../model/interface";
|
||||||
|
import { Event_ComponentSkeletonBeranda } from "../component";
|
||||||
|
import { API_RouteEvent } from "@/app/lib/api_user_router/route_api_event";
|
||||||
|
|
||||||
export default function Event_Beranda({
|
export default function Event_Beranda() {
|
||||||
dataEvent,
|
|
||||||
}: {
|
|
||||||
dataEvent: MODEL_EVENT[];
|
|
||||||
}) {
|
|
||||||
const [data, setData] = useState<MODEL_EVENT[] | null>(null);
|
const [data, setData] = useState<MODEL_EVENT[] | null>(null);
|
||||||
const [activePage, setActivePage] = useState(1);
|
const [activePage, setActivePage] = useState(1);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
@@ -39,6 +38,7 @@ export default function Event_Beranda({
|
|||||||
const [isShowUpdate, setIsShowUpdate] = useState(false);
|
const [isShowUpdate, setIsShowUpdate] = useState(false);
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
|
setIsShowUpdate(false);
|
||||||
loadData();
|
loadData();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@@ -49,14 +49,16 @@ export default function Event_Beranda({
|
|||||||
}, [isTriggerEventBeranda]);
|
}, [isTriggerEventBeranda]);
|
||||||
|
|
||||||
async function loadData() {
|
async function loadData() {
|
||||||
const loadData = await event_getListAllPublish({ page: 1 });
|
const res = await fetch(API_RouteEvent.get_all({ page: activePage }));
|
||||||
setData(loadData as any);
|
const data = await res.json();
|
||||||
|
setData(data.data as any);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onLoadNewData() {
|
async function onLoadNewData() {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
const loadData = await event_getListAllPublish({ page: 1 });
|
const res = await fetch(API_RouteEvent.get_all({ page: 1 }));
|
||||||
setData(loadData as any);
|
const data = await res.json();
|
||||||
|
setData(data.data as any);
|
||||||
|
|
||||||
setIsShowUpdate(false);
|
setIsShowUpdate(false);
|
||||||
setIsTriggerEventBeranca(false);
|
setIsTriggerEventBeranca(false);
|
||||||
@@ -92,16 +94,7 @@ export default function Event_Beranda({
|
|||||||
<ComponentGlobal_CreateButton path={RouterEvent.create} />
|
<ComponentGlobal_CreateButton path={RouterEvent.create} />
|
||||||
|
|
||||||
{data == null ? (
|
{data == null ? (
|
||||||
Array.from({ length: 10 }).map((_, index) => (
|
<Event_ComponentSkeletonBeranda />
|
||||||
<Skeleton
|
|
||||||
animate
|
|
||||||
mb={"15px"}
|
|
||||||
key={index}
|
|
||||||
radius={"md"}
|
|
||||||
height={"15vh"}
|
|
||||||
w={"100%"}
|
|
||||||
/>
|
|
||||||
))
|
|
||||||
) : _.isEmpty(data) ? (
|
) : _.isEmpty(data) ? (
|
||||||
<ComponentGlobal_IsEmptyData />
|
<ComponentGlobal_IsEmptyData />
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export default function Event_SplashScreen() {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
router.replace(RouterEvent.beranda);
|
router.replace(RouterEvent.beranda);
|
||||||
setHotMenu(0);
|
setHotMenu(0);
|
||||||
}, 1000);
|
}, 500);
|
||||||
}, []);
|
}, []);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
Reference in New Issue
Block a user