# Voting
## feat - Voting user - Halaman kontribusi - Halaman riwayat ### No issuue
This commit is contained in:
142
src/app_modules/vote/component/card_view_publish.tsx
Normal file
142
src/app_modules/vote/component/card_view_publish.tsx
Normal file
@@ -0,0 +1,142 @@
|
||||
"use client";
|
||||
|
||||
import { RouterVote } from "@/app/lib/router_hipmi/router_vote";
|
||||
import ComponentGlobal_AuthorNameOnHeader from "@/app_modules/component_global/author_name_on_header";
|
||||
import {
|
||||
Card,
|
||||
Stack,
|
||||
Grid,
|
||||
Avatar,
|
||||
Divider,
|
||||
Badge,
|
||||
Group,
|
||||
Text,
|
||||
Title,
|
||||
Box,
|
||||
} from "@mantine/core";
|
||||
import moment from "moment";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { MODEL_VOTING } from "../model/interface";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/component_global/notif_global/notifikasi_peringatan";
|
||||
|
||||
export default function ComponentVote_CardViewPublish({
|
||||
data,
|
||||
path,
|
||||
pilihanSaya,
|
||||
authorName,
|
||||
namaPilihan,
|
||||
}: {
|
||||
data?: MODEL_VOTING;
|
||||
path: string;
|
||||
pilihanSaya?: boolean;
|
||||
authorName?: boolean;
|
||||
namaPilihan?: string;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
return (
|
||||
<>
|
||||
<Card shadow="lg" withBorder p={30} radius={"md"}>
|
||||
{/* 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 : ""}
|
||||
/>
|
||||
</Card.Section>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
{/* Isi deskripsi */}
|
||||
<Card.Section
|
||||
py={authorName ? "sm" : 0}
|
||||
onClick={() => {
|
||||
if (data?.id === undefined) {
|
||||
ComponentGlobal_NotifikasiPeringatan("Path tidak ditemukan");
|
||||
} else {
|
||||
router.push(path + data?.id);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Stack>
|
||||
<Text fw={"bold"}>{data ? data.title : "Judul Voting"}</Text>
|
||||
<Badge>
|
||||
<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>
|
||||
{data ? (
|
||||
<Stack>
|
||||
<Grid>
|
||||
{data?.Voting_DaftarNamaVote.map((v) => (
|
||||
<Grid.Col key={v.id} span={"auto"}>
|
||||
<Stack align="center" spacing={"xs"}>
|
||||
<Text fz={10} lineClamp={1}>
|
||||
{v.value}
|
||||
</Text>
|
||||
|
||||
<Avatar radius={100} variant="outline" color="blue">
|
||||
<Text>{v.jumlah}</Text>
|
||||
</Avatar>
|
||||
</Stack>
|
||||
</Grid.Col>
|
||||
))}
|
||||
</Grid>
|
||||
</Stack>
|
||||
) : (
|
||||
<Stack>
|
||||
<Grid>
|
||||
<Grid.Col span={6}>
|
||||
<Stack align="center" spacing={"xs"}>
|
||||
<Text fz={10}>Voting A</Text>
|
||||
<Avatar radius={100} variant="outline" color="blue">
|
||||
2
|
||||
</Avatar>
|
||||
</Stack>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={6}>
|
||||
<Stack align="center" spacing={"xs"}>
|
||||
<Text fz={10}>Voting B</Text>
|
||||
<Avatar radius={100} variant="outline" color="red">
|
||||
3
|
||||
</Avatar>
|
||||
</Stack>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</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>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
</Card.Section>
|
||||
</Card>
|
||||
</>
|
||||
);
|
||||
}
|
||||
68
src/app_modules/vote/component/card_view_status.tsx
Normal file
68
src/app_modules/vote/component/card_view_status.tsx
Normal file
@@ -0,0 +1,68 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
Card,
|
||||
Stack,
|
||||
Title,
|
||||
Badge,
|
||||
Group,
|
||||
Radio,
|
||||
Grid,
|
||||
Center,
|
||||
Text,
|
||||
} from "@mantine/core";
|
||||
import moment from "moment";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { MODEL_VOTING } from "../model/interface";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/component_global/notif_global/notifikasi_peringatan";
|
||||
|
||||
export default function ComponentVote_CardViewStatus({
|
||||
path,
|
||||
data,
|
||||
}: {
|
||||
path?: string;
|
||||
data?: MODEL_VOTING;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
return (
|
||||
<>
|
||||
<Card
|
||||
shadow="lg"
|
||||
withBorder
|
||||
p={30}
|
||||
radius={"md"}
|
||||
onClick={() => {
|
||||
if (data?.id === undefined) {
|
||||
ComponentGlobal_NotifikasiPeringatan("Path tidak ditemukan");
|
||||
} else {
|
||||
router.push((path as string) + data?.id);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{/* Isi deskripsi */}
|
||||
<Card.Section>
|
||||
<Stack>
|
||||
<Text fw={"bold"} truncate>
|
||||
{data?.title}
|
||||
</Text>
|
||||
<Badge>
|
||||
<Group>
|
||||
<Text>
|
||||
{data?.awalVote.toLocaleDateString(["id-ID"], {
|
||||
dateStyle: "medium",
|
||||
})}
|
||||
</Text>
|
||||
<Text>-</Text>
|
||||
<Text>
|
||||
{data?.akhirVote.toLocaleDateString(["id-ID"], {
|
||||
dateStyle: "medium",
|
||||
})}
|
||||
</Text>
|
||||
</Group>
|
||||
</Badge>
|
||||
</Stack>
|
||||
</Card.Section>
|
||||
</Card>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
"use client";
|
||||
import {
|
||||
Card,
|
||||
Stack,
|
||||
Center,
|
||||
Title,
|
||||
Badge,
|
||||
Group,
|
||||
Radio,
|
||||
Grid,
|
||||
Text,
|
||||
Avatar,
|
||||
Divider,
|
||||
Box,
|
||||
} from "@mantine/core";
|
||||
import moment from "moment";
|
||||
import { MODEL_VOTE_KONTRIBUTOR } from "../../model/interface";
|
||||
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
|
||||
import _ from "lodash";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
export default function ComponentVote_DaftarKontributorVoter({
|
||||
listKontributor,
|
||||
}: {
|
||||
listKontributor?: MODEL_VOTE_KONTRIBUTOR[];
|
||||
}) {
|
||||
const router = useRouter()
|
||||
return (
|
||||
<>
|
||||
<Card shadow="lg" withBorder p={30}>
|
||||
<Card.Section>
|
||||
<Stack>
|
||||
<Center>
|
||||
<Title order={5}>Daftar Voting</Title>
|
||||
</Center>
|
||||
|
||||
{_.isEmpty(listKontributor) ? (
|
||||
<Center>
|
||||
<Text fz={"xs"} fw={"bold"}>- Tidak ada voting -</Text>
|
||||
</Center>
|
||||
) : (
|
||||
<Stack>
|
||||
{listKontributor?.map((e, i) => (
|
||||
<Stack spacing={"xs"} key={i}>
|
||||
<Grid>
|
||||
<Grid.Col span={2}
|
||||
onClick={() => router.push(RouterProfile.katalog + 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}>
|
||||
<Badge w={130}>
|
||||
<Text
|
||||
truncate
|
||||
fz={
|
||||
e.Voting_DaftarNamaVote.value.length > 10 ? 8 : 10
|
||||
}
|
||||
>
|
||||
{e.Voting_DaftarNamaVote.value}
|
||||
</Text>
|
||||
</Badge>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
<Divider />
|
||||
</Stack>
|
||||
))}
|
||||
</Stack>
|
||||
)}
|
||||
</Stack>
|
||||
</Card.Section>
|
||||
</Card>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
"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";
|
||||
|
||||
export default function ComponentVote_DetailDataSebelumPublish
|
||||
({
|
||||
data,
|
||||
}: {
|
||||
data?: MODEL_VOTING;
|
||||
}) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Card shadow="lg" withBorder p={30}>
|
||||
<Card.Section px={"xs"}>
|
||||
<Stack spacing={"lg"}>
|
||||
<Center>
|
||||
<Title order={5}>{data?.title}</Title>
|
||||
</Center>
|
||||
<Text>{data?.deskripsi}</Text>
|
||||
|
||||
<Stack spacing={0}>
|
||||
<Center>
|
||||
<Text fz={10} fw={"bold"}>
|
||||
Batas Voting
|
||||
</Text>
|
||||
</Center>
|
||||
<Badge>
|
||||
<Group>
|
||||
<Text>
|
||||
{data?.awalVote.toLocaleDateString(["id-ID"], {
|
||||
dateStyle: "medium",
|
||||
})}
|
||||
</Text>
|
||||
<Text>-</Text>
|
||||
<Text>
|
||||
{data?.akhirVote.toLocaleDateString(["id-ID"], {
|
||||
dateStyle: "medium",
|
||||
})}
|
||||
</Text>
|
||||
</Group>
|
||||
</Badge>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Card.Section>
|
||||
<Card.Section py={40}>
|
||||
<Text fz={10} fw={"bold"}>
|
||||
Pilihan :
|
||||
</Text>
|
||||
<Stack spacing={"xs"}>
|
||||
{data?.Voting_DaftarNamaVote.map((e) => (
|
||||
<Group key={e.id}>
|
||||
<Text>
|
||||
<IconCircle size={10} />
|
||||
</Text>
|
||||
<Text truncate>{e.value}</Text>
|
||||
</Group>
|
||||
))}
|
||||
</Stack>
|
||||
</Card.Section>
|
||||
</Card>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
"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/component_global/author_name_on_header";
|
||||
|
||||
export default function ComponentVote_DetailDataSetelahPublish({
|
||||
data,
|
||||
authorName,
|
||||
}: {
|
||||
data?: MODEL_VOTING;
|
||||
authorName?: boolean;
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<Card shadow="lg" withBorder p={30}>
|
||||
{authorName ? (
|
||||
<Card.Section>
|
||||
<ComponentGlobal_AuthorNameOnHeader
|
||||
authorName={data?.Author.Profile.name}
|
||||
imagesId={data?.Author.Profile.imagesId}
|
||||
profileId={data?.Author.Profile.id}
|
||||
/>
|
||||
</Card.Section>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
<Card.Section px={"xs"} py={authorName ? "sm" : 0}>
|
||||
<Stack spacing={"lg"}>
|
||||
<Center>
|
||||
<Title order={5}>{data?.title}</Title>
|
||||
</Center>
|
||||
<Text>{data?.deskripsi}</Text>
|
||||
|
||||
<Stack spacing={0} pb={authorName ? 0 : "xs"}>
|
||||
<Center>
|
||||
<Text fz={10} fw={"bold"}>
|
||||
Batas Voting
|
||||
</Text>
|
||||
</Center>
|
||||
<Badge>
|
||||
<Group>
|
||||
<Text>
|
||||
{data?.awalVote.toLocaleDateString(["id-ID"], {
|
||||
dateStyle: "medium",
|
||||
})}
|
||||
</Text>
|
||||
<Text>-</Text>
|
||||
<Text>
|
||||
{data?.akhirVote.toLocaleDateString(["id-ID"], {
|
||||
dateStyle: "medium",
|
||||
})}
|
||||
</Text>
|
||||
</Group>
|
||||
</Badge>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Card.Section>
|
||||
</Card>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import { Badge, Card, Center, Group, Stack, Text, Title } from "@mantine/core";
|
||||
import moment from "moment";
|
||||
|
||||
|
||||
export default function ComponentVote_DetailDataTanpaVote() {
|
||||
return (
|
||||
<>
|
||||
<Card shadow="lg" withBorder p={30}>
|
||||
<Card.Section px={"xs"}>
|
||||
<Stack spacing={"lg"}>
|
||||
<Center>
|
||||
<Title order={5}>Judul voting</Title>
|
||||
</Center>
|
||||
<Text>
|
||||
Deskripsi: Lorem, ipsum dolor sit amet consectetur adipisicing
|
||||
elit. Mollitia possimus repellendus in, iste voluptatibus sit
|
||||
laborum voluptates aliquam nisi? Earum quas ea quaerat veniam
|
||||
porro, magni nulla consequuntur distinctio at.
|
||||
</Text>
|
||||
</Stack>
|
||||
</Card.Section>
|
||||
<Card.Section py={"lg"}>
|
||||
<Stack spacing={0}>
|
||||
<Center>
|
||||
<Text fz={10} fw={"bold"}>
|
||||
Batas Voting
|
||||
</Text>
|
||||
</Center>
|
||||
<Badge>
|
||||
<Group>
|
||||
<Text>
|
||||
{new Date().toLocaleDateString(["id-ID"], {
|
||||
dateStyle: "medium",
|
||||
})}
|
||||
</Text>
|
||||
<Text>-</Text>
|
||||
<Text>
|
||||
{new Date(
|
||||
moment(Date.now()).add(10, "days").calendar()
|
||||
).toLocaleDateString(["id-ID"], {
|
||||
dateStyle: "medium",
|
||||
})}
|
||||
</Text>
|
||||
</Group>
|
||||
</Badge>
|
||||
</Stack>
|
||||
</Card.Section>
|
||||
</Card>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
Avatar,
|
||||
Box,
|
||||
Card,
|
||||
Center,
|
||||
Grid,
|
||||
Group,
|
||||
List,
|
||||
Stack,
|
||||
Text,
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
import { MODEL_VOTING_DAFTAR_NAMA_VOTE } from "../../model/interface";
|
||||
|
||||
export default function ComponentVote_HasilVoting({
|
||||
data,
|
||||
}: {
|
||||
data?: MODEL_VOTING_DAFTAR_NAMA_VOTE[];
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<Card shadow="lg" withBorder p={30}>
|
||||
<Card.Section>
|
||||
<Stack>
|
||||
<Center>
|
||||
<Title order={5}>Hasil Voting</Title>
|
||||
</Center>
|
||||
|
||||
<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}</Text>
|
||||
</Avatar>
|
||||
<Text fz={"xs"}>{e.value}</Text>
|
||||
</Stack>
|
||||
</Grid.Col>
|
||||
))}
|
||||
</Grid>
|
||||
</Stack>
|
||||
</Card.Section>
|
||||
</Card>
|
||||
</>
|
||||
);
|
||||
}
|
||||
69
src/app_modules/vote/component/header_tamplate.tsx
Normal file
69
src/app_modules/vote/component/header_tamplate.tsx
Normal file
@@ -0,0 +1,69 @@
|
||||
"use client";
|
||||
|
||||
import { Header, Group, ActionIcon, Text, Title } from "@mantine/core";
|
||||
import { IconArrowLeft, IconChevronLeft } from "@tabler/icons-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
|
||||
export default function ComponentVote_HeaderTamplate({
|
||||
hideBack,
|
||||
changeIconBack,
|
||||
route,
|
||||
route2,
|
||||
title,
|
||||
icon,
|
||||
bg,
|
||||
}: {
|
||||
hideBack?: boolean;
|
||||
changeIconBack?: any;
|
||||
route?: any;
|
||||
route2?: any;
|
||||
title: string;
|
||||
icon?: any;
|
||||
bg?: any;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
return (
|
||||
<>
|
||||
<Header
|
||||
height={50}
|
||||
sx={{ borderStyle: "none" }}
|
||||
bg={bg === null ? "" : bg}
|
||||
>
|
||||
<Group h={50} position="apart" px={"md"}>
|
||||
{hideBack ? (
|
||||
<ActionIcon variant="transparent" disabled></ActionIcon>
|
||||
) : (
|
||||
<ActionIcon
|
||||
variant="transparent"
|
||||
onClick={() => {
|
||||
if (route === null || route === undefined) {
|
||||
return router.back();
|
||||
} else {
|
||||
return router.push(route);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{changeIconBack ? changeIconBack : <IconChevronLeft />}
|
||||
</ActionIcon>
|
||||
)}
|
||||
<Title order={5}>{title}</Title>
|
||||
{(() => {
|
||||
if (route2 === null || route2 === undefined) {
|
||||
return <ActionIcon disabled variant="transparent"></ActionIcon>;
|
||||
} else {
|
||||
return (
|
||||
<ActionIcon
|
||||
variant="transparent"
|
||||
onClick={() => router.push(route2)}
|
||||
>
|
||||
{icon}
|
||||
</ActionIcon>
|
||||
);
|
||||
}
|
||||
})()}
|
||||
</Group>
|
||||
</Header>
|
||||
</>
|
||||
);
|
||||
}
|
||||
13
src/app_modules/vote/component/is_empty_data.tsx
Normal file
13
src/app_modules/vote/component/is_empty_data.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
"use client";
|
||||
|
||||
import { Center } from "@mantine/core";
|
||||
|
||||
export default function ComponentVote_IsEmptyData({ text }: { text: string }) {
|
||||
return (
|
||||
<>
|
||||
<Center h={"50vh"} fz={"sm"} fw={"bold"}>
|
||||
{text}
|
||||
</Center>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user