first commit
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
<script setup lang="ts">
|
||||
import { useForm } from '@inertiajs/vue3';
|
||||
import LoginDetailsForm from '@/components/users/LoginDetailsForm.vue';
|
||||
import UserDetailsForm from '@/components/users/UserDetailsForm.vue';
|
||||
import Button from '@/components/ui/Button.vue';
|
||||
import type { SelectOption } from '@/components/ui/Select.vue';
|
||||
import { useTranslations } from '@/composables/useVanguard';
|
||||
import AppLayout from '@/layouts/AppLayout.vue';
|
||||
import type { LoginDetailsFormData, UserDetailsFormData } from '@/types';
|
||||
|
||||
const props = defineProps<{
|
||||
roles: SelectOption[];
|
||||
statuses: SelectOption[];
|
||||
countries: SelectOption[];
|
||||
defaultRoleId: number | null;
|
||||
}>();
|
||||
|
||||
const { __ } = useTranslations();
|
||||
|
||||
const form = useForm<UserDetailsFormData & LoginDetailsFormData>({
|
||||
role_id: props.defaultRoleId ?? props.roles[0]?.value ?? '',
|
||||
status: props.statuses[0]?.value ?? '',
|
||||
first_name: '',
|
||||
last_name: '',
|
||||
birthday: '',
|
||||
phone: '',
|
||||
address: '',
|
||||
country_id: 0,
|
||||
email: '',
|
||||
username: '',
|
||||
password: '',
|
||||
password_confirmation: '',
|
||||
});
|
||||
|
||||
function submit(): void {
|
||||
form.post(route('users.store'));
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AppLayout
|
||||
:title="__('Add User')"
|
||||
:heading="__('Create New User')"
|
||||
:breadcrumbs="[{ label: __('Users'), href: route('users.index') }, { label: __('Create') }]"
|
||||
>
|
||||
<form class="space-y-4" @submit.prevent="submit">
|
||||
<div class="rounded-lg border border-slate-200 bg-white p-6 shadow-sm">
|
||||
<div class="grid grid-cols-1 gap-6 md:grid-cols-4">
|
||||
<div>
|
||||
<h5 class="font-medium text-slate-800">{{ __('User Details') }}</h5>
|
||||
<p class="font-light text-slate-500">
|
||||
{{ __('A general user profile information.') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="md:col-span-3">
|
||||
<UserDetailsForm
|
||||
v-model="form"
|
||||
:roles="roles"
|
||||
:statuses="statuses"
|
||||
:countries="countries"
|
||||
:errors="form.errors"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="rounded-lg border border-slate-200 bg-white p-6 shadow-sm">
|
||||
<div class="grid grid-cols-1 gap-6 md:grid-cols-4">
|
||||
<div>
|
||||
<h5 class="font-medium text-slate-800">{{ __('Login Details') }}</h5>
|
||||
<p class="font-light text-slate-500">
|
||||
{{ __('Details used for authenticating with the application.') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="md:col-span-3">
|
||||
<LoginDetailsForm v-model="form" :errors="form.errors" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Button type="submit" :label="__('Create User')" :loading="form.processing" />
|
||||
</form>
|
||||
</AppLayout>
|
||||
</template>
|
||||
Reference in New Issue
Block a user