| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- <script setup>
- import { ref } from 'vue'
- import { Inertia } from '@inertiajs/inertia'
- import { useForm, Head } from '@inertiajs/inertia-vue3'
- import AppInputText from '@/components/AppInputText.vue'
- import AppDropdown from '@/components/AppDropdown.vue'
- import AppButton from '@/components/AppButton.vue'
- import AppDialog from '@/components/AppDialog.vue'
- import AppLayout from '@/layouts/AppLayout.vue'
-
- const props = defineProps({
- user: Object,
- genders: Array,
- outlets: Array,
- roles: Array,
- })
-
- const form = useForm({
- name: props.user.name,
- phone: props.user.phone,
- email: props.user.email,
- address: props.user.address,
- gender_id: props.user.gender_id,
- outlet_id: props.user.outlet_id,
- role_id: props.user.role_id,
- })
-
- const submit = () => {
- form.put(route('users.update', props.user.id))
- }
-
- const visibleDialog = ref(false)
-
- const confirmDialog = () => {
- visibleDialog.value = true
- }
-
- const onAgree = (id) => Inertia.delete(route('users.destroy', id))
-
- const onCancel = () => (visibleDialog.value = false)
- </script>
-
- <template>
- <Head title="Ubah User" />
-
- <AppLayout>
- <div class="grid">
- <div class="col-12 lg:col-8">
- <Card>
- <template #content>
- <div class="grid">
- <div class="col-12 md:col-6">
- <AppInputText label="Nama" placeholder="nama" :error="form.errors.name" v-model="form.name" />
- </div>
-
- <div class="col-12 md:col-6">
- <AppInputText label="Nomor HP" placeholder="nomor hp" :error="form.errors.phone" v-model="form.phone" />
- </div>
-
- <div class="col-12 md:col-6">
- <AppInputText label="Email" placeholder="email" :error="form.errors.email" v-model="form.email" />
- </div>
-
- <div class="col-12 md:col-6">
- <AppInputText label="Alamat" placeholder="alamat" :error="form.errors.address" v-model="form.address" />
- </div>
-
- <div class="col-12 md:col-6">
- <AppDropdown
- label="Jenis Kelamin"
- placeholder="Pilih satu"
- v-model="form.gender_id"
- :options="genders"
- :error="form.errors.gender_id"
- />
- </div>
-
- <div class="col-12 md:col-6">
- <AppDropdown
- label="Hak Akses"
- placeholder="Pilih satu"
- v-model="form.role_id"
- :options="roles"
- :error="form.errors.role_id"
- />
- </div>
-
- <div class="col-12 md:col-6">
- <AppDropdown
- label="Outlet"
- placeholder="Pilih satu"
- v-model="form.outlet_id"
- :options="outlets"
- :error="form.errors.outlet_id"
- />
- </div>
- </div>
- </template>
-
- <template #footer>
- <div
- class="flex flex-column sm:flex-row align-items-center sm:justify-content-center sm:justify-content-between"
- >
- <AppDialog
- message="Yakin akan menghapus data ini?"
- v-model:visible="visibleDialog"
- @agree="onAgree(user.id)"
- @cancel="onCancel"
- />
-
- <Button label="Hapus" icon="pi pi-trash" class="p-button-text p-button-danger" @click="confirmDialog" />
-
- <div class="flex flex-column sm:flex-row align-items-center sm:justify-content-center">
- <AppButton
- label="Blokir"
- icon="pi pi-ban"
- :href="route('users.block', user.id)"
- method="delete"
- class="p-button-text p-button-danger md:mr-3"
- />
-
- <AppButton @click="submit" label="Simpan" icon="pi pi-check" />
- </div>
- </div>
- </template>
- </Card>
- </div>
- </div>
- </AppLayout>
- </template>
|