Merge pull request #247 from bipproduction/bagas/17-jan-25
Fix notifikasi donasi & event new fiture
This commit is contained in:
@@ -68,18 +68,3 @@ export async function GET(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main({ id }: { id: string }) {
|
|
||||||
const fixData = await prisma.beritaInvestasi.findMany({
|
|
||||||
take: 10,
|
|
||||||
skip: 0,
|
|
||||||
orderBy: {
|
|
||||||
updatedAt: "desc",
|
|
||||||
},
|
|
||||||
where: {
|
|
||||||
investasiId: id.trim(),
|
|
||||||
active: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
console.log("data sebelum disconnect>>", fixData);
|
|
||||||
}
|
|
||||||
|
|||||||
46
src/app/api/user/all/route.ts
Normal file
46
src/app/api/user/all/route.ts
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
import { prisma } from "@/app/lib";
|
||||||
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
|
export async function GET(request: Request) {
|
||||||
|
if (request.method === "GET") {
|
||||||
|
try {
|
||||||
|
let fixData;
|
||||||
|
const { searchParams } = new URL(request.url);
|
||||||
|
const except_id = searchParams.get("except-id");
|
||||||
|
|
||||||
|
if (!except_id) {
|
||||||
|
fixData = await prisma.user.findMany({
|
||||||
|
where: {
|
||||||
|
active: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
fixData = await prisma.user.findMany({
|
||||||
|
where: {
|
||||||
|
active: true,
|
||||||
|
masterUserRoleId: "1",
|
||||||
|
id: {
|
||||||
|
not: except_id,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return NextResponse.json({
|
||||||
|
success: true,
|
||||||
|
message: "Berhasil mendapatkan data",
|
||||||
|
data: fixData,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
return NextResponse.json({
|
||||||
|
success: false,
|
||||||
|
message: "Gagal mendapatkan data",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return NextResponse.json({
|
||||||
|
success: false,
|
||||||
|
message: "Method not allowed",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
import { Donasi_CreateKabar } from "@/app_modules/donasi";
|
import { Donasi_CreateKabar } from "@/app_modules/donasi";
|
||||||
|
|
||||||
export default async function Page({ params }: { params: { id: string } }) {
|
export default async function Page() {
|
||||||
const donasiId = params.id;
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Donasi_CreateKabar donasiId={donasiId} />
|
<Donasi_CreateKabar />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
|
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||||
import { Notifikasi_UiMain } from "@/app_modules/notifikasi/_ui";
|
import { Notifikasi_UiMain } from "@/app_modules/notifikasi/_ui";
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
|
const userLoginId = await funGetUserIdByToken();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Notifikasi_UiMain />
|
<Notifikasi_UiMain userLoginId={userLoginId} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
|
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||||
import { Notifikasi_UiMain } from "@/app_modules/notifikasi/_ui";
|
import { Notifikasi_UiMain } from "@/app_modules/notifikasi/_ui";
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
|
const userLoginId = await funGetUserIdByToken();
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Notifikasi_UiMain />
|
<Notifikasi_UiMain userLoginId={userLoginId} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,4 @@ process.on("SIGINT", async () => {
|
|||||||
process.exit(0);
|
process.exit(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
// console.log("==> Test prisma");
|
|
||||||
|
|
||||||
export default prisma;
|
export default prisma;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export const apiGetUserId = async () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("Ini di pemanggilan API",await response.json());
|
console.log("Ini di pemanggilan API", await response.json());
|
||||||
|
|
||||||
if (!response.ok) return null;
|
if (!response.ok) return null;
|
||||||
const data: Record<string, any> = await response.json();
|
const data: Record<string, any> = await response.json();
|
||||||
@@ -37,3 +37,24 @@ export const apiGetACtivationUser = async () => {
|
|||||||
});
|
});
|
||||||
return await response.json().catch(() => null);
|
return await response.json().catch(() => null);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const apiGetAllUserWithExceptId = async ({
|
||||||
|
exceptId,
|
||||||
|
}: {
|
||||||
|
exceptId?: string;
|
||||||
|
}) => {
|
||||||
|
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||||
|
if (!token) return await token.json().catch(() => null);
|
||||||
|
|
||||||
|
const isExceptId = exceptId ? `?except-id=${exceptId}` : "";
|
||||||
|
|
||||||
|
const response = await fetch(`/api/user/all${isExceptId}`, {
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Accept: "application/json",
|
||||||
|
"Access-Control-Allow-Origin": "*",
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return await response.json().catch(() => null);
|
||||||
|
};
|
||||||
|
|||||||
@@ -18,17 +18,16 @@ import {
|
|||||||
Title,
|
Title,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { IconCirclePlus, IconEdit } from "@tabler/icons-react";
|
import { IconEdit } from "@tabler/icons-react";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { ComponentAdminGlobal_NotifikasiBerhasil } from "../../_admin_global/admin_notifikasi/notifikasi_berhasil";
|
import { ComponentAdminGlobal_NotifikasiBerhasil } from "../../_admin_global/admin_notifikasi/notifikasi_berhasil";
|
||||||
import { ComponentAdminGlobal_NotifikasiGagal } from "../../_admin_global/admin_notifikasi/notifikasi_gagal";
|
import { ComponentAdminGlobal_NotifikasiGagal } from "../../_admin_global/admin_notifikasi/notifikasi_gagal";
|
||||||
|
import { AdminAppInformation_ComponentTitlePageBank } from "../component";
|
||||||
import adminAppInformation_createBank from "../fun/create/fun_create_new_bank";
|
import adminAppInformation_createBank from "../fun/create/fun_create_new_bank";
|
||||||
import adminAppInformation_getMasterBank from "../fun/master/get_list_bank";
|
import adminAppInformation_getMasterBank from "../fun/master/get_list_bank";
|
||||||
import adminAppInformation_updateStatusBankById from "../fun/update/fun_udpate_status_bank";
|
import adminAppInformation_updateStatusBankById from "../fun/update/fun_udpate_status_bank";
|
||||||
import adminAppInformation_updateDataBankById from "../fun/update/fun_update_data_bank";
|
import adminAppInformation_updateDataBankById from "../fun/update/fun_update_data_bank";
|
||||||
import { ComponentAdminGlobal_TitlePage } from "../../_admin_global/_component";
|
|
||||||
import { AdminAppInformation_ComponentTitlePageBank } from "../component";
|
|
||||||
|
|
||||||
export default function AdminAppInformation_ViewInfoBank({
|
export default function AdminAppInformation_ViewInfoBank({
|
||||||
listBank,
|
listBank,
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ import { AdminDonasi_funUpdateStatusPublish } from "../fun/update/fun_status_pub
|
|||||||
import { AdminDonasi_funUpdateStatusReject } from "../fun/update/fun_status_reject";
|
import { AdminDonasi_funUpdateStatusReject } from "../fun/update/fun_status_reject";
|
||||||
import { donasi_checkStatus } from "@/app_modules/donasi/fun";
|
import { donasi_checkStatus } from "@/app_modules/donasi/fun";
|
||||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
||||||
|
import adminNotifikasi_funCreateToAllUser from "../../notifikasi/fun/create/fun_create_notif_to_all_user";
|
||||||
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
|
import { apiGetAllUserWithExceptId } from "@/app_modules/_global/lib/api_user";
|
||||||
|
|
||||||
export default function AdminDonasi_DetailReview({
|
export default function AdminDonasi_DetailReview({
|
||||||
dataReview,
|
dataReview,
|
||||||
@@ -66,51 +69,88 @@ function ButtonOnHeader({
|
|||||||
const [catatan, setCatatan] = useState("");
|
const [catatan, setCatatan] = useState("");
|
||||||
|
|
||||||
async function onPulish() {
|
async function onPulish() {
|
||||||
const checkStatus = await donasi_checkStatus({ id: donasi.id });
|
try {
|
||||||
|
setLoadingPublish(true);
|
||||||
|
const checkStatus = await donasi_checkStatus({ id: donasi.id });
|
||||||
|
|
||||||
if (checkStatus) {
|
if (checkStatus) {
|
||||||
const res = await AdminDonasi_funUpdateStatusPublish(donasi.id, "1");
|
const res = await AdminDonasi_funUpdateStatusPublish(donasi.id, "1");
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
const dataNotifikasi: IRealtimeData = {
|
// ===== TO CREATEOR ====== //
|
||||||
appId: res.data?.id as string,
|
const notifikasiToCreator: IRealtimeData = {
|
||||||
status: res.data?.DonasiMaster_Status?.name as any,
|
appId: res.data?.id as string,
|
||||||
userId: res.data?.authorId as any,
|
status: res.data?.DonasiMaster_Status?.name as any,
|
||||||
pesan: res.data?.title as any,
|
userId: res.data?.authorId as any,
|
||||||
kategoriApp: "DONASI",
|
pesan: res.data?.title as any,
|
||||||
title: "Donasi publish",
|
kategoriApp: "DONASI",
|
||||||
};
|
title: "Donasi publish",
|
||||||
|
};
|
||||||
|
|
||||||
const notif = await adminNotifikasi_funCreateToUser({
|
const notif = await adminNotifikasi_funCreateToUser({
|
||||||
data: dataNotifikasi as any,
|
data: notifikasiToCreator as any,
|
||||||
});
|
|
||||||
|
|
||||||
if (notif.status === 201) {
|
|
||||||
WibuRealtime.setData({
|
|
||||||
type: "notification",
|
|
||||||
pushNotificationTo: "USER",
|
|
||||||
dataMessage: dataNotifikasi,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
WibuRealtime.setData({
|
if (notif.status === 201) {
|
||||||
type: "trigger",
|
WibuRealtime.setData({
|
||||||
pushNotificationTo: "USER",
|
type: "notification",
|
||||||
dataMessage: dataNotifikasi,
|
pushNotificationTo: "USER",
|
||||||
|
dataMessage: notifikasiToCreator,
|
||||||
|
});
|
||||||
|
|
||||||
|
WibuRealtime.setData({
|
||||||
|
type: "trigger",
|
||||||
|
pushNotificationTo: "USER",
|
||||||
|
dataMessage: notifikasiToCreator,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===== TO CREATEOR ====== //
|
||||||
|
|
||||||
|
// TO ALL USER
|
||||||
|
const notificationToAll = await adminNotifikasi_funCreateToAllUser({
|
||||||
|
data: res.data as any,
|
||||||
|
authorId: donasi.authorId,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (notificationToAll.status === 201) {
|
||||||
|
const dataUser = notificationToAll.data;
|
||||||
|
for (let i of dataUser as any) {
|
||||||
|
const dataNotifikasiToAll: IRealtimeData = {
|
||||||
|
appId: res.data?.id as string,
|
||||||
|
status: res.data?.DonasiMaster_Status?.name as any,
|
||||||
|
userId: i.id as any,
|
||||||
|
pesan: res.data?.title as any,
|
||||||
|
kategoriApp: "DONASI",
|
||||||
|
title: "Donasi baru terpublish",
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
WibuRealtime.setData({
|
||||||
|
type: "notification",
|
||||||
|
pushNotificationTo: "USER",
|
||||||
|
dataMessage: dataNotifikasiToAll,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const newData = await AdminDonasi_getOneById(donasi?.id);
|
const newData = await AdminDonasi_getOneById(donasi?.id);
|
||||||
setData(newData);
|
setData(newData);
|
||||||
ComponentAdminGlobal_NotifikasiBerhasil(
|
ComponentAdminGlobal_NotifikasiBerhasil(
|
||||||
"Berhasil Mengubah Status Donasi"
|
"Berhasil Mengubah Status Donasi"
|
||||||
);
|
);
|
||||||
setLoadingPublish(true);
|
} else {
|
||||||
|
setLoadingPublish(false);
|
||||||
|
ComponentAdminGlobal_NotifikasiPeringatan(
|
||||||
|
"Gagal Mengubah Status Donasi"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ComponentAdminGlobal_NotifikasiPeringatan(
|
setLoadingPublish(false);
|
||||||
"Gagal Mengubah Status Donasi"
|
ComponentGlobal_NotifikasiPeringatan("Status donasi telah diubah user");
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else {
|
} catch (error) {
|
||||||
ComponentGlobal_NotifikasiPeringatan("Status donasi telah diubah user");
|
setLoadingPublish(false);
|
||||||
|
clientLogger.error("Error to published donasi", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,6 +210,8 @@ function ButtonOnHeader({
|
|||||||
{donasi.donasiMaster_StatusDonasiId === "2" ? (
|
{donasi.donasiMaster_StatusDonasiId === "2" ? (
|
||||||
<Group>
|
<Group>
|
||||||
<Button
|
<Button
|
||||||
|
loading={isLoadingPublish}
|
||||||
|
loaderPosition="center"
|
||||||
radius={"xl"}
|
radius={"xl"}
|
||||||
bg={"green"}
|
bg={"green"}
|
||||||
color="green"
|
color="green"
|
||||||
|
|||||||
@@ -36,5 +36,7 @@ export async function AdminDonasi_getOneById(id: string) {
|
|||||||
imageId: true,
|
imageId: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await prisma.$disconnect();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,8 +32,14 @@ export async function AdminDonasi_funUpdateStatusPublish(
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!data) return { status: 400, message: "Data tidak ditemukan" };
|
if (!data) {
|
||||||
|
await prisma.$disconnect();
|
||||||
|
return { status: 400, message: "Data tidak ditemukan" };
|
||||||
|
}
|
||||||
|
|
||||||
revalidatePath(RouterAdminDonasi.table_review);
|
revalidatePath(RouterAdminDonasi.table_review);
|
||||||
|
await prisma.$disconnect();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data: data,
|
data: data,
|
||||||
status: 200,
|
status: 200,
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ export function Admin_NewLayout({
|
|||||||
<Grid>
|
<Grid>
|
||||||
<Grid.Col span={7}>
|
<Grid.Col span={7}>
|
||||||
<Title order={3} lineClamp={1}>
|
<Title order={3} lineClamp={1}>
|
||||||
{userRoleId == "2" ? "Admin" : "Developer"}
|
{userRoleId == "2" ? "Admin" : "SuperAdmin"}
|
||||||
</Title>
|
</Title>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
|
|
||||||
@@ -130,7 +130,8 @@ export function Admin_NewLayout({
|
|||||||
onLoadListNotifikasi();
|
onLoadListNotifikasi();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{countNtf == 0 ? (
|
{countNtf == 0 ||
|
||||||
|
dataUser.masterUserRoleId == "3" ? (
|
||||||
<IconBell color="white" />
|
<IconBell color="white" />
|
||||||
) : (
|
) : (
|
||||||
<Indicator
|
<Indicator
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
"use server";
|
||||||
|
|
||||||
|
import prisma from "@/app/lib/prisma";
|
||||||
|
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||||
|
|
||||||
|
export default async function adminNotifikasi_funCreateToAllUser({
|
||||||
|
data,
|
||||||
|
authorId,
|
||||||
|
}: {
|
||||||
|
data: any;
|
||||||
|
authorId: string;
|
||||||
|
}) {
|
||||||
|
const userLoginId = await funGetUserIdByToken();
|
||||||
|
|
||||||
|
const dataUser = await prisma.user.findMany({
|
||||||
|
where: {
|
||||||
|
NOT: {
|
||||||
|
id: authorId,
|
||||||
|
},
|
||||||
|
active: true,
|
||||||
|
masterUserRoleId: "1",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
for (let i of dataUser) {
|
||||||
|
const create = await prisma.notifikasi.create({
|
||||||
|
data: {
|
||||||
|
adminId: userLoginId,
|
||||||
|
userId: i.id,
|
||||||
|
appId: data.id,
|
||||||
|
status: data.DonasiMaster_Status.name,
|
||||||
|
title: "Donasi baru terpublish",
|
||||||
|
pesan: data.title,
|
||||||
|
kategoriApp: "DONASI",
|
||||||
|
userRoleId: "1",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!create) {
|
||||||
|
await prisma.$disconnect();
|
||||||
|
return { status: 400, message: "Gagal mengirim notifikasi" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await prisma.$disconnect();
|
||||||
|
return {
|
||||||
|
status: 201,
|
||||||
|
message: "Berhasil mengirim notifikasi",
|
||||||
|
data: dataUser,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -23,7 +23,12 @@ export default async function adminNotifikasi_funCreateToUser({
|
|||||||
userRoleId: "1",
|
userRoleId: "1",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!create) return { status: 400, message: "Gagal mengirim notifikasi" };
|
if (!create) {
|
||||||
|
await prisma.$disconnect();
|
||||||
|
return { status: 400, message: "Gagal mengirim notifikasi" };
|
||||||
|
}
|
||||||
|
|
||||||
|
await prisma.$disconnect();
|
||||||
return { status: 201, message: "Berhasil mengirim notifikasi" };
|
return { status: 201, message: "Berhasil mengirim notifikasi" };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,37 +1,37 @@
|
|||||||
|
import { DIRECTORY_ID } from "@/app/lib";
|
||||||
import { MainColor } from "@/app_modules/_global/color";
|
import { MainColor } from "@/app_modules/_global/color";
|
||||||
import {
|
import {
|
||||||
ComponentGlobal_BoxInformation,
|
ComponentGlobal_BoxInformation,
|
||||||
ComponentGlobal_BoxUploadImage,
|
ComponentGlobal_BoxUploadImage,
|
||||||
|
ComponentGlobal_ButtonUploadFileImage,
|
||||||
ComponentGlobal_InputCountDown,
|
ComponentGlobal_InputCountDown,
|
||||||
ComponentGlobal_LoadImageCustom,
|
ComponentGlobal_LoadImageCustom,
|
||||||
} from "@/app_modules/_global/component";
|
} from "@/app_modules/_global/component";
|
||||||
import {
|
import {
|
||||||
AspectRatio,
|
funGlobal_DeleteFileById,
|
||||||
Button,
|
funGlobal_UploadToStorage,
|
||||||
FileButton,
|
} from "@/app_modules/_global/fun";
|
||||||
Group,
|
|
||||||
Image,
|
|
||||||
Stack,
|
|
||||||
Text,
|
|
||||||
TextInput,
|
|
||||||
Textarea,
|
|
||||||
} from "@mantine/core";
|
|
||||||
import { IconCamera, IconUpload } from "@tabler/icons-react";
|
|
||||||
import _ from "lodash";
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
import { useState } from "react";
|
|
||||||
import { MODEL_DONASI_KABAR } from "../../model/interface";
|
|
||||||
import {
|
import {
|
||||||
ComponentGlobal_NotifikasiBerhasil,
|
ComponentGlobal_NotifikasiBerhasil,
|
||||||
ComponentGlobal_NotifikasiGagal,
|
ComponentGlobal_NotifikasiGagal,
|
||||||
ComponentGlobal_NotifikasiPeringatan,
|
ComponentGlobal_NotifikasiPeringatan,
|
||||||
} from "@/app_modules/_global/notif_global";
|
} from "@/app_modules/_global/notif_global";
|
||||||
import { DIRECTORY_ID } from "@/app/lib";
|
|
||||||
import {
|
import {
|
||||||
funGlobal_DeleteFileById,
|
AspectRatio,
|
||||||
funGlobal_UploadToStorage,
|
Button,
|
||||||
} from "@/app_modules/_global/fun";
|
Center,
|
||||||
|
Image,
|
||||||
|
Stack,
|
||||||
|
TextInput,
|
||||||
|
Textarea,
|
||||||
|
} from "@mantine/core";
|
||||||
|
import { IconPhoto } from "@tabler/icons-react";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
import { useState } from "react";
|
||||||
import { donasi_funUpdateKabar } from "../../fun";
|
import { donasi_funUpdateKabar } from "../../fun";
|
||||||
|
import { MODEL_DONASI_KABAR } from "../../model/interface";
|
||||||
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
|
|
||||||
export function Donasi_ViewEditKabar({
|
export function Donasi_ViewEditKabar({
|
||||||
dataKabar,
|
dataKabar,
|
||||||
@@ -59,9 +59,8 @@ export function Donasi_ViewEditKabar({
|
|||||||
|
|
||||||
if (!uploadImage.success) {
|
if (!uploadImage.success) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
return ComponentGlobal_NotifikasiPeringatan(
|
ComponentGlobal_NotifikasiPeringatan("Gagal upload file gambar");
|
||||||
"Gagal upload file gambar"
|
return;
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await donasi_funUpdateKabar({
|
const res = await donasi_funUpdateKabar({
|
||||||
@@ -72,12 +71,15 @@ export function Donasi_ViewEditKabar({
|
|||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
|
||||||
const deleteImage = await funGlobal_DeleteFileById({
|
if (dataKabar.imageId !== null) {
|
||||||
fileId: data.imageId,
|
const deleteImage = await funGlobal_DeleteFileById({
|
||||||
});
|
fileId: data.imageId,
|
||||||
if (!deleteImage.success) {
|
});
|
||||||
setLoading(false);
|
|
||||||
ComponentGlobal_NotifikasiPeringatan("Gagal hapus gambar lama");
|
if (!deleteImage.success) {
|
||||||
|
setLoading(false);
|
||||||
|
clientLogger.error("Gagal hapus gambar lama");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||||
@@ -92,7 +94,6 @@ export function Donasi_ViewEditKabar({
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
setLoading(false);
|
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||||
router.back();
|
router.back();
|
||||||
} else {
|
} else {
|
||||||
@@ -101,7 +102,8 @@ export function Donasi_ViewEditKabar({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
setLoading(false);
|
||||||
|
clientLogger.error("Error update donasi", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +131,7 @@ export function Donasi_ViewEditKabar({
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Textarea
|
<Textarea
|
||||||
maxLength={500}
|
maxLength={1000}
|
||||||
styles={{
|
styles={{
|
||||||
label: {
|
label: {
|
||||||
color: "white",
|
color: "white",
|
||||||
@@ -139,7 +141,7 @@ export function Donasi_ViewEditKabar({
|
|||||||
withAsterisk
|
withAsterisk
|
||||||
placeholder="Masukan deskripsi kabar"
|
placeholder="Masukan deskripsi kabar"
|
||||||
autosize
|
autosize
|
||||||
maxRows={4}
|
maxRows={10}
|
||||||
minRows={2}
|
minRows={2}
|
||||||
value={data.deskripsi}
|
value={data.deskripsi}
|
||||||
onChange={(val) => {
|
onChange={(val) => {
|
||||||
@@ -151,7 +153,7 @@ export function Donasi_ViewEditKabar({
|
|||||||
/>
|
/>
|
||||||
<ComponentGlobal_InputCountDown
|
<ComponentGlobal_InputCountDown
|
||||||
lengthInput={data.deskripsi.length}
|
lengthInput={data.deskripsi.length}
|
||||||
maxInput={500}
|
maxInput={1000}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Stack spacing={5}>
|
<Stack spacing={5}>
|
||||||
@@ -167,10 +169,7 @@ export function Donasi_ViewEditKabar({
|
|||||||
</AspectRatio>
|
</AspectRatio>
|
||||||
) : data.imageId === null ? (
|
) : data.imageId === null ? (
|
||||||
<Stack justify="center" align="center" h={"100%"}>
|
<Stack justify="center" align="center" h={"100%"}>
|
||||||
<IconUpload color="white" />
|
<IconPhoto size={100} />
|
||||||
<Text fz={10} fs={"italic"} c={"white"} fw={"bold"}>
|
|
||||||
Upload Gambar
|
|
||||||
</Text>
|
|
||||||
</Stack>
|
</Stack>
|
||||||
) : (
|
) : (
|
||||||
<Stack justify="center" align="center" h={"100%"} p={"sm"}>
|
<Stack justify="center" align="center" h={"100%"} p={"sm"}>
|
||||||
@@ -183,35 +182,12 @@ export function Donasi_ViewEditKabar({
|
|||||||
</ComponentGlobal_BoxUploadImage>
|
</ComponentGlobal_BoxUploadImage>
|
||||||
|
|
||||||
{/* Upload Foto */}
|
{/* Upload Foto */}
|
||||||
<Group position="center">
|
<Center>
|
||||||
<FileButton
|
<ComponentGlobal_ButtonUploadFileImage
|
||||||
onChange={async (files: any) => {
|
onSetFile={setFile}
|
||||||
try {
|
onSetImage={setImg}
|
||||||
const buffer = URL.createObjectURL(
|
/>
|
||||||
new Blob([new Uint8Array(await files.arrayBuffer())])
|
</Center>
|
||||||
);
|
|
||||||
setImg(buffer);
|
|
||||||
setFile(files);
|
|
||||||
} catch (error) {
|
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
accept="image/png,image/jpeg"
|
|
||||||
>
|
|
||||||
{(props) => (
|
|
||||||
<Button
|
|
||||||
{...props}
|
|
||||||
leftIcon={<IconCamera color="black" />}
|
|
||||||
radius={50}
|
|
||||||
bg={MainColor.yellow}
|
|
||||||
color="yellow"
|
|
||||||
c={"black"}
|
|
||||||
>
|
|
||||||
Upload Gambar
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</FileButton>
|
|
||||||
</Group>
|
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -1,33 +1,38 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import { DIRECTORY_ID } from "@/app/lib";
|
||||||
import { MainColor } from "@/app_modules/_global/color/color_pallet";
|
import { MainColor } from "@/app_modules/_global/color/color_pallet";
|
||||||
import { ComponentGlobal_BoxUploadImage } from "@/app_modules/_global/component";
|
import {
|
||||||
|
ComponentGlobal_BoxUploadImage,
|
||||||
|
ComponentGlobal_ButtonUploadFileImage,
|
||||||
|
} from "@/app_modules/_global/component";
|
||||||
import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information";
|
import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information";
|
||||||
import ComponentGlobal_InputCountDown from "@/app_modules/_global/component/input_countdown";
|
import ComponentGlobal_InputCountDown from "@/app_modules/_global/component/input_countdown";
|
||||||
|
import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun";
|
||||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
||||||
import { notifikasiToUser_CreateKabarDonasi } from "@/app_modules/notifikasi/fun/create/create_notif_to_user_kabar_donasi";
|
import { notifikasiToUser_CreateKabarDonasi } from "@/app_modules/notifikasi/fun/create/create_notif_to_user_kabar_donasi";
|
||||||
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
import {
|
import {
|
||||||
AspectRatio,
|
AspectRatio,
|
||||||
Button,
|
Button,
|
||||||
FileButton,
|
Center,
|
||||||
Group,
|
|
||||||
Image,
|
Image,
|
||||||
Stack,
|
Stack,
|
||||||
Text,
|
|
||||||
TextInput,
|
TextInput,
|
||||||
Textarea,
|
Textarea
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { IconCamera, IconUpload } from "@tabler/icons-react";
|
import { IconPhoto } from "@tabler/icons-react";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { useRouter } from "next/navigation";
|
import { useParams, useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { Donasi_funCreateKabar } from "../../fun/create/fun_create_kabar";
|
import { Donasi_funCreateKabar } from "../../fun/create/fun_create_kabar";
|
||||||
import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun";
|
|
||||||
import { DIRECTORY_ID } from "@/app/lib";
|
|
||||||
|
|
||||||
export default function Donasi_CreateKabar({ donasiId }: { donasiId: string }) {
|
export default function Donasi_CreateKabar() {
|
||||||
|
const params = useParams<{ id: string }>();
|
||||||
|
const donasiId = params.id;
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [file, setFile] = useState<File | null>(null);
|
const [file, setFile] = useState<File | null>(null);
|
||||||
const [img, setImg] = useState<any | null>();
|
const [img, setImg] = useState<any | null>();
|
||||||
@@ -58,9 +63,8 @@ export default function Donasi_CreateKabar({ donasiId }: { donasiId: string }) {
|
|||||||
|
|
||||||
if (!uploadImage.success) {
|
if (!uploadImage.success) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
return ComponentGlobal_NotifikasiPeringatan(
|
ComponentGlobal_NotifikasiPeringatan("Gagal upload file gambar");
|
||||||
"Gagal upload file gambar"
|
return;
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await Donasi_funCreateKabar({
|
const res = await Donasi_funCreateKabar({
|
||||||
@@ -76,7 +80,6 @@ export default function Donasi_CreateKabar({ donasiId }: { donasiId: string }) {
|
|||||||
|
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||||
router.back();
|
router.back();
|
||||||
setLoading(false);
|
|
||||||
} else {
|
} else {
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
@@ -94,21 +97,21 @@ export default function Donasi_CreateKabar({ donasiId }: { donasiId: string }) {
|
|||||||
|
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||||
router.back();
|
router.back();
|
||||||
setLoading(false);
|
|
||||||
} else {
|
} else {
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
setLoading(false);
|
||||||
|
clientLogger.error("Error upload berita", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack px={"lg"} pb={"lg"}>
|
<Stack px={"lg"} pb={"lg"}>
|
||||||
<ComponentGlobal_BoxInformation informasi="Gambar tidak wajib di isi ! Hanya upload jika di butuhkan." />
|
<ComponentGlobal_BoxInformation informasi="Upload gambar bersifat opsional untuk melengkapi kabar terkait donasi Anda." />
|
||||||
|
|
||||||
<TextInput
|
<TextInput
|
||||||
maxLength={100}
|
maxLength={100}
|
||||||
@@ -128,7 +131,7 @@ export default function Donasi_CreateKabar({ donasiId }: { donasiId: string }) {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Textarea
|
<Textarea
|
||||||
maxLength={500}
|
maxLength={1000}
|
||||||
styles={{
|
styles={{
|
||||||
label: {
|
label: {
|
||||||
color: "white",
|
color: "white",
|
||||||
@@ -138,7 +141,7 @@ export default function Donasi_CreateKabar({ donasiId }: { donasiId: string }) {
|
|||||||
withAsterisk
|
withAsterisk
|
||||||
placeholder="Masukan deskripsi kabar"
|
placeholder="Masukan deskripsi kabar"
|
||||||
autosize
|
autosize
|
||||||
maxRows={4}
|
maxRows={10}
|
||||||
minRows={2}
|
minRows={2}
|
||||||
onChange={(val) => {
|
onChange={(val) => {
|
||||||
setKabar({
|
setKabar({
|
||||||
@@ -149,7 +152,7 @@ export default function Donasi_CreateKabar({ donasiId }: { donasiId: string }) {
|
|||||||
/>
|
/>
|
||||||
<ComponentGlobal_InputCountDown
|
<ComponentGlobal_InputCountDown
|
||||||
lengthInput={kabar.deskripsi.length}
|
lengthInput={kabar.deskripsi.length}
|
||||||
maxInput={500}
|
maxInput={1000}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Stack spacing={5}>
|
<Stack spacing={5}>
|
||||||
@@ -165,44 +168,18 @@ export default function Donasi_CreateKabar({ donasiId }: { donasiId: string }) {
|
|||||||
</AspectRatio>
|
</AspectRatio>
|
||||||
) : (
|
) : (
|
||||||
<Stack justify="center" align="center" h={"100%"}>
|
<Stack justify="center" align="center" h={"100%"}>
|
||||||
<IconUpload color="white" />
|
<IconPhoto size={100} />
|
||||||
<Text fz={10} fs={"italic"} c={"white"} fw={"bold"}>
|
|
||||||
Upload Gambar
|
|
||||||
</Text>
|
|
||||||
</Stack>
|
</Stack>
|
||||||
)}
|
)}
|
||||||
</ComponentGlobal_BoxUploadImage>
|
</ComponentGlobal_BoxUploadImage>
|
||||||
|
|
||||||
{/* Upload Foto */}
|
{/* Upload Foto */}
|
||||||
<Group position="center">
|
<Center>
|
||||||
<FileButton
|
<ComponentGlobal_ButtonUploadFileImage
|
||||||
onChange={async (files: any) => {
|
onSetFile={setFile}
|
||||||
try {
|
onSetImage={setImg}
|
||||||
const buffer = URL.createObjectURL(
|
/>
|
||||||
new Blob([new Uint8Array(await files.arrayBuffer())])
|
</Center>
|
||||||
);
|
|
||||||
setImg(buffer);
|
|
||||||
setFile(files);
|
|
||||||
} catch (error) {
|
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
accept="image/png,image/jpeg"
|
|
||||||
>
|
|
||||||
{(props) => (
|
|
||||||
<Button
|
|
||||||
{...props}
|
|
||||||
leftIcon={<IconCamera color="black" />}
|
|
||||||
radius={50}
|
|
||||||
bg={MainColor.yellow}
|
|
||||||
color="yellow"
|
|
||||||
c={"black"}
|
|
||||||
>
|
|
||||||
Upload Gambar
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</FileButton>
|
|
||||||
</Group>
|
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ export async function donasi_checkStatus({ id }: { id: string }) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await prisma.$disconnect();
|
||||||
|
|
||||||
|
|
||||||
if (checkStatus?.donasiMaster_StatusDonasiId == "2") return true;
|
if (checkStatus?.donasiMaster_StatusDonasiId == "2") return true;
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -18,7 +18,11 @@ import { gs_notifikasi_kategori_app } from "../lib";
|
|||||||
import { apiGetAllNotifikasiByCategory } from "../lib/api_notifikasi";
|
import { apiGetAllNotifikasiByCategory } from "../lib/api_notifikasi";
|
||||||
import { MODEL_NOTIFIKASI } from "../model/interface";
|
import { MODEL_NOTIFIKASI } from "../model/interface";
|
||||||
|
|
||||||
export default function Notifikasi_UiMain() {
|
export default function Notifikasi_UiMain({
|
||||||
|
userLoginId,
|
||||||
|
}: {
|
||||||
|
userLoginId?: string;
|
||||||
|
}) {
|
||||||
const [data, setData] = useState<MODEL_NOTIFIKASI[] | null>(null);
|
const [data, setData] = useState<MODEL_NOTIFIKASI[] | null>(null);
|
||||||
const [activePage, setActivePage] = useState(1);
|
const [activePage, setActivePage] = useState(1);
|
||||||
const [categoryPage, setCategoryPage] = useAtom(gs_notifikasi_kategori_app);
|
const [categoryPage, setCategoryPage] = useAtom(gs_notifikasi_kategori_app);
|
||||||
@@ -80,6 +84,7 @@ export default function Notifikasi_UiMain() {
|
|||||||
data={item}
|
data={item}
|
||||||
onLoadData={setData}
|
onLoadData={setData}
|
||||||
categoryPage={categoryPage as any}
|
categoryPage={categoryPage as any}
|
||||||
|
userLoginId={userLoginId}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</ScrollOnly>
|
</ScrollOnly>
|
||||||
|
|||||||
@@ -24,15 +24,18 @@ 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";
|
||||||
|
|
||||||
export function ComponentNotifiaksi_CardView({
|
export function ComponentNotifiaksi_CardView({
|
||||||
data,
|
data,
|
||||||
onLoadData,
|
onLoadData,
|
||||||
categoryPage,
|
categoryPage,
|
||||||
|
userLoginId,
|
||||||
}: {
|
}: {
|
||||||
data: MODEL_NOTIFIKASI;
|
data: MODEL_NOTIFIKASI;
|
||||||
onLoadData: (val: any) => void;
|
onLoadData: (val: any) => void;
|
||||||
categoryPage: string;
|
categoryPage: string;
|
||||||
|
userLoginId?: string
|
||||||
}) {
|
}) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
@@ -59,134 +62,146 @@ export function ComponentNotifiaksi_CardView({
|
|||||||
}}
|
}}
|
||||||
my={"xs"}
|
my={"xs"}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
// JOB
|
try {
|
||||||
if (data?.kategoriApp === "JOB") {
|
setVisible(true);
|
||||||
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;
|
// 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// EVENT
|
||||||
|
if (data?.kategoriApp === "EVENT") {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// VOTING
|
||||||
|
if (data?.kategoriApp === "VOTING") {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// DONASI
|
||||||
|
if (data?.kategoriApp === "DONASI") {
|
||||||
|
redirectDonasiPage({
|
||||||
|
appId: data.appId,
|
||||||
|
dataId: data.id,
|
||||||
|
userId: data.userId,
|
||||||
|
userLoginId: userLoginId as any,
|
||||||
|
categoryPage: categoryPage,
|
||||||
|
router: router,
|
||||||
|
onLoadDataEvent(val) {
|
||||||
|
onLoadData(val);
|
||||||
|
},
|
||||||
|
onSetVisible(val) {
|
||||||
|
setVisible(val);
|
||||||
|
},
|
||||||
|
onSetMenuId(val) {
|
||||||
|
setDonasiMenu(val);
|
||||||
|
},
|
||||||
|
onLoadCountNtf(val) {
|
||||||
|
setLoadCountNtf(val);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// INVESTASI
|
||||||
|
if (data?.kategoriApp === "INVESTASI") {
|
||||||
|
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,
|
||||||
|
// });
|
||||||
|
|
||||||
|
// data?.kategoriApp === "COLLABORATION" &&
|
||||||
|
// redirectDetailCollaborationPage({
|
||||||
|
// data: data,
|
||||||
|
// router: router,
|
||||||
|
// });
|
||||||
|
} catch (error) {
|
||||||
|
setVisible(false);
|
||||||
|
clientLogger.error("Error redirect notification page", error);
|
||||||
}
|
}
|
||||||
|
|
||||||
// EVENT
|
|
||||||
if (data?.kategoriApp === "EVENT") {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data?.kategoriApp === "VOTING") {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data?.kategoriApp === "DONASI") {
|
|
||||||
redirectDonasiPage({
|
|
||||||
appId: data.appId,
|
|
||||||
dataId: data.id,
|
|
||||||
categoryPage: categoryPage,
|
|
||||||
router: router,
|
|
||||||
onLoadDataEvent(val) {
|
|
||||||
onLoadData(val);
|
|
||||||
},
|
|
||||||
onSetVisible(val) {
|
|
||||||
setVisible(val);
|
|
||||||
},
|
|
||||||
onSetMenuId(val) {
|
|
||||||
setDonasiMenu(val);
|
|
||||||
},
|
|
||||||
onLoadCountNtf(val) {
|
|
||||||
setLoadCountNtf(val);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data?.kategoriApp === "INVESTASI") {
|
|
||||||
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,
|
|
||||||
// });
|
|
||||||
|
|
||||||
// data?.kategoriApp === "COLLABORATION" &&
|
|
||||||
// redirectDetailCollaborationPage({
|
|
||||||
// data: data,
|
|
||||||
// router: router,
|
|
||||||
// });
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{/* <pre>{JSON.stringify(e, null, 2)}</pre> */}
|
{/* <pre>{JSON.stringify(e, null, 2)}</pre> */}
|
||||||
|
|||||||
@@ -7,11 +7,14 @@ import notifikasi_getByUserId from "../../fun/get/get_notifiaksi_by_id";
|
|||||||
import notifikasi_countUserNotifikasi from "../../fun/count/fun_count_by_id";
|
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";
|
||||||
|
|
||||||
export async function redirectDonasiPage({
|
export async function redirectDonasiPage({
|
||||||
appId,
|
appId,
|
||||||
dataId,
|
dataId,
|
||||||
categoryPage,
|
categoryPage,
|
||||||
|
userId,
|
||||||
|
userLoginId,
|
||||||
router,
|
router,
|
||||||
onLoadDataEvent,
|
onLoadDataEvent,
|
||||||
onSetMenuId,
|
onSetMenuId,
|
||||||
@@ -21,6 +24,8 @@ export async function redirectDonasiPage({
|
|||||||
appId: string;
|
appId: string;
|
||||||
dataId: string;
|
dataId: string;
|
||||||
categoryPage: string;
|
categoryPage: string;
|
||||||
|
userId: string;
|
||||||
|
userLoginId: string;
|
||||||
router: AppRouterInstance;
|
router: AppRouterInstance;
|
||||||
onLoadDataEvent: (val: any) => void;
|
onLoadDataEvent: (val: any) => void;
|
||||||
onSetMenuId(val: number): void;
|
onSetMenuId(val: number): void;
|
||||||
@@ -28,29 +33,38 @@ export async function redirectDonasiPage({
|
|||||||
onLoadCountNtf(val: number): void;
|
onLoadCountNtf(val: number): void;
|
||||||
}) {
|
}) {
|
||||||
const check = await notifikasi_funDonasiCheckStatus({ id: appId });
|
const check = await notifikasi_funDonasiCheckStatus({ id: appId });
|
||||||
|
const checkAuthor = await notifikasi_checkAuthorDonasiById({
|
||||||
|
donasiId: appId,
|
||||||
|
userId: userId,
|
||||||
|
});
|
||||||
|
|
||||||
if (check.status == 200) {
|
if (check.status == 200) {
|
||||||
const loadListNotifikasi = await notifikasi_getByUserId({
|
// const loadListNotifikasi = await notifikasi_getByUserId({
|
||||||
page: 1,
|
// page: 1,
|
||||||
kategoriApp: categoryPage as any,
|
// kategoriApp: categoryPage as any,
|
||||||
});
|
// });
|
||||||
onLoadDataEvent(loadListNotifikasi);
|
// onLoadDataEvent(loadListNotifikasi);
|
||||||
|
|
||||||
const loadCountNotifikasi = await notifikasi_countUserNotifikasi();
|
// const loadCountNotifikasi = await notifikasi_countUserNotifikasi();
|
||||||
onLoadCountNtf(loadCountNotifikasi);
|
// onLoadCountNtf(loadCountNotifikasi);
|
||||||
|
|
||||||
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
||||||
notifId: dataId,
|
notifId: dataId,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (updateReadNotifikasi.status == 200) {
|
if (updateReadNotifikasi.status == 200) {
|
||||||
onSetVisible(true);
|
const pathToCreator = `/dev/donasi/detail/${check.statusName}/${appId}`;
|
||||||
|
const pathToAllUser = `/dev/donasi/detail/main/${appId}`;
|
||||||
|
|
||||||
const path = `/dev/donasi/detail/${check.statusName}/${appId}`;
|
if (checkAuthor) {
|
||||||
onSetMenuId(1);
|
router.push(pathToCreator, { scroll: false });
|
||||||
router.push(path, { scroll: false });
|
} else {
|
||||||
|
router.push(pathToAllUser, { scroll: false });
|
||||||
|
onSetMenuId(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
onSetVisible(false);
|
||||||
ComponentGlobal_NotifikasiPeringatan("Status tidak ditemukan");
|
ComponentGlobal_NotifikasiPeringatan("Status tidak ditemukan");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,9 +37,6 @@ export async function redirectInvestasiPage({
|
|||||||
id: appId,
|
id: appId,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("check", check);
|
|
||||||
console.log("check investor:", checkInvestor);
|
|
||||||
|
|
||||||
if (check.status == 200) {
|
if (check.status == 200) {
|
||||||
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
||||||
notifId: dataId,
|
notifId: dataId,
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
"use server";
|
||||||
|
|
||||||
|
import { prisma } from "@/app/lib";
|
||||||
|
|
||||||
|
export async function notifikasi_checkAuthorDonasiById({
|
||||||
|
userId,
|
||||||
|
donasiId,
|
||||||
|
}: {
|
||||||
|
userId: string;
|
||||||
|
donasiId: string;
|
||||||
|
}) {
|
||||||
|
const check = await prisma.donasi.findFirst({
|
||||||
|
where: {
|
||||||
|
authorId: userId,
|
||||||
|
id: donasiId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (check) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,7 +30,6 @@ export async function notifikasiToUser_CreateKabarDonasi({
|
|||||||
const dataFix = Array.from(data);
|
const dataFix = Array.from(data);
|
||||||
|
|
||||||
for (let authorId of dataFix) {
|
for (let authorId of dataFix) {
|
||||||
console.log(authorId);
|
|
||||||
const createNotifikasi = await prisma.notifikasi.create({
|
const createNotifikasi = await prisma.notifikasi.create({
|
||||||
data: {
|
data: {
|
||||||
userRoleId: "1",
|
userRoleId: "1",
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ const middlewareConfig: MiddlewareConfig = {
|
|||||||
"/api/origin-url",
|
"/api/origin-url",
|
||||||
"/api/event/*",
|
"/api/event/*",
|
||||||
// "/api/image/*",
|
// "/api/image/*",
|
||||||
// "/api/user",
|
// "/api/user/*",
|
||||||
"/api/new/*",
|
// "/api/new/*",
|
||||||
// Akses awal
|
// Akses awal
|
||||||
"/api/get-cookie",
|
"/api/get-cookie",
|
||||||
"/api/user/activation",
|
"/api/user/activation",
|
||||||
|
|||||||
Reference in New Issue
Block a user