Fix QC Kak Inno Admin, Fix QC Keano UI User, Fix QC Pak jun tabel apbdes

This commit is contained in:
2025-11-12 17:42:31 +08:00
parent 417a8937f5
commit 9622eb5a9a
354 changed files with 11444 additions and 4012 deletions

View File

@@ -5,6 +5,7 @@ import {
Box,
Button,
Group,
Loader,
Modal,
Paper,
Select,
@@ -26,6 +27,7 @@ function CreatePolsekTerdekat() {
const [layananOptions, setLayananOptions] = useState<{ value: string; label: string }[]>([]);
const [modalOpen, setModalOpen] = useState(false);
const [namaLayananBaru, setNamaLayananBaru] = useState("");
const [isSubmitting, setIsSubmitting] = useState(false);
const resetForm = () => {
polsekState.create.form = {
@@ -43,9 +45,17 @@ function CreatePolsekTerdekat() {
};
const handleSubmit = async () => {
await polsekState.create.create();
resetForm();
router.push("/admin/keamanan/polsek-terdekat");
try {
setIsSubmitting(true);
await polsekState.create.create();
resetForm();
router.push("/admin/keamanan/polsek-terdekat");
} catch (error) {
console.error(error)
toast.error("Gagal menambah polsek terdekat");
} finally {
setIsSubmitting(false);
}
};
const fetchLayanan = async () => {
@@ -112,7 +122,7 @@ function CreatePolsekTerdekat() {
<TextInput
label="Nama Layanan"
placeholder="Masukkan nama layanan"
defaultValue={namaLayananBaru}
value={namaLayananBaru}
onChange={(e) => setNamaLayananBaru(e.currentTarget.value)}
/>
<Button onClick={handleTambahLayanan}>Simpan</Button>
@@ -145,71 +155,84 @@ function CreatePolsekTerdekat() {
>
<Stack gap="md">
<TextInput
defaultValue={polsekState.create.form.nama}
value={polsekState.create.form.nama}
onChange={(val) => (polsekState.create.form.nama = val.target.value)}
label={<Text fw="bold" fz="sm">Nama Polsek Terdekat</Text>}
placeholder="Masukkan nama Polsek Terdekat"
required
/>
<TextInput
defaultValue={polsekState.create.form.jarakKeDesa}
value={polsekState.create.form.jarakKeDesa}
onChange={(val) => (polsekState.create.form.jarakKeDesa = val.target.value)}
label={<Text fw="bold" fz="sm">Jarak Polsek Terdekat</Text>}
placeholder="Masukkan jarak Polsek Terdekat"
required
/>
<TextInput
defaultValue={polsekState.create.form.alamat}
value={polsekState.create.form.alamat}
onChange={(val) => (polsekState.create.form.alamat = val.target.value)}
label={<Text fw="bold" fz="sm">Alamat Polsek Terdekat</Text>}
placeholder="Masukkan alamat Polsek Terdekat"
required
/>
<TextInput
defaultValue={polsekState.create.form.nomorTelepon}
value={polsekState.create.form.nomorTelepon}
onChange={(val) => (polsekState.create.form.nomorTelepon = val.target.value)}
label={<Text fw="bold" fz="sm">Nomor Telepon Polsek Terdekat</Text>}
placeholder="Masukkan nomor telepon Polsek Terdekat"
required
/>
<TextInput
defaultValue={polsekState.create.form.jamOperasional}
value={polsekState.create.form.jamOperasional}
onChange={(val) => (polsekState.create.form.jamOperasional = val.target.value)}
label={<Text fw="bold" fz="sm">Jam Operasional Polsek Terdekat</Text>}
placeholder="Masukkan jam operasional Polsek Terdekat"
/>
<TextInput
defaultValue={polsekState.create.form.embedMapUrl}
value={polsekState.create.form.embedMapUrl}
onChange={(val) => (polsekState.create.form.embedMapUrl = val.target.value)}
label={<Text fw="bold" fz="sm">Embed Map URL</Text>}
placeholder="Masukkan embed map url"
/>
<TextInput
defaultValue={polsekState.create.form.namaTempatMaps}
value={polsekState.create.form.namaTempatMaps}
onChange={(val) => (polsekState.create.form.namaTempatMaps = val.target.value)}
label={<Text fw="bold" fz="sm">Nama Tempat Maps</Text>}
placeholder="Masukkan nama tempat maps"
/>
<TextInput
defaultValue={polsekState.create.form.alamatMaps}
value={polsekState.create.form.alamatMaps}
onChange={(val) => (polsekState.create.form.alamatMaps = val.target.value)}
label={<Text fw="bold" fz="sm">Alamat Maps</Text>}
placeholder="Masukkan alamat maps"
/>
<TextInput
defaultValue={polsekState.create.form.linkPetunjukArah}
value={polsekState.create.form.linkPetunjukArah}
onChange={(val) => (polsekState.create.form.linkPetunjukArah = val.target.value)}
label={<Text fw="bold" fz="sm">Link Petunjuk Arah</Text>}
placeholder="Masukkan link petunjuk arah"
/>
{/* Dropdown Select */}
<Select
label={<Text fw="bold" fz="sm">Layanan Polsek</Text>}
label="Layanan Polsek"
placeholder="Pilih layanan polsek"
data={layananOptions}
value={polsekState.create.form.layananPolsekId}
onChange={(val) => (polsekState.create.form.layananPolsekId = val || "")}
value={polsekState.create.form.layananPolsekId || null}
onChange={(val: string | null) => {
if (val) {
const selected = layananOptions.find(
(item) => item.value === val
);
if (selected) {
polsekState.create.form.layananPolsekId = selected.value;
}
} else {
polsekState.create.form.layananPolsekId = '';
}
}}
searchable
clearable
nothingFoundMessage="Tidak ditemukan"
required
/>
<Button
variant="light"
@@ -221,6 +244,17 @@ function CreatePolsekTerdekat() {
{/* Tombol Submit */}
<Group justify="right">
<Button
variant="outline"
color="gray"
radius="md"
size="md"
onClick={resetForm}
>
Reset
</Button>
{/* Tombol Simpan */}
<Button
onClick={handleSubmit}
radius="md"
@@ -231,7 +265,7 @@ function CreatePolsekTerdekat() {
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
}}
>
Simpan
{isSubmitting ? <Loader size="sm" color="white" /> : 'Simpan'}
</Button>
</Group>
</Stack>