Edit.vue 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <script setup>
  2. import { Head, useForm } from '@inertiajs/inertia-vue3'
  3. import AppTextInput from '@/components/AppTextInput.vue'
  4. import AppSelectInput from '@/components/AppSelectInput.vue'
  5. import AppButtonCreate from '@/components/AppButtonCreate.vue'
  6. import AppButtonDelete from '@/components/AppButtonDelete.vue'
  7. import AppButtonAction from '@/components/AppButtonAction.vue'
  8. import AppModalAlert from '@/components/AppModalAlert.vue'
  9. import DefaultLayout from '@/layouts/DefaultLayout.vue'
  10. const props = defineProps({
  11. customer: Object,
  12. })
  13. const form = useForm({
  14. customer_number: props.customer.customer_number,
  15. name: props.customer.name,
  16. phone: props.customer.phone,
  17. address: props.customer.address,
  18. gender: props.customer.gender,
  19. })
  20. const submit = () => {
  21. form.put(route('customers.update', props.customer.id))
  22. }
  23. </script>
  24. <template>
  25. <Head title="Ubah Customer" />
  26. <DefaultLayout v-slot="{ toggleModalAlert }">
  27. <CRow>
  28. <CCol md="8">
  29. <CCard color="light" class="border-light">
  30. <CForm @submit.prevent="submit">
  31. <CRow class="p-4">
  32. <CCol md="6" class="mb-4">
  33. <CFormLabel>Id Customer</CFormLabel>
  34. <CFormInput disabled v-model="form.customer_number" />
  35. </CCol>
  36. <CCol md="6" class="mb-4">
  37. <AppTextInput label="Nama" placeholder="nama" :error="form.errors.name" v-model="form.name" />
  38. </CCol>
  39. <CCol md="6" class="mb-4">
  40. <AppTextInput label="Nomor HP" placeholder="nomor hp" :error="form.errors.phone" v-model="form.phone" />
  41. </CCol>
  42. <CCol md="6" class="mb-4">
  43. <AppTextInput
  44. label="Address"
  45. placeholder="address"
  46. :error="form.errors.address"
  47. v-model="form.address"
  48. />
  49. </CCol>
  50. <CCol md="6" class="mb-4">
  51. <AppSelectInput label="Jenis Kelamin" :error="form.errors.gender" v-model="form.gender">
  52. <option value="1">Perempuan</option>
  53. <option value="2">Laki-laki</option>
  54. </AppSelectInput>
  55. </CCol>
  56. </CRow>
  57. <CCardFooter class="d-flex justify-content-between align-items-center">
  58. <AppButtonAction @click="toggleModalAlert">Hapus Customer</AppButtonAction>
  59. <AppModalAlert>
  60. Anda yakin ingin mengahapus customer ini?
  61. <template #footer>
  62. <AppButtonDelete :href="route('customers.destroy', customer.id)">Hapus Customer</AppButtonDelete>
  63. </template>
  64. </AppModalAlert>
  65. <AppButtonCreate :disabled="form.processing">Ubah Customer</AppButtonCreate>
  66. </CCardFooter>
  67. </CForm>
  68. </CCard>
  69. </CCol>
  70. </CRow>
  71. </DefaultLayout>
  72. </template>