QC Admin - User Menu Ekonomi : Jumlah Pengangguran
This commit is contained in:
@@ -1,101 +1,142 @@
|
||||
'use client'
|
||||
'use client';
|
||||
import colors from '@/con/colors';
|
||||
import { Box, Button, Group, Paper, Select, Stack, Text, TextInput, Title } from '@mantine/core';
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Group,
|
||||
Paper,
|
||||
Select,
|
||||
Stack,
|
||||
Text,
|
||||
TextInput,
|
||||
Title,
|
||||
Tooltip,
|
||||
} from '@mantine/core';
|
||||
import { DateTimePicker } from '@mantine/dates';
|
||||
import { IconArrowBack } from '@tabler/icons-react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useProxy } from 'valtio/utils';
|
||||
import CreateEditor from '../../../_com/createEditor';
|
||||
import laporanPublikState from '../../../_state/keamanan/laporan-publik';
|
||||
export type Status = "Selesai" | "Proses" | "Gagal";
|
||||
|
||||
export type Status = 'Selesai' | 'Proses' | 'Gagal';
|
||||
|
||||
function CreateLaporanPublik() {
|
||||
const stateLaporan = useProxy(laporanPublikState)
|
||||
const stateLaporan = useProxy(laporanPublikState);
|
||||
const router = useRouter();
|
||||
|
||||
const resetForm = () => {
|
||||
stateLaporan.create.form = {
|
||||
judul: "",
|
||||
lokasi: "",
|
||||
tanggalWaktu: "",
|
||||
status: "Proses" as Status,
|
||||
penanganan: "",
|
||||
kronologi: "",
|
||||
}
|
||||
}
|
||||
judul: '',
|
||||
lokasi: '',
|
||||
tanggalWaktu: '',
|
||||
status: 'Proses' as Status,
|
||||
penanganan: '',
|
||||
kronologi: '',
|
||||
};
|
||||
};
|
||||
|
||||
const handleSubmit = async () => {
|
||||
await stateLaporan.create.create();
|
||||
resetForm();
|
||||
router.push('/admin/keamanan/laporan-publik');
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<Box mb={10}>
|
||||
<Button onClick={() => router.back()} variant='subtle' color={'blue'}>
|
||||
<IconArrowBack color={colors['blue-button']} size={25} />
|
||||
</Button>
|
||||
</Box>
|
||||
<Box px={{ base: 'sm', md: 'lg' }} py="md">
|
||||
{/* Header with Back Button */}
|
||||
<Group mb="md">
|
||||
<Tooltip label="Kembali ke halaman sebelumnya" withArrow>
|
||||
<Button variant="subtle" onClick={() => router.back()} p="xs" radius="md">
|
||||
<IconArrowBack color={colors['blue-button']} size={24} />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
<Title order={4} ml="sm" c="dark">
|
||||
Tambah Laporan Publik
|
||||
</Title>
|
||||
</Group>
|
||||
|
||||
<Paper w={{ base: '100%', md: '50%' }} bg={colors['white-1']} p={'md'}>
|
||||
<Stack gap={"xs"}>
|
||||
<Title order={4}>Create Laporan Publik</Title>
|
||||
{/* Form Card */}
|
||||
<Paper
|
||||
w={{ base: '100%', md: '50%' }}
|
||||
bg={colors['white-1']}
|
||||
p="lg"
|
||||
radius="md"
|
||||
shadow="sm"
|
||||
style={{ border: '1px solid #e0e0e0' }}
|
||||
>
|
||||
<Stack gap="md">
|
||||
<TextInput
|
||||
value={stateLaporan.create.form.judul}
|
||||
onChange={(e) => stateLaporan.create.form.judul = e.target.value}
|
||||
label={<Text fw={"bold"} fz={"sm"}>Judul Laporan Publik</Text>}
|
||||
placeholder='Masukkan judul LaporanPublik'
|
||||
onChange={(e) => (stateLaporan.create.form.judul = e.target.value)}
|
||||
label={<Text fw="bold" fz="sm">Judul Laporan Publik</Text>}
|
||||
placeholder="Masukkan judul laporan publik"
|
||||
required
|
||||
/>
|
||||
|
||||
<TextInput
|
||||
value={stateLaporan.create.form.lokasi}
|
||||
onChange={(e) => stateLaporan.create.form.lokasi = e.target.value}
|
||||
label={<Text fw={"bold"} fz={"sm"}>Lokasi Laporan Publik</Text>}
|
||||
placeholder='Masukkan lokasi LaporanPublik'
|
||||
onChange={(e) => (stateLaporan.create.form.lokasi = e.target.value)}
|
||||
label={<Text fw="bold" fz="sm">Lokasi Laporan Publik</Text>}
|
||||
placeholder="Masukkan lokasi laporan publik"
|
||||
required
|
||||
/>
|
||||
|
||||
<DateTimePicker
|
||||
label="Tanggal Laporan Publik"
|
||||
label={<Text fw="bold" fz="sm">Tanggal Laporan Publik</Text>}
|
||||
value={
|
||||
stateLaporan.create.form.tanggalWaktu
|
||||
? new Date(stateLaporan.create.form.tanggalWaktu)
|
||||
: null
|
||||
}
|
||||
onChange={(val) => {
|
||||
if (val) {
|
||||
stateLaporan.create.form.tanggalWaktu = val.toString();
|
||||
} else {
|
||||
stateLaporan.create.form.tanggalWaktu = ""; // Reset kalau dikosongkan
|
||||
}
|
||||
stateLaporan.create.form.tanggalWaktu = val ? val.toString() : '';
|
||||
}}
|
||||
/>
|
||||
|
||||
<Select
|
||||
value={stateLaporan.create.form.status}
|
||||
onChange={(e) => stateLaporan.create.form.status = e?.valueOf() as Status}
|
||||
label={<Text fw={"bold"} fz={"sm"}>Status Laporan Publik</Text>}
|
||||
placeholder='Masukkan status LaporanPublik'
|
||||
onChange={(e) => (stateLaporan.create.form.status = e?.valueOf() as Status)}
|
||||
label={<Text fw="bold" fz="sm">Status Laporan Publik</Text>}
|
||||
placeholder="Pilih status laporan publik"
|
||||
data={[
|
||||
{ value: "Selesai", label: "Selesai" },
|
||||
{ value: "Proses", label: "Proses" },
|
||||
{ value: "Gagal", label: "Gagal" },
|
||||
{ value: 'Selesai', label: 'Selesai' },
|
||||
{ value: 'Proses', label: 'Proses' },
|
||||
{ value: 'Gagal', label: 'Gagal' },
|
||||
]}
|
||||
/>
|
||||
|
||||
<TextInput
|
||||
value={stateLaporan.create.form.kronologi}
|
||||
onChange={(e) => stateLaporan.create.form.kronologi = e.target.value}
|
||||
label={<Text fw={"bold"} fz={"sm"}>Kronologi Laporan Publik</Text>}
|
||||
placeholder='Masukkan kronologi LaporanPublik'
|
||||
onChange={(e) => (stateLaporan.create.form.kronologi = e.target.value)}
|
||||
label={<Text fw="bold" fz="sm">Kronologi Laporan Publik</Text>}
|
||||
placeholder="Masukkan kronologi laporan publik"
|
||||
required
|
||||
/>
|
||||
<Text fw={"bold"} fz={"sm"}>Penanganan Laporan Publik</Text>
|
||||
|
||||
<Box>
|
||||
<Text fw={"bold"} fz={"sm"}>Deskripsi Laporan Publik</Text>
|
||||
<Text fw="bold" fz="sm" mb={6}>
|
||||
Penanganan Laporan Publik
|
||||
</Text>
|
||||
<CreateEditor
|
||||
value={stateLaporan.create.form.penanganan}
|
||||
onChange={(e) => stateLaporan.create.form.penanganan = e}
|
||||
onChange={(e) => (stateLaporan.create.form.penanganan = e)}
|
||||
/>
|
||||
</Box>
|
||||
<Group>
|
||||
<Button onClick={handleSubmit} bg={colors['blue-button']}>Submit</Button>
|
||||
|
||||
<Group justify="right">
|
||||
<Button
|
||||
onClick={handleSubmit}
|
||||
radius="md"
|
||||
size="md"
|
||||
style={{
|
||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||
color: '#fff',
|
||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||
}}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Paper>
|
||||
|
||||
Reference in New Issue
Block a user