2023-03-17 15:13:37 +00:00
|
|
|
<script setup lang="ts">
|
|
|
|
import { Head, useForm, router } from '@inertiajs/vue3';
|
2023-03-03 15:54:28 +00:00
|
|
|
import { mdiAccountKey, mdiArrowLeftBoldOutline } from '@mdi/js';
|
|
|
|
import LayoutAuthenticated from '@/Layouts/LayoutAuthenticated.vue';
|
|
|
|
import SectionMain from '@/Components/SectionMain.vue';
|
|
|
|
import SectionTitleLineWithButton from '@/Components/SectionTitleLineWithButton.vue';
|
|
|
|
import CardBox from '@/Components/CardBox.vue';
|
|
|
|
import FormField from '@/Components/FormField.vue';
|
|
|
|
import FormControl from '@/Components/FormControl.vue';
|
|
|
|
import FormCheckRadioGroup from '@/Components/FormCheckRadioGroup.vue';
|
|
|
|
import BaseDivider from '@/Components/BaseDivider.vue';
|
|
|
|
import BaseButton from '@/Components/BaseButton.vue';
|
|
|
|
import BaseButtons from '@/Components/BaseButtons.vue';
|
|
|
|
import { stardust } from '@eidellev/adonis-stardust/client';
|
|
|
|
// import { Inertia } from '@inertiajs/inertia';
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
|
|
roles: {
|
|
|
|
type: Object,
|
|
|
|
default: () => ({}),
|
|
|
|
},
|
|
|
|
errors: {
|
|
|
|
type: Object,
|
|
|
|
default: () => ({}),
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
const form = useForm({
|
|
|
|
login: '',
|
|
|
|
email: '',
|
|
|
|
password: '',
|
|
|
|
password_confirmation: '',
|
|
|
|
roles: [],
|
|
|
|
});
|
|
|
|
|
|
|
|
const submit = async () => {
|
2023-12-15 16:17:33 +00:00
|
|
|
await router.post(stardust.route('settings.user.store'), form);
|
2023-03-03 15:54:28 +00:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<LayoutAuthenticated>
|
|
|
|
<Head title="Add user" />
|
|
|
|
<SectionMain>
|
|
|
|
<SectionTitleLineWithButton :icon="mdiAccountKey" title="Add user" main>
|
2023-10-31 14:38:43 +00:00
|
|
|
<BaseButton
|
2023-12-15 16:17:33 +00:00
|
|
|
:route-name="stardust.route('settings.user.index')"
|
2023-10-31 14:38:43 +00:00
|
|
|
:icon="mdiArrowLeftBoldOutline"
|
|
|
|
label="Back"
|
|
|
|
color="modern"
|
|
|
|
rounded-full
|
|
|
|
small
|
|
|
|
/>
|
2023-03-03 15:54:28 +00:00
|
|
|
</SectionTitleLineWithButton>
|
2023-12-15 16:17:33 +00:00
|
|
|
<!-- @submit.prevent="form.post(stardust.route('settings.user.store'))" -->
|
2023-03-03 15:54:28 +00:00
|
|
|
<CardBox form @submit.prevent="submit()">
|
2023-03-17 15:13:37 +00:00
|
|
|
<FormField label="Login" :class="{ 'text-red-400': errors.login }">
|
2023-03-03 15:54:28 +00:00
|
|
|
<FormControl v-model="form.login" type="text" placeholder="Enter Login" :errors="errors.login">
|
|
|
|
<div class="text-red-400 text-sm" v-if="errors.login && Array.isArray(errors.login)">
|
|
|
|
<!-- {{ errors.login }} -->
|
|
|
|
{{ errors.login.join(', ') }}
|
|
|
|
</div>
|
|
|
|
</FormControl>
|
|
|
|
</FormField>
|
|
|
|
|
|
|
|
<FormField label="Email" :class="{ 'text-red-400': errors.email }">
|
|
|
|
<FormControl v-model="form.email" type="text" placeholder="Enter Email" :errors="errors.email">
|
|
|
|
<div class="text-red-400 text-sm" v-if="errors.email && Array.isArray(errors.email)">
|
|
|
|
<!-- {{ errors.email }} -->
|
|
|
|
{{ errors.email.join(', ') }}
|
|
|
|
</div>
|
|
|
|
</FormControl>
|
|
|
|
</FormField>
|
|
|
|
|
|
|
|
<FormField label="Password" :class="{ 'text-red-400': errors.password }">
|
2023-10-31 14:38:43 +00:00
|
|
|
<FormControl v-model="form.password" type="password" placeholder="Enter Password" :errors="errors.password">
|
2023-03-03 15:54:28 +00:00
|
|
|
<div class="text-red-400 text-sm" v-if="errors.password && Array.isArray(errors.password)">
|
|
|
|
<!-- {{ errors.password }} -->
|
|
|
|
{{ errors.password.join(', ') }}
|
|
|
|
</div>
|
|
|
|
</FormControl>
|
|
|
|
</FormField>
|
|
|
|
|
|
|
|
<FormField label="Password Confirmation" :class="{ 'text-red-400': errors.password_confirmation }">
|
2023-10-31 14:38:43 +00:00
|
|
|
<FormControl
|
|
|
|
v-model="form.password_confirmation"
|
|
|
|
type="password"
|
|
|
|
placeholder="Enter Password Confirmation"
|
|
|
|
:errors="errors.password"
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
class="text-red-400 text-sm"
|
|
|
|
v-if="errors.password_confirmation && Array.isArray(errors.password_confirmation)"
|
|
|
|
>
|
2023-03-03 15:54:28 +00:00
|
|
|
<!-- {{ errors.password_confirmation }} -->
|
|
|
|
{{ errors.password_confirmation.join(', ') }}
|
|
|
|
</div>
|
|
|
|
</FormControl>
|
|
|
|
</FormField>
|
|
|
|
|
|
|
|
<BaseDivider />
|
|
|
|
|
|
|
|
<FormField label="Roles" wrap-body :class="{ 'text-red-400': errors.roles }">
|
|
|
|
<FormCheckRadioGroup v-model="form.roles" name="roles" is-column :options="props.roles" />
|
|
|
|
</FormField>
|
|
|
|
<div class="text-red-400 text-sm" v-if="errors.roles && Array.isArray(errors.roles)">
|
|
|
|
<!-- {{ errors.password_confirmation }} -->
|
|
|
|
{{ errors.roles.join(', ') }}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<template #footer>
|
|
|
|
<BaseButtons>
|
2023-10-31 14:38:43 +00:00
|
|
|
<BaseButton
|
|
|
|
type="submit"
|
|
|
|
color="info"
|
|
|
|
label="Submit"
|
|
|
|
:class="{ 'opacity-25': form.processing }"
|
|
|
|
:disabled="form.processing"
|
|
|
|
/>
|
2023-03-03 15:54:28 +00:00
|
|
|
</BaseButtons>
|
|
|
|
</template>
|
|
|
|
</CardBox>
|
|
|
|
</SectionMain>
|
|
|
|
</LayoutAuthenticated>
|
|
|
|
</template>
|