fix: fixing super admin
Deskripsi: - tugas divisi - kegiatan - home - filter No Issues
This commit is contained in:
@@ -1,36 +1,24 @@
|
||||
"use client";
|
||||
import { LayoutNavbarNew, TEMA } from "@/module/_global";
|
||||
import {
|
||||
ActionIcon,
|
||||
Avatar,
|
||||
Box,
|
||||
Button,
|
||||
Flex,
|
||||
Group,
|
||||
Input,
|
||||
rem,
|
||||
SimpleGrid,
|
||||
Stack,
|
||||
Text,
|
||||
TextInput,
|
||||
} from "@mantine/core";
|
||||
import React, { useState } from "react";
|
||||
import { DatePicker } from "@mantine/dates";
|
||||
import { useRouter } from "next/navigation";
|
||||
import toast from "react-hot-toast";
|
||||
import moment from "moment";
|
||||
import { IFormDateProject } from "../lib/type_project";
|
||||
import { HiChevronLeft } from "react-icons/hi2";
|
||||
import { useHookstate } from "@hookstate/core";
|
||||
import { ActionIcon, Box, Button, Flex, Group, rem, SimpleGrid, Stack, Text, TextInput } from "@mantine/core";
|
||||
import { DatePicker } from "@mantine/dates";
|
||||
import moment from "moment";
|
||||
import { useState } from "react";
|
||||
import toast from "react-hot-toast";
|
||||
import { HiChevronLeft } from "react-icons/hi2";
|
||||
import { IFormDateProject } from "../lib/type_project";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
|
||||
|
||||
export default function ViewDateEndTask({ onClose, onSet }: {onClose: (val: boolean) => void, onSet: (val: IFormDateProject) => void }) {
|
||||
export default function ViewDateEndTask({ onClose, onSet }: { onClose: (val: boolean) => void, onSet: (val: IFormDateProject) => void }) {
|
||||
const [value, setValue] = useState<[Date | null, Date | null]>([null, null]);
|
||||
const router = useRouter()
|
||||
const [title, setTitle] = useState("")
|
||||
const tema = useHookstate(TEMA)
|
||||
const [acuan, setAcuan] = useState(false)
|
||||
const [touched, setTouched] = useState({
|
||||
title: false
|
||||
title: false,
|
||||
date: false
|
||||
});
|
||||
|
||||
function onSubmit() {
|
||||
@@ -40,16 +28,64 @@ export default function ViewDateEndTask({ onClose, onSet }: {onClose: (val: bool
|
||||
if (title == "")
|
||||
return toast.error("Error! harus memasukkan judul tugas")
|
||||
|
||||
onSet(
|
||||
{
|
||||
dateStart: value[0],
|
||||
dateEnd: value[1],
|
||||
title: title
|
||||
}
|
||||
)
|
||||
onSet({
|
||||
dateStart: value[0],
|
||||
dateEnd: value[1],
|
||||
title: title
|
||||
})
|
||||
}
|
||||
|
||||
function onCheck() {
|
||||
const cek = checkAll()
|
||||
if (!cek)
|
||||
return false
|
||||
onSubmit()
|
||||
}
|
||||
|
||||
function checkAll() {
|
||||
let nilai = true
|
||||
|
||||
if (title == "") {
|
||||
setTouched(touched => ({ ...touched, title: true }))
|
||||
nilai = false
|
||||
}
|
||||
|
||||
if (value[0] == null || value[1] == null) {
|
||||
setTouched(touched => ({ ...touched, date: true }))
|
||||
nilai = false
|
||||
}
|
||||
|
||||
return nilai
|
||||
|
||||
}
|
||||
|
||||
|
||||
function onValidation(kategori: string, val: string) {
|
||||
if (kategori == 'title') {
|
||||
setTitle(val)
|
||||
if (val === "") {
|
||||
setTouched({ ...touched, title: true })
|
||||
} else {
|
||||
setTouched({ ...touched, title: false })
|
||||
}
|
||||
} else if (kategori == 'date') {
|
||||
const array = val.split(",")
|
||||
if (array[0] == '' || array[1] == '') {
|
||||
setTouched({ ...touched, date: true })
|
||||
} else {
|
||||
setTouched({ ...touched, date: false })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
useShallowEffect(() => {
|
||||
if (acuan) {
|
||||
onValidation('date', String(value))
|
||||
} else {
|
||||
setAcuan(true)
|
||||
}
|
||||
}, [value])
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<LayoutNavbarNew state={
|
||||
@@ -77,7 +113,9 @@ export default function ViewDateEndTask({ onClose, onSet }: {onClose: (val: bool
|
||||
</Group>
|
||||
<SimpleGrid cols={{ base: 2, sm: 2, lg: 2 }} mt={20}>
|
||||
<Box>
|
||||
<Text>Tanggal Mulai</Text>
|
||||
<Flex justify="flex-start" align="flex-start" direction="row" wrap="nowrap" gap={5}>
|
||||
<Text fw={500}>Tanggal Mulai</Text> <Text c={"red"}>*</Text>
|
||||
</Flex>
|
||||
<Group
|
||||
justify="center"
|
||||
bg={"white"}
|
||||
@@ -88,7 +126,9 @@ export default function ViewDateEndTask({ onClose, onSet }: {onClose: (val: bool
|
||||
</Group>
|
||||
</Box>
|
||||
<Box>
|
||||
<Text>Tanggal Berakhir</Text>
|
||||
<Flex justify="flex-start" align="flex-start" direction="row" wrap="nowrap" gap={5}>
|
||||
<Text fw={500}>Tanggal Berakhir</Text> <Text c={"red"}>*</Text>
|
||||
</Flex>
|
||||
<Group
|
||||
justify="center"
|
||||
bg={"white"}
|
||||
@@ -99,6 +139,11 @@ export default function ViewDateEndTask({ onClose, onSet }: {onClose: (val: bool
|
||||
</Group>
|
||||
</Box>
|
||||
</SimpleGrid>
|
||||
{
|
||||
(touched && touched.date)
|
||||
? <Text size="sm" c={"red"}>Tanggal Tidak Boleh Kosong</Text>
|
||||
: <></>
|
||||
}
|
||||
<Stack pt={15} pb={100}>
|
||||
<TextInput
|
||||
styles={{
|
||||
@@ -107,40 +152,38 @@ export default function ViewDateEndTask({ onClose, onSet }: {onClose: (val: bool
|
||||
borderRadius: 10,
|
||||
},
|
||||
}}
|
||||
placeholder="Input Judul Tahapan"
|
||||
label="Judul Tahapan"
|
||||
placeholder="Input Judul Tugas"
|
||||
label="Judul Tugas"
|
||||
required
|
||||
size="md"
|
||||
value={title}
|
||||
onChange={(e) => {
|
||||
setTitle(e.target.value)
|
||||
setTouched({ ...touched, title: false })
|
||||
onValidation('title', e.target.value)
|
||||
}}
|
||||
onBlur={() => setTouched({ ...touched, title: true })}
|
||||
error={
|
||||
touched.title && (
|
||||
title == "" ? "Judul Tahapan Tidak Boleh Kosong" : null
|
||||
title == "" ? "Judul Tugas Tidak Boleh Kosong" : null
|
||||
)
|
||||
}
|
||||
/>
|
||||
</Stack>
|
||||
</Box>
|
||||
<Box pos={'fixed'} bottom={0} p={rem(20)} w={"100%"} style={{
|
||||
maxWidth: rem(550),
|
||||
zIndex: 999,
|
||||
backgroundColor: `${tema.get().bgUtama}`,
|
||||
}}>
|
||||
<Button
|
||||
c={"white"}
|
||||
bg={tema.get().utama}
|
||||
size="lg"
|
||||
radius={30}
|
||||
fullWidth
|
||||
onClick={() => { onSubmit() }}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
</Box>
|
||||
<Box pos={'fixed'} bottom={0} p={rem(20)} w={"100%"} style={{
|
||||
maxWidth: rem(550),
|
||||
zIndex: 999,
|
||||
backgroundColor: `${tema.get().bgUtama}`,
|
||||
}}>
|
||||
<Button
|
||||
c={"white"}
|
||||
bg={tema.get().utama}
|
||||
size="lg"
|
||||
radius={30}
|
||||
fullWidth
|
||||
onClick={() => { onCheck() }}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user