upd: grup
Deskripsi: - menggunakan layout navbar new - menggunakan local state - menggunakan modal konfirmasi dan toast No Issues
This commit is contained in:
@@ -1,50 +1,50 @@
|
||||
import { isDrawer, LayoutDrawer, WARNA } from '@/module/_global';
|
||||
import { LayoutDrawer, WARNA } from '@/module/_global';
|
||||
import { ActionIcon, Box, Group, Text, TextInput } from '@mantine/core';
|
||||
import React, { useState } from 'react';
|
||||
import { HiOutlineOfficeBuilding } from 'react-icons/hi';
|
||||
import { HiMagnifyingGlass } from 'react-icons/hi2';
|
||||
import EditDrawerGroup from './ui/edit_drawer_group';
|
||||
import { useHookstate } from '@hookstate/core';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import toast from 'react-hot-toast';
|
||||
|
||||
const dataGroup = [
|
||||
{
|
||||
id: 1,
|
||||
name: 'Lembaga Pengkreditan Desa'
|
||||
name: 'Dinas'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'Lembaga Pengkreditan Desa'
|
||||
name: 'Adat'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: 'Lembaga Pengkreditan Desa'
|
||||
name: 'LPD'
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: 'Lembaga Pengkreditan Desa'
|
||||
name: 'Karang Taruna'
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: 'Lembaga Pengkreditan Desa'
|
||||
name: 'BPD'
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
name: 'Lembaga Pengkreditan Desa'
|
||||
name: 'LPM'
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
name: 'Lembaga Pengkreditan Desa'
|
||||
name: 'PKK'
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
name: 'Lembaga Pengkreditan Desa'
|
||||
name: 'Pengelolaan Penduduk'
|
||||
},
|
||||
]
|
||||
|
||||
export default function ListGroupActive() {
|
||||
// const openDrawerEdit = useHookstate(isDrawer)
|
||||
const [openDrawer, setOpenDrawer] = useState(false)
|
||||
const [valChoose, setValChoose] = useState("")
|
||||
|
||||
return (
|
||||
<Box pt={20}>
|
||||
<TextInput
|
||||
@@ -63,11 +63,18 @@ export default function ListGroupActive() {
|
||||
{dataGroup.map((v, i) => {
|
||||
return (
|
||||
<Box pt={20} key={i}>
|
||||
<Group align='center' style={{
|
||||
border: `1px solid ${"#DCEED8"}`,
|
||||
padding: 10,
|
||||
borderRadius: 10
|
||||
}} onClick={() => setOpenDrawer(true)} >
|
||||
<Group align='center'
|
||||
style={{
|
||||
border: `1px solid ${"#DCEED8"}`,
|
||||
padding: 10,
|
||||
borderRadius: 10,
|
||||
cursor: 'pointer'
|
||||
}}
|
||||
onClick={() => {
|
||||
setValChoose(v.name)
|
||||
setOpenDrawer(true)
|
||||
}}
|
||||
>
|
||||
<Box>
|
||||
<ActionIcon variant="light" bg={'#DCEED8'} size={50} radius={100} aria-label="icon">
|
||||
<HiOutlineOfficeBuilding color={WARNA.biruTua} size={25} />
|
||||
@@ -80,8 +87,13 @@ export default function ListGroupActive() {
|
||||
</Box>
|
||||
)
|
||||
})}
|
||||
<LayoutDrawer opened={openDrawer} onClose={() => setOpenDrawer(false)} title="LEMBAGA PENGKREDITAN DESA">
|
||||
<EditDrawerGroup />
|
||||
<LayoutDrawer opened={openDrawer} onClose={() => setOpenDrawer(false)} title={valChoose}>
|
||||
<EditDrawerGroup onUpdated={(val) => {
|
||||
if (val) {
|
||||
toast.success('Sukses! data tersimpan')
|
||||
}
|
||||
setOpenDrawer(false)
|
||||
}} />
|
||||
</LayoutDrawer>
|
||||
</Box>
|
||||
);
|
||||
|
||||
@@ -1,47 +1,50 @@
|
||||
import { isDrawer, LayoutDrawer, WARNA } from '@/module/_global';
|
||||
import { LayoutDrawer, WARNA } from '@/module/_global';
|
||||
import { ActionIcon, Box, Group, Text, TextInput } from '@mantine/core';
|
||||
import React, { useState } from 'react';
|
||||
import { HiOutlineOfficeBuilding } from 'react-icons/hi';
|
||||
import { HiMagnifyingGlass } from 'react-icons/hi2';
|
||||
import EditDrawerGroup from './ui/edit_drawer_group';
|
||||
import toast from 'react-hot-toast';
|
||||
|
||||
const dataGroup = [
|
||||
{
|
||||
id: 1,
|
||||
name: 'No Active Desa'
|
||||
name: 'Dinas'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'No Active Desa'
|
||||
name: 'Adat'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: 'No Active Desa'
|
||||
name: 'LPD'
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: 'No Active Desa'
|
||||
name: 'Karang Taruna'
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: 'No Active Desa'
|
||||
name: 'BPD'
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
name: 'No Active Desa'
|
||||
name: 'LPM'
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
name: 'No Active Desa'
|
||||
name: 'PKK'
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
name: 'No Active Desa'
|
||||
name: 'Pengelolaan Penduduk'
|
||||
},
|
||||
]
|
||||
|
||||
export default function ListGroupNonActive() {
|
||||
const [openDrawer, setOpenDrawer] = useState(false)
|
||||
const [valChoose, setValChoose] = useState("")
|
||||
|
||||
return (
|
||||
<Box pt={20}>
|
||||
<TextInput
|
||||
@@ -60,11 +63,18 @@ export default function ListGroupNonActive() {
|
||||
{dataGroup.map((v, i) => {
|
||||
return (
|
||||
<Box pt={20} key={i}>
|
||||
<Group align='center' style={{
|
||||
border: `1px solid ${"#DCEED8"}`,
|
||||
padding: 10,
|
||||
borderRadius: 10
|
||||
}} onClick={() => setOpenDrawer(true)}>
|
||||
<Group align='center'
|
||||
style={{
|
||||
border: `1px solid ${"#DCEED8"}`,
|
||||
padding: 10,
|
||||
borderRadius: 10,
|
||||
cursor: 'pointer'
|
||||
}}
|
||||
onClick={() => {
|
||||
setValChoose(v.name)
|
||||
setOpenDrawer(true)
|
||||
}}
|
||||
>
|
||||
<Box>
|
||||
<ActionIcon variant="light" bg={'#DCEED8'} size={50} radius={100} aria-label="icon">
|
||||
<HiOutlineOfficeBuilding color={WARNA.biruTua} size={25} />
|
||||
@@ -77,8 +87,13 @@ export default function ListGroupNonActive() {
|
||||
</Box>
|
||||
)
|
||||
})}
|
||||
<LayoutDrawer opened={openDrawer} onClose={() => setOpenDrawer(false)} title="LEMBAGA PENGKREDITAN DESA">
|
||||
<EditDrawerGroup />
|
||||
<LayoutDrawer opened={openDrawer} onClose={() => setOpenDrawer(false)} title={valChoose}>
|
||||
<EditDrawerGroup onUpdated={(val) => {
|
||||
if (val) {
|
||||
toast.success('Sukses! data tersimpan')
|
||||
}
|
||||
setOpenDrawer(false)
|
||||
}} />
|
||||
</LayoutDrawer>
|
||||
</Box>
|
||||
);
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
import { isDrawer, LayoutDrawer, WARNA } from '@/module/_global';
|
||||
import { useHookstate } from '@hookstate/core';
|
||||
import { LayoutDrawer, WARNA } from '@/module/_global';
|
||||
import { Box, Button, Center, Flex, Group, SimpleGrid, Stack, Text, TextInput } from '@mantine/core';
|
||||
import React, { useState } from 'react';
|
||||
import { IoAddCircle } from "react-icons/io5";
|
||||
|
||||
export default function DrawerGroup() {
|
||||
export default function DrawerGroup({ onSuccess }: { onSuccess: (val: boolean) => void }) {
|
||||
const [openDrawerGroup, setOpenDrawerGroup] = useState(false)
|
||||
const openDrawer = useHookstate(isDrawer)
|
||||
|
||||
function onCLose() {
|
||||
setOpenDrawerGroup(false)
|
||||
openDrawer.set(false)
|
||||
onSuccess(true)
|
||||
}
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<Stack pt={10}>
|
||||
@@ -29,7 +28,7 @@ export default function DrawerGroup() {
|
||||
</Flex>
|
||||
</SimpleGrid>
|
||||
</Stack>
|
||||
<LayoutDrawer opened={openDrawerGroup} onClose={() => setOpenDrawerGroup(false)} title={'TAMBAH GRUP'}>
|
||||
<LayoutDrawer opened={openDrawerGroup} onClose={() => setOpenDrawerGroup(false)} title={'Tambah Grup'}>
|
||||
<Box pt={10}>
|
||||
<TextInput
|
||||
styles={{
|
||||
@@ -41,7 +40,7 @@ export default function DrawerGroup() {
|
||||
}}
|
||||
size="lg"
|
||||
radius={10}
|
||||
placeholder="Tambah Grup"
|
||||
placeholder="Grup"
|
||||
/>
|
||||
<Box mt={'xl'}>
|
||||
<Button
|
||||
@@ -52,7 +51,7 @@ export default function DrawerGroup() {
|
||||
fullWidth
|
||||
onClick={onCLose}
|
||||
>
|
||||
MASUK
|
||||
Simpan
|
||||
</Button>
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
@@ -1,26 +1,31 @@
|
||||
'use client'
|
||||
import { isDrawer, LayoutDrawer, WARNA } from '@/module/_global';
|
||||
import { useHookstate } from '@hookstate/core';
|
||||
import { LayoutDrawer, WARNA } from '@/module/_global';
|
||||
import LayoutModal from '@/module/_global/layout/layout_modal';
|
||||
import { Box, Button, Center, Flex, Group, SimpleGrid, Stack, Text, TextInput } from '@mantine/core';
|
||||
import React, { useState } from 'react';
|
||||
import { IoAddCircle, IoCloseCircleOutline } from "react-icons/io5";
|
||||
|
||||
export default function EditDrawerGroup() {
|
||||
export default function EditDrawerGroup({ onUpdated }: { onUpdated: (val: boolean) => void }) {
|
||||
const [openDrawerGroup, setOpenDrawerGroup] = useState(false)
|
||||
const openDrawerEdit = useHookstate(isDrawer)
|
||||
const [isModal, setModal] = useState(false)
|
||||
|
||||
function onCLose() {
|
||||
setOpenDrawerGroup(false)
|
||||
openDrawerEdit.set(false)
|
||||
onUpdated(true)
|
||||
}
|
||||
|
||||
function onTrue(val: boolean) {
|
||||
if (val) {
|
||||
onUpdated(true)
|
||||
}
|
||||
setModal(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<Stack pt={10}>
|
||||
<SimpleGrid
|
||||
cols={{ base: 3, sm: 3, lg: 3 }}
|
||||
|
||||
>
|
||||
<Flex justify={'center'} align={'center'} direction={'column'} >
|
||||
<SimpleGrid cols={{ base: 3, sm: 3, lg: 3 }}>
|
||||
<Flex justify={'center'} align={'center'} direction={'column'} onClick={() => setModal(true)} style={{ cursor: 'pointer' }}>
|
||||
<Box>
|
||||
<IoCloseCircleOutline size={30} color={WARNA.biruTua} />
|
||||
</Box>
|
||||
@@ -28,7 +33,7 @@ export default function EditDrawerGroup() {
|
||||
<Text c={WARNA.biruTua}>Tidak Aktif</Text>
|
||||
</Box>
|
||||
</Flex>
|
||||
<Flex justify={'center'} align={'center'} direction={'column'} onClick={() => setOpenDrawerGroup(true)}>
|
||||
<Flex justify={'center'} align={'center'} direction={'column'} onClick={() => setOpenDrawerGroup(true)} style={{ cursor: 'pointer' }}>
|
||||
<Box>
|
||||
<IoAddCircle size={30} color={WARNA.biruTua} />
|
||||
</Box>
|
||||
@@ -38,7 +43,7 @@ export default function EditDrawerGroup() {
|
||||
</Flex>
|
||||
</SimpleGrid>
|
||||
</Stack>
|
||||
<LayoutDrawer opened={openDrawerGroup} onClose={() => setOpenDrawerGroup(false)} title={'EDIT GRUP'}>
|
||||
<LayoutDrawer opened={openDrawerGroup} onClose={() => setOpenDrawerGroup(false)} title={'Edit Grup'}>
|
||||
<Box pt={10}>
|
||||
<TextInput
|
||||
styles={{
|
||||
@@ -50,7 +55,7 @@ export default function EditDrawerGroup() {
|
||||
}}
|
||||
size="lg"
|
||||
radius={10}
|
||||
placeholder="Edit Grup"
|
||||
placeholder="Grup"
|
||||
/>
|
||||
<Box mt={'xl'}>
|
||||
<Button
|
||||
@@ -61,11 +66,15 @@ export default function EditDrawerGroup() {
|
||||
fullWidth
|
||||
onClick={onCLose}
|
||||
>
|
||||
EDIT
|
||||
Simpan
|
||||
</Button>
|
||||
</Box>
|
||||
</Box>
|
||||
</LayoutDrawer>
|
||||
|
||||
<LayoutModal opened={isModal} onClose={() => setModal(false)}
|
||||
description="Apakah Anda yakin ingin mangubah status aktifasi data?"
|
||||
onYes={(val) => { onTrue(val) }} />
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,34 +1,27 @@
|
||||
"use client"
|
||||
import { isDrawer, LayoutDrawer, LayoutIconBack, LayoutNavbarHome, WARNA } from '@/module/_global';
|
||||
import { ActionIcon, Box, Drawer, Grid, Group, Text } from '@mantine/core';
|
||||
import React from 'react';
|
||||
import { LayoutDrawer, LayoutNavbarNew, WARNA } from '@/module/_global';
|
||||
import { ActionIcon, } from '@mantine/core';
|
||||
import React, { useState } from 'react';
|
||||
import { HiMenu } from "react-icons/hi";
|
||||
import DrawerGroup from './drawer_group';
|
||||
import { useHookstate } from '@hookstate/core';
|
||||
import toast from 'react-hot-toast';
|
||||
|
||||
export default function NavbarGroup() {
|
||||
const openDrawerMenu = useHookstate(isDrawer)
|
||||
const [isOpen, setOpen] = useState(false)
|
||||
return (
|
||||
<>
|
||||
<LayoutNavbarHome>
|
||||
<Grid justify='center' align='center'>
|
||||
<Grid.Col span="auto">
|
||||
<LayoutIconBack back='/home' />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={6}>
|
||||
<Text ta={'center'} fw={'bold'} c={'white'}>GROUP</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span="auto">
|
||||
<Group justify='flex-end'>
|
||||
<ActionIcon onClick={() => openDrawerMenu.set(true)} variant="light" bg={WARNA.bgIcon} size="lg" radius="lg" aria-label="Settings">
|
||||
<HiMenu size={20} color='white' />
|
||||
</ActionIcon>
|
||||
</Group>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</LayoutNavbarHome>
|
||||
<LayoutDrawer opened={openDrawerMenu.get()} title={'Menu'} onClose={() => openDrawerMenu.set(false)}>
|
||||
<DrawerGroup />
|
||||
<LayoutNavbarNew back='/home' title='Grup'
|
||||
menu={
|
||||
<ActionIcon onClick={() => setOpen(true)} variant="light" bg={WARNA.bgIcon} size="lg" radius="lg" aria-label="Settings">
|
||||
<HiMenu size={20} color='white' />
|
||||
</ActionIcon>
|
||||
}
|
||||
/>
|
||||
<LayoutDrawer opened={isOpen} title={'Menu'} onClose={() => setOpen(false)}>
|
||||
<DrawerGroup onSuccess={() => {
|
||||
setOpen(false)
|
||||
toast.success('Sukses! data tersimpan')
|
||||
}} />
|
||||
</LayoutDrawer>
|
||||
</>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user