QC Voting

- # fix
- Beranda dan mandatori input
## No issuee
This commit is contained in:
2024-05-21 15:24:37 +08:00
parent dbeb740d1f
commit ce35aa8f51
32 changed files with 568 additions and 234 deletions

View File

@@ -127,13 +127,13 @@ function DetailRiwayat({ listRiwayat }: { listRiwayat: MODEL_EVENT[] }) {
sx={{ borderStyle: "solid", borderWidth: "0.5px" }}
radius={"xl"}
src={
RouterProfile.api_foto_profile + e.User.Profile.imagesId
RouterProfile.api_foto_profile + e?.User?.Profile?.imagesId
}
/>
</Grid.Col>
<Grid.Col span={"auto"}>
<Group align="center" h={"100%"}>
<Text>{e.User.Profile.name}</Text>
<Text>{e?.User?.Profile?.name}</Text>
</Group>
</Grid.Col>
</Grid>

View File

@@ -130,13 +130,13 @@ function TableStatus({ listPublish }: { listPublish: MODEL_EVENT[] }) {
radius={"xl"}
src={
RouterProfile.api_foto_profile +
e.User.Profile.imagesId
e?.User?.Profile?.imagesId
}
/>
</Grid.Col>
<Grid.Col span={"auto"}>
<Group align="center" h={"100%"}>
<Text>{e.User.Profile.name}</Text>
<Text>{e?.User?.Profile?.name}</Text>
</Group>
</Grid.Col>
</Grid>

View File

@@ -69,7 +69,7 @@ function TableStatus({ listReject }: { listReject: MODEL_EVENT[] }) {
const TableRows = data.map((e, i) => (
<tr key={i}>
<td>
<Box w={200}>{e.Author.Profile.name}</Box>
<Box w={200}>{e?.Author?.Profile?.name}</Box>
</td>
<td>
<Box w={200}>{e.title}</Box>

View File

@@ -66,7 +66,7 @@ function TableStatus({ listReview }: { listReview: MODEL_EVENT[] }) {
const TableRows = data.map((e, i) => (
<tr key={i}>
<td>{e.Author.Profile.name}</td>
<td>{e?.Author?.Profile?.name}</td>
<td>{e.title}</td>
<td>{e.lokasi}</td>
<td>{e.EventMaster_TipeAcara.name}</td>

View File

@@ -70,16 +70,16 @@ function TableStatus({ listPublish }: { listPublish: MODEL_VOTING[] }) {
<Center>
<Button
loading={
e.id === voteId ? (loading === true ? true : false) : false
e?.id === voteId ? (loading === true ? true : false) : false
}
radius={"xl"}
color="green"
leftIcon={<IconEyeCheck />}
onClick={async () => {
setVoteId(e.id);
setVoteId(e?.id);
setLoading(true);
await new Promise((r) => setTimeout(r, 500));
onList(e.id, setHasil, setKontributor, setLoading, open);
onList(e?.id, setHasil, setKontributor, setLoading, open);
}}
>
Lihat Hasil
@@ -87,7 +87,10 @@ function TableStatus({ listPublish }: { listPublish: MODEL_VOTING[] }) {
</Center>
</td>
<td>
<Center>{e.title}</Center>
<Center>{e?.Author?.Profile?.name}</Center>
</td>
<td>
<Center>{e?.title}</Center>
</td>
<td>
<Center>
@@ -97,27 +100,27 @@ function TableStatus({ listPublish }: { listPublish: MODEL_VOTING[] }) {
maxHeight={50}
showLabel="tampilkan"
>
{e.deskripsi}
{e?.deskripsi}
</Spoiler>
</Center>
</td>
<th>
<Stack>
{e.Voting_DaftarNamaVote.map((v) => (
<Box key={v.id}>
<Text>- {v.value}</Text>
{e?.Voting_DaftarNamaVote.map((v) => (
<Box key={v?.id}>
<Text>- {v?.value}</Text>
</Box>
))}
</Stack>
</th>
<td>
<Center>
{e.awalVote.toLocaleDateString("id-ID", { dateStyle: "long" })}
{e?.awalVote.toLocaleDateString("id-ID", { dateStyle: "long" })}
</Center>
</td>
<td>
<Center>
{e.akhirVote.toLocaleDateString("id-ID", { dateStyle: "long" })}
{e?.akhirVote.toLocaleDateString("id-ID", { dateStyle: "long" })}
</Center>
</td>
</tr>
@@ -131,7 +134,10 @@ function TableStatus({ listPublish }: { listPublish: MODEL_VOTING[] }) {
size={"xl"}
withCloseButton={false}
>
<ComponentAdminVote_DetailHasil hasil={hasil} kontributor={kontributor}/>
<ComponentAdminVote_DetailHasil
hasil={hasil}
kontributor={kontributor}
/>
</Modal>
<Box>
<Box bg={"green.1"} p={"xs"}>
@@ -152,6 +158,9 @@ function TableStatus({ listPublish }: { listPublish: MODEL_VOTING[] }) {
<th>
<Center>Aksi</Center>
</th>
<th>
<Center>Author</Center>
</th>
<th>
<Center>Judul</Center>
</th>

View File

@@ -87,6 +87,9 @@ function TableStatus({ listData }: { listData: MODEL_VOTING[] }) {
</Spoiler>
</Center>
</td>
<td>
<Center>{e?.Author?.Profile?.name}</Center>
</td>
<td>
<Center>{e.title}</Center>
</td>
@@ -184,7 +187,9 @@ function TableStatus({ listData }: { listData: MODEL_VOTING[] }) {
<th>
<Center>Catatan</Center>
</th>
<th>
<Center>Author</Center>
</th>
<th>
<Center>Judul</Center>
</th>

View File

@@ -36,6 +36,7 @@ import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_glob
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
import { AdminEvent_funEditCatatanById } from "../../fun/edit/fun_edit_status_reject_by_id";
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/component_global/notif_global/notifikasi_peringatan";
import moment from "moment";
export default function AdminVote_TableReview({
listVote,
@@ -58,9 +59,14 @@ function TableStatus({ listData }: { listData: MODEL_VOTING[] }) {
const [data, setData] = useState(listData);
const [votingId, setVotingId] = useState("");
const [catatan, setCatatan] = useState("");
const [isLoadingPublish, setLoadingPublish] = useState(false);
const [isSaveLoading, setSaveLoading] = useState(false);
const TableRows = data.map((e, i) => (
<tr key={i}>
<td>
<Center>{e?.Author?.Profile?.name}</Center>
</td>
<td>
<Center>{e.title}</Center>
</td>
@@ -99,11 +105,23 @@ function TableStatus({ listData }: { listData: MODEL_VOTING[] }) {
<td>
<Stack align="center">
<Button
loaderPosition="center"
loading={
e?.id === votingId ? (isLoadingPublish ? true : false) : false
}
w={120}
color={"green"}
leftIcon={<IconEyeShare />}
radius={"xl"}
onClick={() => onPublish(e.id, setData, e.awalVote)}
onClick={() =>
onPublish(
e.id,
setData,
e.awalVote,
setLoadingPublish,
setVotingId
)
}
>
Publish
</Button>
@@ -146,12 +164,15 @@ function TableStatus({ listData }: { listData: MODEL_VOTING[] }) {
}}
/>
<Group position="right">
<Button radius={"xl"} onClick={() => close()}>
Batal
</Button>
<Button
loaderPosition="center"
loading={isSaveLoading ? true : false}
radius={"xl"}
onClick={() => {
onReject(votingId, setData, catatan, close);
// console.log("hehe")
onReject(votingId, setData, catatan, close, setSaveLoading);
}}
>
Simpan
@@ -178,6 +199,9 @@ function TableStatus({ listData }: { listData: MODEL_VOTING[] }) {
>
<thead>
<tr>
<th>
<Center>Author</Center>
</th>
<th>
<Center>Judul</Center>
</th>
@@ -217,19 +241,26 @@ function TableStatus({ listData }: { listData: MODEL_VOTING[] }) {
);
}
async function onPublish(voteId: string, setData: any, awalVote: Date) {
async function onPublish(
voteId: string,
setData: any,
awalVote: Date,
setLoadingPublish: any,
setVotingId: any
) {
const hariIni = new Date();
if (awalVote < hariIni)
return ComponentGlobal_NotifikasiPeringatan(
"Tanggal Mulai Votig Lewat, Edit Kembali",
1500
);
const cekHari = moment(awalVote).diff(hariIni, "days");
if (cekHari < 0)
return ComponentGlobal_NotifikasiPeringatan("Tanggal Voting Lewat");
setVotingId(voteId);
await AdminVote_funEditStatusPublishById(voteId).then(async (res) => {
if (res.status === 200) {
await AdminVote_getListTableByStatusId("2").then((val) => {
setData(val);
ComponentGlobal_NotifikasiBerhasil(res.message);
setLoadingPublish(true);
});
} else {
ComponentGlobal_NotifikasiGagal(res.message);
@@ -241,7 +272,8 @@ async function onReject(
voteId: string,
setData: any,
catatan: string,
close: any
close: any,
setSaveLoading: any
) {
const data = {
id: voteId,
@@ -251,6 +283,7 @@ async function onReject(
if (res.status === 200) {
await AdminVote_getListTableByStatusId("2").then((val) => {
setData(val);
setSaveLoading(true);
ComponentGlobal_NotifikasiBerhasil(res.message);
close();
});

View File

@@ -1,8 +1,22 @@
"use client"
"use client";
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
import { MODEL_VOTE_KONTRIBUTOR, MODEL_VOTING_DAFTAR_NAMA_VOTE } from "@/app_modules/vote/model/interface";
import { Paper, Stack, Center, Title, Grid, Card, Avatar, Badge, Divider, Text } from "@mantine/core";
import {
MODEL_VOTE_KONTRIBUTOR,
MODEL_VOTING_DAFTAR_NAMA_VOTE,
} from "@/app_modules/vote/model/interface";
import {
Paper,
Stack,
Center,
Title,
Grid,
Card,
Avatar,
Badge,
Divider,
Text,
} from "@mantine/core";
import _ from "lodash";
import router from "next/router";
@@ -11,7 +25,7 @@ export default function ComponentAdminVote_DetailHasil({
kontributor,
}: {
hasil?: MODEL_VOTING_DAFTAR_NAMA_VOTE[];
kontributor?: MODEL_VOTE_KONTRIBUTOR[]
kontributor?: MODEL_VOTE_KONTRIBUTOR[];
}) {
return (
<>
@@ -58,7 +72,7 @@ export default function ComponentAdminVote_DetailHasil({
span={2}
onClick={() =>
router.push(
RouterProfile.katalog + e.Author.Profile.id
RouterProfile.katalog + e?.Author?.Profile?.id
)
}
>
@@ -73,7 +87,7 @@ export default function ComponentAdminVote_DetailHasil({
src={
e
? RouterProfile.api_foto_profile +
e.Author.Profile.imagesId
e?.Author?.Profile?.imagesId
: "/aset/global/avatar.png"
}
/>
@@ -81,7 +95,7 @@ export default function ComponentAdminVote_DetailHasil({
<Grid.Col span={5}>
<Stack justify="center" h={"100%"}>
<Text truncate fz={"sm"} fw={"bold"}>
{e ? e.Author.Profile.name : "Nama author"}
{e ? e?.Author?.Profile?.name : "Nama author"}
</Text>
</Stack>
</Grid.Col>
@@ -116,4 +130,4 @@ export default function ComponentAdminVote_DetailHasil({
</Paper>
</>
);
}
}

View File

@@ -23,7 +23,18 @@ export async function AdminVote_getListTableByStatusId(statusId: string) {
akhirVote: true,
catatan: true,
authorId: true,
Author: true,
Author: {
select: {
id: true,
username: true,
Profile: {
select: {
id: true,
name: true,
},
},
},
},
voting_StatusId: true,
Voting_DaftarNamaVote: true,
},
@@ -52,7 +63,18 @@ export async function AdminVote_getListTableByStatusId(statusId: string) {
akhirVote: true,
catatan: true,
authorId: true,
Author: true,
Author: {
select: {
id: true,
username: true,
Profile: {
select: {
id: true,
name: true,
},
},
},
},
voting_StatusId: true,
Voting_DaftarNamaVote: true,
},
@@ -63,6 +85,9 @@ export async function AdminVote_getListTableByStatusId(statusId: string) {
if (statusId === "2") {
const getData = await prisma.voting.findMany({
orderBy: {
updatedAt: "desc",
},
where: {
voting_StatusId: "2",
isActive: true,
@@ -78,7 +103,18 @@ export async function AdminVote_getListTableByStatusId(statusId: string) {
akhirVote: true,
catatan: true,
authorId: true,
Author: true,
Author: {
select: {
id: true,
username: true,
Profile: {
select: {
id: true,
name: true,
},
},
},
},
voting_StatusId: true,
Voting_DaftarNamaVote: true,
},
@@ -104,7 +140,18 @@ export async function AdminVote_getListTableByStatusId(statusId: string) {
akhirVote: true,
catatan: true,
authorId: true,
Author: true,
Author: {
select: {
id: true,
username: true,
Profile: {
select: {
id: true,
name: true,
},
},
},
},
voting_StatusId: true,
Voting_DaftarNamaVote: true,
},
@@ -112,6 +159,4 @@ export async function AdminVote_getListTableByStatusId(statusId: string) {
return getData;
}
}