fix notifikasi
deskripsi: - fix load data notifikasi: semua, event, job, donasi, investasi
This commit is contained in:
@@ -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 = [
|
export const globalStatusApp = [
|
||||||
{
|
{
|
||||||
@@ -20,3 +21,35 @@ 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,
|
Notifikasi_ComponentSkeletonView,
|
||||||
} from "../component";
|
} from "../component";
|
||||||
import { gs_notifikasi_kategori_app } from "../lib";
|
import { gs_notifikasi_kategori_app } from "../lib";
|
||||||
import { apiGetAllNotifikasiByCategory } from "../lib/api_notifikasi";
|
|
||||||
import { MODEL_NOTIFIKASI } from "../model/interface";
|
import { MODEL_NOTIFIKASI } from "../model/interface";
|
||||||
|
import { apiGetAllNotifikasiByCategory } from "../lib/api_fetch_notifikasi";
|
||||||
|
|
||||||
export default function Notifikasi_UiMain({
|
export default function Notifikasi_UiMain({
|
||||||
userLoginId,
|
userLoginId,
|
||||||
@@ -82,9 +82,6 @@ export default function Notifikasi_UiMain({
|
|||||||
{(item) => (
|
{(item) => (
|
||||||
<ComponentNotifiaksi_CardView
|
<ComponentNotifiaksi_CardView
|
||||||
data={item}
|
data={item}
|
||||||
onLoadData={setData}
|
|
||||||
categoryPage={categoryPage as any}
|
|
||||||
userLoginId={userLoginId}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</ScrollOnly>
|
</ScrollOnly>
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { gs_count_ntf } from "@/lib/global_state";
|
|
||||||
import {
|
import {
|
||||||
AccentColor,
|
AccentColor,
|
||||||
MainColor,
|
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_investas_menu } from "@/app_modules/investasi/g_state";
|
||||||
import { gs_job_hot_menu } from "@/app_modules/job/global_state";
|
import { gs_job_hot_menu } from "@/app_modules/job/global_state";
|
||||||
import { gs_vote_hotMenu } from "@/app_modules/vote/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 { Badge, Card, Divider, Group, Stack, Text } from "@mantine/core";
|
||||||
import { IconCheck, IconChecks } from "@tabler/icons-react";
|
import { IconCheck, IconChecks } from "@tabler/icons-react";
|
||||||
import { useAtom } from "jotai";
|
import { useAtom } from "jotai";
|
||||||
@@ -24,18 +25,12 @@ import { notifikasi_eventCheckStatus } from "./path/event";
|
|||||||
import { redirectInvestasiPage } from "./path/investasi";
|
import { redirectInvestasiPage } from "./path/investasi";
|
||||||
import { notifikasi_jobCheckStatus } from "./path/job";
|
import { notifikasi_jobCheckStatus } from "./path/job";
|
||||||
import { notifikasi_votingCheckStatus } from "./path/voting";
|
import { notifikasi_votingCheckStatus } from "./path/voting";
|
||||||
import { clientLogger } from "@/util/clientLogger";
|
import { redirectDetailForumPage } from "./path/forum";
|
||||||
|
|
||||||
export function ComponentNotifiaksi_CardView({
|
export function ComponentNotifiaksi_CardView({
|
||||||
data,
|
data,
|
||||||
onLoadData,
|
|
||||||
categoryPage,
|
|
||||||
userLoginId,
|
|
||||||
}: {
|
}: {
|
||||||
data: MODEL_NOTIFIKASI;
|
data: MODEL_NOTIFIKASI;
|
||||||
onLoadData: (val: any) => void;
|
|
||||||
categoryPage: string;
|
|
||||||
userLoginId?: string
|
|
||||||
}) {
|
}) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
@@ -65,25 +60,19 @@ export function ComponentNotifiaksi_CardView({
|
|||||||
try {
|
try {
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
|
|
||||||
|
console.log("data", data);
|
||||||
// JOB
|
// JOB
|
||||||
if (data?.kategoriApp === "JOB") {
|
if (data?.kategoriApp === "JOB") {
|
||||||
await notifikasi_jobCheckStatus({
|
await notifikasi_jobCheckStatus({
|
||||||
appId: data.appId,
|
appId: data.appId,
|
||||||
dataId: data.id,
|
dataId: data.id,
|
||||||
categoryPage: categoryPage,
|
|
||||||
router: router,
|
router: router,
|
||||||
onLoadDataJob(val) {
|
|
||||||
onLoadData(val);
|
|
||||||
},
|
|
||||||
onSetJobMenuId(val) {
|
onSetJobMenuId(val) {
|
||||||
setJobMenuId(val);
|
setJobMenuId(val);
|
||||||
},
|
},
|
||||||
onSetVisible(val) {
|
onSetVisible(val) {
|
||||||
setVisible(val);
|
setVisible(val);
|
||||||
},
|
},
|
||||||
onLoadCountNtf(val) {
|
|
||||||
setLoadCountNtf(val);
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -94,20 +83,13 @@ export function ComponentNotifiaksi_CardView({
|
|||||||
await notifikasi_eventCheckStatus({
|
await notifikasi_eventCheckStatus({
|
||||||
appId: data.appId,
|
appId: data.appId,
|
||||||
dataId: data.id,
|
dataId: data.id,
|
||||||
categoryPage: categoryPage,
|
|
||||||
router: router,
|
router: router,
|
||||||
onLoadDataEvent(val) {
|
|
||||||
onLoadData(val);
|
|
||||||
},
|
|
||||||
onSetVisible(val) {
|
onSetVisible(val) {
|
||||||
setVisible(val);
|
setVisible(val);
|
||||||
},
|
},
|
||||||
onSetEventMenuId(val) {
|
onSetEventMenuId(val) {
|
||||||
setEventMenuId(val);
|
setEventMenuId(val);
|
||||||
},
|
},
|
||||||
onLoadCountNtf(val) {
|
|
||||||
setLoadCountNtf(val);
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -118,20 +100,13 @@ export function ComponentNotifiaksi_CardView({
|
|||||||
await notifikasi_votingCheckStatus({
|
await notifikasi_votingCheckStatus({
|
||||||
appId: data.appId,
|
appId: data.appId,
|
||||||
dataId: data.id,
|
dataId: data.id,
|
||||||
categoryPage: categoryPage,
|
|
||||||
router: router,
|
router: router,
|
||||||
onLoadDataEvent(val) {
|
|
||||||
onLoadData(val);
|
|
||||||
},
|
|
||||||
onSetVisible(val) {
|
onSetVisible(val) {
|
||||||
setVisible(val);
|
setVisible(val);
|
||||||
},
|
},
|
||||||
onSetMenuId(val) {
|
onSetMenuId(val) {
|
||||||
setVotingMenu(val);
|
setVotingMenu(val);
|
||||||
},
|
},
|
||||||
onLoadCountNtf(val) {
|
|
||||||
setLoadCountNtf(val);
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -143,21 +118,13 @@ export function ComponentNotifiaksi_CardView({
|
|||||||
appId: data.appId,
|
appId: data.appId,
|
||||||
dataId: data.id,
|
dataId: data.id,
|
||||||
userId: data.userId,
|
userId: data.userId,
|
||||||
userLoginId: userLoginId as any,
|
|
||||||
categoryPage: categoryPage,
|
|
||||||
router: router,
|
router: router,
|
||||||
onLoadDataEvent(val) {
|
|
||||||
onLoadData(val);
|
|
||||||
},
|
|
||||||
onSetVisible(val) {
|
onSetVisible(val) {
|
||||||
setVisible(val);
|
setVisible(val);
|
||||||
},
|
},
|
||||||
onSetMenuId(val) {
|
onSetMenuId(val) {
|
||||||
setDonasiMenu(val);
|
setDonasiMenu(val);
|
||||||
},
|
},
|
||||||
onLoadCountNtf(val) {
|
|
||||||
setLoadCountNtf(val);
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -168,30 +135,29 @@ export function ComponentNotifiaksi_CardView({
|
|||||||
redirectInvestasiPage({
|
redirectInvestasiPage({
|
||||||
appId: data.appId,
|
appId: data.appId,
|
||||||
dataId: data.id,
|
dataId: data.id,
|
||||||
categoryPage: categoryPage,
|
|
||||||
router: router,
|
router: router,
|
||||||
onLoadDataEvent(val) {
|
|
||||||
onLoadData(val);
|
|
||||||
},
|
|
||||||
onSetVisible(val) {
|
onSetVisible(val) {
|
||||||
setVisible(val);
|
setVisible(val);
|
||||||
},
|
},
|
||||||
onSetMenuId(val) {
|
onSetMenuId(val) {
|
||||||
setInvestasiMenu(val);
|
setInvestasiMenu(val);
|
||||||
},
|
},
|
||||||
onLoadCountNtf(val) {
|
|
||||||
setLoadCountNtf(val);
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// data?.kategoriApp === "FORUM" &&
|
if (data?.kategoriApp === "FORUM") {
|
||||||
// redirectDetailForumPage({
|
redirectDetailForumPage({
|
||||||
// data: data,
|
data: data,
|
||||||
// router: router,
|
router: router,
|
||||||
// });
|
onSetVisible(val) {
|
||||||
|
setVisible(val);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// data?.kategoriApp === "COLLABORATION" &&
|
// data?.kategoriApp === "COLLABORATION" &&
|
||||||
// redirectDetailCollaborationPage({
|
// redirectDetailCollaborationPage({
|
||||||
|
|||||||
@@ -8,46 +8,48 @@ import notifikasi_countUserNotifikasi from "../../fun/count/fun_count_by_id";
|
|||||||
import notifikasi_funUpdateIsReadById from "../../fun/update/fun_update_is_read_by_user_id";
|
import notifikasi_funUpdateIsReadById from "../../fun/update/fun_update_is_read_by_user_id";
|
||||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
||||||
import { notifikasi_checkAuthorDonasiById } from "../../fun/check/fun_check_author_donasi_by_id";
|
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({
|
export async function redirectDonasiPage({
|
||||||
appId,
|
appId,
|
||||||
dataId,
|
dataId,
|
||||||
categoryPage,
|
|
||||||
userId,
|
userId,
|
||||||
userLoginId,
|
|
||||||
router,
|
router,
|
||||||
onLoadDataEvent,
|
|
||||||
onSetMenuId,
|
onSetMenuId,
|
||||||
onSetVisible,
|
onSetVisible,
|
||||||
onLoadCountNtf,
|
|
||||||
}: {
|
}: {
|
||||||
appId: string;
|
appId: string;
|
||||||
dataId: string;
|
dataId: string;
|
||||||
categoryPage: string;
|
|
||||||
userId: string;
|
userId: string;
|
||||||
userLoginId: string;
|
|
||||||
router: AppRouterInstance;
|
router: AppRouterInstance;
|
||||||
onLoadDataEvent: (val: any) => void;
|
|
||||||
onSetMenuId(val: number): void;
|
onSetMenuId(val: number): void;
|
||||||
onSetVisible(val: boolean): void;
|
onSetVisible(val: boolean): void;
|
||||||
onLoadCountNtf(val: number): void;
|
|
||||||
}) {
|
}) {
|
||||||
const check = await notifikasi_funDonasiCheckStatus({ id: appId });
|
const check = await notifikasi_funDonasiCheckStatus({ id: appId });
|
||||||
|
|
||||||
|
if (check.statusName == "") {
|
||||||
|
const checkTransaksi = await apiNotifikasiDonasiCheckTransaksiById({
|
||||||
|
id: appId,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (checkTransaksi.success) {
|
||||||
|
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
||||||
|
notifId: dataId,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (updateReadNotifikasi.status == 200) {
|
||||||
|
router.push(RouterDonasi.main_donasi_saya, { scroll: false });
|
||||||
|
onSetMenuId(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
const checkAuthor = await notifikasi_checkAuthorDonasiById({
|
const checkAuthor = await notifikasi_checkAuthorDonasiById({
|
||||||
donasiId: appId,
|
donasiId: appId,
|
||||||
userId: userId,
|
userId: userId,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (check.status == 200) {
|
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({
|
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
||||||
notifId: dataId,
|
notifId: dataId,
|
||||||
});
|
});
|
||||||
@@ -67,4 +69,5 @@ export async function redirectDonasiPage({
|
|||||||
onSetVisible(false);
|
onSetVisible(false);
|
||||||
ComponentGlobal_NotifikasiPeringatan("Status tidak ditemukan");
|
ComponentGlobal_NotifikasiPeringatan("Status tidak ditemukan");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,33 +8,19 @@ import notifikasi_countUserNotifikasi from "../../fun/count/fun_count_by_id";
|
|||||||
export async function notifikasi_eventCheckStatus({
|
export async function notifikasi_eventCheckStatus({
|
||||||
appId,
|
appId,
|
||||||
dataId,
|
dataId,
|
||||||
categoryPage,
|
|
||||||
router,
|
router,
|
||||||
onLoadDataEvent,
|
|
||||||
onSetEventMenuId,
|
onSetEventMenuId,
|
||||||
onSetVisible,
|
onSetVisible,
|
||||||
onLoadCountNtf,
|
|
||||||
}: {
|
}: {
|
||||||
appId: string;
|
appId: string;
|
||||||
dataId: string;
|
dataId: string;
|
||||||
categoryPage: string
|
|
||||||
router: AppRouterInstance;
|
router: AppRouterInstance;
|
||||||
onLoadDataEvent: (val: any) => void;
|
|
||||||
onSetEventMenuId(val: number): void;
|
onSetEventMenuId(val: number): void;
|
||||||
onSetVisible(val: boolean): void;
|
onSetVisible(val: boolean): void;
|
||||||
onLoadCountNtf(val: number): void;
|
|
||||||
}) {
|
}) {
|
||||||
const check = await notifikasi_funEventCheckStatus({ id: appId });
|
const check = await notifikasi_funEventCheckStatus({ id: appId });
|
||||||
|
|
||||||
if (check.status == 200) {
|
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({
|
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
||||||
notifId: dataId,
|
notifId: dataId,
|
||||||
|
|||||||
@@ -1,14 +1,19 @@
|
|||||||
import { RouterForum } from "@/lib/router_hipmi/router_forum";
|
import { RouterForum } from "@/lib/router_hipmi/router_forum";
|
||||||
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
||||||
import { MODEL_NOTIFIKASI } from "../../model/interface";
|
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,
|
data,
|
||||||
router,
|
router,
|
||||||
|
onSetVisible,
|
||||||
}: {
|
}: {
|
||||||
data: MODEL_NOTIFIKASI;
|
data: MODEL_NOTIFIKASI;
|
||||||
router: AppRouterInstance;
|
router: AppRouterInstance;
|
||||||
|
onSetVisible(val: boolean): void;
|
||||||
}) {
|
}) {
|
||||||
|
try {
|
||||||
if (data.status === null) {
|
if (data.status === null) {
|
||||||
const path = RouterForum.main_detail + data.appId;
|
const path = RouterForum.main_detail + data.appId;
|
||||||
router.push(path, { scroll: false });
|
router.push(path, { scroll: false });
|
||||||
@@ -23,4 +28,19 @@ export function redirectDetailForumPage({
|
|||||||
const path = RouterForum.detail_report_posting + data.appId;
|
const path = RouterForum.detail_report_posting + data.appId;
|
||||||
router.push(path, { scroll: false });
|
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({
|
export async function redirectInvestasiPage({
|
||||||
appId,
|
appId,
|
||||||
dataId,
|
dataId,
|
||||||
categoryPage,
|
|
||||||
router,
|
router,
|
||||||
onLoadDataEvent,
|
|
||||||
onSetMenuId,
|
onSetMenuId,
|
||||||
onSetVisible,
|
onSetVisible,
|
||||||
onLoadCountNtf,
|
|
||||||
}: {
|
}: {
|
||||||
appId: string;
|
appId: string;
|
||||||
dataId: string;
|
dataId: string;
|
||||||
categoryPage: string;
|
|
||||||
router: AppRouterInstance;
|
router: AppRouterInstance;
|
||||||
onLoadDataEvent: (val: any) => void;
|
|
||||||
onSetMenuId(val: number): void;
|
onSetMenuId(val: number): void;
|
||||||
onSetVisible(val: boolean): void;
|
onSetVisible(val: boolean): void;
|
||||||
onLoadCountNtf(val: number): void;
|
|
||||||
}) {
|
}) {
|
||||||
const check = await notifikasi_funInvestasiCheckStatus({ id: appId });
|
const check = await notifikasi_funInvestasiCheckStatus({ id: appId });
|
||||||
const checkInvestor = await notifikasi_funInvestasiChecInvestaorStatus({
|
const checkInvestor = await notifikasi_funInvestasiChecInvestaorStatus({
|
||||||
|
|||||||
@@ -8,35 +8,20 @@ import notifikasi_countUserNotifikasi from "../../fun/count/fun_count_by_id";
|
|||||||
export async function notifikasi_jobCheckStatus({
|
export async function notifikasi_jobCheckStatus({
|
||||||
appId,
|
appId,
|
||||||
dataId,
|
dataId,
|
||||||
categoryPage,
|
|
||||||
router,
|
router,
|
||||||
onLoadDataJob,
|
|
||||||
onSetJobMenuId,
|
onSetJobMenuId,
|
||||||
onSetVisible,
|
onSetVisible,
|
||||||
onLoadCountNtf,
|
|
||||||
}: {
|
}: {
|
||||||
appId: string;
|
appId: string;
|
||||||
dataId: string;
|
dataId: string;
|
||||||
categoryPage:string
|
|
||||||
router: AppRouterInstance;
|
router: AppRouterInstance;
|
||||||
onLoadDataJob: (val: any) => void;
|
|
||||||
onSetJobMenuId(val: number): void;
|
onSetJobMenuId(val: number): void;
|
||||||
onSetVisible(val: boolean): void;
|
onSetVisible(val: boolean): void;
|
||||||
onLoadCountNtf(val: number): void;
|
|
||||||
}) {
|
}) {
|
||||||
const check = await notifikasi_funJobCheckStatus({
|
const check = await notifikasi_funJobCheckStatus({
|
||||||
id: appId,
|
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) {
|
if (check.status == 200) {
|
||||||
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
||||||
notifId: dataId,
|
notifId: dataId,
|
||||||
|
|||||||
@@ -10,34 +10,19 @@ import notifikasi_funUpdateIsReadById from "../../fun/update/fun_update_is_read_
|
|||||||
export async function notifikasi_votingCheckStatus({
|
export async function notifikasi_votingCheckStatus({
|
||||||
appId,
|
appId,
|
||||||
dataId,
|
dataId,
|
||||||
categoryPage,
|
|
||||||
router,
|
router,
|
||||||
onLoadDataEvent,
|
|
||||||
onSetMenuId,
|
onSetMenuId,
|
||||||
onSetVisible,
|
onSetVisible,
|
||||||
onLoadCountNtf,
|
|
||||||
}: {
|
}: {
|
||||||
appId: string;
|
appId: string;
|
||||||
dataId: string;
|
dataId: string;
|
||||||
categoryPage: string;
|
|
||||||
router: AppRouterInstance;
|
router: AppRouterInstance;
|
||||||
onLoadDataEvent: (val: any) => void;
|
|
||||||
onSetMenuId(val: number): void;
|
onSetMenuId(val: number): void;
|
||||||
onSetVisible(val: boolean): void;
|
onSetVisible(val: boolean): void;
|
||||||
onLoadCountNtf(val: number): void;
|
|
||||||
}) {
|
}) {
|
||||||
const check = await notifikasi_funVotingCheckStatus({ id: appId });
|
const check = await notifikasi_funVotingCheckStatus({ id: appId });
|
||||||
|
|
||||||
if (check.status == 200) {
|
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({
|
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
||||||
notifId: dataId,
|
notifId: dataId,
|
||||||
});
|
});
|
||||||
@@ -52,6 +37,4 @@ export async function notifikasi_votingCheckStatus({
|
|||||||
} else {
|
} else {
|
||||||
ComponentGlobal_NotifikasiPeringatan("Status tidak ditemukan");
|
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