@@ -1 +1 @@
|
||||
bun --env-file=.env run --bun dev -p 3005
|
||||
bun --env-file=.env run --bun dev -p 3000
|
||||
@@ -1 +1 @@
|
||||
bun --env-file=.env run --bun start
|
||||
bun --env-file=.env run --bun start -p 3005
|
||||
39
src/app/api/notifikasi/donasi/transaksi/[id]/route.ts
Normal file
39
src/app/api/notifikasi/donasi/transaksi/[id]/route.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { prisma } from "@/lib";
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
export async function GET(
|
||||
request: Request,
|
||||
{ params }: { params: { id: string } }
|
||||
) {
|
||||
try {
|
||||
const { id } = params;
|
||||
console.log("id server", id);
|
||||
const data = await prisma.donasi_Invoice.findUnique({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
select: {
|
||||
// DonasiMaster_Status: true,
|
||||
DonasiMaster_StatusInvoice: true,
|
||||
},
|
||||
});
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: "Berhasil di check transaksis donasi",
|
||||
statusTransaksi: _.lowerCase(data?.DonasiMaster_StatusInvoice?.name),
|
||||
});
|
||||
} catch (error) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: false,
|
||||
message: "Gagal di check transaksis donasi",
|
||||
reason: (error as Error).message,
|
||||
},
|
||||
{
|
||||
status: 500,
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
89
src/app/api/notifikasi/kategori/[name]/route.ts
Normal file
89
src/app/api/notifikasi/kategori/[name]/route.ts
Normal file
@@ -0,0 +1,89 @@
|
||||
import { prisma } from "@/lib";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import { ICategoryapp } from "@/app_modules/notifikasi/model/interface";
|
||||
import backendLogger from "@/util/backendLogger";
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export async function GET(
|
||||
request: Request,
|
||||
{ params }: { params: { name: string } }
|
||||
) {
|
||||
try {
|
||||
let fixData;
|
||||
const { name } = params;
|
||||
const { searchParams } = new URL(request.url);
|
||||
const page = searchParams.get("page");
|
||||
|
||||
const takeData = 10;
|
||||
const skipData = Number(page) * takeData - takeData;
|
||||
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
if (!userLoginId)
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "User not found" },
|
||||
{ status: 404 }
|
||||
);
|
||||
|
||||
if (!page) {
|
||||
fixData = await prisma.notifikasi.findMany({
|
||||
orderBy: [
|
||||
{
|
||||
isRead: "asc",
|
||||
},
|
||||
{ createdAt: "desc" },
|
||||
],
|
||||
where: {
|
||||
userId: userLoginId,
|
||||
userRoleId: "1",
|
||||
},
|
||||
});
|
||||
} else {
|
||||
const fixNameKategori = _.startCase(name);
|
||||
if (fixNameKategori === "Semua") {
|
||||
fixData = await prisma.notifikasi.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: [
|
||||
{
|
||||
isRead: "asc",
|
||||
},
|
||||
{ createdAt: "desc" },
|
||||
],
|
||||
where: {
|
||||
userId: userLoginId,
|
||||
userRoleId: "1",
|
||||
},
|
||||
});
|
||||
} else {
|
||||
fixData = await prisma.notifikasi.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: [
|
||||
{
|
||||
isRead: "asc",
|
||||
},
|
||||
{ createdAt: "desc" },
|
||||
],
|
||||
where: {
|
||||
userId: userLoginId,
|
||||
userRoleId: "1",
|
||||
kategoriApp: _.upperCase(name),
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return NextResponse.json(
|
||||
{ success: true, data: fixData, message: "Berhasil mendapatkan data" },
|
||||
{ status: 200 }
|
||||
);
|
||||
} catch (error) {
|
||||
backendLogger.error("Error get data notifikasi: " + error);
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "Gagal mendapatkan data" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
88
src/app/api/notifikasi/kategori/route.ts
Normal file
88
src/app/api/notifikasi/kategori/route.ts
Normal file
@@ -0,0 +1,88 @@
|
||||
import { prisma } from "@/lib";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import { ICategoryapp } from "@/app_modules/notifikasi/model/interface";
|
||||
import backendLogger from "@/util/backendLogger";
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export async function GET(
|
||||
request: Request,
|
||||
) {
|
||||
try {
|
||||
let fixData;
|
||||
const { searchParams } = new URL(request.url);
|
||||
const category = searchParams.get("category") as ICategoryapp;
|
||||
const page = searchParams.get("page");
|
||||
|
||||
const takeData = 10;
|
||||
const skipData = Number(page) * takeData - takeData;
|
||||
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
if (!userLoginId)
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "User not found" },
|
||||
{ status: 404 }
|
||||
);
|
||||
|
||||
if (!page) {
|
||||
fixData = await prisma.notifikasi.findMany({
|
||||
orderBy: [
|
||||
{
|
||||
isRead: "asc",
|
||||
},
|
||||
{ createdAt: "desc" },
|
||||
],
|
||||
where: {
|
||||
userId: userLoginId,
|
||||
userRoleId: "1",
|
||||
},
|
||||
});
|
||||
} else {
|
||||
const fixNameKategori = _.startCase(category);
|
||||
if (fixNameKategori === "Semua") {
|
||||
fixData = await prisma.notifikasi.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: [
|
||||
{
|
||||
isRead: "asc",
|
||||
},
|
||||
{ createdAt: "desc" },
|
||||
],
|
||||
where: {
|
||||
userId: userLoginId,
|
||||
userRoleId: "1",
|
||||
},
|
||||
});
|
||||
} else {
|
||||
fixData = await prisma.notifikasi.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: [
|
||||
{
|
||||
isRead: "asc",
|
||||
},
|
||||
{ createdAt: "desc" },
|
||||
],
|
||||
where: {
|
||||
userId: userLoginId,
|
||||
userRoleId: "1",
|
||||
kategoriApp: _.upperCase(category),
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return NextResponse.json(
|
||||
{ success: true, data: fixData, message: "Berhasil mendapatkan data" },
|
||||
{ status: 200 }
|
||||
);
|
||||
} catch (error) {
|
||||
backendLogger.error("Error get data notifikasi: " + error);
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "Gagal mendapatkan data" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import statusTransaksi from "../../../../src/bin/seeder/master/master_status_transaksi.json"
|
||||
import statusTransaksi from "../../../../src/bin/seeder/master/master_status_transaksi.json";
|
||||
import masterKategoriApp from "../../../../src/bin/seeder/master/master_kategori_app.json";
|
||||
|
||||
export const globalStatusApp = [
|
||||
{
|
||||
@@ -19,4 +20,36 @@ export const globalStatusApp = [
|
||||
},
|
||||
];
|
||||
|
||||
export const globalStatusTransaksi = statusTransaksi;
|
||||
export const globalStatusTransaksi = statusTransaksi;
|
||||
|
||||
export const globalMasterApp = [
|
||||
{ id: "0", name: "Semua" },
|
||||
{
|
||||
id: "1",
|
||||
name: "Event",
|
||||
},
|
||||
{
|
||||
id: "2",
|
||||
name: "Job",
|
||||
},
|
||||
{
|
||||
id: "3",
|
||||
name: "Voting",
|
||||
},
|
||||
{
|
||||
id: "4",
|
||||
name: "Donasi",
|
||||
},
|
||||
{
|
||||
id: "5",
|
||||
name: "Investasi",
|
||||
},
|
||||
{
|
||||
id: "6",
|
||||
name: "Forum",
|
||||
},
|
||||
{
|
||||
id: "7",
|
||||
name: "Collaboration",
|
||||
},
|
||||
];
|
||||
|
||||
@@ -36,6 +36,8 @@ import colab_funCreatePartisipan from "../../fun/create/fun_create_partisipan_by
|
||||
import { MODEL_COLLABORATION_PARTISIPASI } from "../../model/interface";
|
||||
import { Collaboration_SkeletonListPrtisipanIsUser } from "../skeleton_view";
|
||||
import ComponentColab_AuthorNameOnListPartisipan from "./header_author_list_partisipan";
|
||||
import { WibuRealtime } from "wibu-pkg";
|
||||
import { IRealtimeData } from "@/lib/global_state";
|
||||
|
||||
export default function ComponentColab_DetailListPartisipasiUser({
|
||||
userLoginId,
|
||||
@@ -103,37 +105,42 @@ export default function ComponentColab_DetailListPartisipasiUser({
|
||||
});
|
||||
|
||||
if (res.status === 201) {
|
||||
// const dataNotif = {
|
||||
// appId: res?.data?.ProjectCollaboration?.id,
|
||||
// userId: res?.data?.ProjectCollaboration?.userId,
|
||||
// pesan: res?.data?.ProjectCollaboration?.title,
|
||||
// status: "Partisipan Project",
|
||||
// kategoriApp: "COLLABORATION",
|
||||
// title: "Partisipan baru telah bergabung !",
|
||||
// };
|
||||
const dataNotifikasi: IRealtimeData = {
|
||||
appId: res?.data?.ProjectCollaboration?.id,
|
||||
userId: res?.data?.ProjectCollaboration?.userId as any,
|
||||
pesan: res?.data?.ProjectCollaboration?.title,
|
||||
status: "Partisipan Project" as any,
|
||||
kategoriApp: "COLLABORATION",
|
||||
title: "Partisipan baru telah bergabung !",
|
||||
};
|
||||
|
||||
// const createNotifikasi = await notifikasiToUser_funCreate({
|
||||
// data: dataNotif as any,
|
||||
// });
|
||||
const createNotifikasi = await notifikasiToUser_funCreate({
|
||||
data: dataNotifikasi as any,
|
||||
});
|
||||
|
||||
// if (createNotifikasi.status === 201) {
|
||||
// mqtt_client.publish(
|
||||
// "USER",
|
||||
// JSON.stringify({
|
||||
// userId: dataNotif.userId,
|
||||
// count: 1,
|
||||
// })
|
||||
// );
|
||||
// }
|
||||
if (createNotifikasi.status === 201) {
|
||||
WibuRealtime.setData({
|
||||
type: "trigger",
|
||||
pushNotificationTo: "USER",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
// mqtt_client.publish(
|
||||
// "USER",
|
||||
// JSON.stringify({
|
||||
// userId: dataNotif.userId,
|
||||
// count: 1,
|
||||
// })
|
||||
// );
|
||||
}
|
||||
|
||||
const respone = await apiGetOneCollaborationById({
|
||||
const response = await apiGetOneCollaborationById({
|
||||
id: params.id,
|
||||
kategori: "list_partisipan",
|
||||
page: `${activePage}`,
|
||||
});
|
||||
|
||||
if (respone) {
|
||||
setData(respone.data);
|
||||
if (response) {
|
||||
setData(response.data);
|
||||
}
|
||||
|
||||
const cekPartisipan = await apiGetOneCollaborationById({
|
||||
@@ -274,8 +281,8 @@ export default function ComponentColab_DetailListPartisipasiUser({
|
||||
}
|
||||
styles={{
|
||||
input: {
|
||||
backgroundColor: MainColor.white
|
||||
}
|
||||
backgroundColor: MainColor.white,
|
||||
},
|
||||
}}
|
||||
placeholder="Deskripsikan diri anda yang sesuai dengan proyek ini.."
|
||||
minRows={4}
|
||||
|
||||
@@ -12,37 +12,46 @@ export default async function colab_funCreatePartisipan({
|
||||
id: string;
|
||||
deskripsi: string;
|
||||
}) {
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
try {
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
if (userLoginId == null) {
|
||||
return {
|
||||
status: 500,
|
||||
message: "Gagal mendapatkan data, user id tidak ada",
|
||||
};
|
||||
}
|
||||
if (!userLoginId) {
|
||||
return {
|
||||
status: 404,
|
||||
message: "Gagal mendapatkan data, user id tidak ada",
|
||||
};
|
||||
}
|
||||
|
||||
const create = await prisma.projectCollaboration_Partisipasi.create({
|
||||
data: {
|
||||
projectCollaborationId: id,
|
||||
userId: userLoginId,
|
||||
deskripsi_diri: deskripsi,
|
||||
},
|
||||
select: {
|
||||
ProjectCollaboration: {
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
userId: true,
|
||||
const create = await prisma.projectCollaboration_Partisipasi.create({
|
||||
data: {
|
||||
projectCollaborationId: id,
|
||||
userId: userLoginId,
|
||||
deskripsi_diri: deskripsi,
|
||||
},
|
||||
select: {
|
||||
ProjectCollaboration: {
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
userId: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
if (!create) return { status: 400, message: "Gagal menambahkan partisipan" };
|
||||
revalidatePath(RouterColab.main_detail + id);
|
||||
return {
|
||||
data: create,
|
||||
status: 201,
|
||||
message: "Berhasil menambahkan partisipan",
|
||||
};
|
||||
if (!create)
|
||||
return { status: 400, message: "Gagal menambahkan partisipan" };
|
||||
revalidatePath(RouterColab.main_detail + id);
|
||||
return {
|
||||
data: create,
|
||||
status: 201,
|
||||
message: "Berhasil menambahkan partisipan",
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
status: 500,
|
||||
message: "Error menambahkan partisipan",
|
||||
error: (error as Error).message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,33 +23,36 @@ import { Event_funDeleteById } from "../../fun/delete/fun_delete";
|
||||
import { Event_funEditStatusById } from "../../fun/edit/fun_edit_status_by_id";
|
||||
|
||||
export default function Event_DetailDraft() {
|
||||
const params = useParams<{ id: string }>();
|
||||
const eventId = params.id as string;
|
||||
const [data, setData] = useState<MODEL_EVENT | null>(null);
|
||||
const params = useParams<{ id: string }>();
|
||||
const eventId = params.id as string;
|
||||
const [data, setData] = useState<MODEL_EVENT | null>(null);
|
||||
|
||||
useShallowEffect(() => {
|
||||
onLoadData();
|
||||
}, []);
|
||||
useShallowEffect(() => {
|
||||
onLoadData();
|
||||
}, []);
|
||||
|
||||
async function onLoadData() {
|
||||
try {
|
||||
const respone = await apiGetEventDetailById({
|
||||
id: eventId,
|
||||
});
|
||||
async function onLoadData() {
|
||||
try {
|
||||
const respone = await apiGetEventDetailById({
|
||||
id: eventId,
|
||||
});
|
||||
|
||||
if (respone) {
|
||||
setData(respone.data);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error get data detail event", error);
|
||||
}
|
||||
}
|
||||
if (respone) {
|
||||
setData(respone.data);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error get data detail event", error);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack spacing={"lg"}>
|
||||
<ComponentEvent_DetailData isReport data={data} />
|
||||
<ButtonAction eventId={eventId} endDate={data?.tanggalSelesai} />
|
||||
<ButtonAction
|
||||
eventId={eventId}
|
||||
endDate={data?.tanggalSelesai}
|
||||
/>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
@@ -62,7 +65,6 @@ function ButtonAction({ eventId, endDate }: { eventId: string; endDate: any }) {
|
||||
const [openModal1, setOpenModal1] = useState(false);
|
||||
const [openModal2, setOpenModal2] = useState(false);
|
||||
|
||||
|
||||
async function onDelete() {
|
||||
try {
|
||||
const res = await Event_funDeleteById(eventId);
|
||||
@@ -86,7 +88,9 @@ function ButtonAction({ eventId, endDate }: { eventId: string; endDate: any }) {
|
||||
}
|
||||
|
||||
async function onAjukan() {
|
||||
if (moment(endDate.toISOString().toString()).diff(moment(), "minutes") < 0)
|
||||
// console.log("end Date", endDate)
|
||||
|
||||
if (moment(endDate).diff(moment(), "minutes") < 0)
|
||||
return ComponentGlobal_NotifikasiPeringatan("Waktu acara telah lewat");
|
||||
|
||||
try {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"use client";
|
||||
import { gs_count_ntf, gs_user_ntf } from "@/lib/global_state";
|
||||
import { gs_user_ntf } from "@/lib/global_state";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import { useAtom } from "jotai";
|
||||
import { useState } from "react";
|
||||
@@ -22,7 +22,7 @@ export default function HomeView({
|
||||
}) {
|
||||
const [countNtf, setCountNtf] = useState(countNotifikasi);
|
||||
const [newUserNtf, setNewUserNtf] = useAtom(gs_user_ntf);
|
||||
const [countLoadNtf, setCountLoadNtf] = useAtom(gs_count_ntf);
|
||||
// const [countLoadNtf, setCountLoadNtf] = useAtom(gs_count_ntf);
|
||||
const userRoleId = dataUser.masterUserRoleId;
|
||||
|
||||
// useShallowEffect(() => {
|
||||
@@ -33,15 +33,15 @@ export default function HomeView({
|
||||
// }
|
||||
// }, [userRoleId]);
|
||||
|
||||
useShallowEffect(() => {
|
||||
onLoadNotifikasi({
|
||||
onLoad(val) {
|
||||
setCountNtf(val);
|
||||
},
|
||||
});
|
||||
// useShallowEffect(() => {
|
||||
// onLoadNotifikasi({
|
||||
// onLoad(val) {
|
||||
// setCountNtf(val);
|
||||
// },
|
||||
// });
|
||||
|
||||
setCountNtf(countLoadNtf as any);
|
||||
}, [countLoadNtf, setCountNtf]);
|
||||
// setCountNtf(countLoadNtf as any);
|
||||
// }, [countLoadNtf, setCountNtf]);
|
||||
|
||||
useShallowEffect(() => {
|
||||
setCountNtf(countNtf + newUserNtf);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"use client";
|
||||
import { gs_count_ntf, gs_user_ntf } from "@/lib/global_state";
|
||||
import { gs_user_ntf } from "@/lib/global_state";
|
||||
import global_limit from "@/lib/limit";
|
||||
import { RouterProfile } from "@/lib/router_hipmi/router_katalog";
|
||||
import { RouterNotifikasi } from "@/lib/router_hipmi/router_notifikasi";
|
||||
@@ -20,7 +20,7 @@ import FooterHome from "./component/footer_home";
|
||||
import { apiGetDataHome, apiGetNotifikasiHome } from "./fun/get/api_home";
|
||||
|
||||
export default function HomeViewNew() {
|
||||
const [countNtf, setCountNtf] = useAtom(gs_count_ntf);
|
||||
const [countNtf, setCountNtf] = useState<number | null>(null);
|
||||
const [newUserNtf, setNewUserNtf] = useAtom(gs_user_ntf);
|
||||
const [dataUser, setDataUser] = useState<any | null>(null);
|
||||
const [categoryPage, setCategoryPage] = useAtom(gs_notifikasi_kategori_app);
|
||||
@@ -31,7 +31,7 @@ export default function HomeViewNew() {
|
||||
setCountNtf(countNtf + newUserNtf);
|
||||
setNewUserNtf(0);
|
||||
}
|
||||
}, [newUserNtf, countNtf]);
|
||||
}, [newUserNtf]);
|
||||
|
||||
useShallowEffect(() => {
|
||||
hanlderLoadData();
|
||||
@@ -77,6 +77,7 @@ export default function HomeViewNew() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<UIGlobal_LayoutTamplate
|
||||
@@ -84,7 +85,7 @@ export default function HomeViewNew() {
|
||||
<UIGlobal_LayoutHeaderTamplate
|
||||
title="HIPMI"
|
||||
customButtonLeft={
|
||||
!dataUser || !countNtf ? (
|
||||
!dataUser && !countNtf ? (
|
||||
<ActionIcon radius={"xl"} variant={"transparent"}>
|
||||
<IconUserSearch color={"gray"} />
|
||||
</ActionIcon>
|
||||
@@ -111,7 +112,7 @@ export default function HomeViewNew() {
|
||||
)
|
||||
}
|
||||
customButtonRight={
|
||||
!dataUser || !countNtf ? (
|
||||
!dataUser && !countNtf ? (
|
||||
<ActionIcon radius={"xl"} variant={"transparent"}>
|
||||
<IconBell color={"gray"} />
|
||||
</ActionIcon>
|
||||
|
||||
@@ -15,8 +15,8 @@ import {
|
||||
Notifikasi_ComponentSkeletonView,
|
||||
} from "../component";
|
||||
import { gs_notifikasi_kategori_app } from "../lib";
|
||||
import { apiGetAllNotifikasiByCategory } from "../lib/api_notifikasi";
|
||||
import { MODEL_NOTIFIKASI } from "../model/interface";
|
||||
import { apiGetAllNotifikasiByCategory } from "../lib/api_fetch_notifikasi";
|
||||
|
||||
export default function Notifikasi_UiMain({
|
||||
userLoginId,
|
||||
@@ -82,9 +82,6 @@ export default function Notifikasi_UiMain({
|
||||
{(item) => (
|
||||
<ComponentNotifiaksi_CardView
|
||||
data={item}
|
||||
onLoadData={setData}
|
||||
categoryPage={categoryPage as any}
|
||||
userLoginId={userLoginId}
|
||||
/>
|
||||
)}
|
||||
</ScrollOnly>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
"use client";
|
||||
|
||||
import { gs_count_ntf } from "@/lib/global_state";
|
||||
import {
|
||||
AccentColor,
|
||||
MainColor,
|
||||
@@ -11,6 +10,7 @@ import { gs_event_hotMenu } from "@/app_modules/event/global_state";
|
||||
import { gs_investas_menu } from "@/app_modules/investasi/g_state";
|
||||
import { gs_job_hot_menu } from "@/app_modules/job/global_state";
|
||||
import { gs_vote_hotMenu } from "@/app_modules/vote/global_state";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import { Badge, Card, Divider, Group, Stack, Text } from "@mantine/core";
|
||||
import { IconCheck, IconChecks } from "@tabler/icons-react";
|
||||
import { useAtom } from "jotai";
|
||||
@@ -21,25 +21,19 @@ import { useState } from "react";
|
||||
import { MODEL_NOTIFIKASI } from "../model/interface";
|
||||
import { redirectDonasiPage } from "./path/donasi";
|
||||
import { notifikasi_eventCheckStatus } from "./path/event";
|
||||
import { redirectDetailForumPage } from "./path/forum";
|
||||
import { redirectInvestasiPage } from "./path/investasi";
|
||||
import { notifikasi_jobCheckStatus } from "./path/job";
|
||||
import { notifikasi_votingCheckStatus } from "./path/voting";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import { redirectDetailCollaborationPage } from "./path/collaboration";
|
||||
|
||||
export function ComponentNotifiaksi_CardView({
|
||||
data,
|
||||
onLoadData,
|
||||
categoryPage,
|
||||
userLoginId,
|
||||
}: {
|
||||
data: MODEL_NOTIFIKASI;
|
||||
onLoadData: (val: any) => void;
|
||||
categoryPage: string;
|
||||
userLoginId?: string
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [visible, setVisible] = useState(false);
|
||||
const [loadCountNtf, setLoadCountNtf] = useAtom(gs_count_ntf);
|
||||
|
||||
const [jobMenuId, setJobMenuId] = useAtom(gs_job_hot_menu);
|
||||
const [eventMenuId, setEventMenuId] = useAtom(gs_event_hotMenu);
|
||||
@@ -64,26 +58,20 @@ export function ComponentNotifiaksi_CardView({
|
||||
onClick={async () => {
|
||||
try {
|
||||
setVisible(true);
|
||||
console.log("data", data);
|
||||
|
||||
// JOB
|
||||
if (data?.kategoriApp === "JOB") {
|
||||
await notifikasi_jobCheckStatus({
|
||||
appId: data.appId,
|
||||
dataId: data.id,
|
||||
categoryPage: categoryPage,
|
||||
router: router,
|
||||
onLoadDataJob(val) {
|
||||
onLoadData(val);
|
||||
},
|
||||
onSetJobMenuId(val) {
|
||||
setJobMenuId(val);
|
||||
},
|
||||
onSetVisible(val) {
|
||||
setVisible(val);
|
||||
},
|
||||
onLoadCountNtf(val) {
|
||||
setLoadCountNtf(val);
|
||||
},
|
||||
});
|
||||
|
||||
return;
|
||||
@@ -94,20 +82,13 @@ export function ComponentNotifiaksi_CardView({
|
||||
await notifikasi_eventCheckStatus({
|
||||
appId: data.appId,
|
||||
dataId: data.id,
|
||||
categoryPage: categoryPage,
|
||||
router: router,
|
||||
onLoadDataEvent(val) {
|
||||
onLoadData(val);
|
||||
},
|
||||
onSetVisible(val) {
|
||||
setVisible(val);
|
||||
},
|
||||
onSetEventMenuId(val) {
|
||||
setEventMenuId(val);
|
||||
},
|
||||
onLoadCountNtf(val) {
|
||||
setLoadCountNtf(val);
|
||||
},
|
||||
});
|
||||
|
||||
return;
|
||||
@@ -118,20 +99,13 @@ export function ComponentNotifiaksi_CardView({
|
||||
await notifikasi_votingCheckStatus({
|
||||
appId: data.appId,
|
||||
dataId: data.id,
|
||||
categoryPage: categoryPage,
|
||||
router: router,
|
||||
onLoadDataEvent(val) {
|
||||
onLoadData(val);
|
||||
},
|
||||
onSetVisible(val) {
|
||||
setVisible(val);
|
||||
},
|
||||
onSetMenuId(val) {
|
||||
setVotingMenu(val);
|
||||
},
|
||||
onLoadCountNtf(val) {
|
||||
setLoadCountNtf(val);
|
||||
},
|
||||
});
|
||||
|
||||
return;
|
||||
@@ -139,25 +113,17 @@ export function ComponentNotifiaksi_CardView({
|
||||
|
||||
// DONASI
|
||||
if (data?.kategoriApp === "DONASI") {
|
||||
redirectDonasiPage({
|
||||
await redirectDonasiPage({
|
||||
appId: data.appId,
|
||||
dataId: data.id,
|
||||
userId: data.userId,
|
||||
userLoginId: userLoginId as any,
|
||||
categoryPage: categoryPage,
|
||||
router: router,
|
||||
onLoadDataEvent(val) {
|
||||
onLoadData(val);
|
||||
},
|
||||
onSetVisible(val) {
|
||||
setVisible(val);
|
||||
},
|
||||
onSetMenuId(val) {
|
||||
setDonasiMenu(val);
|
||||
},
|
||||
onLoadCountNtf(val) {
|
||||
setLoadCountNtf(val);
|
||||
},
|
||||
});
|
||||
|
||||
return;
|
||||
@@ -165,39 +131,44 @@ export function ComponentNotifiaksi_CardView({
|
||||
|
||||
// INVESTASI
|
||||
if (data?.kategoriApp === "INVESTASI") {
|
||||
redirectInvestasiPage({
|
||||
await redirectInvestasiPage({
|
||||
appId: data.appId,
|
||||
dataId: data.id,
|
||||
categoryPage: categoryPage,
|
||||
router: router,
|
||||
onLoadDataEvent(val) {
|
||||
onLoadData(val);
|
||||
},
|
||||
onSetVisible(val) {
|
||||
setVisible(val);
|
||||
},
|
||||
onSetMenuId(val) {
|
||||
setInvestasiMenu(val);
|
||||
},
|
||||
onLoadCountNtf(val) {
|
||||
setLoadCountNtf(val);
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (data?.kategoriApp === "FORUM") {
|
||||
await redirectDetailForumPage({
|
||||
data: data,
|
||||
router: router,
|
||||
onSetVisible(val) {
|
||||
setVisible(val);
|
||||
},
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// data?.kategoriApp === "FORUM" &&
|
||||
// redirectDetailForumPage({
|
||||
// data: data,
|
||||
// router: router,
|
||||
// });
|
||||
if (data?.kategoriApp === "COLLABORATION") {
|
||||
await redirectDetailCollaborationPage({
|
||||
data: data,
|
||||
router: router,
|
||||
onSetVisible(val) {
|
||||
setVisible(val);
|
||||
},
|
||||
});
|
||||
|
||||
// data?.kategoriApp === "COLLABORATION" &&
|
||||
// redirectDetailCollaborationPage({
|
||||
// data: data,
|
||||
// router: router,
|
||||
// });
|
||||
return;
|
||||
}
|
||||
} catch (error) {
|
||||
setVisible(false);
|
||||
clientLogger.error("Error redirect notification page", error);
|
||||
|
||||
@@ -1,26 +1,40 @@
|
||||
import { RouterColab } from "@/lib/router_hipmi/router_colab";
|
||||
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
||||
import { MODEL_NOTIFIKASI } from "../../model/interface";
|
||||
import notifikasi_funUpdateIsReadById from "../../fun/update/fun_update_is_read_by_user_id";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
||||
|
||||
export function redirectDetailCollaborationPage({
|
||||
export async function redirectDetailCollaborationPage({
|
||||
data,
|
||||
router,
|
||||
onSetVisible,
|
||||
}: {
|
||||
data: MODEL_NOTIFIKASI;
|
||||
router: AppRouterInstance;
|
||||
onSetVisible(val: boolean): void;
|
||||
}) {
|
||||
if (data.status === "Partisipan Project") {
|
||||
const path = RouterColab.main_detail + data.appId;
|
||||
router.push(path, { scroll: false });
|
||||
try {
|
||||
if (data.status === "Partisipan Project") {
|
||||
const path = RouterColab.main_detail + data.appId;
|
||||
router.push(path, { scroll: false });
|
||||
}
|
||||
|
||||
if (data.status === "Collaboration Group") {
|
||||
const path = RouterColab.grup_diskusi;
|
||||
router.push(path, { scroll: false });
|
||||
}
|
||||
|
||||
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
||||
notifId: data.id,
|
||||
});
|
||||
|
||||
if (updateReadNotifikasi.status == 200) {
|
||||
onSetVisible(true);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error get all forum :", error);
|
||||
ComponentGlobal_NotifikasiPeringatan("Status tidak ditemukan");
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (data.status === "Collaboration Group") {
|
||||
const path = RouterColab.grup_diskusi;
|
||||
router.push(path, { scroll: false });
|
||||
}
|
||||
|
||||
// if (data.status === "Report Komentar") {
|
||||
// const path = RouterForum.detail_report_komentar + data.appId;
|
||||
// router.push(path, { scroll: false });
|
||||
|
||||
@@ -8,63 +8,66 @@ import notifikasi_countUserNotifikasi from "../../fun/count/fun_count_by_id";
|
||||
import notifikasi_funUpdateIsReadById from "../../fun/update/fun_update_is_read_by_user_id";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
||||
import { notifikasi_checkAuthorDonasiById } from "../../fun/check/fun_check_author_donasi_by_id";
|
||||
import { apiNotifikasiDonasiCheckTransaksiById } from "../../lib/api_fetch_ntf_donasi";
|
||||
import { cookies } from "next/headers";
|
||||
|
||||
export async function redirectDonasiPage({
|
||||
appId,
|
||||
dataId,
|
||||
categoryPage,
|
||||
userId,
|
||||
userLoginId,
|
||||
router,
|
||||
onLoadDataEvent,
|
||||
onSetMenuId,
|
||||
onSetVisible,
|
||||
onLoadCountNtf,
|
||||
}: {
|
||||
appId: string;
|
||||
dataId: string;
|
||||
categoryPage: string;
|
||||
userId: string;
|
||||
userLoginId: string;
|
||||
router: AppRouterInstance;
|
||||
onLoadDataEvent: (val: any) => void;
|
||||
onSetMenuId(val: number): void;
|
||||
onSetVisible(val: boolean): void;
|
||||
onLoadCountNtf(val: number): void;
|
||||
}) {
|
||||
const check = await notifikasi_funDonasiCheckStatus({ id: appId });
|
||||
const checkAuthor = await notifikasi_checkAuthorDonasiById({
|
||||
donasiId: appId,
|
||||
userId: userId,
|
||||
});
|
||||
|
||||
if (check.status == 200) {
|
||||
// const loadListNotifikasi = await notifikasi_getByUserId({
|
||||
// page: 1,
|
||||
// kategoriApp: categoryPage as any,
|
||||
// });
|
||||
// onLoadDataEvent(loadListNotifikasi);
|
||||
|
||||
// const loadCountNotifikasi = await notifikasi_countUserNotifikasi();
|
||||
// onLoadCountNtf(loadCountNotifikasi);
|
||||
|
||||
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
||||
notifId: dataId,
|
||||
if (check.statusName == "") {
|
||||
const checkTransaksi = await apiNotifikasiDonasiCheckTransaksiById({
|
||||
id: appId,
|
||||
});
|
||||
|
||||
if (updateReadNotifikasi.status == 200) {
|
||||
const pathToCreator = `/dev/donasi/detail/${check.statusName}/${appId}`;
|
||||
const pathToAllUser = `/dev/donasi/detail/main/${appId}`;
|
||||
if (checkTransaksi.success) {
|
||||
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
||||
notifId: dataId,
|
||||
});
|
||||
|
||||
if (checkAuthor) {
|
||||
router.push(pathToCreator, { scroll: false });
|
||||
} else {
|
||||
router.push(pathToAllUser, { scroll: false });
|
||||
onSetMenuId(1);
|
||||
if (updateReadNotifikasi.status == 200) {
|
||||
router.push(RouterDonasi.main_donasi_saya, { scroll: false });
|
||||
onSetMenuId(2);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
onSetVisible(false);
|
||||
ComponentGlobal_NotifikasiPeringatan("Status tidak ditemukan");
|
||||
const checkAuthor = await notifikasi_checkAuthorDonasiById({
|
||||
donasiId: appId,
|
||||
userId: userId,
|
||||
});
|
||||
|
||||
if (check.status == 200) {
|
||||
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
||||
notifId: dataId,
|
||||
});
|
||||
|
||||
if (updateReadNotifikasi.status == 200) {
|
||||
const pathToCreator = `/dev/donasi/detail/${check.statusName}/${appId}`;
|
||||
const pathToAllUser = `/dev/donasi/detail/main/${appId}`;
|
||||
|
||||
if (checkAuthor) {
|
||||
router.push(pathToCreator, { scroll: false });
|
||||
} else {
|
||||
router.push(pathToAllUser, { scroll: false });
|
||||
onSetMenuId(1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
onSetVisible(false);
|
||||
ComponentGlobal_NotifikasiPeringatan("Status tidak ditemukan");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,33 +8,19 @@ import notifikasi_countUserNotifikasi from "../../fun/count/fun_count_by_id";
|
||||
export async function notifikasi_eventCheckStatus({
|
||||
appId,
|
||||
dataId,
|
||||
categoryPage,
|
||||
router,
|
||||
onLoadDataEvent,
|
||||
onSetEventMenuId,
|
||||
onSetVisible,
|
||||
onLoadCountNtf,
|
||||
}: {
|
||||
appId: string;
|
||||
dataId: string;
|
||||
categoryPage: string
|
||||
router: AppRouterInstance;
|
||||
onLoadDataEvent: (val: any) => void;
|
||||
onSetEventMenuId(val: number): void;
|
||||
onSetVisible(val: boolean): void;
|
||||
onLoadCountNtf(val: number): void;
|
||||
}) {
|
||||
const check = await notifikasi_funEventCheckStatus({ id: appId });
|
||||
|
||||
if (check.status == 200) {
|
||||
const loadListNotifikasi = await notifikasi_getByUserId({
|
||||
page: 1,
|
||||
kategoriApp: categoryPage as any,
|
||||
});
|
||||
onLoadDataEvent(loadListNotifikasi);
|
||||
|
||||
const loadCountNotifikasi = await notifikasi_countUserNotifikasi();
|
||||
onLoadCountNtf(loadCountNotifikasi);
|
||||
|
||||
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
||||
notifId: dataId,
|
||||
|
||||
@@ -1,26 +1,46 @@
|
||||
import { RouterForum } from "@/lib/router_hipmi/router_forum";
|
||||
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
||||
import { MODEL_NOTIFIKASI } from "../../model/interface";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
||||
import notifikasi_funUpdateIsReadById from "../../fun/update/fun_update_is_read_by_user_id";
|
||||
|
||||
export function redirectDetailForumPage({
|
||||
export async function redirectDetailForumPage({
|
||||
data,
|
||||
router,
|
||||
onSetVisible,
|
||||
}: {
|
||||
data: MODEL_NOTIFIKASI;
|
||||
router: AppRouterInstance;
|
||||
onSetVisible(val: boolean): void;
|
||||
}) {
|
||||
if (data.status === null) {
|
||||
const path = RouterForum.main_detail + data.appId;
|
||||
router.push(path, { scroll: false });
|
||||
}
|
||||
try {
|
||||
if (data.status === null) {
|
||||
const path = RouterForum.main_detail + data.appId;
|
||||
router.push(path, { scroll: false });
|
||||
}
|
||||
|
||||
if (data.status === "Report Komentar") {
|
||||
const path = RouterForum.detail_report_komentar + data.appId;
|
||||
router.push(path, { scroll: false });
|
||||
}
|
||||
if (data.status === "Report Komentar") {
|
||||
const path = RouterForum.detail_report_komentar + data.appId;
|
||||
router.push(path, { scroll: false });
|
||||
}
|
||||
|
||||
if (data.status === "Report Posting") {
|
||||
const path = RouterForum.detail_report_posting + data.appId;
|
||||
router.push(path, { scroll: false });
|
||||
if (data.status === "Report Posting") {
|
||||
const path = RouterForum.detail_report_posting + data.appId;
|
||||
router.push(path, { scroll: false });
|
||||
}
|
||||
|
||||
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
||||
notifId: data.id,
|
||||
});
|
||||
|
||||
if (updateReadNotifikasi.status == 200) {
|
||||
onSetVisible(true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
} catch (error) {
|
||||
console.error("Error get all forum :", error);
|
||||
ComponentGlobal_NotifikasiPeringatan("Status tidak ditemukan");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,21 +16,15 @@ import {
|
||||
export async function redirectInvestasiPage({
|
||||
appId,
|
||||
dataId,
|
||||
categoryPage,
|
||||
router,
|
||||
onLoadDataEvent,
|
||||
onSetMenuId,
|
||||
onSetVisible,
|
||||
onLoadCountNtf,
|
||||
}: {
|
||||
appId: string;
|
||||
dataId: string;
|
||||
categoryPage: string;
|
||||
router: AppRouterInstance;
|
||||
onLoadDataEvent: (val: any) => void;
|
||||
onSetMenuId(val: number): void;
|
||||
onSetVisible(val: boolean): void;
|
||||
onLoadCountNtf(val: number): void;
|
||||
}) {
|
||||
const check = await notifikasi_funInvestasiCheckStatus({ id: appId });
|
||||
const checkInvestor = await notifikasi_funInvestasiChecInvestaorStatus({
|
||||
|
||||
@@ -8,35 +8,20 @@ import notifikasi_countUserNotifikasi from "../../fun/count/fun_count_by_id";
|
||||
export async function notifikasi_jobCheckStatus({
|
||||
appId,
|
||||
dataId,
|
||||
categoryPage,
|
||||
router,
|
||||
onLoadDataJob,
|
||||
onSetJobMenuId,
|
||||
onSetVisible,
|
||||
onLoadCountNtf,
|
||||
}: {
|
||||
appId: string;
|
||||
dataId: string;
|
||||
categoryPage:string
|
||||
router: AppRouterInstance;
|
||||
onLoadDataJob: (val: any) => void;
|
||||
onSetJobMenuId(val: number): void;
|
||||
onSetVisible(val: boolean): void;
|
||||
onLoadCountNtf(val: number): void;
|
||||
}) {
|
||||
const check = await notifikasi_funJobCheckStatus({
|
||||
id: appId,
|
||||
});
|
||||
|
||||
const loadListNotifikasi = await notifikasi_getByUserId({
|
||||
page: 1,
|
||||
kategoriApp: categoryPage as any,
|
||||
});
|
||||
onLoadDataJob(loadListNotifikasi);
|
||||
|
||||
const loadCountNotifikasi = await notifikasi_countUserNotifikasi();
|
||||
onLoadCountNtf(loadCountNotifikasi);
|
||||
|
||||
if (check.status == 200) {
|
||||
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
||||
notifId: dataId,
|
||||
|
||||
@@ -10,34 +10,19 @@ import notifikasi_funUpdateIsReadById from "../../fun/update/fun_update_is_read_
|
||||
export async function notifikasi_votingCheckStatus({
|
||||
appId,
|
||||
dataId,
|
||||
categoryPage,
|
||||
router,
|
||||
onLoadDataEvent,
|
||||
onSetMenuId,
|
||||
onSetVisible,
|
||||
onLoadCountNtf,
|
||||
}: {
|
||||
appId: string;
|
||||
dataId: string;
|
||||
categoryPage: string;
|
||||
router: AppRouterInstance;
|
||||
onLoadDataEvent: (val: any) => void;
|
||||
onSetMenuId(val: number): void;
|
||||
onSetVisible(val: boolean): void;
|
||||
onLoadCountNtf(val: number): void;
|
||||
}) {
|
||||
const check = await notifikasi_funVotingCheckStatus({ id: appId });
|
||||
|
||||
if (check.status == 200) {
|
||||
const loadListNotifikasi = await notifikasi_getByUserId({
|
||||
page: 1,
|
||||
kategoriApp: categoryPage as any,
|
||||
});
|
||||
onLoadDataEvent(loadListNotifikasi);
|
||||
|
||||
const loadCountNotifikasi = await notifikasi_countUserNotifikasi();
|
||||
onLoadCountNtf(loadCountNotifikasi);
|
||||
|
||||
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
||||
notifId: dataId,
|
||||
});
|
||||
@@ -52,6 +37,4 @@ export async function notifikasi_votingCheckStatus({
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiPeringatan("Status tidak ditemukan");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
46
src/app_modules/notifikasi/lib/api_fetch_notifikasi.ts
Normal file
46
src/app_modules/notifikasi/lib/api_fetch_notifikasi.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { API_RouteNotifikasi } from "@/lib/api_user_router/route_api_notifikasi";
|
||||
import { ICategoryapp } from "../model/interface";
|
||||
|
||||
export const apiGetAllNotifikasiByCategory = async ({
|
||||
category,
|
||||
page,
|
||||
}: {
|
||||
category: ICategoryapp;
|
||||
page: number;
|
||||
}) => {
|
||||
try {
|
||||
// Fetch token from cookie
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) {
|
||||
console.error("No token found");
|
||||
return null;
|
||||
}
|
||||
|
||||
const isCategory = category ? `?category=${category}` : "";
|
||||
const isPage = page ? `&page=${page}` : "";
|
||||
const response = await fetch(
|
||||
`/api/notifikasi/kategori${isCategory}${isPage}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
// Check if the response is OK
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json().catch(() => null);
|
||||
console.error("Failed to get all forum:", response.statusText, errorData);
|
||||
throw new Error(errorData?.message || "Failed to get all forum");
|
||||
}
|
||||
|
||||
// Return the JSON response
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
console.error("Error get all forum", error);
|
||||
throw error; // Re-throw the error to handle it in the calling function
|
||||
}
|
||||
};
|
||||
44
src/app_modules/notifikasi/lib/api_fetch_ntf_donasi.ts
Normal file
44
src/app_modules/notifikasi/lib/api_fetch_ntf_donasi.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
export { apiNotifikasiDonasiCheckTransaksiById };
|
||||
|
||||
const apiNotifikasiDonasiCheckTransaksiById = async ({
|
||||
id,
|
||||
}: {
|
||||
id: string;
|
||||
}) => {
|
||||
try {
|
||||
// Fetch token from cookie
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) {
|
||||
console.error("No token found");
|
||||
return null;
|
||||
}
|
||||
|
||||
const response = await fetch(`/api/notifikasi/donasi/transaksi/${id}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
|
||||
// Check if the response is OK
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json().catch(() => null);
|
||||
console.error(
|
||||
"Failed to check donasi transaksi:",
|
||||
response.statusText,
|
||||
errorData
|
||||
);
|
||||
throw new Error(
|
||||
errorData?.message || "Failed to check donasi transaksi:"
|
||||
);
|
||||
}
|
||||
|
||||
// Return the JSON response
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
console.error("Error to check donasi transaksi:", error);
|
||||
throw error; // Re-throw the error to handle it in the calling function
|
||||
}
|
||||
};
|
||||
@@ -1,10 +0,0 @@
|
||||
import { API_RouteNotifikasi } from "@/lib/api_user_router/route_api_notifikasi";
|
||||
import { ICategoryapp } from "../model/interface";
|
||||
|
||||
export const apiGetAllNotifikasiByCategory = async ({category, page}: {category: ICategoryapp; page: number}) => {
|
||||
const respone = await fetch(
|
||||
`/api/notifikasi/get-all-by-category?category=${category}&page=${page}`
|
||||
);
|
||||
|
||||
return await respone.json().catch(() => null);
|
||||
}
|
||||
@@ -17,7 +17,9 @@ export type ITypeStatusNotifikasi =
|
||||
| "Berhasil"
|
||||
| "Proses"
|
||||
| "Menunggu"
|
||||
| "Gagal";
|
||||
| "Gagal"
|
||||
// Collaboration
|
||||
| "Partisipan Project"
|
||||
|
||||
/**
|
||||
* @param kategoriApp | "JOB", "VOTING", "EVENT", "DONASI", "INVESTASI", "COLLABORATION", "FORUM"
|
||||
|
||||
@@ -246,6 +246,17 @@ export default function RealtimeProvider({
|
||||
}
|
||||
|
||||
// ---------------------- INVESTASI ------------------------- //
|
||||
|
||||
// ---------------------- COLLABORATION ------------------------- //
|
||||
if (
|
||||
data.type == "trigger" &&
|
||||
data.pushNotificationTo == "USER" &&
|
||||
data.dataMessage?.kategoriApp == "COLLABORATION" &&
|
||||
data.dataMessage?.status == "Partisipan Project"
|
||||
) {
|
||||
setNewUserNtf((e) => e + 1);
|
||||
}
|
||||
// ---------------------- COLLABORATION ------------------------- //
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user