Fix QC Kak Inno Admin, Fix QC Keano UI User, Fix QC Pak jun tabel apbdes
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
Box,
|
||||
Button,
|
||||
Group,
|
||||
Loader,
|
||||
Paper,
|
||||
Stack,
|
||||
TextInput,
|
||||
@@ -12,7 +13,7 @@ import {
|
||||
} from '@mantine/core';
|
||||
import { IconArrowBack } from '@tabler/icons-react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useEffect } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { toast } from 'react-toastify';
|
||||
import { useProxy } from 'valtio/utils';
|
||||
import infoSekolahPaud from '../../../../_state/pendidikan/info-sekolah-paud';
|
||||
@@ -20,6 +21,7 @@ import infoSekolahPaud from '../../../../_state/pendidikan/info-sekolah-paud';
|
||||
function CreateJenjangPendidikan() {
|
||||
const router = useRouter();
|
||||
const stateJenjang = useProxy(infoSekolahPaud.jenjangPendidikan);
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
stateJenjang.findMany.load();
|
||||
@@ -32,13 +34,20 @@ function CreateJenjangPendidikan() {
|
||||
};
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (!stateJenjang.create.form.nama) {
|
||||
return toast.warn('Nama jenjang pendidikan tidak boleh kosong');
|
||||
}
|
||||
try {
|
||||
if (!stateJenjang.create.form.nama) {
|
||||
return toast.warn('Nama jenjang pendidikan tidak boleh kosong');
|
||||
}
|
||||
|
||||
await stateJenjang.create.create();
|
||||
resetForm();
|
||||
router.push('/admin/pendidikan/info-sekolah/jenjang-pendidikan');
|
||||
setIsSubmitting(true);
|
||||
await stateJenjang.create.create();
|
||||
resetForm();
|
||||
router.push('/admin/pendidikan/info-sekolah/jenjang-pendidikan');
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -71,12 +80,23 @@ function CreateJenjangPendidikan() {
|
||||
<TextInput
|
||||
label="Nama Jenjang Pendidikan"
|
||||
placeholder="Masukkan nama jenjang pendidikan"
|
||||
defaultValue={stateJenjang.create.form.nama || ''}
|
||||
value={stateJenjang.create.form.nama || ''}
|
||||
onChange={(e) => (stateJenjang.create.form.nama = e.target.value)}
|
||||
required
|
||||
/>
|
||||
|
||||
<Group justify="right">
|
||||
<Button
|
||||
variant="outline"
|
||||
color="gray"
|
||||
radius="md"
|
||||
size="md"
|
||||
onClick={resetForm}
|
||||
>
|
||||
Reset
|
||||
</Button>
|
||||
|
||||
{/* Tombol Simpan */}
|
||||
<Button
|
||||
onClick={handleSubmit}
|
||||
radius="md"
|
||||
@@ -87,7 +107,7 @@ function CreateJenjangPendidikan() {
|
||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||
}}
|
||||
>
|
||||
Simpan
|
||||
{isSubmitting ? <Loader size="sm" color="white" /> : 'Simpan'}
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
|
||||
Reference in New Issue
Block a user