fix collaboration notifikasi
This commit is contained in:
@@ -36,6 +36,8 @@ import colab_funCreatePartisipan from "../../fun/create/fun_create_partisipan_by
|
||||
import { MODEL_COLLABORATION_PARTISIPASI } from "../../model/interface";
|
||||
import { Collaboration_SkeletonListPrtisipanIsUser } from "../skeleton_view";
|
||||
import ComponentColab_AuthorNameOnListPartisipan from "./header_author_list_partisipan";
|
||||
import { WibuRealtime } from "wibu-pkg";
|
||||
import { IRealtimeData } from "@/lib/global_state";
|
||||
|
||||
export default function ComponentColab_DetailListPartisipasiUser({
|
||||
userLoginId,
|
||||
@@ -103,37 +105,42 @@ export default function ComponentColab_DetailListPartisipasiUser({
|
||||
});
|
||||
|
||||
if (res.status === 201) {
|
||||
// const dataNotif = {
|
||||
// appId: res?.data?.ProjectCollaboration?.id,
|
||||
// userId: res?.data?.ProjectCollaboration?.userId,
|
||||
// pesan: res?.data?.ProjectCollaboration?.title,
|
||||
// status: "Partisipan Project",
|
||||
// kategoriApp: "COLLABORATION",
|
||||
// title: "Partisipan baru telah bergabung !",
|
||||
// };
|
||||
const dataNotifikasi: IRealtimeData = {
|
||||
appId: res?.data?.ProjectCollaboration?.id,
|
||||
userId: res?.data?.ProjectCollaboration?.userId as any,
|
||||
pesan: res?.data?.ProjectCollaboration?.title,
|
||||
status: "Partisipan Project" as any,
|
||||
kategoriApp: "COLLABORATION",
|
||||
title: "Partisipan baru telah bergabung !",
|
||||
};
|
||||
|
||||
// const createNotifikasi = await notifikasiToUser_funCreate({
|
||||
// data: dataNotif as any,
|
||||
// });
|
||||
const createNotifikasi = await notifikasiToUser_funCreate({
|
||||
data: dataNotifikasi as any,
|
||||
});
|
||||
|
||||
// if (createNotifikasi.status === 201) {
|
||||
// mqtt_client.publish(
|
||||
// "USER",
|
||||
// JSON.stringify({
|
||||
// userId: dataNotif.userId,
|
||||
// count: 1,
|
||||
// })
|
||||
// );
|
||||
// }
|
||||
if (createNotifikasi.status === 201) {
|
||||
WibuRealtime.setData({
|
||||
type: "trigger",
|
||||
pushNotificationTo: "USER",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
// mqtt_client.publish(
|
||||
// "USER",
|
||||
// JSON.stringify({
|
||||
// userId: dataNotif.userId,
|
||||
// count: 1,
|
||||
// })
|
||||
// );
|
||||
}
|
||||
|
||||
const respone = await apiGetOneCollaborationById({
|
||||
const response = await apiGetOneCollaborationById({
|
||||
id: params.id,
|
||||
kategori: "list_partisipan",
|
||||
page: `${activePage}`,
|
||||
});
|
||||
|
||||
if (respone) {
|
||||
setData(respone.data);
|
||||
if (response) {
|
||||
setData(response.data);
|
||||
}
|
||||
|
||||
const cekPartisipan = await apiGetOneCollaborationById({
|
||||
@@ -274,8 +281,8 @@ export default function ComponentColab_DetailListPartisipasiUser({
|
||||
}
|
||||
styles={{
|
||||
input: {
|
||||
backgroundColor: MainColor.white
|
||||
}
|
||||
backgroundColor: MainColor.white,
|
||||
},
|
||||
}}
|
||||
placeholder="Deskripsikan diri anda yang sesuai dengan proyek ini.."
|
||||
minRows={4}
|
||||
|
||||
@@ -12,37 +12,46 @@ export default async function colab_funCreatePartisipan({
|
||||
id: string;
|
||||
deskripsi: string;
|
||||
}) {
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
try {
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
if (userLoginId == null) {
|
||||
return {
|
||||
status: 500,
|
||||
message: "Gagal mendapatkan data, user id tidak ada",
|
||||
};
|
||||
}
|
||||
if (!userLoginId) {
|
||||
return {
|
||||
status: 404,
|
||||
message: "Gagal mendapatkan data, user id tidak ada",
|
||||
};
|
||||
}
|
||||
|
||||
const create = await prisma.projectCollaboration_Partisipasi.create({
|
||||
data: {
|
||||
projectCollaborationId: id,
|
||||
userId: userLoginId,
|
||||
deskripsi_diri: deskripsi,
|
||||
},
|
||||
select: {
|
||||
ProjectCollaboration: {
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
userId: true,
|
||||
const create = await prisma.projectCollaboration_Partisipasi.create({
|
||||
data: {
|
||||
projectCollaborationId: id,
|
||||
userId: userLoginId,
|
||||
deskripsi_diri: deskripsi,
|
||||
},
|
||||
select: {
|
||||
ProjectCollaboration: {
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
userId: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
if (!create) return { status: 400, message: "Gagal menambahkan partisipan" };
|
||||
revalidatePath(RouterColab.main_detail + id);
|
||||
return {
|
||||
data: create,
|
||||
status: 201,
|
||||
message: "Berhasil menambahkan partisipan",
|
||||
};
|
||||
if (!create)
|
||||
return { status: 400, message: "Gagal menambahkan partisipan" };
|
||||
revalidatePath(RouterColab.main_detail + id);
|
||||
return {
|
||||
data: create,
|
||||
status: 201,
|
||||
message: "Berhasil menambahkan partisipan",
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
status: 500,
|
||||
message: "Error menambahkan partisipan",
|
||||
error: (error as Error).message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,6 +77,9 @@ export default function HomeViewNew() {
|
||||
}
|
||||
}
|
||||
|
||||
console.log("count >", countNtf);
|
||||
console.log("user >", dataUser);
|
||||
|
||||
return (
|
||||
<>
|
||||
<UIGlobal_LayoutTamplate
|
||||
@@ -84,7 +87,7 @@ export default function HomeViewNew() {
|
||||
<UIGlobal_LayoutHeaderTamplate
|
||||
title="HIPMI"
|
||||
customButtonLeft={
|
||||
!dataUser || !countNtf ? (
|
||||
!dataUser && !countNtf ? (
|
||||
<ActionIcon radius={"xl"} variant={"transparent"}>
|
||||
<IconUserSearch color={"gray"} />
|
||||
</ActionIcon>
|
||||
@@ -111,7 +114,7 @@ export default function HomeViewNew() {
|
||||
)
|
||||
}
|
||||
customButtonRight={
|
||||
!dataUser || !countNtf ? (
|
||||
!dataUser && !countNtf ? (
|
||||
<ActionIcon radius={"xl"} variant={"transparent"}>
|
||||
<IconBell color={"gray"} />
|
||||
</ActionIcon>
|
||||
|
||||
@@ -25,6 +25,7 @@ import { redirectDetailForumPage } from "./path/forum";
|
||||
import { redirectInvestasiPage } from "./path/investasi";
|
||||
import { notifikasi_jobCheckStatus } from "./path/job";
|
||||
import { notifikasi_votingCheckStatus } from "./path/voting";
|
||||
import { redirectDetailCollaborationPage } from "./path/collaboration";
|
||||
|
||||
export function ComponentNotifiaksi_CardView({
|
||||
data,
|
||||
@@ -157,11 +158,17 @@ export function ComponentNotifiaksi_CardView({
|
||||
return;
|
||||
}
|
||||
|
||||
// data?.kategoriApp === "COLLABORATION" &&
|
||||
// redirectDetailCollaborationPage({
|
||||
// data: data,
|
||||
// router: router,
|
||||
// });
|
||||
if (data?.kategoriApp === "COLLABORATION") {
|
||||
await redirectDetailCollaborationPage({
|
||||
data: data,
|
||||
router: router,
|
||||
onSetVisible(val) {
|
||||
setVisible(val);
|
||||
},
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
} catch (error) {
|
||||
setVisible(false);
|
||||
clientLogger.error("Error redirect notification page", error);
|
||||
|
||||
@@ -1,26 +1,40 @@
|
||||
import { RouterColab } from "@/lib/router_hipmi/router_colab";
|
||||
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
||||
import { MODEL_NOTIFIKASI } from "../../model/interface";
|
||||
import notifikasi_funUpdateIsReadById from "../../fun/update/fun_update_is_read_by_user_id";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
||||
|
||||
export function redirectDetailCollaborationPage({
|
||||
export async function redirectDetailCollaborationPage({
|
||||
data,
|
||||
router,
|
||||
onSetVisible,
|
||||
}: {
|
||||
data: MODEL_NOTIFIKASI;
|
||||
router: AppRouterInstance;
|
||||
onSetVisible(val: boolean): void;
|
||||
}) {
|
||||
if (data.status === "Partisipan Project") {
|
||||
const path = RouterColab.main_detail + data.appId;
|
||||
router.push(path, { scroll: false });
|
||||
try {
|
||||
if (data.status === "Partisipan Project") {
|
||||
const path = RouterColab.main_detail + data.appId;
|
||||
router.push(path, { scroll: false });
|
||||
}
|
||||
|
||||
if (data.status === "Collaboration Group") {
|
||||
const path = RouterColab.grup_diskusi;
|
||||
router.push(path, { scroll: false });
|
||||
}
|
||||
|
||||
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
||||
notifId: data.id,
|
||||
});
|
||||
|
||||
if (updateReadNotifikasi.status == 200) {
|
||||
onSetVisible(true);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error get all forum :", error);
|
||||
ComponentGlobal_NotifikasiPeringatan("Status tidak ditemukan");
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (data.status === "Collaboration Group") {
|
||||
const path = RouterColab.grup_diskusi;
|
||||
router.push(path, { scroll: false });
|
||||
}
|
||||
|
||||
// if (data.status === "Report Komentar") {
|
||||
// const path = RouterForum.detail_report_komentar + data.appId;
|
||||
// router.push(path, { scroll: false });
|
||||
|
||||
@@ -17,7 +17,9 @@ export type ITypeStatusNotifikasi =
|
||||
| "Berhasil"
|
||||
| "Proses"
|
||||
| "Menunggu"
|
||||
| "Gagal";
|
||||
| "Gagal"
|
||||
// Collaboration
|
||||
| "Partisipan Project"
|
||||
|
||||
/**
|
||||
* @param kategoriApp | "JOB", "VOTING", "EVENT", "DONASI", "INVESTASI", "COLLABORATION", "FORUM"
|
||||
|
||||
@@ -246,6 +246,17 @@ export default function RealtimeProvider({
|
||||
}
|
||||
|
||||
// ---------------------- INVESTASI ------------------------- //
|
||||
|
||||
// ---------------------- COLLABORATION ------------------------- //
|
||||
if (
|
||||
data.type == "trigger" &&
|
||||
data.pushNotificationTo == "USER" &&
|
||||
data.dataMessage?.kategoriApp == "COLLABORATION" &&
|
||||
data.dataMessage?.status == "Partisipan Project"
|
||||
) {
|
||||
setNewUserNtf((e) => e + 1);
|
||||
}
|
||||
// ---------------------- COLLABORATION ------------------------- //
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user