- Integrated toast notifications to display error messages when form submissions fail across various components, enhancing user feedback and experience. - Updated components including DeleteUser, FormDialog, ManageTwoFactor, TwoFactorRecoveryCodes, TwoFactorSetupModal, PayrollPeriodShow, EmployeeCreate, EmployeeEdit, CuttingCreate, CuttingEdit, PurchaseCreate, PurchaseEdit, RestockCreate, RestockEdit, TransactionCreate, TransactionEdit, Category management, Product management, Raw Material management, Role management, Settings, and Authentication pages.
124 lines
5.4 KiB
TypeScript
124 lines
5.4 KiB
TypeScript
import { Form } from '@inertiajs/react';
|
|
import { useRef } from 'react';
|
|
import { toast } from 'sonner';
|
|
import ProfileController from '@/actions/App/Http/Controllers/Settings/ProfileController';
|
|
import Heading from '@/components/heading';
|
|
import InputError from '@/components/input-error';
|
|
import PasswordInput from '@/components/password-input';
|
|
import { Button } from '@/components/ui/button';
|
|
import {
|
|
Dialog,
|
|
DialogClose,
|
|
DialogContent,
|
|
DialogDescription,
|
|
DialogFooter,
|
|
DialogTitle,
|
|
DialogTrigger,
|
|
} from '@/components/ui/dialog';
|
|
import { Label } from '@/components/ui/label';
|
|
|
|
export default function DeleteUser() {
|
|
const passwordInput = useRef<HTMLInputElement>(null);
|
|
|
|
return (
|
|
<div className="space-y-6">
|
|
<Heading
|
|
variant="small"
|
|
title="Delete account"
|
|
description="Delete your account and all of its resources"
|
|
/>
|
|
<div className="space-y-4 rounded-lg border border-red-100 bg-red-50 p-4 dark:border-red-200/10 dark:bg-red-700/10">
|
|
<div className="relative space-y-0.5 text-red-600 dark:text-red-100">
|
|
<p className="font-medium">Warning</p>
|
|
<p className="text-sm">
|
|
Please proceed with caution, this cannot be undone.
|
|
</p>
|
|
</div>
|
|
|
|
<Dialog>
|
|
<DialogTrigger asChild>
|
|
<Button
|
|
variant="destructive"
|
|
data-test="delete-user-button"
|
|
>
|
|
Delete account
|
|
</Button>
|
|
</DialogTrigger>
|
|
<DialogContent>
|
|
<DialogTitle>
|
|
Are you sure you want to delete your account?
|
|
</DialogTitle>
|
|
<DialogDescription>
|
|
Once your account is deleted, all of its resources
|
|
and data will also be permanently deleted. Please
|
|
enter your password to confirm you would like to
|
|
permanently delete your account.
|
|
</DialogDescription>
|
|
|
|
<Form
|
|
{...ProfileController.destroy.form()}
|
|
options={{
|
|
preserveScroll: true,
|
|
}}
|
|
onError={() => {
|
|
toast.error('Terjadi kesalahan saat menyimpan data. Silakan periksa kembali input Anda.');
|
|
}}
|
|
resetOnSuccess
|
|
className="space-y-6"
|
|
>
|
|
{({ resetAndClearErrors, processing, errors }) => (
|
|
<>
|
|
<div className="grid gap-2">
|
|
<Label
|
|
htmlFor="password"
|
|
className="sr-only"
|
|
>
|
|
Password
|
|
</Label>
|
|
|
|
<PasswordInput
|
|
id="password"
|
|
name="password"
|
|
ref={passwordInput}
|
|
placeholder="Password"
|
|
autoComplete="current-password"
|
|
/>
|
|
|
|
<InputError message={errors.password} />
|
|
</div>
|
|
|
|
<DialogFooter className="gap-2">
|
|
<DialogClose asChild>
|
|
<Button
|
|
variant="secondary"
|
|
onClick={() =>
|
|
resetAndClearErrors()
|
|
}
|
|
>
|
|
Cancel
|
|
</Button>
|
|
</DialogClose>
|
|
|
|
<Button
|
|
variant="destructive"
|
|
disabled={processing}
|
|
asChild
|
|
>
|
|
<button
|
|
type="submit"
|
|
data-test="confirm-delete-user-button"
|
|
>
|
|
Delete account
|
|
</button>
|
|
</Button>
|
|
</DialogFooter>
|
|
</>
|
|
)}
|
|
</Form>
|
|
</DialogContent>
|
|
</Dialog>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|