upd: document
Deskripsi: - persiapan pindah item No Issues
This commit is contained in:
@@ -2,39 +2,63 @@ import { WARNA } from '@/module/_global';
|
||||
import { Box, Button, Divider, Flex, Grid, Group, Modal, Text, TextInput } from '@mantine/core';
|
||||
import React, { useState } from 'react';
|
||||
import toast from 'react-hot-toast';
|
||||
import { FcFolder } from 'react-icons/fc';
|
||||
const dataDocuments = [
|
||||
{
|
||||
id: 1,
|
||||
name: 'Administrasi',
|
||||
date: '18/06/2024 14.00 PM',
|
||||
icon: <FcFolder size={40} />
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'Administrasi',
|
||||
date: '18/06/2024 14.00 PM',
|
||||
icon: <FcFolder size={40} />
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: 'Administrasi',
|
||||
date: '18/06/2024 14.00 PM',
|
||||
icon: <FcFolder size={40} />
|
||||
},
|
||||
]
|
||||
import { FcDocument, FcFolder, FcImageFile } from 'react-icons/fc';
|
||||
import { funCreateFolder, funGetAllDocument } from '../lib/api_document';
|
||||
import { useParams } from 'next/navigation';
|
||||
import { IDataDocument } from '../lib/type_document';
|
||||
import { useShallowEffect } from '@mantine/hooks';
|
||||
|
||||
export default function DrawerCutDocuments() {
|
||||
const [opened, setOpened] = useState(false);
|
||||
function onCreate(val: boolean) {
|
||||
if (val) {
|
||||
toast.success("Sukses! Membuat Folder");
|
||||
const param = useParams<{ id: string }>()
|
||||
const [path, setPath] = useState('home')
|
||||
const [dataDocument, setDataDocument] = useState<IDataDocument[]>([])
|
||||
const [valName, setValName] = useState('')
|
||||
|
||||
|
||||
async function onCreateFolder() {
|
||||
try {
|
||||
const res = await funCreateFolder({
|
||||
name: valName,
|
||||
path: path,
|
||||
idDivision: param.id
|
||||
})
|
||||
if (res.success) {
|
||||
getOneData()
|
||||
} else {
|
||||
toast.error(res.message)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
toast.error("Gagal membuat folder baru, coba lagi nanti");
|
||||
}
|
||||
|
||||
setOpened(false)
|
||||
}
|
||||
|
||||
|
||||
async function getOneData() {
|
||||
try {
|
||||
const respon = await funGetAllDocument("?division=" + param.id + "&path=" + path);
|
||||
if (respon.success) {
|
||||
setDataDocument(respon.data);
|
||||
} else {
|
||||
toast.error(respon.message);
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
toast.error("Gagal mendapatkan item, coba lagi nanti");
|
||||
}
|
||||
}
|
||||
|
||||
useShallowEffect(() => {
|
||||
getOneData()
|
||||
}, [param.id, path])
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<Box h={60} pos={"fixed"} bottom={0} w={{base: "92%", md: "94%"}} style={{
|
||||
<Box h={60} pos={"fixed"} bottom={0} w={{ base: "92%", md: "94%" }} style={{
|
||||
zIndex: 999
|
||||
}}>
|
||||
<Grid justify='center'>
|
||||
@@ -42,34 +66,42 @@ export default function DrawerCutDocuments() {
|
||||
<Button variant="subtle" fullWidth color={WARNA.biruTua} radius={"xl"} onClick={() => setOpened(true)}>BUAT FOLDER BARU</Button>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={6}>
|
||||
<Button variant="filled" fullWidth color={WARNA.biruTua} radius={"xl"}>PIDAH</Button>
|
||||
<Button variant="filled" fullWidth color={WARNA.biruTua} radius={"xl"}>PINDAH</Button>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</Box>
|
||||
<Box p={10} pb={60}>
|
||||
{dataDocuments.map((v, i) => {
|
||||
return (
|
||||
<Box key={i}>
|
||||
<Box mt={10} mb={10}>
|
||||
<Grid align='center'>
|
||||
<Grid.Col span={12}>
|
||||
<Group gap={20}>
|
||||
<Box>
|
||||
{v.icon}
|
||||
</Box>
|
||||
<Flex direction={'column'}>
|
||||
<Text>{v.name}</Text>
|
||||
<Text fz={10}>{v.date}</Text>
|
||||
</Flex>
|
||||
</Group>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</Box>
|
||||
<Divider size="xs" />
|
||||
{dataDocument.map((v, i) => {
|
||||
return (
|
||||
<Box key={i}>
|
||||
<Box mt={10} mb={10} onClick={() => setPath(v.id)}>
|
||||
<Grid align='center'>
|
||||
<Grid.Col span={12}>
|
||||
<Group gap={20}>
|
||||
<Box>
|
||||
{
|
||||
(v.category == "FOLDER") ?
|
||||
<FcFolder size={60} /> :
|
||||
(v.extension == "pdf" || v.extension == "csv") ?
|
||||
<FcDocument size={60} /> :
|
||||
<FcImageFile size={60} />
|
||||
}
|
||||
</Box>
|
||||
<Flex direction={'column'}>
|
||||
<Text>{(v.category == "FOLDER") ? v.name : v.name + '.' + v.extension}</Text>
|
||||
</Flex>
|
||||
</Group>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</Box>
|
||||
)
|
||||
})}
|
||||
<Divider size="xs" />
|
||||
</Box>
|
||||
)
|
||||
})}
|
||||
</Box>
|
||||
|
||||
|
||||
|
||||
<Modal styles={{
|
||||
body: {
|
||||
borderRadius: 20
|
||||
@@ -92,7 +124,9 @@ export default function DrawerCutDocuments() {
|
||||
}}
|
||||
size="md"
|
||||
radius={10}
|
||||
placeholder="Buat Folder Baru"
|
||||
placeholder="Nama folder"
|
||||
value={valName}
|
||||
onChange={(e) => setValName(e.target.value)}
|
||||
/>
|
||||
</Box>
|
||||
<Grid mt={40}>
|
||||
@@ -100,7 +134,7 @@ export default function DrawerCutDocuments() {
|
||||
<Button variant="subtle" fullWidth color='#969494' onClick={() => setOpened(false)}>Batalkan</Button>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={6}>
|
||||
<Button variant="subtle" fullWidth color={WARNA.biruTua} onClick={(val) => onCreate(true)}>Membuat</Button>
|
||||
<Button variant="subtle" fullWidth color={WARNA.biruTua} onClick={() => onCreateFolder()}>Membuat</Button>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</Box>
|
||||
|
||||
@@ -32,9 +32,14 @@ export default function DrawerMore() {
|
||||
</Flex>
|
||||
</SimpleGrid>
|
||||
</Stack>
|
||||
|
||||
|
||||
<LayoutDrawer opened={isCut} onClose={() => setIsCut(false)} title={'Pilih Lokasi Pemindahan'} size="lg">
|
||||
<DrawerCutDocuments />
|
||||
</LayoutDrawer>
|
||||
|
||||
|
||||
|
||||
<LayoutDrawer opened={isCopy} onClose={() => setIsCopy(false)} title={'Pilih Lokasi Salin'} size="lg">
|
||||
<DrawerCopyDocuments />
|
||||
</LayoutDrawer>
|
||||
|
||||
@@ -159,7 +159,7 @@ export default function NavbarDocumentDivision() {
|
||||
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
toast.error("Gagal mendapatkan divisi, coba lagi nanti");
|
||||
toast.error("Gagal mendapatkan item, coba lagi nanti");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user