|
| 1 | +<template> |
| 2 | + <div> |
| 3 | + <h1 class="mb-8 font-bold text-3xl"> |
| 4 | + <inertia-link class="text-indigo-400 hover:text-indigo-600" :href="route('demo:contacts')">Contacts</inertia-link> |
| 5 | + <span class="text-indigo-400 font-medium">/</span> Create |
| 6 | + </h1> |
| 7 | + <div class="bg-white rounded shadow overflow-hidden max-w-3xl"> |
| 8 | + <form @submit.prevent="submit"> |
| 9 | + <div class="p-8 -mr-6 -mb-8 flex flex-wrap"> |
| 10 | + <text-input v-model="form.first_name" :errors="$page.errors.first_name" class="pr-6 pb-8 w-full lg:w-1/2" label="First name" /> |
| 11 | + <text-input v-model="form.last_name" :errors="$page.errors.last_name" class="pr-6 pb-8 w-full lg:w-1/2" label="Last name" /> |
| 12 | + <select-input v-model="form.organization_id" :errors="$page.errors.organization_id" class="pr-6 pb-8 w-full lg:w-1/2" label="Organization"> |
| 13 | + <option :value="null" /> |
| 14 | + <option v-for="organization in organizations" :key="organization.id" :value="organization.id">{{ organization.name }}</option> |
| 15 | + </select-input> |
| 16 | + <text-input v-model="form.email" :errors="$page.errors.email" class="pr-6 pb-8 w-full lg:w-1/2" label="Email" /> |
| 17 | + <text-input v-model="form.phone" :errors="$page.errors.phone" class="pr-6 pb-8 w-full lg:w-1/2" label="Phone" /> |
| 18 | + <text-input v-model="form.address" :errors="$page.errors.address" class="pr-6 pb-8 w-full lg:w-1/2" label="Address" /> |
| 19 | + <text-input v-model="form.city" :errors="$page.errors.city" class="pr-6 pb-8 w-full lg:w-1/2" label="City" /> |
| 20 | + <text-input v-model="form.region" :errors="$page.errors.region" class="pr-6 pb-8 w-full lg:w-1/2" label="Province/State" /> |
| 21 | + <select-input v-model="form.country" :errors="$page.errors.country" class="pr-6 pb-8 w-full lg:w-1/2" label="Country"> |
| 22 | + <option :value="null" /> |
| 23 | + <option value="CA">Canada</option> |
| 24 | + <option value="US">United States</option> |
| 25 | + </select-input> |
| 26 | + <text-input v-model="form.postal_code" :errors="$page.errors.postal_code" class="pr-6 pb-8 w-full lg:w-1/2" label="Postal code" /> |
| 27 | + </div> |
| 28 | + <div class="px-8 py-4 bg-gray-100 border-t border-gray-200 flex justify-end items-center"> |
| 29 | + <loading-button :loading="sending" class="btn-indigo" type="submit">Create Contact</loading-button> |
| 30 | + </div> |
| 31 | + </form> |
| 32 | + </div> |
| 33 | + </div> |
| 34 | +</template> |
| 35 | + |
| 36 | +<script> |
| 37 | +import Layout from '../Shared/Layout' |
| 38 | +import LoadingButton from '../Shared/LoadingButton' |
| 39 | +import SelectInput from '../Shared/SelectInput' |
| 40 | +import TextInput from '../Shared/TextInput' |
| 41 | +
|
| 42 | +export default { |
| 43 | + metaInfo: { title: 'Create Contact' }, |
| 44 | + layout: Layout, |
| 45 | + components: { |
| 46 | + LoadingButton, |
| 47 | + SelectInput, |
| 48 | + TextInput, |
| 49 | + }, |
| 50 | + props: { |
| 51 | + organizations: Array, |
| 52 | + }, |
| 53 | + remember: 'form', |
| 54 | + data() { |
| 55 | + return { |
| 56 | + sending: false, |
| 57 | + form: { |
| 58 | + first_name: null, |
| 59 | + last_name: null, |
| 60 | + organization_id: null, |
| 61 | + email: null, |
| 62 | + phone: null, |
| 63 | + address: null, |
| 64 | + city: null, |
| 65 | + region: null, |
| 66 | + country: null, |
| 67 | + postal_code: null, |
| 68 | + }, |
| 69 | + } |
| 70 | + }, |
| 71 | + methods: { |
| 72 | + submit() { |
| 73 | + this.sending = true |
| 74 | + this.$inertia.post(this.route('demo:contacts.create'), this.form) |
| 75 | + .then(() => this.sending = false) |
| 76 | + }, |
| 77 | + }, |
| 78 | +} |
| 79 | +</script> |
0 commit comments