@@ -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",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ import colab_funCreatePartisipan from "../../fun/create/fun_create_partisipan_by
|
|||||||
import { MODEL_COLLABORATION_PARTISIPASI } from "../../model/interface";
|
import { MODEL_COLLABORATION_PARTISIPASI } from "../../model/interface";
|
||||||
import { Collaboration_SkeletonListPrtisipanIsUser } from "../skeleton_view";
|
import { Collaboration_SkeletonListPrtisipanIsUser } from "../skeleton_view";
|
||||||
import ComponentColab_AuthorNameOnListPartisipan from "./header_author_list_partisipan";
|
import ComponentColab_AuthorNameOnListPartisipan from "./header_author_list_partisipan";
|
||||||
|
import { WibuRealtime } from "wibu-pkg";
|
||||||
|
import { IRealtimeData } from "@/lib/global_state";
|
||||||
|
|
||||||
export default function ComponentColab_DetailListPartisipasiUser({
|
export default function ComponentColab_DetailListPartisipasiUser({
|
||||||
userLoginId,
|
userLoginId,
|
||||||
@@ -103,20 +105,25 @@ export default function ComponentColab_DetailListPartisipasiUser({
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (res.status === 201) {
|
if (res.status === 201) {
|
||||||
// const dataNotif = {
|
const dataNotifikasi: IRealtimeData = {
|
||||||
// appId: res?.data?.ProjectCollaboration?.id,
|
appId: res?.data?.ProjectCollaboration?.id,
|
||||||
// userId: res?.data?.ProjectCollaboration?.userId,
|
userId: res?.data?.ProjectCollaboration?.userId as any,
|
||||||
// pesan: res?.data?.ProjectCollaboration?.title,
|
pesan: res?.data?.ProjectCollaboration?.title,
|
||||||
// status: "Partisipan Project",
|
status: "Partisipan Project" as any,
|
||||||
// kategoriApp: "COLLABORATION",
|
kategoriApp: "COLLABORATION",
|
||||||
// title: "Partisipan baru telah bergabung !",
|
title: "Partisipan baru telah bergabung !",
|
||||||
// };
|
};
|
||||||
|
|
||||||
// const createNotifikasi = await notifikasiToUser_funCreate({
|
const createNotifikasi = await notifikasiToUser_funCreate({
|
||||||
// data: dataNotif as any,
|
data: dataNotifikasi as any,
|
||||||
// });
|
});
|
||||||
|
|
||||||
// if (createNotifikasi.status === 201) {
|
if (createNotifikasi.status === 201) {
|
||||||
|
WibuRealtime.setData({
|
||||||
|
type: "trigger",
|
||||||
|
pushNotificationTo: "USER",
|
||||||
|
dataMessage: dataNotifikasi,
|
||||||
|
});
|
||||||
// mqtt_client.publish(
|
// mqtt_client.publish(
|
||||||
// "USER",
|
// "USER",
|
||||||
// JSON.stringify({
|
// JSON.stringify({
|
||||||
@@ -124,16 +131,16 @@ export default function ComponentColab_DetailListPartisipasiUser({
|
|||||||
// count: 1,
|
// count: 1,
|
||||||
// })
|
// })
|
||||||
// );
|
// );
|
||||||
// }
|
}
|
||||||
|
|
||||||
const respone = await apiGetOneCollaborationById({
|
const response = await apiGetOneCollaborationById({
|
||||||
id: params.id,
|
id: params.id,
|
||||||
kategori: "list_partisipan",
|
kategori: "list_partisipan",
|
||||||
page: `${activePage}`,
|
page: `${activePage}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (respone) {
|
if (response) {
|
||||||
setData(respone.data);
|
setData(response.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
const cekPartisipan = await apiGetOneCollaborationById({
|
const cekPartisipan = await apiGetOneCollaborationById({
|
||||||
@@ -274,8 +281,8 @@ export default function ComponentColab_DetailListPartisipasiUser({
|
|||||||
}
|
}
|
||||||
styles={{
|
styles={{
|
||||||
input: {
|
input: {
|
||||||
backgroundColor: MainColor.white
|
backgroundColor: MainColor.white,
|
||||||
}
|
},
|
||||||
}}
|
}}
|
||||||
placeholder="Deskripsikan diri anda yang sesuai dengan proyek ini.."
|
placeholder="Deskripsikan diri anda yang sesuai dengan proyek ini.."
|
||||||
minRows={4}
|
minRows={4}
|
||||||
|
|||||||
@@ -12,11 +12,12 @@ export default async function colab_funCreatePartisipan({
|
|||||||
id: string;
|
id: string;
|
||||||
deskripsi: string;
|
deskripsi: string;
|
||||||
}) {
|
}) {
|
||||||
|
try {
|
||||||
const userLoginId = await funGetUserIdByToken();
|
const userLoginId = await funGetUserIdByToken();
|
||||||
|
|
||||||
if (userLoginId == null) {
|
if (!userLoginId) {
|
||||||
return {
|
return {
|
||||||
status: 500,
|
status: 404,
|
||||||
message: "Gagal mendapatkan data, user id tidak ada",
|
message: "Gagal mendapatkan data, user id tidak ada",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -38,11 +39,19 @@ export default async function colab_funCreatePartisipan({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!create) return { status: 400, message: "Gagal menambahkan partisipan" };
|
if (!create)
|
||||||
|
return { status: 400, message: "Gagal menambahkan partisipan" };
|
||||||
revalidatePath(RouterColab.main_detail + id);
|
revalidatePath(RouterColab.main_detail + id);
|
||||||
return {
|
return {
|
||||||
data: create,
|
data: create,
|
||||||
status: 201,
|
status: 201,
|
||||||
message: "Berhasil menambahkan partisipan",
|
message: "Berhasil menambahkan partisipan",
|
||||||
};
|
};
|
||||||
|
} catch (error) {
|
||||||
|
return {
|
||||||
|
status: 500,
|
||||||
|
message: "Error menambahkan partisipan",
|
||||||
|
error: (error as Error).message,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,10 @@ export default function Event_DetailDraft() {
|
|||||||
<>
|
<>
|
||||||
<Stack spacing={"lg"}>
|
<Stack spacing={"lg"}>
|
||||||
<ComponentEvent_DetailData isReport data={data} />
|
<ComponentEvent_DetailData isReport data={data} />
|
||||||
<ButtonAction eventId={eventId} endDate={data?.tanggalSelesai} />
|
<ButtonAction
|
||||||
|
eventId={eventId}
|
||||||
|
endDate={data?.tanggalSelesai}
|
||||||
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
@@ -62,7 +65,6 @@ function ButtonAction({ eventId, endDate }: { eventId: string; endDate: any }) {
|
|||||||
const [openModal1, setOpenModal1] = useState(false);
|
const [openModal1, setOpenModal1] = useState(false);
|
||||||
const [openModal2, setOpenModal2] = useState(false);
|
const [openModal2, setOpenModal2] = useState(false);
|
||||||
|
|
||||||
|
|
||||||
async function onDelete() {
|
async function onDelete() {
|
||||||
try {
|
try {
|
||||||
const res = await Event_funDeleteById(eventId);
|
const res = await Event_funDeleteById(eventId);
|
||||||
@@ -86,7 +88,9 @@ function ButtonAction({ eventId, endDate }: { eventId: string; endDate: any }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function onAjukan() {
|
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");
|
return ComponentGlobal_NotifikasiPeringatan("Waktu acara telah lewat");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
"use client";
|
"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 { useShallowEffect } from "@mantine/hooks";
|
||||||
import { useAtom } from "jotai";
|
import { useAtom } from "jotai";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
@@ -22,7 +22,7 @@ export default function HomeView({
|
|||||||
}) {
|
}) {
|
||||||
const [countNtf, setCountNtf] = useState(countNotifikasi);
|
const [countNtf, setCountNtf] = useState(countNotifikasi);
|
||||||
const [newUserNtf, setNewUserNtf] = useAtom(gs_user_ntf);
|
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;
|
const userRoleId = dataUser.masterUserRoleId;
|
||||||
|
|
||||||
// useShallowEffect(() => {
|
// useShallowEffect(() => {
|
||||||
@@ -33,15 +33,15 @@ export default function HomeView({
|
|||||||
// }
|
// }
|
||||||
// }, [userRoleId]);
|
// }, [userRoleId]);
|
||||||
|
|
||||||
useShallowEffect(() => {
|
// useShallowEffect(() => {
|
||||||
onLoadNotifikasi({
|
// onLoadNotifikasi({
|
||||||
onLoad(val) {
|
// onLoad(val) {
|
||||||
setCountNtf(val);
|
// setCountNtf(val);
|
||||||
},
|
// },
|
||||||
});
|
// });
|
||||||
|
|
||||||
setCountNtf(countLoadNtf as any);
|
// setCountNtf(countLoadNtf as any);
|
||||||
}, [countLoadNtf, setCountNtf]);
|
// }, [countLoadNtf, setCountNtf]);
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
setCountNtf(countNtf + newUserNtf);
|
setCountNtf(countNtf + newUserNtf);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
"use client";
|
"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 global_limit from "@/lib/limit";
|
||||||
import { RouterProfile } from "@/lib/router_hipmi/router_katalog";
|
import { RouterProfile } from "@/lib/router_hipmi/router_katalog";
|
||||||
import { RouterNotifikasi } from "@/lib/router_hipmi/router_notifikasi";
|
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";
|
import { apiGetDataHome, apiGetNotifikasiHome } from "./fun/get/api_home";
|
||||||
|
|
||||||
export default function HomeViewNew() {
|
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 [newUserNtf, setNewUserNtf] = useAtom(gs_user_ntf);
|
||||||
const [dataUser, setDataUser] = useState<any | null>(null);
|
const [dataUser, setDataUser] = useState<any | null>(null);
|
||||||
const [categoryPage, setCategoryPage] = useAtom(gs_notifikasi_kategori_app);
|
const [categoryPage, setCategoryPage] = useAtom(gs_notifikasi_kategori_app);
|
||||||
@@ -31,7 +31,7 @@ export default function HomeViewNew() {
|
|||||||
setCountNtf(countNtf + newUserNtf);
|
setCountNtf(countNtf + newUserNtf);
|
||||||
setNewUserNtf(0);
|
setNewUserNtf(0);
|
||||||
}
|
}
|
||||||
}, [newUserNtf, countNtf]);
|
}, [newUserNtf]);
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
hanlderLoadData();
|
hanlderLoadData();
|
||||||
@@ -77,6 +77,7 @@ export default function HomeViewNew() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<UIGlobal_LayoutTamplate
|
<UIGlobal_LayoutTamplate
|
||||||
@@ -84,7 +85,7 @@ export default function HomeViewNew() {
|
|||||||
<UIGlobal_LayoutHeaderTamplate
|
<UIGlobal_LayoutHeaderTamplate
|
||||||
title="HIPMI"
|
title="HIPMI"
|
||||||
customButtonLeft={
|
customButtonLeft={
|
||||||
!dataUser || !countNtf ? (
|
!dataUser && !countNtf ? (
|
||||||
<ActionIcon radius={"xl"} variant={"transparent"}>
|
<ActionIcon radius={"xl"} variant={"transparent"}>
|
||||||
<IconUserSearch color={"gray"} />
|
<IconUserSearch color={"gray"} />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
@@ -111,7 +112,7 @@ export default function HomeViewNew() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
customButtonRight={
|
customButtonRight={
|
||||||
!dataUser || !countNtf ? (
|
!dataUser && !countNtf ? (
|
||||||
<ActionIcon radius={"xl"} variant={"transparent"}>
|
<ActionIcon radius={"xl"} variant={"transparent"}>
|
||||||
<IconBell color={"gray"} />
|
<IconBell color={"gray"} />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
|
|||||||
@@ -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,7 @@ 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 { 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";
|
||||||
@@ -21,25 +21,19 @@ import { useState } from "react";
|
|||||||
import { MODEL_NOTIFIKASI } from "../model/interface";
|
import { MODEL_NOTIFIKASI } from "../model/interface";
|
||||||
import { redirectDonasiPage } from "./path/donasi";
|
import { redirectDonasiPage } from "./path/donasi";
|
||||||
import { notifikasi_eventCheckStatus } from "./path/event";
|
import { notifikasi_eventCheckStatus } from "./path/event";
|
||||||
|
import { redirectDetailForumPage } from "./path/forum";
|
||||||
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 { redirectDetailCollaborationPage } from "./path/collaboration";
|
||||||
|
|
||||||
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);
|
||||||
const [loadCountNtf, setLoadCountNtf] = useAtom(gs_count_ntf);
|
|
||||||
|
|
||||||
const [jobMenuId, setJobMenuId] = useAtom(gs_job_hot_menu);
|
const [jobMenuId, setJobMenuId] = useAtom(gs_job_hot_menu);
|
||||||
const [eventMenuId, setEventMenuId] = useAtom(gs_event_hotMenu);
|
const [eventMenuId, setEventMenuId] = useAtom(gs_event_hotMenu);
|
||||||
@@ -64,26 +58,20 @@ export function ComponentNotifiaksi_CardView({
|
|||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
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 +82,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 +99,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;
|
||||||
@@ -139,25 +113,17 @@ export function ComponentNotifiaksi_CardView({
|
|||||||
|
|
||||||
// DONASI
|
// DONASI
|
||||||
if (data?.kategoriApp === "DONASI") {
|
if (data?.kategoriApp === "DONASI") {
|
||||||
redirectDonasiPage({
|
await redirectDonasiPage({
|
||||||
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;
|
||||||
@@ -165,39 +131,44 @@ export function ComponentNotifiaksi_CardView({
|
|||||||
|
|
||||||
// INVESTASI
|
// INVESTASI
|
||||||
if (data?.kategoriApp === "INVESTASI") {
|
if (data?.kategoriApp === "INVESTASI") {
|
||||||
redirectInvestasiPage({
|
await 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data?.kategoriApp === "FORUM") {
|
||||||
|
await redirectDetailForumPage({
|
||||||
|
data: data,
|
||||||
|
router: router,
|
||||||
|
onSetVisible(val) {
|
||||||
|
setVisible(val);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// data?.kategoriApp === "FORUM" &&
|
if (data?.kategoriApp === "COLLABORATION") {
|
||||||
// redirectDetailForumPage({
|
await redirectDetailCollaborationPage({
|
||||||
// data: data,
|
data: data,
|
||||||
// router: router,
|
router: router,
|
||||||
// });
|
onSetVisible(val) {
|
||||||
|
setVisible(val);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
// data?.kategoriApp === "COLLABORATION" &&
|
return;
|
||||||
// redirectDetailCollaborationPage({
|
}
|
||||||
// data: data,
|
|
||||||
// router: router,
|
|
||||||
// });
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
clientLogger.error("Error redirect notification page", error);
|
clientLogger.error("Error redirect notification page", error);
|
||||||
|
|||||||
@@ -1,26 +1,40 @@
|
|||||||
import { RouterColab } from "@/lib/router_hipmi/router_colab";
|
import { RouterColab } from "@/lib/router_hipmi/router_colab";
|
||||||
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 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,
|
data,
|
||||||
router,
|
router,
|
||||||
|
onSetVisible,
|
||||||
}: {
|
}: {
|
||||||
data: MODEL_NOTIFIKASI;
|
data: MODEL_NOTIFIKASI;
|
||||||
router: AppRouterInstance;
|
router: AppRouterInstance;
|
||||||
|
onSetVisible(val: boolean): void;
|
||||||
}) {
|
}) {
|
||||||
|
try {
|
||||||
if (data.status === "Partisipan Project") {
|
if (data.status === "Partisipan Project") {
|
||||||
const path = RouterColab.main_detail + data.appId;
|
const path = RouterColab.main_detail + data.appId;
|
||||||
router.push(path, { scroll: false });
|
router.push(path, { scroll: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (data.status === "Collaboration Group") {
|
if (data.status === "Collaboration Group") {
|
||||||
const path = RouterColab.grup_diskusi;
|
const path = RouterColab.grup_diskusi;
|
||||||
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");
|
||||||
|
}
|
||||||
// if (data.status === "Report Komentar") {
|
// if (data.status === "Report Komentar") {
|
||||||
// const path = RouterForum.detail_report_komentar + data.appId;
|
// const path = RouterForum.detail_report_komentar + data.appId;
|
||||||
// router.push(path, { scroll: false });
|
// router.push(path, { scroll: false });
|
||||||
|
|||||||
@@ -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);
|
|
||||||
}
|
|
||||||
@@ -17,7 +17,9 @@ export type ITypeStatusNotifikasi =
|
|||||||
| "Berhasil"
|
| "Berhasil"
|
||||||
| "Proses"
|
| "Proses"
|
||||||
| "Menunggu"
|
| "Menunggu"
|
||||||
| "Gagal";
|
| "Gagal"
|
||||||
|
// Collaboration
|
||||||
|
| "Partisipan Project"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param kategoriApp | "JOB", "VOTING", "EVENT", "DONASI", "INVESTASI", "COLLABORATION", "FORUM"
|
* @param kategoriApp | "JOB", "VOTING", "EVENT", "DONASI", "INVESTASI", "COLLABORATION", "FORUM"
|
||||||
|
|||||||
@@ -246,6 +246,17 @@ export default function RealtimeProvider({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------- INVESTASI ------------------------- //
|
// ---------------------- 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