Deskripsi:
- UI Voting bagian beranda dan status
## Noissue
This commit is contained in:
2024-07-12 16:02:28 +08:00
parent e744bb95fa
commit 7e21694324
50 changed files with 1222 additions and 812 deletions

View File

@@ -13,7 +13,7 @@ import {
Stack,
Text,
TextInput,
Textarea
Textarea,
} from "@mantine/core";
import { DatePickerInput } from "@mantine/dates";
import { IconMinus, IconPlus } from "@tabler/icons-react";
@@ -26,6 +26,7 @@ import { useState } from "react";
import { Vote_funCreate } from "../fun/create/create_vote";
import { gs_vote_hotMenu, gs_vote_status } from "../global_state";
import { MODEL_VOTING } from "../model/interface";
import { MainColor } from "@/app_modules/_global/color/color_pallet";
export default function Vote_Create() {
const router = useRouter();
@@ -36,13 +37,10 @@ export default function Vote_Create() {
const [data, setData] = useState({
title: "",
deskripsi: "",
awalVote: Date,
akhirVote: Date,
awalVote: "",
akhirVote: "",
});
// const [range, setRange] = useState({
// });
const [listVote, setListVote] = useState([
{
name: "Nama Pilihan",
@@ -56,9 +54,14 @@ export default function Vote_Create() {
return (
<>
<Stack px={"sm"} spacing={"xl"}>
<Stack px={"sm"} spacing={"xl"} mb={"xl"}>
<Stack>
<TextInput
styles={{
label: {
color: "white",
},
}}
label="Judul"
withAsterisk
placeholder="Masukan judul"
@@ -72,6 +75,11 @@ export default function Vote_Create() {
/>
<Stack spacing={5}>
<Textarea
styles={{
label: {
color: "white",
},
}}
label="Deskripsi"
autosize
minRows={2}
@@ -93,6 +101,11 @@ export default function Vote_Create() {
</Stack>
<DatePickerInput
styles={{
label: {
color: "white",
},
}}
label="Jangka Waktu"
placeholder="Masukan jangka waktu voting"
withAsterisk
@@ -118,11 +131,16 @@ export default function Vote_Create() {
</Text>
</Center>
<Stack>
<Stack spacing={"xl"}>
<Stack>
{listVote.map((e, index) => (
<Box key={index}>
<TextInput
styles={{
label: {
color: "white",
},
}}
label={e.name}
withAsterisk
maxLength={100}
@@ -140,31 +158,33 @@ export default function Vote_Create() {
<Group position="center">
<Button
disabled={listVote.length >= 4 ? true : false}
compact
w={100}
radius={"xl"}
leftIcon={<IconPlus size={15} />}
variant="outline"
onClick={() => {
setListVote([
...listVote,
{ name: "Nama Voting", value: "" },
]);
}}
compact
bg={MainColor.yellow}
color={"yellow"}
c={"black"}
>
<Text fz={8}>Tambah List</Text>
</Button>
<Button
disabled={listVote.length <= 2 ? true : false}
compact
w={100}
radius={"xl"}
leftIcon={<IconMinus size={15} />}
variant="outline"
onClick={() => {
setListVote([...listVote.slice(0, -1)]);
}}
compact
bg={MainColor.yellow}
color={"yellow"}
c={"black"}
>
<Text fz={8}>Kurangi List</Text>
</Button>
@@ -173,7 +193,15 @@ export default function Vote_Create() {
</Stack>
<Button
// disabled
disabled={
!data.title ||
!data.deskripsi ||
!data.awalVote ||
!data.akhirVote ||
listVote.map((e, i) => e.value).includes("")
? true
: false
}
loaderPosition="center"
loading={isLoading ? true : false}
mt={"lg"}
@@ -188,6 +216,12 @@ export default function Vote_Create() {
setIsLoading
);
}}
c={"black"}
bg={MainColor.yellow}
color="yellow"
style={{
transition: "0.5s",
}}
>
Simpan
</Button>
@@ -222,7 +256,7 @@ async function onSave(
await Vote_funCreate(data, listVote).then((res) => {
if (res.status === 201) {
setHotMenu(1);
setHotMenu(2);
setTabsStatus("Review");
router.replace(RouterVote.status);
ComponentGlobal_NotifikasiBerhasil(res.message);

View File

@@ -1,9 +1,8 @@
"use client";
import { AppShell } from "@mantine/core";
import UIGlobal_LayoutHeaderTamplate from "@/app_modules/_global/ui/ui_header_tamplate";
import UIGlobal_LayoutTamplate from "@/app_modules/_global/ui/ui_layout_tamplate";
import React from "react";
import ComponentVote_HeaderTamplate from "../component/header_tamplate";
import AppComponentGlobal_LayoutTamplate from "@/app_modules/_global/component_layout_tamplate";
export default function LayoutVote_Create({
children,
@@ -12,9 +11,9 @@ export default function LayoutVote_Create({
}) {
return (
<>
<AppComponentGlobal_LayoutTamplate header={<ComponentVote_HeaderTamplate title="Tambah Vote" />}>
<UIGlobal_LayoutTamplate header={<UIGlobal_LayoutHeaderTamplate title="Tambah Vote" />}>
{children}
</AppComponentGlobal_LayoutTamplate>
</UIGlobal_LayoutTamplate>
</>
);
}