Fix: Avatar

Deskripsi:
- Avatar job
- Avatar collaboration
- Avatar event
## No Issuue
This commit is contained in:
2024-10-01 16:31:12 +08:00
parent ca5c30499a
commit 284787243b
110 changed files with 1122 additions and 2064 deletions

View File

@@ -1,20 +1,10 @@
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
import { AccentColor } from "@/app_modules/_global/color";
import { ComponentGlobal_AvatarAndAuthorName } from "@/app_modules/_global/component";
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
import {
Card,
Stack,
Center,
Title,
Grid,
Avatar,
Badge,
Divider,
Text,
} from "@mantine/core";
ComponentGlobal_AvatarAndUsername,
ComponentGlobal_CardStyles,
} from "@/app_modules/_global/component";
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
import { Badge, Group, Stack, Text } from "@mantine/core";
import _ from "lodash";
import router from "next/router";
import { MODEL_VOTE_KONTRIBUTOR } from "../model/interface";
export function Voting_ViewDetailKontributorVoting({
@@ -24,40 +14,32 @@ export function Voting_ViewDetailKontributorVoting({
}) {
return (
<>
<Card
p={30}
style={{
backgroundColor: AccentColor.darkblue,
borderRadius: "10px",
border: `2px solid ${AccentColor.blue}`,
color: "white",
}}
>
<Card.Section>
{_.isEmpty(listKontributor) ? (
<ComponentGlobal_IsEmptyData text="Tidak ada kontributor" />
) : (
<Stack>
{listKontributor?.map((e, i) => (
<ComponentGlobal_AvatarAndAuthorName
key={e.id}
dataUser={e.Author}
componentRight={
<ComponentGlobal_CardStyles>
{_.isEmpty(listKontributor) ? (
<ComponentGlobal_IsEmptyData text="Tidak ada kontributor" />
) : (
<Stack spacing={"lg"}>
{listKontributor?.map((e, i) => (
<ComponentGlobal_AvatarAndUsername
key={e.id}
profile={e.Author.Profile as any}
component={
<Group position="right">
<Badge w={130}>
<Text
lineClamp={1}
lineClamp={1}
fz={e.Voting_DaftarNamaVote.value.length > 10 ? 8 : 10}
>
{e.Voting_DaftarNamaVote.value}
</Text>
</Badge>
}
/>
))}
</Stack>
)}
</Card.Section>
</Card>
</Group>
}
/>
))}
</Stack>
)}
</ComponentGlobal_CardStyles>
</>
);
}

View File

@@ -23,7 +23,11 @@ import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/noti
import { AccentColor } from "@/app_modules/_global/color/color_pallet";
import { toNumber } from "lodash";
import { useState } from "react";
import { ComponentGlobal_CardLoadingOverlay } from "@/app_modules/_global/component";
import {
ComponentGlobal_AvatarAndUsername,
ComponentGlobal_CardLoadingOverlay,
ComponentGlobal_CardStyles,
} from "@/app_modules/_global/component";
export default function ComponentVote_CardViewPublish({
data,
@@ -45,140 +49,125 @@ export default function ComponentVote_CardViewPublish({
return (
<>
<Card
radius={"md"}
px={30}
pt={authorName ? 30 : 10}
pb={30}
mb={"lg"}
style={{
backgroundColor: AccentColor.darkblue,
borderRadius: "10px",
border: `2px solid ${AccentColor.blue}`,
color: "white",
}}
>
{/* Header name */}
{authorName ? (
<Card.Section>
<ComponentGlobal_AuthorNameOnHeader
authorName={data?.Author ? data?.Author.Profile.name : ""}
imagesId={data?.Author ? data?.Author.Profile.imagesId : ""}
profileId={data?.Author ? data?.Author.Profile.id : ""}
<ComponentGlobal_CardStyles marginBottom={"15px"}>
<Stack>
{/* Header name */}
{authorName ? (
<ComponentGlobal_AvatarAndUsername
profile={data?.Author.Profile as any}
/>
</Card.Section>
) : (
""
)}
) : (
""
)}
{/* Isi deskripsi */}
<Card.Section
py={authorName ? "sm" : 0}
onClick={() => {
if (data?.id === undefined) {
ComponentGlobal_NotifikasiPeringatan("Halaman tidak ditemukan");
} else {
setVisible(true);
router.push(path + data?.id);
}
}}
>
<Stack spacing={"xl"}>
<Stack align="center">
<Text align="center" fw={"bold"}>
{data ? data.title : "Judul Voting"}
</Text>
<Badge
styles={{
root: {
backgroundColor: AccentColor.blue,
border: `1px solid ${AccentColor.skyblue}`,
color: "white",
width: "80%",
},
}}
>
<Group>
<Text>
{data
? data?.awalVote.toLocaleDateString(["id-ID"], {
dateStyle: "medium",
})
: "tgl awal voting"}
</Text>
<Text>-</Text>
<Text>
{data
? data?.akhirVote.toLocaleDateString(["id-ID"], {
dateStyle: "medium",
})
: "tgl akhir voting"}
</Text>
</Group>
</Badge>
{/* Isi deskripsi */}
<Box
onClick={() => {
if (data?.id === undefined) {
ComponentGlobal_NotifikasiPeringatan("Halaman tidak ditemukan");
} else {
setVisible(true);
router.push(path + data?.id);
}
}}
>
<Stack spacing={"xl"}>
<Stack align="center">
<Text align="center" fw={"bold"}>
{data ? data.title : "Judul Voting"}
</Text>
<Badge
styles={{
root: {
backgroundColor: AccentColor.blue,
border: `1px solid ${AccentColor.skyblue}`,
color: "white",
width: "80%",
},
}}
>
<Group>
<Text>
{data
? data?.awalVote.toLocaleDateString(["id-ID"], {
dateStyle: "medium",
})
: "tgl awal voting"}
</Text>
<Text>-</Text>
<Text>
{data
? data?.akhirVote.toLocaleDateString(["id-ID"], {
dateStyle: "medium",
})
: "tgl akhir voting"}
</Text>
</Group>
</Badge>
</Stack>
{data ? (
<Stack>
<Center>
<Title order={5}>Hasil Voting</Title>
</Center>
<Grid justify="center">
{data?.Voting_DaftarNamaVote.map((e) => (
<Grid.Col
key={e.id}
span={data?.Voting_DaftarNamaVote?.length >= 4 ? 6 : 4}
>
<Stack align="center">
<Avatar
radius={100}
size={70}
variant="outline"
color="yellow"
>
<Text>{e.jumlah}</Text>
</Avatar>
<Text fz={"xs"} align="center">
{e.value}
</Text>
</Stack>
</Grid.Col>
))}
</Grid>
</Stack>
) : (
""
)}
</Stack>
{data ? (
<Stack>
<Center>
<Title order={5}>Hasil Voting</Title>
</Center>
<Grid justify="center">
{data?.Voting_DaftarNamaVote.map((e) => (
<Grid.Col
key={e.id}
span={data?.Voting_DaftarNamaVote?.length >= 4 ? 6 : 4}
>
<Stack align="center">
<Avatar
radius={100}
size={70}
variant="outline"
color="yellow"
>
<Text>{e.jumlah}</Text>
</Avatar>
<Text fz={"xs"} align="center">
{e.value}
</Text>
</Stack>
</Grid.Col>
))}
</Grid>
{pilihanSaya ? (
<Stack align="center" spacing={0} mt="md">
<Text mb={"xs"} fw={"bold"} fz={"xs"}>
Pilihan anda:
</Text>
<Badge size="lg">
<Text truncate fz={"xs"}>
{namaPilihan}
</Text>
</Badge>
</Stack>
) : (
""
)}
</Stack>
{pilihanSaya ? (
<Stack align="center" spacing={0} mt="md">
<Text mb={"xs"} fw={"bold"} fz={"xs"}>
Pilihan anda:
</Text>
<Badge size="lg">
<Text truncate fz={"xs"}>
{namaPilihan}
</Text>
</Badge>
</Stack>
) : (
""
)}
{statusArsip ? (
<Center mt="md">
<Badge color={data?.isArsip ? "gray" : "green"}>
{data?.isArsip ? "Arsip" : "Publish"}
</Badge>
</Center>
) : (
""
)}
{statusArsip ? (
<Center mt="md">
<Badge color={data?.isArsip ? "gray" : "green"}>
{data?.isArsip ? "Arsip" : "Publish"}
</Badge>
</Center>
) : (
""
)}
{visible && <ComponentGlobal_CardLoadingOverlay />}
</Card.Section>
</Card>
{visible && <ComponentGlobal_CardLoadingOverlay />}
</Box>
</Stack>
</ComponentGlobal_CardStyles>
</>
);
}

View File

@@ -1,8 +1,9 @@
import { RouterVote } from "@/app/lib/router_hipmi/router_vote";
import { AccentColor } from "@/app_modules/_global/color";
import ComponentGlobal_Loader from "@/app_modules/_global/component/loader";
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
import { UIGlobal_Modal } from "@/app_modules/_global/ui";
import UIGlobal_Drawer from "@/app_modules/_global/ui/ui_drawer";
import UIGlobal_LayoutHeaderTamplate from "@/app_modules/_global/ui/ui_header_tamplate";
import {
ActionIcon,
@@ -13,47 +14,48 @@ import {
Stack,
Text,
} from "@mantine/core";
import { IconArchive, IconUsersGroup, IconX } from "@tabler/icons-react";
import { IconDots, IconDotsVertical } from "@tabler/icons-react";
import {
IconArchive,
IconDotsVertical,
IconUsersGroup,
IconX,
} from "@tabler/icons-react";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { voting_funGetOneVotingbyId } from "../../fun/get/fun_get_one_by_id";
import { useShallowEffect } from "@mantine/hooks";
import { MODEL_VOTING } from "../../model/interface";
import { voting_funUpdateIsArsipById } from "../../fun";
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
import { MODEL_VOTING } from "../../model/interface";
import { voting_funGetOneVotingbyId } from "../../fun/get/fun_get_one_by_id";
export function Voting_ComponentLayoutHeaderDetailPublish({
votingId,
title,
userLoginId,
dataVoting,
}: {
votingId: string;
title: string;
userLoginId: string;
dataVoting: any;
}) {
const [data, setData] = useState<MODEL_VOTING>();
const [data, setData] = useState<MODEL_VOTING>(dataVoting);
const [openDrawer, setOpenDrawer] = useState(false);
const [openModal, setOpenModal] = useState(false);
useShallowEffect(() => {
onLoadData({ onSetData: setData });
}, [setData]);
async function onLoadData({ onSetData }: { onSetData: any }) {
const dataVoting = await voting_funGetOneVotingbyId(votingId);
onSetData(dataVoting);
}
async function onUpdateStatusArsip({ isArsip }: { isArsip: boolean }) {
const res = await voting_funUpdateIsArsipById({
votingId,
isArsip: isArsip,
});
if (res.status === 200) {
setOpenModal(false);
ComponentGlobal_NotifikasiBerhasil(res.message);
try {
const loadData = await voting_funGetOneVotingbyId(votingId);
setData(loadData as any);
} catch (error) {
console.log(error);
} finally {
setOpenModal(false);
ComponentGlobal_NotifikasiBerhasil(res.message);
}
} else {
ComponentGlobal_NotifikasiGagal(res.message);
}

View File

@@ -1,21 +1,21 @@
"use client";
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
import { AccentColor } from "@/app_modules/_global/color/color_pallet";
import {
Avatar,
ComponentGlobal_AvatarAndUsername,
ComponentGlobal_CardStyles,
} from "@/app_modules/_global/component";
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
import {
Badge,
Card,
Box,
Center,
Divider,
Grid,
Group,
Stack,
Text,
Title,
Title
} from "@mantine/core";
import _ from "lodash";
import { useRouter } from "next/navigation";
import { MODEL_VOTE_KONTRIBUTOR } from "../../model/interface";
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
export default function ComponentVote_DaftarKontributorVoter({
listKontributor,
@@ -25,63 +25,29 @@ export default function ComponentVote_DaftarKontributorVoter({
const router = useRouter();
return (
<>
<Card
p={30}
style={{
backgroundColor: AccentColor.darkblue,
borderRadius: "10px",
border: `2px solid ${AccentColor.blue}`,
color: "white",
}}
>
<Card.Section>
<Stack>
<Center>
<Title order={5}>Daftar Kontributor</Title>
</Center>
<ComponentGlobal_CardStyles>
<Stack>
<Center>
<Title order={5}>Daftar Kontributor</Title>
</Center>
{_.isEmpty(listKontributor) ? (
<ComponentGlobal_IsEmptyData
height={20}
text="Tidak ada kontributor"
/>
) : (
<Stack>
{listKontributor?.map((e, i) => (
<Stack spacing={"xs"} key={i}>
<Grid>
<Grid.Col
span={2}
onClick={() =>
router.push(
RouterProfile.katalogOLD + e.Author.Profile.id
)
}
>
<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={5}>
<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={5}>
{_.isEmpty(listKontributor) ? (
<ComponentGlobal_IsEmptyData
height={20}
text="Tidak ada kontributor"
/>
) : (
<Stack>
{listKontributor?.map((e, i) => (
<Box key={e.id}>
<ComponentGlobal_AvatarAndUsername
profile={e.Author.Profile as any}
sizeAvatar={30}
component={
<Group position="right" align="center" h={"100%"}>
<Badge w={130}>
<Text
truncate
lineClamp={1}
fz={
e.Voting_DaftarNamaVote.value.length > 10 ? 8 : 10
}
@@ -89,16 +55,15 @@ export default function ComponentVote_DaftarKontributorVoter({
{e.Voting_DaftarNamaVote.value}
</Text>
</Badge>
</Grid.Col>
</Grid>
<Divider />
</Stack>
))}
</Stack>
)}
</Stack>
</Card.Section>
</Card>
</Group>
}
/>
</Box>
))}
</Stack>
)}
</Stack>
</ComponentGlobal_CardStyles>
</>
);
}

View File

@@ -1,21 +1,11 @@
"use client";
import {
Card,
Stack,
Center,
Title,
Badge,
Group,
Radio,
Grid,
Text,
} from "@mantine/core";
import moment from "moment";
import { MODEL_VOTING } from "../../model/interface";
import { IconCircle } from "@tabler/icons-react";
import _ from "lodash";
import ComponentGlobal_AuthorNameOnHeader from "@/app_modules/_global/author_name_on_header";
import { AccentColor } from "@/app_modules/_global/color/color_pallet";
import {
ComponentGlobal_AvatarAndUsername,
ComponentGlobal_CardStyles,
} from "@/app_modules/_global/component";
import { Badge, Center, Group, Stack, Text, Title } from "@mantine/core";
import { MODEL_VOTING } from "../../model/interface";
export default function ComponentVote_DetailDataSetelahPublish({
data,
@@ -26,27 +16,15 @@ export default function ComponentVote_DetailDataSetelahPublish({
}) {
return (
<>
<Card
p={30}
style={{
backgroundColor: AccentColor.darkblue,
borderRadius: "10px",
border: `2px solid ${AccentColor.blue}`,
color: "white",
}}
>
{authorName ? (
<Card.Section>
<ComponentGlobal_AuthorNameOnHeader
authorName={data?.Author.Profile.name}
imagesId={data?.Author.Profile.imagesId}
profileId={data?.Author.Profile.id}
<ComponentGlobal_CardStyles marginBottom={"0px"}>
<Stack>
{authorName ? (
<ComponentGlobal_AvatarAndUsername
profile={data?.Author.Profile as any}
/>
</Card.Section>
) : (
""
)}
<Card.Section px={"xs"} py={authorName ? "sm" : 0}>
) : (
""
)}
<Stack spacing={"lg"}>
<Center>
<Title order={4} align="center">
@@ -87,8 +65,8 @@ export default function ComponentVote_DetailDataSetelahPublish({
</Stack>
</Stack>
</Stack>
</Card.Section>
</Card>
</Stack>
</ComponentGlobal_CardStyles>
</>
);
}

View File

@@ -1,21 +1,11 @@
"use client";
import {
Badge,
Card,
Center,
Grid,
Group,
Radio,
Stack,
Text,
Title,
Stack
} from "@mantine/core";
import moment from "moment";
import ComponentVote_HasilVoting from "../../component/detail/detail_hasil_voting";
import ComponentVote_DaftarKontributorVoter from "../../component/detail/detail_daftar_kontributor";
import { MODEL_VOTING } from "../../model/interface";
import ComponentVote_DetailDataSetelahPublish from "../../component/detail/detail_data_setelah_publish";
import ComponentVote_HasilVoting from "../../component/detail/detail_hasil_voting";
import { MODEL_VOTING } from "../../model/interface";
export default function Vote_DetailKontribusi({
dataVote,

View File

@@ -8,16 +8,19 @@ export default function LayoutVote_DetailKontribusi({
children,
votingId,
userLoginId,
dataVoting
}: {
children: React.ReactNode;
votingId: string;
userLoginId: string;
dataVoting: any
}) {
return (
<>
<UIGlobal_LayoutTamplate
header={
<Voting_ComponentLayoutHeaderDetailPublish
dataVoting={dataVoting}
title="Detail Kontribusi"
userLoginId={userLoginId}
votingId={votingId}

View File

@@ -5,9 +5,11 @@ import {
AccentColor,
MainColor,
} from "@/app_modules/_global/color/color_pallet";
import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information";
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
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 mqtt_client from "@/util/mqtt_client";
import {
Badge,
Box,
@@ -21,15 +23,14 @@ import {
Title,
} from "@mantine/core";
import _ from "lodash";
import moment from "moment";
import { useState } from "react";
import ComponentVote_DaftarKontributorVoter from "../../component/detail/detail_daftar_kontributor";
import ComponentVote_HasilVoting from "../../component/detail/detail_hasil_voting";
import { Vote_funCreateHasil } from "../../fun/create/create_hasil";
import { voting_funGetOneVotingbyId } from "../../fun/get/fun_get_one_by_id";
import { MODEL_VOTING } from "../../model/interface";
import mqtt_client from "@/util/mqtt_client";
import moment from "moment";
import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information";
import { ComponentDonasi_CardStatus } from "@/app_modules/donasi/component/card_view/card_status";
import { ComponentGlobal_AvatarAndUsername, ComponentGlobal_CardStyles } from "@/app_modules/_global/component";
export default function Vote_MainDetail({
dataVote,
@@ -51,7 +52,7 @@ export default function Vote_MainDetail({
return (
<>
<Stack py={"md"}>
<Stack pb={"md"}>
{moment(dataVote?.awalVote).diff(today, "hours") < 0 ? (
""
) : (
@@ -88,23 +89,14 @@ function TampilanDataVoting({
return (
<>
<Card
p={30}
style={{
backgroundColor: AccentColor.darkblue,
borderRadius: "10px",
border: `2px solid ${AccentColor.blue}`,
color: "white",
}}
>
<Card.Section mb={"md"}>
<ComponentGlobal_AuthorNameOnHeader
<ComponentGlobal_CardStyles>
<Stack>
<ComponentGlobal_AvatarAndUsername profile={dataVote?.Author?.Profile as any}/>
{/* <ComponentGlobal_AuthorNameOnHeader
authorName={dataVote?.Author.Profile.name}
imagesId={dataVote?.Author.Profile.imagesId}
profileId={dataVote?.Author.Profile.id}
/>
</Card.Section>
<Card.Section px={"xs"} py={"sm"}>
/> */}
<Stack spacing={"lg"}>
<Center>
<Title order={5} align="center">
@@ -146,10 +138,6 @@ function TampilanDataVoting({
</Stack>
</Stack>
</Stack>
</Card.Section>
{/* Voting View */}
<Card.Section py={"xl"}>
{isKontributor ? (
<Stack
align="center"
@@ -232,8 +220,9 @@ function TampilanDataVoting({
</Center>
</Stack>
)}
</Card.Section>
</Card>
</Stack>
</ComponentGlobal_CardStyles>
</>
);
}

View File

@@ -8,10 +8,12 @@ export default function LayoutVote_MainDetail({
children,
votingId,
userLoginId,
dataVoting,
}: {
children: React.ReactNode;
votingId: string;
userLoginId: string;
dataVoting: any
}) {
return (
<>
@@ -21,6 +23,7 @@ export default function LayoutVote_MainDetail({
title="Detail Voting"
votingId={votingId}
userLoginId={userLoginId}
dataVoting={dataVoting}
/>
}
>

View File

@@ -1,10 +1,9 @@
"use client";
import { Badge, Center, Stack } from "@mantine/core";
import ComponentVote_DaftarKontributorVoter from "../../component/detail/detail_daftar_kontributor";
import ComponentVote_DetailDataSetelahPublish from "../../component/detail/detail_data_setelah_publish";
import ComponentVote_HasilVoting from "../../component/detail/detail_hasil_voting";
import { MODEL_VOTE_KONTRIBUTOR, MODEL_VOTING } from "../../model/interface";
import { MODEL_VOTING } from "../../model/interface";
export default function Vote_DetailPublish({
dataVote,

View File

@@ -9,16 +9,19 @@ export default function LayoutVote_DetailPublish({
children,
votingId,
userLoginId,
dataVoting,
}: {
children: React.ReactNode;
votingId: string;
userLoginId: string;
dataVoting: any;
}) {
return (
<>
<UIGlobal_LayoutTamplate
header={
<Voting_ComponentLayoutHeaderDetailPublish
dataVoting={dataVoting}
title="Detail Publish"
votingId={votingId}
userLoginId={userLoginId}

View File

@@ -15,7 +15,7 @@ export default function Vote_DetailRiwayatSaya({
}) {
return (
<>
<Stack py={"md"}>
<Stack pb={"md"}>
<ComponentVote_DetailDataSetelahPublish
data={dataVote}
authorName={true}

View File

@@ -16,7 +16,7 @@ export default function Vote_DetailSemuaRiwayat({
}) {
return (
<>
<Stack py={"md"}>
<Stack pb={"md"}>
<ComponentVote_DetailDataSetelahPublish
data={dataVote}
authorName={true}

View File

@@ -16,7 +16,7 @@ export async function vote_getAllListKontribusiByAuthorId({
take: takeData,
skip: skipData,
orderBy: {
createdAt: "asc",
createdAt: "desc",
},
where: {
authorId: userLoginId,

View File

@@ -4,6 +4,9 @@ import prisma from "@/app/lib/prisma";
export async function Vote_getListKontributorById(votingId: string) {
const data = await prisma.voting_Kontributor.findMany({
orderBy:{
createdAt: "desc"
},
where: {
votingId: votingId,
},