Fix UI Admin Menu Pendidikam, Add Menu User & Role
This commit is contained in:
@@ -1,81 +1,93 @@
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
'use client'
|
||||
import colors from '@/con/colors';
|
||||
import { Box, Button, Group, Paper, Stack, TextInput, Title } from '@mantine/core';
|
||||
import { Box, Button, Group, Paper, Stack, Text, TextInput, Title, Tooltip } from '@mantine/core';
|
||||
import { IconArrowBack } from '@tabler/icons-react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useState } from 'react';
|
||||
import { useProxy } from 'valtio/utils';
|
||||
import dataPendidikan from '../../../_state/pendidikan/data-pendidikan';
|
||||
|
||||
function CreateDataPendidikan() {
|
||||
export default function CreateDataPendidikan() {
|
||||
const stateDPM = useProxy(dataPendidikan);
|
||||
const [chartData, setChartData] = useState<any[]>([]);
|
||||
const router = useRouter()
|
||||
const router = useRouter();
|
||||
|
||||
const resetForm = () => {
|
||||
stateDPM.create.form = {
|
||||
name: "",
|
||||
jumlah: "",
|
||||
}
|
||||
}
|
||||
stateDPM.create.form = { name: '', jumlah: '' };
|
||||
};
|
||||
|
||||
const handleSubmit = async () => {
|
||||
const id = await stateDPM.create.create();
|
||||
if (id) {
|
||||
const idStr = String(id);
|
||||
await stateDPM.findUnique.load(idStr);
|
||||
if (stateDPM.findUnique.data) {
|
||||
setChartData([stateDPM.findUnique.data]);
|
||||
}
|
||||
if (stateDPM.findUnique.data) setChartData([stateDPM.findUnique.data]);
|
||||
}
|
||||
resetForm();
|
||||
router.push("/admin/pendidikan/data-pendidikan");
|
||||
}
|
||||
router.push('/admin/pendidikan/data-pendidikan');
|
||||
};
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<Box mb={10}>
|
||||
<Button variant="subtle" onClick={() => router.back()}>
|
||||
<IconArrowBack size={20} />
|
||||
</Button>
|
||||
</Box>
|
||||
<Box>
|
||||
<Paper w={{ base: '100%', md: '50%' }} bg={colors['white-1']} p={'md'}>
|
||||
<Title order={4}>Tambah Data Pendidikan</Title>
|
||||
<Stack gap={"xs"}>
|
||||
<TextInput
|
||||
label="Nama"
|
||||
type="text"
|
||||
value={stateDPM.create.form.name}
|
||||
placeholder="Masukkan nama"
|
||||
onChange={(val) => {
|
||||
stateDPM.create.form.name = val.currentTarget.value;
|
||||
<Box px={{ base: 'sm', md: 'xl' }} py="md">
|
||||
<Group mb="md" gap="sm">
|
||||
<Tooltip label="Kembali ke halaman sebelumnya" position="bottom" withArrow>
|
||||
<Button variant="subtle" onClick={() => router.back()} radius="md">
|
||||
<IconArrowBack size={20} stroke={2} />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
<Title order={3} c='black'>Tambah Data Pendidikan</Title>
|
||||
</Group>
|
||||
|
||||
<Paper
|
||||
withBorder
|
||||
w={{ base: '100%', md: '60%' }}
|
||||
p="lg"
|
||||
radius="md"
|
||||
shadow="xl"
|
||||
bg="white"
|
||||
>
|
||||
<Stack gap="md">
|
||||
<TextInput
|
||||
label="Nama Pendidikan"
|
||||
placeholder="Contoh: SD, SMP, SMA"
|
||||
value={stateDPM.create.form.name}
|
||||
onChange={(e) => (stateDPM.create.form.name = e.currentTarget.value)}
|
||||
radius="md"
|
||||
required
|
||||
/>
|
||||
<TextInput
|
||||
label="Jumlah Peserta"
|
||||
placeholder="Masukkan jumlah peserta"
|
||||
value={stateDPM.create.form.jumlah}
|
||||
onChange={(e) => (stateDPM.create.form.jumlah = e.currentTarget.value)}
|
||||
radius="md"
|
||||
type="number"
|
||||
required
|
||||
/>
|
||||
<Group justify="right" mt="sm">
|
||||
<Button
|
||||
onClick={handleSubmit}
|
||||
style={{
|
||||
background: `linear-gradient(135deg, ${colors['blue-button']}, ${colors['blue-button-trans']})`,
|
||||
color: 'white',
|
||||
boxShadow: '0 0 10px rgba(0,123,255,0.5)',
|
||||
'&:hover': { opacity: 0.9 },
|
||||
}}
|
||||
/>
|
||||
<TextInput
|
||||
label="Jumlah"
|
||||
type="number"
|
||||
value={stateDPM.create.form.jumlah}
|
||||
placeholder="Masukkan jumlah"
|
||||
onChange={(val) => {
|
||||
stateDPM.create.form.jumlah = val.currentTarget.value;
|
||||
}}
|
||||
/>
|
||||
<Group>
|
||||
<Button
|
||||
bg={colors['blue-button']}
|
||||
mt={10}
|
||||
onClick={handleSubmit}
|
||||
>
|
||||
Submit
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Paper>
|
||||
</Box>
|
||||
radius="md"
|
||||
size="md"
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Paper>
|
||||
|
||||
{chartData.length === 0 && (
|
||||
<Text mt="md" c={colors['white-1']} ta="center">
|
||||
Data belum tersedia. Silakan tambahkan data pendidikan baru.
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
export default CreateDataPendidikan;
|
||||
|
||||
Reference in New Issue
Block a user