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 { 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,37 +105,42 @@ 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) {
|
||||||
// mqtt_client.publish(
|
WibuRealtime.setData({
|
||||||
// "USER",
|
type: "trigger",
|
||||||
// JSON.stringify({
|
pushNotificationTo: "USER",
|
||||||
// userId: dataNotif.userId,
|
dataMessage: dataNotifikasi,
|
||||||
// count: 1,
|
});
|
||||||
// })
|
// mqtt_client.publish(
|
||||||
// );
|
// "USER",
|
||||||
// }
|
// JSON.stringify({
|
||||||
|
// userId: dataNotif.userId,
|
||||||
|
// 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,37 +12,46 @@ export default async function colab_funCreatePartisipan({
|
|||||||
id: string;
|
id: string;
|
||||||
deskripsi: string;
|
deskripsi: string;
|
||||||
}) {
|
}) {
|
||||||
const userLoginId = await funGetUserIdByToken();
|
try {
|
||||||
|
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",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const create = await prisma.projectCollaboration_Partisipasi.create({
|
const create = await prisma.projectCollaboration_Partisipasi.create({
|
||||||
data: {
|
data: {
|
||||||
projectCollaborationId: id,
|
projectCollaborationId: id,
|
||||||
userId: userLoginId,
|
userId: userLoginId,
|
||||||
deskripsi_diri: deskripsi,
|
deskripsi_diri: deskripsi,
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
ProjectCollaboration: {
|
ProjectCollaboration: {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
title: true,
|
title: true,
|
||||||
userId: true,
|
userId: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
});
|
|
||||||
|
|
||||||
if (!create) return { status: 400, message: "Gagal menambahkan partisipan" };
|
if (!create)
|
||||||
revalidatePath(RouterColab.main_detail + id);
|
return { status: 400, message: "Gagal menambahkan partisipan" };
|
||||||
return {
|
revalidatePath(RouterColab.main_detail + id);
|
||||||
data: create,
|
return {
|
||||||
status: 201,
|
data: create,
|
||||||
message: "Berhasil menambahkan partisipan",
|
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 (
|
return (
|
||||||
<>
|
<>
|
||||||
<UIGlobal_LayoutTamplate
|
<UIGlobal_LayoutTamplate
|
||||||
@@ -84,7 +87,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 +114,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>
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ 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 { redirectDetailCollaborationPage } from "./path/collaboration";
|
||||||
|
|
||||||
export function ComponentNotifiaksi_CardView({
|
export function ComponentNotifiaksi_CardView({
|
||||||
data,
|
data,
|
||||||
@@ -157,11 +158,17 @@ export function ComponentNotifiaksi_CardView({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// data?.kategoriApp === "COLLABORATION" &&
|
if (data?.kategoriApp === "COLLABORATION") {
|
||||||
// redirectDetailCollaborationPage({
|
await redirectDetailCollaborationPage({
|
||||||
// data: data,
|
data: data,
|
||||||
// router: router,
|
router: router,
|
||||||
// });
|
onSetVisible(val) {
|
||||||
|
setVisible(val);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
} 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;
|
||||||
}) {
|
}) {
|
||||||
if (data.status === "Partisipan Project") {
|
try {
|
||||||
const path = RouterColab.main_detail + data.appId;
|
if (data.status === "Partisipan Project") {
|
||||||
router.push(path, { scroll: false });
|
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") {
|
// 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 });
|
||||||
|
|||||||
@@ -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