# feat:
## Deskripsi: - Notifikasi admin to user - Notifikasi user to user ### Issue: - Pada table admin harus di sediakan untuk triger update data saat ada notifikasi
This commit is contained in:
@@ -1,9 +0,0 @@
|
|||||||
import ComponentGlobal_V2_LoadingPage from "@/app_modules/_global/loading_page_v2";
|
|
||||||
|
|
||||||
export default async function Page() {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<ComponentGlobal_V2_LoadingPage />
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,20 @@
|
|||||||
import { Event_DetailPublish } from "@/app_modules/event";
|
import { Event_DetailPublish } from "@/app_modules/event";
|
||||||
|
import { Event_countTotalPesertaById } from "@/app_modules/event/fun/count/count_total_peserta_by_id";
|
||||||
|
import { Event_getListPesertaById } from "@/app_modules/event/fun/get/get_list_peserta_by_id";
|
||||||
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";
|
||||||
|
|
||||||
export default async function Page({ params }: { params: { id: string } }) {
|
export default async function Page({ params }: { params: { id: string } }) {
|
||||||
let eventId = params.id;
|
let eventId = params.id;
|
||||||
const dataEvent = await Event_getOneById(eventId);
|
const dataEvent = await Event_getOneById(eventId);
|
||||||
|
const listPeserta = await Event_getListPesertaById(eventId);
|
||||||
|
const totalPeserta = await Event_countTotalPesertaById(eventId);
|
||||||
|
|
||||||
return <Event_DetailPublish dataEvent={dataEvent as any} />;
|
|
||||||
|
return (
|
||||||
|
<Event_DetailPublish
|
||||||
|
dataEvent={dataEvent as any}
|
||||||
|
listPeserta={listPeserta}
|
||||||
|
totalPeserta={totalPeserta}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ export async function AdminEvent_funEditStatusPublishById(
|
|||||||
eventId: string,
|
eventId: string,
|
||||||
statusId: string
|
statusId: string
|
||||||
) {
|
) {
|
||||||
console.log(eventId);
|
|
||||||
const updt = await prisma.event.update({
|
const updt = await prisma.event.update({
|
||||||
where: {
|
where: {
|
||||||
id: eventId,
|
id: eventId,
|
||||||
@@ -15,11 +14,22 @@ export async function AdminEvent_funEditStatusPublishById(
|
|||||||
data: {
|
data: {
|
||||||
eventMaster_StatusId: statusId,
|
eventMaster_StatusId: statusId,
|
||||||
},
|
},
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
title: true,
|
||||||
|
authorId: true,
|
||||||
|
EventMaster_Status: {
|
||||||
|
select: {
|
||||||
|
name: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!updt) return { status: 400, message: "Update Gagal" };
|
if (!updt) return { status: 400, message: "Update Gagal" };
|
||||||
revalidatePath("/dev/admin/event/main");
|
revalidatePath("/dev/admin/event/main");
|
||||||
return {
|
return {
|
||||||
|
data: updt,
|
||||||
status: 200,
|
status: 200,
|
||||||
message: "Berhasil Update Status",
|
message: "Berhasil Update Status",
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,13 +14,24 @@ export async function AdminEvent_funEditCatatanById(
|
|||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
eventMaster_StatusId: statudId,
|
eventMaster_StatusId: statudId,
|
||||||
catatan: data.catatan
|
catatan: data.catatan,
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
title: true,
|
||||||
|
authorId: true,
|
||||||
|
EventMaster_Status: {
|
||||||
|
select: {
|
||||||
|
name: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!updt) return { status: 400, message: "Update Gagal" };
|
if (!updt) return { status: 400, message: "Update Gagal" };
|
||||||
revalidatePath("/dev/admin/event/main");
|
revalidatePath("/dev/admin/event/main");
|
||||||
return {
|
return {
|
||||||
|
data: updt,
|
||||||
status: 200,
|
status: 200,
|
||||||
message: "Berhasil Update Status",
|
message: "Berhasil Update Status",
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,18 +3,13 @@
|
|||||||
import { RouterAdminEvent } from "@/app/lib/router_admin/router_admin_event";
|
import { RouterAdminEvent } from "@/app/lib/router_admin/router_admin_event";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Stack,
|
|
||||||
Title,
|
|
||||||
Divider,
|
|
||||||
SimpleGrid,
|
|
||||||
Paper,
|
|
||||||
Center,
|
|
||||||
Text,
|
|
||||||
Box,
|
|
||||||
Group,
|
Group,
|
||||||
ActionIcon,
|
Paper,
|
||||||
|
SimpleGrid,
|
||||||
|
Stack,
|
||||||
|
Text,
|
||||||
|
Title
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { IconChevronsRight } from "@tabler/icons-react";
|
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import ComponentAdminGlobal_HeaderTamplate from "../../component_global/header_tamplate";
|
import ComponentAdminGlobal_HeaderTamplate from "../../component_global/header_tamplate";
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { RouterAdminDonasi_OLD } from "@/app/lib/router_hipmi/router_admin";
|
|
||||||
import {
|
import {
|
||||||
ActionIcon,
|
|
||||||
Box,
|
Box,
|
||||||
Button,
|
Button,
|
||||||
Center,
|
Center,
|
||||||
@@ -11,37 +9,27 @@ import {
|
|||||||
Spoiler,
|
Spoiler,
|
||||||
Stack,
|
Stack,
|
||||||
Table,
|
Table,
|
||||||
Text,
|
|
||||||
TextInput,
|
|
||||||
Textarea,
|
Textarea,
|
||||||
Title,
|
Title,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import {
|
import { IconBan, IconEyeShare } from "@tabler/icons-react";
|
||||||
IconBan,
|
|
||||||
IconChevronLeft,
|
|
||||||
IconEyeCheck,
|
|
||||||
IconEyeShare,
|
|
||||||
IconShare,
|
|
||||||
} from "@tabler/icons-react";
|
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
|
|
||||||
import { useDisclosure } from "@mantine/hooks";
|
import { useDisclosure } from "@mantine/hooks";
|
||||||
|
|
||||||
import { useState } from "react";
|
|
||||||
import TampilanRupiahDonasi from "@/app_modules/donasi/component/tampilan_rupiah";
|
|
||||||
import ComponentAdminDonasi_TombolKembali from "../../donasi/component/tombol_kembali";
|
|
||||||
import { MODEL_EVENT } from "@/app_modules/event/model/interface";
|
|
||||||
import ComponentAdminGlobal_HeaderTamplate from "../../component_global/header_tamplate";
|
|
||||||
import moment from "moment";
|
|
||||||
import _ from "lodash";
|
|
||||||
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
|
||||||
import { AdminEvent_funEditStatusPublishById } from "../fun/edit/fun_edit_status_publish_by_id";
|
|
||||||
import { AdminEvent_getListTableByStatusId } from "../fun/get/get_list_table_by_status_id";
|
|
||||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||||
import { AdminEvent_funEditCatatanById } from "../fun/edit/fun_edit_status_reject_by_id";
|
|
||||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
||||||
|
import { MODEL_EVENT } from "@/app_modules/event/model/interface";
|
||||||
|
import mqtt_client from "@/util/mqtt_client";
|
||||||
|
import _ from "lodash";
|
||||||
|
import moment from "moment";
|
||||||
|
import { useState } from "react";
|
||||||
|
import ComponentAdminGlobal_HeaderTamplate from "../../component_global/header_tamplate";
|
||||||
|
import adminNotifikasi_funCreateToUser from "../../notifikasi/fun/create/fun_create_notif_user";
|
||||||
|
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 { AdminEvent_getListTableByStatusId } from "../fun/get/get_list_table_by_status_id";
|
||||||
export default function AdminEvent_TableReview({
|
export default function AdminEvent_TableReview({
|
||||||
listReview,
|
listReview,
|
||||||
}: {
|
}: {
|
||||||
@@ -197,16 +185,35 @@ async function onPublish(eventId: string, setData: any, tanggal: Date) {
|
|||||||
"Waktu acara telah lewat, Report untuk memberitahu user !"
|
"Waktu acara telah lewat, Report untuk memberitahu user !"
|
||||||
);
|
);
|
||||||
|
|
||||||
await AdminEvent_funEditStatusPublishById(eventId, "1").then(async (res) => {
|
const res = await AdminEvent_funEditStatusPublishById(eventId, "1");
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
await AdminEvent_getListTableByStatusId("2").then((res) => {
|
const dataNotif = {
|
||||||
setData(res);
|
appId: res.data?.id,
|
||||||
ComponentGlobal_NotifikasiBerhasil("Berhasil update status");
|
status: res.data?.EventMaster_Status?.name as any,
|
||||||
});
|
userId: res.data?.authorId as any,
|
||||||
} else {
|
pesan: res.data?.title as any,
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
kategoriApp: "EVENT",
|
||||||
|
title: "Event publish",
|
||||||
|
};
|
||||||
|
|
||||||
|
const notif = await adminNotifikasi_funCreateToUser({
|
||||||
|
data: dataNotif as any,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (notif.status === 201) {
|
||||||
|
mqtt_client.publish(
|
||||||
|
"USER",
|
||||||
|
JSON.stringify({ userId: res?.data?.authorId, count: 1 })
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
await AdminEvent_getListTableByStatusId("2").then((res) => {
|
||||||
|
setData(res);
|
||||||
|
ComponentGlobal_NotifikasiBerhasil("Berhasil update status");
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onReject(
|
async function onReject(
|
||||||
@@ -222,15 +229,34 @@ async function onReject(
|
|||||||
catatan: catatan,
|
catatan: catatan,
|
||||||
};
|
};
|
||||||
|
|
||||||
await AdminEvent_funEditCatatanById(body as any, "4").then(async (res) => {
|
const res = await AdminEvent_funEditCatatanById(body as any, "4");
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
await AdminEvent_getListTableByStatusId("2").then((val) => {
|
const dataNotif = {
|
||||||
setData(val);
|
appId: res.data?.id,
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
status: res.data?.EventMaster_Status?.name as any,
|
||||||
close();
|
userId: res.data?.authorId as any,
|
||||||
});
|
pesan: res.data?.title as any,
|
||||||
} else {
|
kategoriApp: "EVENT",
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
title: "Event anda di tolak !",
|
||||||
|
};
|
||||||
|
|
||||||
|
const notif = await adminNotifikasi_funCreateToUser({
|
||||||
|
data: dataNotif as any,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (notif.status === 201) {
|
||||||
|
mqtt_client.publish(
|
||||||
|
"USER",
|
||||||
|
JSON.stringify({ userId: res?.data?.authorId, count: 1 })
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
await AdminEvent_getListTableByStatusId("2").then((val) => {
|
||||||
|
setData(val);
|
||||||
|
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||||
|
close();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import { RouterEvent } from "@/app/lib/router_hipmi/router_event";
|
import { RouterEvent } from "@/app/lib/router_hipmi/router_event";
|
||||||
import ComponentGlobal_AuthorNameOnHeader from "@/app_modules/_global/author_name_on_header";
|
import ComponentGlobal_AuthorNameOnHeader from "@/app_modules/_global/author_name_on_header";
|
||||||
import { AccentColor } from "@/app_modules/_global/color/color_pallet";
|
import { AccentColor } from "@/app_modules/_global/color/color_pallet";
|
||||||
import { Card, Stack, Grid, Title, Text, Group } from "@mantine/core";
|
import { Card, Group, Stack, Text, Title } from "@mantine/core";
|
||||||
import moment from "moment";
|
|
||||||
import router from "next/router";
|
import { useRouter } from "next/navigation";
|
||||||
import { MODEL_EVENT } from "../../model/interface";
|
import { MODEL_EVENT } from "../../model/interface";
|
||||||
|
|
||||||
export function ComponentEvent_CardRiwayat({ data }: { data: MODEL_EVENT }) {
|
export function ComponentEvent_CardRiwayat({ data }: { data: MODEL_EVENT }) {
|
||||||
|
const router = useRouter();
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Card
|
<Card
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ export default function Event_Create({
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* <pre>{JSON.stringify(value, null, 2)}</pre> */}
|
{/* <pre>{JSON.stringify(value, null, 2)}</pre> */}
|
||||||
<Stack px={"sm"}>
|
<Stack px={"xl"}>
|
||||||
<TextInput
|
<TextInput
|
||||||
styles={{
|
styles={{
|
||||||
label: {
|
label: {
|
||||||
|
|||||||
@@ -2,10 +2,7 @@
|
|||||||
|
|
||||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||||
import {
|
import { Button, Stack } from "@mantine/core";
|
||||||
Button,
|
|
||||||
Stack
|
|
||||||
} from "@mantine/core";
|
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import ComponentEvent_DetailMainData from "../../component/detail/detail_main";
|
import ComponentEvent_DetailMainData from "../../component/detail/detail_main";
|
||||||
@@ -14,6 +11,8 @@ import { Event_countTotalPesertaById } from "../../fun/count/count_total_peserta
|
|||||||
import { Event_funJoinEvent } from "../../fun/create/fun_join_event";
|
import { Event_funJoinEvent } from "../../fun/create/fun_join_event";
|
||||||
import { Event_getListPesertaById } from "../../fun/get/get_list_peserta_by_id";
|
import { Event_getListPesertaById } from "../../fun/get/get_list_peserta_by_id";
|
||||||
import { MODEL_EVENT, MODEL_EVENT_PESERTA } from "../../model/interface";
|
import { MODEL_EVENT, MODEL_EVENT_PESERTA } from "../../model/interface";
|
||||||
|
import mqtt_client from "@/util/mqtt_client";
|
||||||
|
import notifikasiToUser_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_user";
|
||||||
|
|
||||||
export default function Event_DetailMain({
|
export default function Event_DetailMain({
|
||||||
dataEvent,
|
dataEvent,
|
||||||
@@ -79,18 +78,43 @@ async function onJoin(
|
|||||||
eventId: eventId,
|
eventId: eventId,
|
||||||
};
|
};
|
||||||
|
|
||||||
await Event_funJoinEvent(body as any).then(async (res) => {
|
const userLoginId = userId;
|
||||||
if (res.status === 200) {
|
|
||||||
await Event_getListPesertaById(eventId).then(async (val) => {
|
const res = await Event_funJoinEvent(body as any);
|
||||||
await Event_countTotalPesertaById(eventId).then((ttl) => {
|
if (res.status === 200) {
|
||||||
setPeserta(val);
|
if (userLoginId !== res.data?.Event?.authorId) {
|
||||||
setTotal(ttl);
|
const dataNotif = {
|
||||||
setLoading(true);
|
appId: res?.data?.Event?.id,
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
|
userId: res?.data?.Event?.authorId,
|
||||||
});
|
pesan: res?.data?.Event?.title,
|
||||||
|
status: "Peserta event",
|
||||||
|
kategoriApp: "EVENT",
|
||||||
|
title: "Peserta baru telah masuk !",
|
||||||
|
};
|
||||||
|
|
||||||
|
const createNotifikasi = await notifikasiToUser_funCreate({
|
||||||
|
data: dataNotif as any,
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
if (createNotifikasi.status === 201) {
|
||||||
|
mqtt_client.publish(
|
||||||
|
"USER",
|
||||||
|
JSON.stringify({
|
||||||
|
userId: dataNotif.userId,
|
||||||
|
count: 1,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
const resPeserta = await Event_getListPesertaById(eventId);
|
||||||
|
setPeserta(resPeserta);
|
||||||
|
|
||||||
|
const resTotal = await Event_countTotalPesertaById(eventId);
|
||||||
|
setTotal(resTotal);
|
||||||
|
setLoading(true);
|
||||||
|
ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
|
||||||
|
} else {
|
||||||
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,25 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { Button, Grid, Group, Stack, Text, Title } from "@mantine/core";
|
|
||||||
import moment from "moment";
|
|
||||||
import ComponentEvent_DetailData from "../../component/detail/detail_data";
|
import ComponentEvent_DetailData from "../../component/detail/detail_data";
|
||||||
|
import ComponentEvent_ListPeserta from "../../component/detail/list_peserta";
|
||||||
import { MODEL_EVENT } from "../../model/interface";
|
import { MODEL_EVENT } from "../../model/interface";
|
||||||
|
|
||||||
export default function Event_DetailPublish({
|
export default function Event_DetailPublish({
|
||||||
dataEvent,
|
dataEvent,
|
||||||
|
listPeserta,
|
||||||
|
totalPeserta,
|
||||||
}: {
|
}: {
|
||||||
dataEvent: MODEL_EVENT;
|
dataEvent: MODEL_EVENT;
|
||||||
|
listPeserta: any[];
|
||||||
|
totalPeserta: number;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ComponentEvent_DetailData data={dataEvent} />
|
<ComponentEvent_DetailData data={dataEvent} />
|
||||||
|
<ComponentEvent_ListPeserta
|
||||||
|
listPeserta={listPeserta}
|
||||||
|
total={totalPeserta}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import { AppShell } from "@mantine/core";
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import ComponentEvent_HeaderTamplate from "../../component/header_tamplate";
|
import ComponentEvent_HeaderTamplate from "../../component/header_tamplate";
|
||||||
import AppComponentGlobal_LayoutTamplate from "@/app_modules/_global/component_layout_tamplate";
|
import AppComponentGlobal_LayoutTamplate from "@/app_modules/_global/component_layout_tamplate";
|
||||||
|
import UIGlobal_LayoutTamplate from "@/app_modules/_global/ui/ui_layout_tamplate";
|
||||||
|
import UIGlobal_LayoutHeaderTamplate from "@/app_modules/_global/ui/ui_header_tamplate";
|
||||||
|
|
||||||
export default function LayoutEvent_DetailPublish({
|
export default function LayoutEvent_DetailPublish({
|
||||||
children,
|
children,
|
||||||
@@ -12,11 +14,11 @@ export default function LayoutEvent_DetailPublish({
|
|||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<AppComponentGlobal_LayoutTamplate
|
<UIGlobal_LayoutTamplate
|
||||||
header={<ComponentEvent_HeaderTamplate title="Detail Publish" />}
|
header={<UIGlobal_LayoutHeaderTamplate title="Detail Publish" />}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</AppComponentGlobal_LayoutTamplate>
|
</UIGlobal_LayoutTamplate>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export default function Event_Edit({
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* <pre>{JSON.stringify(value, null, 2)}</pre> */}
|
{/* <pre>{JSON.stringify(value, null, 2)}</pre> */}
|
||||||
<Stack px={"sm"}>
|
<Stack px={"xl"}>
|
||||||
<TextInput
|
<TextInput
|
||||||
styles={{
|
styles={{
|
||||||
label: {
|
label: {
|
||||||
|
|||||||
@@ -5,16 +5,27 @@ import { MODEL_EVENT_PESERTA } from "../../model/interface";
|
|||||||
import { revalidatePath } from "next/cache";
|
import { revalidatePath } from "next/cache";
|
||||||
|
|
||||||
export async function Event_funJoinEvent(data: MODEL_EVENT_PESERTA) {
|
export async function Event_funJoinEvent(data: MODEL_EVENT_PESERTA) {
|
||||||
const crt = await prisma.event_Peserta.create({
|
const res = await prisma.event_Peserta.create({
|
||||||
data: {
|
data: {
|
||||||
eventId: data.eventId,
|
eventId: data.eventId,
|
||||||
userId: data.userId,
|
userId: data.userId,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
select: {
|
||||||
|
Event: {
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
title: true,
|
||||||
|
authorId: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!crt) return { status: 400, message: "Gagal Join" };
|
if (!res) return { status: 400, message: "Gagal Join" };
|
||||||
revalidatePath("/dev/event/detail/main");
|
revalidatePath("/dev/event/detail/main");
|
||||||
return {
|
return {
|
||||||
|
data: res,
|
||||||
status: 200,
|
status: 200,
|
||||||
message: "Berhasil Join",
|
message: "Berhasil Join",
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,9 +10,11 @@ export async function event_getListAllPublish({ page }: { page: number }) {
|
|||||||
const data = await prisma.event.findMany({
|
const data = await prisma.event.findMany({
|
||||||
take: takeData,
|
take: takeData,
|
||||||
skip: skipData,
|
skip: skipData,
|
||||||
orderBy: {
|
orderBy: [
|
||||||
tanggal: "desc",
|
{
|
||||||
},
|
tanggal: "desc",
|
||||||
|
},
|
||||||
|
],
|
||||||
where: {
|
where: {
|
||||||
active: true,
|
active: true,
|
||||||
eventMaster_StatusId: "1",
|
eventMaster_StatusId: "1",
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
import { atomWithStorage } from "jotai/utils";
|
import { atomWithStorage } from "jotai/utils";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param index | 0 - 3 | 0: Beranda, 1: Status, 2: Kontibusi, 3: Riwayat
|
||||||
|
* @type number
|
||||||
|
*/
|
||||||
export const gs_event_hotMenu = atomWithStorage("gs_event_hotMenu", 0)
|
export const gs_event_hotMenu = atomWithStorage("gs_event_hotMenu", 0)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -7,4 +11,9 @@ export const gs_event_hotMenu = atomWithStorage("gs_event_hotMenu", 0)
|
|||||||
* @type string
|
* @type string
|
||||||
*/
|
*/
|
||||||
export const gs_event_status = atomWithStorage<string | any>("gs_status_event", "Publish")
|
export const gs_event_status = atomWithStorage<string | any>("gs_status_event", "Publish")
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param riwayat | "Semua", "Saya"
|
||||||
|
* @type string
|
||||||
|
*/
|
||||||
export const gs_event_riwayat = atomWithStorage<string | any>("gs_event_riwayat", "Semua")
|
export const gs_event_riwayat = atomWithStorage<string | any>("gs_event_riwayat", "Semua")
|
||||||
@@ -153,7 +153,7 @@ export function Home_UiView({
|
|||||||
e.icon
|
e.icon
|
||||||
)}
|
)}
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
<Text c={e.link === "" ? "gray.3" : "white"} fz={"sm"}>
|
<Text c={e.link === "" ? "gray.3" : "white"} fz={"xs"}>
|
||||||
{e.name}
|
{e.name}
|
||||||
</Text>
|
</Text>
|
||||||
</Stack>
|
</Stack>
|
||||||
@@ -162,7 +162,6 @@ export function Home_UiView({
|
|||||||
</SimpleGrid>
|
</SimpleGrid>
|
||||||
|
|
||||||
{/* Job View */}
|
{/* Job View */}
|
||||||
|
|
||||||
<Paper
|
<Paper
|
||||||
p={"md"}
|
p={"md"}
|
||||||
w={"100%"}
|
w={"100%"}
|
||||||
@@ -218,10 +217,15 @@ export function Home_UiView({
|
|||||||
<IconUserSearch size={20} color="white" />
|
<IconUserSearch size={20} color="white" />
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack spacing={0} w={"80%"}>
|
<Stack spacing={0} w={"80%"}>
|
||||||
<Text c={MainColor.yellow} fw={"bold"}>
|
<Text
|
||||||
|
lineClamp={1}
|
||||||
|
fz={"sm"}
|
||||||
|
c={MainColor.yellow}
|
||||||
|
fw={"bold"}
|
||||||
|
>
|
||||||
{e?.Author.username}
|
{e?.Author.username}
|
||||||
</Text>
|
</Text>
|
||||||
<Text c={"white"} lineClamp={2} fz={"sm"}>
|
<Text fz={"sm"} c={"white"} lineClamp={2}>
|
||||||
{e?.title}
|
{e?.title}
|
||||||
</Text>
|
</Text>
|
||||||
</Stack>
|
</Stack>
|
||||||
@@ -303,7 +307,11 @@ export function Home_UiFooter({ dataUser }: { dataUser: MODEL_USER }) {
|
|||||||
e.icon
|
e.icon
|
||||||
)}
|
)}
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
<Text c={e.link === "" ? "gray" : "white"} fz={"xs"}>
|
<Text
|
||||||
|
lineClamp={1}
|
||||||
|
c={e.link === "" ? "gray" : "white"}
|
||||||
|
fz={10}
|
||||||
|
>
|
||||||
{e.name}
|
{e.name}
|
||||||
</Text>
|
</Text>
|
||||||
</Stack>
|
</Stack>
|
||||||
@@ -347,7 +355,7 @@ export function Home_UiFooter({ dataUser }: { dataUser: MODEL_USER }) {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
<Text fz={"xs"} c={"white"}>
|
<Text fz={10} c={"white"}>
|
||||||
Profile
|
Profile
|
||||||
</Text>
|
</Text>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
} from "@/app_modules/_global/color/color_pallet";
|
} from "@/app_modules/_global/color/color_pallet";
|
||||||
import notifikasi_getByUserId from "../fun/get/get_notifiaksi_by_id";
|
import notifikasi_getByUserId from "../fun/get/get_notifiaksi_by_id";
|
||||||
import { redirectVotingPage } from "./path/voting";
|
import { redirectVotingPage } from "./path/voting";
|
||||||
|
import { redirectEventPage } from "./path/event";
|
||||||
|
|
||||||
export function ComponentNotifiaksi_CardView({
|
export function ComponentNotifiaksi_CardView({
|
||||||
data,
|
data,
|
||||||
@@ -41,6 +42,18 @@ export function ComponentNotifiaksi_CardView({
|
|||||||
}}
|
}}
|
||||||
my={"xs"}
|
my={"xs"}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
|
|
||||||
|
await notifikasi_funUpdateIsReadById({
|
||||||
|
notifId: data?.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
// if (updateIsRead.status === 200) {
|
||||||
|
// const loadData = await notifikasi_getByUserId({
|
||||||
|
// page: activePage + 1,
|
||||||
|
// });
|
||||||
|
// onLoadData(loadData);
|
||||||
|
// }
|
||||||
|
|
||||||
data?.kategoriApp === "JOB" &&
|
data?.kategoriApp === "JOB" &&
|
||||||
redirectJobPage({
|
redirectJobPage({
|
||||||
data: data,
|
data: data,
|
||||||
@@ -65,16 +78,14 @@ export function ComponentNotifiaksi_CardView({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const updateIsRead = await notifikasi_funUpdateIsReadById({
|
data?.kategoriApp === "EVENT" &&
|
||||||
notifId: data?.id,
|
redirectEventPage({
|
||||||
});
|
data: data,
|
||||||
|
router: router,
|
||||||
if (updateIsRead.status === 200) {
|
onSetPage(val) {
|
||||||
// console.log(updateIsRead.status);
|
onSetMenu(val);
|
||||||
// const loadData = await notifikasi_getByUserId({ page: activePage });
|
},
|
||||||
// onLoadData(loadData);
|
});
|
||||||
// console.log("berhasil load")
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{/* <pre>{JSON.stringify(e, null, 2)}</pre> */}
|
{/* <pre>{JSON.stringify(e, null, 2)}</pre> */}
|
||||||
|
|||||||
36
src/app_modules/notifikasi/component/path/event.ts
Normal file
36
src/app_modules/notifikasi/component/path/event.ts
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import { RouterEvent } from "@/app/lib/router_hipmi/router_event";
|
||||||
|
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
||||||
|
import { MODEL_NOTIFIKASI } from "../../model/interface";
|
||||||
|
|
||||||
|
export function redirectEventPage({
|
||||||
|
data,
|
||||||
|
router,
|
||||||
|
onSetPage,
|
||||||
|
}: {
|
||||||
|
data: MODEL_NOTIFIKASI;
|
||||||
|
router: AppRouterInstance;
|
||||||
|
onSetPage: (val: any) => void;
|
||||||
|
}) {
|
||||||
|
const path = RouterEvent.status_page;
|
||||||
|
|
||||||
|
if (data.status === "Publish") {
|
||||||
|
onSetPage({
|
||||||
|
menuId: 2,
|
||||||
|
status: data.status,
|
||||||
|
});
|
||||||
|
router.push(path, { scroll: false });
|
||||||
|
}
|
||||||
|
// console.log(data)
|
||||||
|
|
||||||
|
if (data.status === "Reject") {
|
||||||
|
onSetPage({
|
||||||
|
menuId: 2,
|
||||||
|
status: data.status,
|
||||||
|
});
|
||||||
|
router.push(path, { scroll: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.status === "Peserta event") {
|
||||||
|
router.push(RouterEvent.detail_main + data.appId, { scroll: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,6 +16,10 @@ import {
|
|||||||
gs_vote_hotMenu,
|
gs_vote_hotMenu,
|
||||||
gs_vote_status,
|
gs_vote_status,
|
||||||
} from "@/app_modules/vote/global_state";
|
} from "@/app_modules/vote/global_state";
|
||||||
|
import {
|
||||||
|
gs_event_hotMenu,
|
||||||
|
gs_event_status,
|
||||||
|
} from "@/app_modules/event/global_state";
|
||||||
|
|
||||||
export function Notifikasi_UiView({
|
export function Notifikasi_UiView({
|
||||||
listNotifikasi,
|
listNotifikasi,
|
||||||
@@ -29,20 +33,22 @@ export function Notifikasi_UiView({
|
|||||||
const [jobMenuId, setJobMenuId] = useAtom(gs_job_hot_menu);
|
const [jobMenuId, setJobMenuId] = useAtom(gs_job_hot_menu);
|
||||||
const [jobStatus, setJobStatus] = useAtom(gs_job_status);
|
const [jobStatus, setJobStatus] = useAtom(gs_job_status);
|
||||||
const [voteMenu, setVoteMenu] = useAtom(gs_vote_hotMenu);
|
const [voteMenu, setVoteMenu] = useAtom(gs_vote_hotMenu);
|
||||||
const [voeStatus, setVoteStatus] = useAtom(gs_vote_status);
|
const [voteStatus, setVoteStatus] = useAtom(gs_vote_status);
|
||||||
|
const [eventMenu, setEventMenu] = useAtom(gs_event_hotMenu);
|
||||||
|
const [eventStatus, setEventStatus] = useAtom(gs_event_status);
|
||||||
|
|
||||||
useShallowEffect(() => {
|
// useShallowEffect(() => {
|
||||||
onLoadData({
|
// onLoadData({
|
||||||
onLoad(val) {
|
// onLoad(val) {
|
||||||
setData(val);
|
// setData(val);
|
||||||
},
|
// },
|
||||||
});
|
// });
|
||||||
}, []);
|
// }, []);
|
||||||
|
|
||||||
async function onLoadData({ onLoad }: { onLoad: (val: any) => void }) {
|
// async function onLoadData({ onLoad }: { onLoad: (val: any) => void }) {
|
||||||
const loadData = await notifikasi_getByUserId({ page: 1 });
|
// const loadData = await notifikasi_getByUserId({ page: 1 });
|
||||||
onLoad(loadData);
|
// onLoad(loadData);
|
||||||
}
|
// }
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -71,17 +77,23 @@ export function Notifikasi_UiView({
|
|||||||
{(item) => (
|
{(item) => (
|
||||||
<ComponentNotifiaksi_CardView
|
<ComponentNotifiaksi_CardView
|
||||||
data={item}
|
data={item}
|
||||||
onLoadData={(val) => setData(val)}
|
onLoadData={setData}
|
||||||
activePage={activePage}
|
activePage={activePage}
|
||||||
onSetMenu={(val) => {
|
onSetMenu={(val) => {
|
||||||
if (item?.kategoriApp === "JOB") {
|
if (item?.kategoriApp === "JOB") {
|
||||||
setJobMenuId(val.menuId);
|
setJobMenuId(val.menuId);
|
||||||
setJobStatus(val.status);
|
setJobStatus(val.status);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item?.kategoriApp === "VOTING") {
|
if (item?.kategoriApp === "VOTING") {
|
||||||
setVoteMenu(val.menuId);
|
setVoteMenu(val.menuId);
|
||||||
setVoteStatus(val.status);
|
setVoteStatus(val.status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item?.kategoriApp === "EVENT") {
|
||||||
|
setEventMenu(val.menuId);
|
||||||
|
setEventStatus(val.status);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user