#feat:
Deskripsi: - Realtime notifikasi ## No Issue
This commit is contained in:
@@ -2,6 +2,9 @@
|
|||||||
"name": "hipmi",
|
"name": "hipmi",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
"prisma": {
|
||||||
|
"seed": "npx tsx ./prisma/seed.ts"
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
|
|||||||
8
prisma/seed.ts
Normal file
8
prisma/seed.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import prisma from "@/app/lib/prisma";
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
console.log("start");
|
||||||
|
})().finally(() => {
|
||||||
|
console.log("success");
|
||||||
|
prisma.$disconnect();
|
||||||
|
});
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||||
import { Vote_MainDetail } from "@/app_modules/vote";
|
import { Vote_MainDetail } from "@/app_modules/vote";
|
||||||
import { Vote_cekKontributorById } from "@/app_modules/vote/fun/get/cek_kontributor_by_id";
|
import { Vote_cekKontributorById } from "@/app_modules/vote/fun/get/cek_kontributor_by_id";
|
||||||
import { Vote_getHasilVoteById } from "@/app_modules/vote/fun/get/get_list_hasil_by_id";
|
import { Vote_getHasilVoteById } from "@/app_modules/vote/fun/get/get_list_hasil_by_id";
|
||||||
@@ -12,7 +13,7 @@ export default async function Page({ params }: { params: { id: string } }) {
|
|||||||
const isKontributor = await Vote_cekKontributorById(voteId);
|
const isKontributor = await Vote_cekKontributorById(voteId);
|
||||||
const pilihanKontributor = await Vote_getOnePilihanVotingByUserId(voteId);
|
const pilihanKontributor = await Vote_getOnePilihanVotingByUserId(voteId);
|
||||||
const listKontributor = await Vote_getListKontributorById(voteId);
|
const listKontributor = await Vote_getListKontributorById(voteId);
|
||||||
|
const userLoginId = await user_getOneUserId();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -22,6 +23,7 @@ export default async function Page({ params }: { params: { id: string } }) {
|
|||||||
isKontributor={isKontributor}
|
isKontributor={isKontributor}
|
||||||
pilihanKontributor={pilihanKontributor as any}
|
pilihanKontributor={pilihanKontributor as any}
|
||||||
listKontributor={listKontributor as any}
|
listKontributor={listKontributor as any}
|
||||||
|
userLoginId={userLoginId}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
3
src/app_modules/_global/api/generate_api.ts
Normal file
3
src/app_modules/_global/api/generate_api.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export function generate_api({dev}: {dev: string}) {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -51,6 +51,7 @@ import adminNotifikasi_getByUserId from "./notifikasi/fun/get/get_notifikasi_by_
|
|||||||
import adminNotifikasi_funUpdateIsReadById from "./notifikasi/fun/update/fun_update_is_read_by_id";
|
import adminNotifikasi_funUpdateIsReadById from "./notifikasi/fun/update/fun_update_is_read_by_id";
|
||||||
import adminNotifikasi_findRouterJob from "./notifikasi/route_setting/job";
|
import adminNotifikasi_findRouterJob from "./notifikasi/route_setting/job";
|
||||||
import adminNotifikasi_findRouterForum from "./notifikasi/route_setting/forum";
|
import adminNotifikasi_findRouterForum from "./notifikasi/route_setting/forum";
|
||||||
|
import { adminNotifikasi_findRouterVoting } from "./notifikasi/route_setting/voting";
|
||||||
|
|
||||||
export default function AdminLayout({
|
export default function AdminLayout({
|
||||||
children,
|
children,
|
||||||
@@ -297,6 +298,7 @@ export default function AdminLayout({
|
|||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</AppShell>
|
</AppShell>
|
||||||
|
|
||||||
{/* Drawer Mobile View */}
|
{/* Drawer Mobile View */}
|
||||||
<Drawer opened={opened} onClose={() => setOpened(false)} size={"50%"}>
|
<Drawer opened={opened} onClose={() => setOpened(false)} size={"50%"}>
|
||||||
<Stack spacing={"xl"}>
|
<Stack spacing={"xl"}>
|
||||||
@@ -389,6 +391,7 @@ function DrawerNotifikasi({
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
|
// JOB
|
||||||
e?.kategoriApp === "JOB" &&
|
e?.kategoriApp === "JOB" &&
|
||||||
adminNotifikasi_findRouterJob({
|
adminNotifikasi_findRouterJob({
|
||||||
data: e,
|
data: e,
|
||||||
@@ -399,6 +402,7 @@ function DrawerNotifikasi({
|
|||||||
onToggleNavbar: onToggleNavbar,
|
onToggleNavbar: onToggleNavbar,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// FORUM
|
||||||
e?.kategoriApp === "FORUM" &&
|
e?.kategoriApp === "FORUM" &&
|
||||||
adminNotifikasi_findRouterForum({
|
adminNotifikasi_findRouterForum({
|
||||||
data: e,
|
data: e,
|
||||||
@@ -411,6 +415,19 @@ function DrawerNotifikasi({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// VOTE
|
||||||
|
e?.kategoriApp === "VOTING" &&
|
||||||
|
adminNotifikasi_findRouterVoting({
|
||||||
|
data: e,
|
||||||
|
router: router,
|
||||||
|
onChangeNavbar(val) {
|
||||||
|
onChangeNavbar(val);
|
||||||
|
},
|
||||||
|
onToggleNavbar(val) {
|
||||||
|
onToggleNavbar(val);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const updateIsRead = await adminNotifikasi_funUpdateIsReadById({
|
const updateIsRead = await adminNotifikasi_funUpdateIsReadById({
|
||||||
notifId: e?.id,
|
notifId: e?.id,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,22 +1,14 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ActionIcon,
|
|
||||||
Box,
|
|
||||||
Center,
|
|
||||||
Divider,
|
Divider,
|
||||||
Grid,
|
Grid,
|
||||||
Group,
|
Group,
|
||||||
Paper,
|
Paper,
|
||||||
Stack,
|
Stack,
|
||||||
Text,
|
Text,
|
||||||
Title,
|
Title
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import Admin_Investasi from "../../investasi/main/view";
|
|
||||||
import { IconChevronsRight } from "@tabler/icons-react";
|
|
||||||
import router from "next/router";
|
|
||||||
import * as echarts from 'echarts';
|
|
||||||
import EChartsReact from "echarts-for-react";
|
|
||||||
|
|
||||||
|
|
||||||
export default function AdminMain({countUser, countPorto}: {countUser: number, countPorto: number} ) {
|
export default function AdminMain({countUser, countPorto}: {countUser: number, countPorto: number} ) {
|
||||||
|
|||||||
@@ -8,10 +8,14 @@ export default async function adminNotifikasi_getByUserId() {
|
|||||||
const adminId = await user_getOneUserId();
|
const adminId = await user_getOneUserId();
|
||||||
|
|
||||||
const data = await prisma.notifikasi.findMany({
|
const data = await prisma.notifikasi.findMany({
|
||||||
|
orderBy: [
|
||||||
orderBy: {
|
{
|
||||||
createdAt: "desc",
|
isRead: "asc",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
createdAt: "desc",
|
||||||
|
},
|
||||||
|
],
|
||||||
where: {
|
where: {
|
||||||
adminId: adminId,
|
adminId: adminId,
|
||||||
userRoleId: "2",
|
userRoleId: "2",
|
||||||
|
|||||||
27
src/app_modules/admin/notifikasi/route_setting/voting.ts
Normal file
27
src/app_modules/admin/notifikasi/route_setting/voting.ts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import { RouterAdminVote } from "@/app/lib/router_admin/router_admin_vote";
|
||||||
|
import { MODEL_NOTIFIKASI } from "@/app_modules/notifikasi/model/interface";
|
||||||
|
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
||||||
|
|
||||||
|
export async function adminNotifikasi_findRouterVoting({
|
||||||
|
data,
|
||||||
|
router,
|
||||||
|
onChangeNavbar,
|
||||||
|
onToggleNavbar,
|
||||||
|
}: {
|
||||||
|
data: MODEL_NOTIFIKASI;
|
||||||
|
router: AppRouterInstance;
|
||||||
|
onChangeNavbar: (val: any) => void;
|
||||||
|
onToggleNavbar: (val: any) => void;
|
||||||
|
}) {
|
||||||
|
const path = RouterAdminVote.table_review;
|
||||||
|
|
||||||
|
if (data.status === "Review") {
|
||||||
|
router.push(path, { scroll: false });
|
||||||
|
onChangeNavbar({
|
||||||
|
id: 5,
|
||||||
|
childId: 53,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onToggleNavbar(true);
|
||||||
|
}
|
||||||
@@ -1,19 +1,13 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
|
|
||||||
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/component_global/header_tamplate";
|
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/component_global/header_tamplate";
|
||||||
import { AdminEvent_getListPesertaById } from "@/app_modules/admin/event/fun/get/get_list_peserta_by_id";
|
|
||||||
import { MODEL_VOTING } from "@/app_modules/vote/model/interface";
|
import { MODEL_VOTING } from "@/app_modules/vote/model/interface";
|
||||||
import {
|
import {
|
||||||
Avatar,
|
|
||||||
Box,
|
Box,
|
||||||
Button,
|
Button,
|
||||||
Center,
|
Center,
|
||||||
Divider,
|
|
||||||
Grid,
|
|
||||||
Group,
|
Group,
|
||||||
Modal,
|
Modal,
|
||||||
Paper,
|
|
||||||
ScrollArea,
|
ScrollArea,
|
||||||
Spoiler,
|
Spoiler,
|
||||||
Stack,
|
Stack,
|
||||||
@@ -23,20 +17,20 @@ import {
|
|||||||
Title,
|
Title,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { useDisclosure } from "@mantine/hooks";
|
import { useDisclosure } from "@mantine/hooks";
|
||||||
import { IconBan } from "@tabler/icons-react";
|
import { IconBan, IconEyeShare } from "@tabler/icons-react";
|
||||||
import { IconEyeShare } from "@tabler/icons-react";
|
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
|
|
||||||
import { useState } from "react";
|
|
||||||
import { AdminVote_funEditStatusPublishById } from "../../fun/edit/fun_edit_status_publish_by_id";
|
|
||||||
import toast from "react-simple-toasts";
|
|
||||||
import { AdminVote_getListTableByStatusId } from "../../fun/get/get_list_table_by_status_id";
|
|
||||||
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 { AdminEvent_funEditCatatanById } from "../../fun/edit/fun_edit_status_reject_by_id";
|
|
||||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { AdminVote_funEditStatusPublishById } from "../../fun/edit/fun_edit_status_publish_by_id";
|
||||||
|
import { AdminEvent_funEditCatatanById } from "../../fun/edit/fun_edit_status_reject_by_id";
|
||||||
|
import { AdminVote_getListTableByStatusId } from "../../fun/get/get_list_table_by_status_id";
|
||||||
|
import mqtt_client from "@/util/mqtt_client";
|
||||||
|
import adminNotifikasi_funCreateToUser from "@/app_modules/admin/notifikasi/fun/create/fun_create_notif_user";
|
||||||
|
|
||||||
export default function AdminVote_TableReview({
|
export default function AdminVote_TableReview({
|
||||||
listVote,
|
listVote,
|
||||||
@@ -255,17 +249,36 @@ async function onPublish(
|
|||||||
return ComponentGlobal_NotifikasiPeringatan("Tanggal Voting Lewat");
|
return ComponentGlobal_NotifikasiPeringatan("Tanggal Voting Lewat");
|
||||||
|
|
||||||
setVotingId(voteId);
|
setVotingId(voteId);
|
||||||
await AdminVote_funEditStatusPublishById(voteId).then(async (res) => {
|
const res = await AdminVote_funEditStatusPublishById(voteId);
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
await AdminVote_getListTableByStatusId("2").then((val) => {
|
const dataNotif = {
|
||||||
setData(val);
|
appId: res.data?.id,
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
status: res.data?.Voting_Status?.name as any,
|
||||||
setLoadingPublish(true);
|
userId: res.data?.authorId as any,
|
||||||
});
|
pesan: res.data?.title as any,
|
||||||
} else {
|
kategoriApp: "VOTING",
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
title: "Voting publish",
|
||||||
|
};
|
||||||
|
|
||||||
|
const notif = await adminNotifikasi_funCreateToUser({
|
||||||
|
data: dataNotif as any,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (notif.status === 201) {
|
||||||
|
mqtt_client.publish(
|
||||||
|
"USER",
|
||||||
|
JSON.stringify({ userId: res?.data?.authorId, count: 1 })
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
await AdminVote_getListTableByStatusId("2").then((val) => {
|
||||||
|
setData(val);
|
||||||
|
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||||
|
setLoadingPublish(true);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onReject(
|
async function onReject(
|
||||||
@@ -279,16 +292,36 @@ async function onReject(
|
|||||||
id: voteId,
|
id: voteId,
|
||||||
catatan: catatan,
|
catatan: catatan,
|
||||||
};
|
};
|
||||||
await AdminEvent_funEditCatatanById(data as any).then(async (res) => {
|
|
||||||
if (res.status === 200) {
|
const res = await AdminEvent_funEditCatatanById(data as any);
|
||||||
await AdminVote_getListTableByStatusId("2").then((val) => {
|
if (res.status === 200) {
|
||||||
setData(val);
|
const dataNotif = {
|
||||||
setSaveLoading(true);
|
appId: res.data?.id,
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
status: res.data?.Voting_Status?.name as any,
|
||||||
close();
|
userId: res.data?.authorId as any,
|
||||||
});
|
pesan: res.data?.title as any,
|
||||||
} else {
|
kategoriApp: "VOTING",
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
title: "Voting anda di tolak !",
|
||||||
|
};
|
||||||
|
|
||||||
|
const notif = await adminNotifikasi_funCreateToUser({
|
||||||
|
data: dataNotif as any,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (notif.status === 201) {
|
||||||
|
mqtt_client.publish(
|
||||||
|
"USER",
|
||||||
|
JSON.stringify({ userId: res?.data?.authorId, count: 1 })
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
await AdminVote_getListTableByStatusId("2").then((val) => {
|
||||||
|
setData(val);
|
||||||
|
setSaveLoading(true);
|
||||||
|
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||||
|
close();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,20 +4,31 @@ import prisma from "@/app/lib/prisma";
|
|||||||
import { revalidatePath } from "next/cache";
|
import { revalidatePath } from "next/cache";
|
||||||
|
|
||||||
export async function AdminVote_funEditStatusPublishById(voteId: string) {
|
export async function AdminVote_funEditStatusPublishById(voteId: string) {
|
||||||
|
const updt = await prisma.voting.update({
|
||||||
const updt = await prisma.voting.update({
|
where: {
|
||||||
where: {
|
id: voteId,
|
||||||
id: voteId,
|
},
|
||||||
|
data: {
|
||||||
|
voting_StatusId: "1",
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
title: true,
|
||||||
|
authorId: true,
|
||||||
|
Voting_Status: {
|
||||||
|
select: {
|
||||||
|
name: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
data: {
|
},
|
||||||
voting_StatusId: "1",
|
});
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!updt) return { status: 400, message: "Update Gagal" };
|
if (!updt) return { status: 400, message: "Update Gagal" };
|
||||||
revalidatePath("/dev/admin/vote/main");
|
revalidatePath("/dev/admin/vote/main");
|
||||||
return {
|
|
||||||
status: 200,
|
return {
|
||||||
message: "Berhasil Update Status",
|
data: updt,
|
||||||
};
|
status: 200,
|
||||||
|
message: "Berhasil Update Status",
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,11 +15,22 @@ export async function AdminEvent_funEditCatatanById(
|
|||||||
voting_StatusId: "4",
|
voting_StatusId: "4",
|
||||||
catatan: data.catatan,
|
catatan: data.catatan,
|
||||||
},
|
},
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
title: true,
|
||||||
|
authorId: true,
|
||||||
|
Voting_Status: {
|
||||||
|
select: {
|
||||||
|
name: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!updt) return { status: 400, message: "Update Gagal" };
|
if (!updt) return { status: 400, message: "Update Gagal" };
|
||||||
revalidatePath("/dev/admin/event/main");
|
revalidatePath("/dev/admin/event/main");
|
||||||
return {
|
return {
|
||||||
|
data: updt,
|
||||||
status: 200,
|
status: 200,
|
||||||
message: "Berhasil Update Status",
|
message: "Berhasil Update Status",
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import _ from "lodash";
|
|||||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
||||||
import { MainColor } from "@/app_modules/_global/color/color_pallet";
|
import { MainColor } from "@/app_modules/_global/color/color_pallet";
|
||||||
import ComponentGlobal_InputCountDown from "@/app_modules/_global/component/input_countdown";
|
import ComponentGlobal_InputCountDown from "@/app_modules/_global/component/input_countdown";
|
||||||
|
import mqtt_client from "@/util/mqtt_client";
|
||||||
|
|
||||||
export default function Colab_Create({
|
export default function Colab_Create({
|
||||||
listIndustri,
|
listIndustri,
|
||||||
@@ -184,18 +185,24 @@ function ButtonAction({ value }: { value: any }) {
|
|||||||
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data");
|
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data");
|
||||||
if (value.projectCollaborationMaster_IndustriId === 0)
|
if (value.projectCollaborationMaster_IndustriId === 0)
|
||||||
return ComponentGlobal_NotifikasiPeringatan("Pilih Industri");
|
return ComponentGlobal_NotifikasiPeringatan("Pilih Industri");
|
||||||
// if (value.jumlah_partisipan < 2)
|
|
||||||
// return ComponentGlobal_NotifikasiPeringatan("Minimal Ada 2 Partisipan");
|
|
||||||
|
|
||||||
await colab_funCreateProyek(value).then((res) => {
|
const res = await colab_funCreateProyek(value);
|
||||||
if (res.status === 201) {
|
if (res.status === 201) {
|
||||||
setLoading(true);
|
// const dataNotif: any = {
|
||||||
router.back();
|
// appId: res.data?.id as any,
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
// kategoriApp: "VOTING",
|
||||||
} else {
|
// status: create.data?.MasterStatus?.name as any,
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
// userId: create.data?.authorId as any,
|
||||||
}
|
// pesan: create.data?.title as any,
|
||||||
});
|
// title: "Job baru",
|
||||||
|
// };
|
||||||
|
|
||||||
|
setLoading(true);
|
||||||
|
router.back();
|
||||||
|
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||||
|
} else {
|
||||||
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log(value);
|
// console.log(value);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export default async function colab_funCreateProyek(
|
|||||||
) {
|
) {
|
||||||
const AuthorId = await user_getOneUserId();
|
const AuthorId = await user_getOneUserId();
|
||||||
|
|
||||||
const create = await prisma.projectCollaboration.create({
|
const data = await prisma.projectCollaboration.create({
|
||||||
data: {
|
data: {
|
||||||
title: value.title,
|
title: value.title,
|
||||||
lokasi: value.lokasi,
|
lokasi: value.lokasi,
|
||||||
@@ -25,7 +25,7 @@ export default async function colab_funCreateProyek(
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!create) return { status: 400, message: "Gagal Membuat Proyek" };
|
if (!data) return { status: 400, message: "Gagal Membuat Proyek" };
|
||||||
revalidatePath(RouterColab.beranda);
|
revalidatePath(RouterColab.beranda);
|
||||||
return { status: 201, message: "Berhasil Membuar Proyek" };
|
return { data, status: 201, message: "Berhasil Membuar Proyek" };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import { IconBell, IconUserSearch } from "@tabler/icons-react";
|
|||||||
import { RouterNotifikasi } from "@/app/lib/router_hipmi/router_notifikasi";
|
import { RouterNotifikasi } from "@/app/lib/router_hipmi/router_notifikasi";
|
||||||
import { useShallowEffect } from "@mantine/hooks";
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
import notifikasi_countUserNotifikasi from "@/app_modules/notifikasi/fun/count/fun_count_by_id";
|
import notifikasi_countUserNotifikasi from "@/app_modules/notifikasi/fun/count/fun_count_by_id";
|
||||||
|
import mqtt_client from "@/util/mqtt_client";
|
||||||
|
|
||||||
export function ComponentHome_ButtonHeaderLeft({
|
export function ComponentHome_ButtonHeaderLeft({
|
||||||
dataUser,
|
dataUser,
|
||||||
@@ -59,17 +60,41 @@ export function ComponentHome_ButtonHeaderRight({
|
|||||||
const [count, setCount] = useState(countNotifikasi);
|
const [count, setCount] = useState(countNotifikasi);
|
||||||
const [isLoadingBell, setIsLoadingBell] = useState(false);
|
const [isLoadingBell, setIsLoadingBell] = useState(false);
|
||||||
|
|
||||||
|
// useShallowEffect(() => {
|
||||||
|
// onLoadNotifkasi({
|
||||||
|
// onLoad(val) {
|
||||||
|
// setCount(val);
|
||||||
|
// },
|
||||||
|
// });
|
||||||
|
// }, []);
|
||||||
|
|
||||||
|
// async function onLoadNotifkasi({ onLoad }: { onLoad: (val: any) => void }) {
|
||||||
|
// const loadNotifikasi = await notifikasi_countUserNotifikasi();
|
||||||
|
// onLoad(loadNotifikasi);
|
||||||
|
// }
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
onLoadNotifkasi({
|
mqtt_client.subscribe("USER");
|
||||||
|
|
||||||
|
mqtt_client.on("message", (topic: any, message: any) => {
|
||||||
|
// console.log(topic);
|
||||||
|
const data = JSON.parse(message.toString());
|
||||||
|
|
||||||
|
if (data.userId === dataUser.id) {
|
||||||
|
setCount(count + data.count);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
onLoadNotifikasi({
|
||||||
onLoad(val) {
|
onLoad(val) {
|
||||||
setCount(val);
|
setCount(val);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}, []);
|
}, [count]);
|
||||||
|
|
||||||
async function onLoadNotifkasi({ onLoad }: { onLoad: (val: any) => void }) {
|
async function onLoadNotifikasi({ onLoad }: { onLoad: (val: any) => void }) {
|
||||||
const loadNotifikasi = await notifikasi_countUserNotifikasi();
|
const loadNotif = await notifikasi_countUserNotifikasi();
|
||||||
onLoad(loadNotifikasi);
|
onLoad(loadNotif);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -12,17 +12,18 @@ import {
|
|||||||
MainColor,
|
MainColor,
|
||||||
} from "@/app_modules/_global/color/color_pallet";
|
} from "@/app_modules/_global/color/color_pallet";
|
||||||
import notifikasi_getByUserId from "../fun/get/get_notifiaksi_by_id";
|
import notifikasi_getByUserId from "../fun/get/get_notifiaksi_by_id";
|
||||||
|
import { redirectVotingPage } from "./path/voting";
|
||||||
|
|
||||||
export function ComponentNotifiaksi_CardView({
|
export function ComponentNotifiaksi_CardView({
|
||||||
data,
|
data,
|
||||||
onLoadData,
|
onLoadData,
|
||||||
activePage,
|
activePage,
|
||||||
onSetJob,
|
onSetMenu,
|
||||||
}: {
|
}: {
|
||||||
data: MODEL_NOTIFIKASI;
|
data: MODEL_NOTIFIKASI;
|
||||||
onLoadData: (val: any) => void;
|
onLoadData: (val: any) => void;
|
||||||
activePage: number;
|
activePage: number;
|
||||||
onSetJob: (val: any) => void;
|
onSetMenu: (val: any) => void;
|
||||||
}) {
|
}) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
return (
|
return (
|
||||||
@@ -45,7 +46,7 @@ export function ComponentNotifiaksi_CardView({
|
|||||||
data: data,
|
data: data,
|
||||||
router: router,
|
router: router,
|
||||||
onSetPage(val) {
|
onSetPage(val) {
|
||||||
onSetJob(val);
|
onSetMenu(val);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -55,6 +56,15 @@ export function ComponentNotifiaksi_CardView({
|
|||||||
router: router,
|
router: router,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
data?.kategoriApp === "VOTING" &&
|
||||||
|
redirectVotingPage({
|
||||||
|
data: data,
|
||||||
|
router: router,
|
||||||
|
onSetPage(val) {
|
||||||
|
onSetMenu(val);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const updateIsRead = await notifikasi_funUpdateIsReadById({
|
const updateIsRead = await notifikasi_funUpdateIsReadById({
|
||||||
notifId: data?.id,
|
notifId: data?.id,
|
||||||
});
|
});
|
||||||
|
|||||||
36
src/app_modules/notifikasi/component/path/voting.ts
Normal file
36
src/app_modules/notifikasi/component/path/voting.ts
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import { RouterVote } from "@/app/lib/router_hipmi/router_vote";
|
||||||
|
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
||||||
|
import { MODEL_NOTIFIKASI } from "../../model/interface";
|
||||||
|
|
||||||
|
export function redirectVotingPage({
|
||||||
|
data,
|
||||||
|
router,
|
||||||
|
onSetPage,
|
||||||
|
}: {
|
||||||
|
data: MODEL_NOTIFIKASI;
|
||||||
|
router: AppRouterInstance;
|
||||||
|
onSetPage: (val: any) => void;
|
||||||
|
}) {
|
||||||
|
const path = RouterVote.status;
|
||||||
|
|
||||||
|
if (data.status === "Publish") {
|
||||||
|
onSetPage({
|
||||||
|
menuId: 2,
|
||||||
|
status: data.status,
|
||||||
|
});
|
||||||
|
router.push(path, { scroll: false });
|
||||||
|
}
|
||||||
|
// console.log(data)
|
||||||
|
|
||||||
|
if (data.status === "Reject") {
|
||||||
|
onSetPage({
|
||||||
|
menuId: 2,
|
||||||
|
status: data.status,
|
||||||
|
});
|
||||||
|
router.push(path, { scroll: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.status === "Voting Masuk") {
|
||||||
|
router.push(RouterVote.main_detail + data.appId, { scroll: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,10 @@ import { useState } from "react";
|
|||||||
import notifikasi_getByUserId from "../fun/get/get_notifiaksi_by_id";
|
import notifikasi_getByUserId from "../fun/get/get_notifiaksi_by_id";
|
||||||
import { MODEL_NOTIFIKASI } from "../model/interface";
|
import { MODEL_NOTIFIKASI } from "../model/interface";
|
||||||
import { ComponentNotifiaksi_CardView } from "./card_view";
|
import { ComponentNotifiaksi_CardView } from "./card_view";
|
||||||
|
import {
|
||||||
|
gs_vote_hotMenu,
|
||||||
|
gs_vote_status,
|
||||||
|
} from "@/app_modules/vote/global_state";
|
||||||
|
|
||||||
export function Notifikasi_UiView({
|
export function Notifikasi_UiView({
|
||||||
listNotifikasi,
|
listNotifikasi,
|
||||||
@@ -24,19 +28,21 @@ export function Notifikasi_UiView({
|
|||||||
// JOB
|
// JOB
|
||||||
const [jobMenuId, setJobMenuId] = useAtom(gs_job_hot_menu);
|
const [jobMenuId, setJobMenuId] = useAtom(gs_job_hot_menu);
|
||||||
const [jobStatus, setJobStatus] = useAtom(gs_job_status);
|
const [jobStatus, setJobStatus] = useAtom(gs_job_status);
|
||||||
|
const [voteMenu, setVoteMenu] = useAtom(gs_vote_hotMenu);
|
||||||
|
const [voeStatus, setVoteStatus] = useAtom(gs_vote_status);
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
onLoadData({
|
onLoadData({
|
||||||
onLoad(val) {
|
onLoad(val) {
|
||||||
setData(val);
|
setData(val);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
async function onLoadData({ onLoad }: { onLoad: (val: any) => void }) {
|
async function onLoadData({ onLoad }: { onLoad: (val: any) => void }) {
|
||||||
const loadData = await notifikasi_getByUserId({ page: 1 });
|
const loadData = await notifikasi_getByUserId({ page: 1 });
|
||||||
onLoad(loadData);
|
onLoad(loadData);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -67,9 +73,15 @@ export function Notifikasi_UiView({
|
|||||||
data={item}
|
data={item}
|
||||||
onLoadData={(val) => setData(val)}
|
onLoadData={(val) => setData(val)}
|
||||||
activePage={activePage}
|
activePage={activePage}
|
||||||
onSetJob={(val) => {
|
onSetMenu={(val) => {
|
||||||
setJobMenuId(val.menuId);
|
if (item?.kategoriApp === "JOB") {
|
||||||
setJobStatus(val.status);
|
setJobMenuId(val.menuId);
|
||||||
|
setJobStatus(val.status);
|
||||||
|
}
|
||||||
|
if (item?.kategoriApp === "VOTING") {
|
||||||
|
setVoteMenu(val.menuId);
|
||||||
|
setVoteStatus(val.status);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -3,17 +3,24 @@
|
|||||||
import prisma from "@/app/lib/prisma";
|
import prisma from "@/app/lib/prisma";
|
||||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||||
|
|
||||||
export default async function notifikasi_getByUserId({page}: {page: number }) {
|
export default async function notifikasi_getByUserId({
|
||||||
|
page,
|
||||||
|
}: {
|
||||||
|
page: number;
|
||||||
|
}) {
|
||||||
const userId = await user_getOneUserId();
|
const userId = await user_getOneUserId();
|
||||||
const takeData = 10;
|
const takeData = 10;
|
||||||
const skipData = page * takeData - takeData;
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
const data = await prisma.notifikasi.findMany({
|
const data = await prisma.notifikasi.findMany({
|
||||||
take: takeData,
|
take: takeData,
|
||||||
skip: skipData,
|
skip: skipData,
|
||||||
orderBy: {
|
orderBy: [
|
||||||
isRead: "asc"
|
{
|
||||||
},
|
isRead: "asc",
|
||||||
|
},
|
||||||
|
{ createdAt: "desc" },
|
||||||
|
],
|
||||||
where: {
|
where: {
|
||||||
userId: userId,
|
userId: userId,
|
||||||
userRoleId: "1",
|
userRoleId: "1",
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ import { Vote_funCreate } from "../fun/create/create_vote";
|
|||||||
import { gs_vote_hotMenu, gs_vote_status } from "../global_state";
|
import { gs_vote_hotMenu, gs_vote_status } from "../global_state";
|
||||||
import { MODEL_VOTING } from "../model/interface";
|
import { MODEL_VOTING } from "../model/interface";
|
||||||
import { MainColor } from "@/app_modules/_global/color/color_pallet";
|
import { MainColor } from "@/app_modules/_global/color/color_pallet";
|
||||||
|
import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin";
|
||||||
|
import mqtt_client from "@/util/mqtt_client";
|
||||||
|
|
||||||
export default function Vote_Create() {
|
export default function Vote_Create() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -254,15 +256,36 @@ async function onSave(
|
|||||||
|
|
||||||
// console.log("berhasil");
|
// console.log("berhasil");
|
||||||
|
|
||||||
await Vote_funCreate(data, listVote).then((res) => {
|
const res = await Vote_funCreate(data, listVote);
|
||||||
if (res.status === 201) {
|
if (res.status === 201) {
|
||||||
|
const dataNotif: any = {
|
||||||
|
appId: res.data?.id as any,
|
||||||
|
status: res.data?.Voting_Status?.name as any,
|
||||||
|
userId: res.data?.authorId as any,
|
||||||
|
pesan: res.data?.title as any,
|
||||||
|
kategoriApp: "VOTING",
|
||||||
|
title: "Voting baru",
|
||||||
|
};
|
||||||
|
|
||||||
|
const notif = await notifikasiToAdmin_funCreate({
|
||||||
|
data: dataNotif as any,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (notif.status === 201) {
|
||||||
|
mqtt_client.publish(
|
||||||
|
"ADMIN",
|
||||||
|
JSON.stringify({
|
||||||
|
count: 1,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
setHotMenu(2);
|
setHotMenu(2);
|
||||||
setTabsStatus("Review");
|
setTabsStatus("Review");
|
||||||
router.replace(RouterVote.status);
|
router.replace(RouterVote.status);
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
} else {
|
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
|
||||||
}
|
}
|
||||||
});
|
} else {
|
||||||
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,23 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { Button, Group, Modal, SimpleGrid, Stack, Title } from "@mantine/core";
|
import { MainColor } from "@/app_modules/_global/color/color_pallet";
|
||||||
import ComponentVote_DetailDataSebelumPublish from "../../component/detail/detail_data_sebelum_publish";
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
import { useAtom } from "jotai";
|
|
||||||
import { gs_vote_status } from "../../global_state";
|
|
||||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
|
||||||
import { useDisclosure } from "@mantine/hooks";
|
|
||||||
import { MODEL_VOTING } from "../../model/interface";
|
|
||||||
import { Vote_funEditStatusByStatusId } from "../../fun/edit/fun_edit_status_by_id";
|
|
||||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
|
||||||
import { Vote_funDeleteById } from "../../fun/delete/fun_delete_by_id";
|
|
||||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
|
||||||
import moment from "moment";
|
|
||||||
import {
|
|
||||||
AccentColor,
|
|
||||||
MainColor,
|
|
||||||
} from "@/app_modules/_global/color/color_pallet";
|
|
||||||
import { useState } from "react";
|
|
||||||
import UIGlobal_Modal from "@/app_modules/_global/ui/ui_modal";
|
|
||||||
import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information";
|
import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information";
|
||||||
|
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||||
|
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||||
|
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
||||||
|
import UIGlobal_Modal from "@/app_modules/_global/ui/ui_modal";
|
||||||
|
import { Button, SimpleGrid, Stack } from "@mantine/core";
|
||||||
|
import { useAtom } from "jotai";
|
||||||
|
import moment from "moment";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
import { useState } from "react";
|
||||||
|
import ComponentVote_DetailDataSebelumPublish from "../../component/detail/detail_data_sebelum_publish";
|
||||||
|
import { Vote_funDeleteById } from "../../fun/delete/fun_delete_by_id";
|
||||||
|
import { Vote_funEditStatusByStatusId } from "../../fun/edit/fun_edit_status_by_id";
|
||||||
|
import { gs_vote_status } from "../../global_state";
|
||||||
|
import { MODEL_VOTING } from "../../model/interface";
|
||||||
|
import mqtt_client from "@/util/mqtt_client";
|
||||||
|
import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin";
|
||||||
|
|
||||||
export default function Vote_DetailDraft({
|
export default function Vote_DetailDraft({
|
||||||
dataVote,
|
dataVote,
|
||||||
@@ -64,16 +62,36 @@ function ButtonAction({
|
|||||||
if (cekHari < 0)
|
if (cekHari < 0)
|
||||||
return ComponentGlobal_NotifikasiPeringatan("Tanggal Voting Lewat");
|
return ComponentGlobal_NotifikasiPeringatan("Tanggal Voting Lewat");
|
||||||
|
|
||||||
await Vote_funEditStatusByStatusId(voteId, "2").then((res) => {
|
const res = await Vote_funEditStatusByStatusId(voteId, "2");
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
|
const dataNotif: any = {
|
||||||
|
appId: res.data?.id as any,
|
||||||
|
status: res.data?.Voting_Status?.name as any,
|
||||||
|
userId: res.data?.authorId as any,
|
||||||
|
pesan: res.data?.title as any,
|
||||||
|
kategoriApp: "VOTING",
|
||||||
|
title: "Mengajukan review",
|
||||||
|
};
|
||||||
|
|
||||||
|
const notif = await notifikasiToAdmin_funCreate({
|
||||||
|
data: dataNotif as any,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (notif.status === 201) {
|
||||||
|
mqtt_client.publish(
|
||||||
|
"ADMIN",
|
||||||
|
JSON.stringify({
|
||||||
|
count: 1,
|
||||||
|
})
|
||||||
|
);
|
||||||
setTabsStatus("Review");
|
setTabsStatus("Review");
|
||||||
ComponentGlobal_NotifikasiBerhasil("Berhasil Ajukan Review", 2000);
|
ComponentGlobal_NotifikasiBerhasil("Berhasil Ajukan Review", 2000);
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
router.back();
|
router.back();
|
||||||
} else {
|
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
|
||||||
}
|
}
|
||||||
});
|
} else {
|
||||||
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onDelete() {
|
async function onDelete() {
|
||||||
|
|||||||
@@ -1,18 +1,19 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
|
|
||||||
import ComponentGlobal_AuthorNameOnHeader from "@/app_modules/_global/author_name_on_header";
|
import ComponentGlobal_AuthorNameOnHeader from "@/app_modules/_global/author_name_on_header";
|
||||||
|
import {
|
||||||
|
AccentColor,
|
||||||
|
MainColor,
|
||||||
|
} from "@/app_modules/_global/color/color_pallet";
|
||||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
||||||
|
import notifikasiToUser_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_user";
|
||||||
import {
|
import {
|
||||||
Avatar,
|
|
||||||
Badge,
|
Badge,
|
||||||
Box,
|
Box,
|
||||||
Button,
|
Button,
|
||||||
Card,
|
Card,
|
||||||
Center,
|
Center,
|
||||||
Divider,
|
|
||||||
Grid,
|
|
||||||
Group,
|
Group,
|
||||||
Radio,
|
Radio,
|
||||||
Stack,
|
Stack,
|
||||||
@@ -25,12 +26,8 @@ import ComponentVote_DaftarKontributorVoter from "../../component/detail/detail_
|
|||||||
import ComponentVote_HasilVoting from "../../component/detail/detail_hasil_voting";
|
import ComponentVote_HasilVoting from "../../component/detail/detail_hasil_voting";
|
||||||
import { Vote_funCreateHasil } from "../../fun/create/create_hasil";
|
import { Vote_funCreateHasil } from "../../fun/create/create_hasil";
|
||||||
import { Vote_getOnebyId } from "../../fun/get/get_one_by_id";
|
import { Vote_getOnebyId } from "../../fun/get/get_one_by_id";
|
||||||
import {
|
import { MODEL_VOTING } from "../../model/interface";
|
||||||
MODEL_VOTE_KONTRIBUTOR,
|
import mqtt_client from "@/util/mqtt_client";
|
||||||
MODEL_VOTING,
|
|
||||||
MODEL_VOTING_DAFTAR_NAMA_VOTE,
|
|
||||||
} from "../../model/interface";
|
|
||||||
import { AccentColor, MainColor } from "@/app_modules/_global/color/color_pallet";
|
|
||||||
|
|
||||||
export default function Vote_MainDetail({
|
export default function Vote_MainDetail({
|
||||||
dataVote,
|
dataVote,
|
||||||
@@ -38,12 +35,14 @@ export default function Vote_MainDetail({
|
|||||||
isKontributor,
|
isKontributor,
|
||||||
pilihanKontributor,
|
pilihanKontributor,
|
||||||
listKontributor,
|
listKontributor,
|
||||||
|
userLoginId,
|
||||||
}: {
|
}: {
|
||||||
dataVote: MODEL_VOTING;
|
dataVote: MODEL_VOTING;
|
||||||
hasilVoting: any;
|
hasilVoting: any;
|
||||||
isKontributor: boolean;
|
isKontributor: boolean;
|
||||||
pilihanKontributor: string;
|
pilihanKontributor: string;
|
||||||
listKontributor: any[];
|
listKontributor: any[];
|
||||||
|
userLoginId: string;
|
||||||
}) {
|
}) {
|
||||||
const [data, setData] = useState(dataVote);
|
const [data, setData] = useState(dataVote);
|
||||||
return (
|
return (
|
||||||
@@ -54,6 +53,7 @@ export default function Vote_MainDetail({
|
|||||||
setData={setData}
|
setData={setData}
|
||||||
isKontributor={isKontributor}
|
isKontributor={isKontributor}
|
||||||
pilihanKontributor={pilihanKontributor}
|
pilihanKontributor={pilihanKontributor}
|
||||||
|
userLoginId={userLoginId}
|
||||||
/>
|
/>
|
||||||
<ComponentVote_HasilVoting data={data.Voting_DaftarNamaVote} />
|
<ComponentVote_HasilVoting data={data.Voting_DaftarNamaVote} />
|
||||||
<ComponentVote_DaftarKontributorVoter
|
<ComponentVote_DaftarKontributorVoter
|
||||||
@@ -69,11 +69,13 @@ function TampilanDataVoting({
|
|||||||
setData,
|
setData,
|
||||||
isKontributor,
|
isKontributor,
|
||||||
pilihanKontributor,
|
pilihanKontributor,
|
||||||
|
userLoginId,
|
||||||
}: {
|
}: {
|
||||||
dataVote?: MODEL_VOTING;
|
dataVote?: MODEL_VOTING;
|
||||||
setData: any;
|
setData: any;
|
||||||
isKontributor: boolean;
|
isKontributor: boolean;
|
||||||
pilihanKontributor: any;
|
pilihanKontributor: any;
|
||||||
|
userLoginId: string;
|
||||||
}) {
|
}) {
|
||||||
const [votingNameId, setVotingNameId] = useState("");
|
const [votingNameId, setVotingNameId] = useState("");
|
||||||
return (
|
return (
|
||||||
@@ -182,7 +184,7 @@ function TampilanDataVoting({
|
|||||||
{dataVote?.Voting_DaftarNamaVote.map((v) => (
|
{dataVote?.Voting_DaftarNamaVote.map((v) => (
|
||||||
<Box key={v.id}>
|
<Box key={v.id}>
|
||||||
<Radio
|
<Radio
|
||||||
color="yellow"
|
color="yellow"
|
||||||
styles={{ label: { color: "white" } }}
|
styles={{ label: { color: "white" } }}
|
||||||
label={v.value}
|
label={v.value}
|
||||||
value={v.id}
|
value={v.id}
|
||||||
@@ -200,7 +202,12 @@ function TampilanDataVoting({
|
|||||||
<Button
|
<Button
|
||||||
radius={"xl"}
|
radius={"xl"}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
onVote(votingNameId, dataVote?.id as any, setData)
|
onVote(
|
||||||
|
votingNameId,
|
||||||
|
dataVote?.id as any,
|
||||||
|
setData,
|
||||||
|
userLoginId
|
||||||
|
)
|
||||||
}
|
}
|
||||||
bg={MainColor.yellow}
|
bg={MainColor.yellow}
|
||||||
color="yellow"
|
color="yellow"
|
||||||
@@ -218,141 +225,46 @@ function TampilanDataVoting({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onVote(pilihanVotingId: string, voteId: string, setData: any) {
|
async function onVote(
|
||||||
await Vote_funCreateHasil(pilihanVotingId, voteId).then(async (res) => {
|
pilihanVotingId: string,
|
||||||
if (res.status === 201) {
|
voteId: string,
|
||||||
await Vote_getOnebyId(voteId).then((val) => {
|
setData: any,
|
||||||
setData(val);
|
userLoginId: string
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
) {
|
||||||
|
const res = await Vote_funCreateHasil(pilihanVotingId, voteId);
|
||||||
|
if (res.status === 201) {
|
||||||
|
await Vote_getOnebyId(voteId).then((val) => {
|
||||||
|
setData(val);
|
||||||
|
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (userLoginId !== res?.data?.Voting?.authorId) {
|
||||||
|
const dataNotif = {
|
||||||
|
appId: res?.data?.Voting?.id,
|
||||||
|
userId: res?.data?.Voting?.authorId,
|
||||||
|
pesan: res?.pilihan,
|
||||||
|
status: "Voting Masuk",
|
||||||
|
kategoriApp: "VOTING",
|
||||||
|
title: "User lain telah melakukan voting !",
|
||||||
|
};
|
||||||
|
|
||||||
|
const createNotifikasi = await notifikasiToUser_funCreate({
|
||||||
|
data: dataNotif as any,
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
ComponentGlobal_NotifikasiPeringatan(res.message);
|
if (createNotifikasi.status === 201) {
|
||||||
|
mqtt_client.publish(
|
||||||
|
"USER",
|
||||||
|
JSON.stringify({
|
||||||
|
userId: dataNotif.userId,
|
||||||
|
count: 1,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
} else {
|
||||||
function TampilanHasil({
|
ComponentGlobal_NotifikasiPeringatan(res.message);
|
||||||
data,
|
}
|
||||||
hasil,
|
|
||||||
}: {
|
|
||||||
data: MODEL_VOTING_DAFTAR_NAMA_VOTE[];
|
|
||||||
hasil: any;
|
|
||||||
}) {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Card shadow="lg" withBorder p={30}>
|
|
||||||
<Card.Section>
|
|
||||||
<Stack>
|
|
||||||
<Center>
|
|
||||||
<Title order={5}>Hasil Voting</Title>
|
|
||||||
</Center>
|
|
||||||
|
|
||||||
{/* <pre>{JSON.stringify(data, null,2)}</pre> */}
|
|
||||||
|
|
||||||
<Grid justify="center">
|
|
||||||
{data.map((e) => (
|
|
||||||
<Grid.Col key={e.id} span={data.length >= 4 ? 6 : 4}>
|
|
||||||
<Stack align="center">
|
|
||||||
<Avatar
|
|
||||||
radius={100}
|
|
||||||
size={70}
|
|
||||||
variant="outline"
|
|
||||||
color="blue"
|
|
||||||
>
|
|
||||||
<Text>
|
|
||||||
{e.jumlah}
|
|
||||||
{/* {hasil.filter((i: any) => i.idDaftarNama == "clsijw6ur0002x5loqsq6g4id")} */}
|
|
||||||
</Text>
|
|
||||||
</Avatar>
|
|
||||||
<Text>{e.value}</Text>
|
|
||||||
</Stack>
|
|
||||||
</Grid.Col>
|
|
||||||
))}
|
|
||||||
</Grid>
|
|
||||||
</Stack>
|
|
||||||
</Card.Section>
|
|
||||||
</Card>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function TampilanListKontributor({
|
|
||||||
lisKontributor,
|
|
||||||
}: {
|
|
||||||
lisKontributor: MODEL_VOTE_KONTRIBUTOR[];
|
|
||||||
}) {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Card shadow="lg" withBorder p={30}>
|
|
||||||
<Card.Section>
|
|
||||||
<Stack>
|
|
||||||
<Center>
|
|
||||||
<Title order={5}>Daftar Voting</Title>
|
|
||||||
</Center>
|
|
||||||
{lisKontributor.map((e, i) => (
|
|
||||||
<Stack spacing={"xs"} key={i}>
|
|
||||||
<Grid>
|
|
||||||
<Grid.Col span={2}>
|
|
||||||
<Avatar
|
|
||||||
size={30}
|
|
||||||
sx={{ borderStyle: "solid", borderWidth: "0.5px" }}
|
|
||||||
radius={"xl"}
|
|
||||||
bg={"gray.1"}
|
|
||||||
src={
|
|
||||||
e
|
|
||||||
? RouterProfile.api_foto_profile +
|
|
||||||
e.Author.Profile.imagesId
|
|
||||||
: "/aset/global/avatar.png"
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</Grid.Col>
|
|
||||||
<Grid.Col span={6}>
|
|
||||||
<Stack justify="center" h={"100%"}>
|
|
||||||
<Text truncate fz={"sm"} fw={"bold"}>
|
|
||||||
{e ? e.Author.Profile.name : "Nama author"}
|
|
||||||
</Text>
|
|
||||||
</Stack>
|
|
||||||
</Grid.Col>
|
|
||||||
<Grid.Col span={4}>
|
|
||||||
<Badge w={100}>
|
|
||||||
<Text truncate>{e.Voting_DaftarNamaVote.value}</Text>
|
|
||||||
</Badge>
|
|
||||||
</Grid.Col>
|
|
||||||
</Grid>
|
|
||||||
<Divider />
|
|
||||||
</Stack>
|
|
||||||
))}
|
|
||||||
{/* {lisKontributor.map((e) => (
|
|
||||||
<Stack key={e.id}>
|
|
||||||
<Group position="apart">
|
|
||||||
<Group>
|
|
||||||
<Avatar
|
|
||||||
size={30}
|
|
||||||
sx={{ borderStyle: "solid", borderWidth: "0.5px" }}
|
|
||||||
radius={"xl"}
|
|
||||||
bg={"gray.1"}
|
|
||||||
src={
|
|
||||||
e
|
|
||||||
? RouterProfile.api_foto_profile +
|
|
||||||
e.Author.Profile.imagesId
|
|
||||||
: "/aset/global/avatar.png"
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<Text truncate fz={"sm"} fw={"bold"}>
|
|
||||||
{e ? e.Author.Profile.name : "Nama author"}
|
|
||||||
</Text>
|
|
||||||
</Group>
|
|
||||||
<Badge>
|
|
||||||
<Text truncate>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Harum minus libero, ullam ipsum quasi labore iure doloremque sunt et mollitia dolorem laborum quisquam, dolores quis deserunt id. Ipsa, minus temporibus.</Text>
|
|
||||||
</Badge>
|
|
||||||
</Group>
|
|
||||||
<Divider />
|
|
||||||
</Stack>
|
|
||||||
))} */}
|
|
||||||
</Stack>
|
|
||||||
</Card.Section>
|
|
||||||
</Card>
|
|
||||||
{/* <pre>{JSON.stringify(lisKontributor, null, 2)}</pre> */}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import { Vote_funEditStatusByStatusId } from "../../fun/edit/fun_edit_status_by_
|
|||||||
import { gs_vote_status } from "../../global_state";
|
import { gs_vote_status } from "../../global_state";
|
||||||
import { MODEL_VOTING } from "../../model/interface";
|
import { MODEL_VOTING } from "../../model/interface";
|
||||||
import UIGlobal_Modal from "@/app_modules/_global/ui/ui_modal";
|
import UIGlobal_Modal from "@/app_modules/_global/ui/ui_modal";
|
||||||
|
import mqtt_client from "@/util/mqtt_client";
|
||||||
|
import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin";
|
||||||
|
|
||||||
export default function Vote_DetailReview({
|
export default function Vote_DetailReview({
|
||||||
dataVote,
|
dataVote,
|
||||||
@@ -34,16 +36,36 @@ function ButtonAction({ voteId }: { voteId: string }) {
|
|||||||
const [openModal, setOpenModal] = useState(false);
|
const [openModal, setOpenModal] = useState(false);
|
||||||
|
|
||||||
async function onUpdate() {
|
async function onUpdate() {
|
||||||
await Vote_funEditStatusByStatusId(voteId, "3").then((res) => {
|
const res = await Vote_funEditStatusByStatusId(voteId, "3");
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
|
const dataNotif: any = {
|
||||||
|
appId: res.data?.id as any,
|
||||||
|
status: res.data?.Voting_Status?.name as any,
|
||||||
|
userId: res.data?.authorId as any,
|
||||||
|
pesan: res.data?.title as any,
|
||||||
|
kategoriApp: "VOTING",
|
||||||
|
title: "Membatalkan review",
|
||||||
|
};
|
||||||
|
|
||||||
|
const notif = await notifikasiToAdmin_funCreate({
|
||||||
|
data: dataNotif as any,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (notif.status === 201) {
|
||||||
|
mqtt_client.publish(
|
||||||
|
"ADMIN",
|
||||||
|
JSON.stringify({
|
||||||
|
count: 1,
|
||||||
|
})
|
||||||
|
);
|
||||||
setTabsStatus("Draft");
|
setTabsStatus("Draft");
|
||||||
ComponentGlobal_NotifikasiBerhasil("Berhasil Batalkan Review", 2000);
|
ComponentGlobal_NotifikasiBerhasil("Berhasil Batalkan Review", 2000);
|
||||||
router.back();
|
router.back();
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
} else {
|
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
|
||||||
}
|
}
|
||||||
});
|
} else {
|
||||||
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export async function Vote_funCreateHasil(
|
|||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
jumlah: true,
|
jumlah: true,
|
||||||
|
value: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -31,16 +32,30 @@ export async function Vote_funCreateHasil(
|
|||||||
});
|
});
|
||||||
if (!updt) return { status: 400, message: "Gagal Update" };
|
if (!updt) return { status: 400, message: "Gagal Update" };
|
||||||
|
|
||||||
const create = await prisma.voting_Kontributor.create({
|
const createKontributor = await prisma.voting_Kontributor.create({
|
||||||
data: {
|
data: {
|
||||||
voting_DaftarNamaVoteId: pilihanVotingId,
|
voting_DaftarNamaVoteId: pilihanVotingId,
|
||||||
votingId: votingId,
|
votingId: votingId,
|
||||||
authorId: authorId,
|
authorId: authorId,
|
||||||
},
|
},
|
||||||
|
select: {
|
||||||
|
Voting: {
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
title: true,
|
||||||
|
authorId: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
if (!create) return { status: 400, message: "Gagal Menjadi Kontributor" };
|
|
||||||
|
|
||||||
|
|
||||||
|
if (!createKontributor)
|
||||||
|
return { status: 400, message: "Gagal Menjadi Kontributor" };
|
||||||
revalidatePath("/dev/vote/detail/main/");
|
revalidatePath("/dev/vote/detail/main/");
|
||||||
return { status: 201, message: "Berhasil Voting" };
|
return {
|
||||||
|
data: createKontributor,
|
||||||
|
pilihan: get.value,
|
||||||
|
status: 201,
|
||||||
|
message: "Berhasil Voting",
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,16 @@ export async function Vote_funCreate(req: MODEL_VOTING, listVote: any[]) {
|
|||||||
akhirVote: req.akhirVote,
|
akhirVote: req.akhirVote,
|
||||||
authorId: authorId,
|
authorId: authorId,
|
||||||
},
|
},
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
title: true,
|
||||||
|
Voting_Status: {
|
||||||
|
select: {
|
||||||
|
name: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
authorId: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!create) return { status: 400, message: "Gagal Membuat Vote" };
|
if (!create) return { status: 400, message: "Gagal Membuat Vote" };
|
||||||
@@ -35,6 +45,7 @@ export async function Vote_funCreate(req: MODEL_VOTING, listVote: any[]) {
|
|||||||
revalidatePath("/dev/vote/main/status");
|
revalidatePath("/dev/vote/main/status");
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
data: create,
|
||||||
status: 201,
|
status: 201,
|
||||||
message: "Berhasil Membuat Vote",
|
message: "Berhasil Membuat Vote",
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import prisma from "@/app/lib/prisma";
|
import prisma from "@/app/lib/prisma";
|
||||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||||
|
import { data } from "autoprefixer";
|
||||||
import { revalidatePath } from "next/cache";
|
import { revalidatePath } from "next/cache";
|
||||||
|
|
||||||
export async function Vote_funEditStatusByStatusId(
|
export async function Vote_funEditStatusByStatusId(
|
||||||
@@ -15,11 +16,22 @@ export async function Vote_funEditStatusByStatusId(
|
|||||||
data: {
|
data: {
|
||||||
voting_StatusId: statusId,
|
voting_StatusId: statusId,
|
||||||
},
|
},
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
title: true,
|
||||||
|
authorId: true,
|
||||||
|
Voting_Status: {
|
||||||
|
select: {
|
||||||
|
name: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!updt) return { status: 400, message: "Gagal Update" };
|
if (!updt) return { status: 400, message: "Gagal Update" };
|
||||||
revalidatePath("/dev/vote/main/status");
|
revalidatePath("/dev/vote/main/status");
|
||||||
return {
|
return {
|
||||||
|
data: updt,
|
||||||
status: 200,
|
status: 200,
|
||||||
message: "Update Berhasil",
|
message: "Update Berhasil",
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user