121 lines
5.0 KiB
Vue
121 lines
5.0 KiB
Vue
<script setup lang="ts">
|
|
import { Form } from '@inertiajs/vue3';
|
|
import { useTemplateRef } from 'vue';
|
|
import ProfileController from '@/actions/App/Http/Controllers/Settings/ProfileController';
|
|
import InputError from '@/components/InputError.vue';
|
|
import PasswordInput from '@/components/PasswordInput.vue';
|
|
import { Button } from '@/components/ui/button';
|
|
import { Card, CardContent, CardHeader } from '@/components/ui/card';
|
|
import {
|
|
Dialog,
|
|
DialogClose,
|
|
DialogContent,
|
|
DialogDescription,
|
|
DialogFooter,
|
|
DialogHeader,
|
|
DialogTitle,
|
|
DialogTrigger,
|
|
} from '@/components/ui/dialog';
|
|
import { Label } from '@/components/ui/label';
|
|
import { useLocalization } from '@/composables/useLocalization';
|
|
|
|
const passwordInput = useTemplateRef('passwordInput');
|
|
const { t } = useLocalization();
|
|
</script>
|
|
|
|
<template>
|
|
<Card
|
|
class="border-destructive/35 gap-0 overflow-hidden rounded-xl py-0 shadow-none"
|
|
>
|
|
<CardHeader class="gap-stack border-b p-5 sm:p-6">
|
|
<h2 class="text-title">{{ t('profile.delete.title') }}</h2>
|
|
<p class="text-muted-foreground">
|
|
{{ t('profile.delete.description') }}
|
|
</p>
|
|
</CardHeader>
|
|
<CardContent class="p-5 sm:p-6">
|
|
<div
|
|
class="bg-destructive/8 border-destructive/25 gap-column grid rounded-lg border p-4"
|
|
>
|
|
<div class="gap-stack grid">
|
|
<p class="text-destructive font-semibold">
|
|
{{ t('profile.delete.warning') }}
|
|
</p>
|
|
<p class="text-body text-muted-foreground">
|
|
{{ t('profile.delete.warningDescription') }}
|
|
</p>
|
|
</div>
|
|
<Dialog>
|
|
<DialogTrigger as-child>
|
|
<Button
|
|
variant="destructive"
|
|
class="justify-self-start"
|
|
data-test="delete-user-button"
|
|
>{{ t('profile.delete.action') }}</Button
|
|
>
|
|
</DialogTrigger>
|
|
<DialogContent>
|
|
<Form
|
|
v-bind="ProfileController.destroy.form()"
|
|
reset-on-success
|
|
@error="() => passwordInput?.focus()"
|
|
:options="{
|
|
preserveScroll: true,
|
|
}"
|
|
class="space-y-6"
|
|
v-slot="{ errors, processing, reset, clearErrors }"
|
|
>
|
|
<DialogHeader class="space-y-3">
|
|
<DialogTitle>{{
|
|
t('profile.delete.confirmTitle')
|
|
}}</DialogTitle>
|
|
<DialogDescription>
|
|
{{ t('profile.delete.confirmDescription') }}
|
|
</DialogDescription>
|
|
</DialogHeader>
|
|
|
|
<div class="grid gap-2">
|
|
<Label for="password" class="sr-only">{{
|
|
t('profile.delete.password')
|
|
}}</Label>
|
|
<PasswordInput
|
|
id="password"
|
|
name="password"
|
|
ref="passwordInput"
|
|
:placeholder="t('profile.delete.password')"
|
|
/>
|
|
<InputError :message="errors.password" />
|
|
</div>
|
|
|
|
<DialogFooter class="gap-2">
|
|
<DialogClose as-child>
|
|
<Button
|
|
variant="secondary"
|
|
@click="
|
|
() => {
|
|
clearErrors();
|
|
reset();
|
|
}
|
|
"
|
|
>
|
|
{{ t('common.cancel') }}
|
|
</Button>
|
|
</DialogClose>
|
|
|
|
<Button
|
|
type="submit"
|
|
variant="destructive"
|
|
:disabled="processing"
|
|
data-test="confirm-delete-user-button"
|
|
>
|
|
{{ t('profile.delete.confirmAction') }}
|
|
</Button>
|
|
</DialogFooter>
|
|
</Form>
|
|
</DialogContent>
|
|
</Dialog>
|
|
</div>
|
|
</CardContent>
|
|
</Card>
|
|
</template>
|