fix notifikasi
deskripsi: - fix load data notifikasi: semua, event, job, donasi, investasi
This commit is contained in:
@@ -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",
|
||||
},
|
||||
];
|
||||
|
||||
@@ -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,8 @@ 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 { gs_count_ntf } from "@/lib/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";
|
||||
@@ -24,18 +25,12 @@ import { notifikasi_eventCheckStatus } from "./path/event";
|
||||
import { redirectInvestasiPage } from "./path/investasi";
|
||||
import { notifikasi_jobCheckStatus } from "./path/job";
|
||||
import { notifikasi_votingCheckStatus } from "./path/voting";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import { redirectDetailForumPage } from "./path/forum";
|
||||
|
||||
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);
|
||||
@@ -65,25 +60,19 @@ export function ComponentNotifiaksi_CardView({
|
||||
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 +83,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 +100,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;
|
||||
@@ -143,21 +118,13 @@ export function ComponentNotifiaksi_CardView({
|
||||
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;
|
||||
@@ -168,30 +135,29 @@ export function ComponentNotifiaksi_CardView({
|
||||
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;
|
||||
}
|
||||
|
||||
// data?.kategoriApp === "FORUM" &&
|
||||
// redirectDetailForumPage({
|
||||
// data: data,
|
||||
// router: router,
|
||||
// });
|
||||
if (data?.kategoriApp === "FORUM") {
|
||||
redirectDetailForumPage({
|
||||
data: data,
|
||||
router: router,
|
||||
onSetVisible(val) {
|
||||
setVisible(val);
|
||||
},
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// data?.kategoriApp === "COLLABORATION" &&
|
||||
// redirectDetailCollaborationPage({
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user