import AdminLayout from '@/Layouts/AdminLayout';
import { Head, useForm, usePage } from '@inertiajs/react';
import { Button } from "@/Components/ui/button"
import { Card, CardContent, CardHeader, CardTitle } from "@/Components/ui/card"
import { Input } from "@/Components/ui/input"
import { Label } from "@/Components/ui/label"
import { FormEventHandler } from 'react';
import { Switch } from "@/Components/ui/switch"
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/Components/ui/select"
import { Loader2 } from 'lucide-react';
import { PageProps } from '@/types';
import InputError from '@/Components/InputError';
export default function Create() {
const user = usePage<PageProps>().props.auth.user;
const { data, setData, post, processing, errors, reset } = useForm({
kabupaten_kota_id: '',
nama: '',
email: '',
role: 'admin',
password: '',
password_confirmation: '',
});
const submit: FormEventHandler = (e) => {
e.preventDefault();
post(route('admin.user.store'), {
onFinish: () => console.log("okoc"),
});
};
return (
<AdminLayout
user={user}
header={
<h2 className="text-xl font-semibold leading-tight text-gray-800">
Tambah User
</h2>
}
>
<Head title="Tambah User" />
<div className="flex items-center justify-between mb-2">
<h1 className="text-lg font-bold md:text-2xl">Tambah User</h1>
</div>
<Card className="max-w-2xl shadow-xl">
<CardHeader>
<CardTitle >
Tambah User
</CardTitle>
</CardHeader>
<CardContent >
<form onSubmit={submit} className="space-y-4">
<div className="space-y-2">
<Label htmlFor="email">Email*</Label>
<Input type='email' onChange={(e) => {
setData('email', e.target.value);
}} id="email" placeholder="[email protected]" required />
<InputError message={errors.email} className="mt-2" />
</div>
<div className="space-y-2">
<Label htmlFor="nama">Nama*</Label>
<Input onChange={(e) => {
setData('nama', e.target.value);
}} id="nama" placeholder="Nama User" required />
<InputError message={errors.nama} className="mt-2" />
</div>
<div className="space-y-2">
<Label htmlFor="role">Role*</Label>
<Select required={true} onValueChange={(e) => {
setData('role', e);
}}>
<SelectTrigger className="w-full">
<SelectValue placeholder="Pilih Role" />
</SelectTrigger>
<SelectContent>
<SelectItem value={"admin"}>Admin</SelectItem>
<SelectItem value={"operator"}>Operator</SelectItem>
</SelectContent>
</Select>
<InputError message={errors.role} className="mt-2" />
</div>
<div className='space-y-2'>
<Label htmlFor="password">Password*</Label>
<Input onChange={(e) => {
setData('password', e.target.value);
}} id="password" placeholder="Password" type="password" required />
<InputError message={errors.password} className="mt-2" />
</div>
<div className='space-y-2'>
<Label htmlFor="password_confirmation">Password Confirm*</Label>
<Input onChange={(e) => {
setData('password_confirmation', e.target.value);
}} id="password_confirmation" placeholder="password_confirmation" type="password" required />
</div>
<Button disabled={processing}>
{processing && <Loader2 className="animate-spin" />} Tambah
</Button>
</form>
</CardContent>
</Card>
</AdminLayout>
);
}
Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]