83 lines
3.0 KiB
PHP
83 lines
3.0 KiB
PHP
<x-app-layout>
|
|
<x-slot name="header">
|
|
<h2 class="font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight">
|
|
{{ __('customer.Create new customer') }}
|
|
</h2>
|
|
</x-slot>
|
|
|
|
<div class="py-12" x-data="customerForm()">
|
|
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8 space-y-6">
|
|
<!-- Customer data -->
|
|
<div class="p-4 sm:p-8 bg-white dark:bg-gray-800 shadow sm:rounded-lg">
|
|
<div class="max-w-xl">
|
|
<section>
|
|
<header>
|
|
<h2 class="text-lg font-medium text-gray-900 dark:text-gray-100">
|
|
{{ __('customer.New customer') }}
|
|
</h2>
|
|
<p class="mt-1 text-sm text-gray-600 dark:text-gray-400">
|
|
{{ __("customer.Enter your customer's information and email address.") }}
|
|
</p>
|
|
</header>
|
|
|
|
<form class="mt-6 space-y-6" @submit.prevent="">
|
|
<p class="text-red-600 font-bold" x-text="message" x-show="error"></p>
|
|
|
|
<div>
|
|
<x-input-label for="name" :value="__('common.Name')"/>
|
|
<x-text-input id="name" name="name" type="text" class="mt-1 block w-full"
|
|
:value="old('name')" required autofocus autocomplete="name"
|
|
x-model="customer.name"/>
|
|
</div>
|
|
|
|
<div>
|
|
<x-input-label for="email" :value="__('common.Email')"/>
|
|
<x-text-input id="email" name="email" type="email" class="mt-1 block w-full"
|
|
:value="old('email')" required autocomplete="username"
|
|
x-model="customer.email"/>
|
|
</div>
|
|
|
|
<div class="flex items-center gap-4">
|
|
<x-primary-button @click="submit">{{ __('form.Save') }}</x-primary-button>
|
|
</div>
|
|
|
|
</form>
|
|
</section>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</x-app-layout>
|
|
|
|
<script>
|
|
function customerForm() {
|
|
return {
|
|
customer: {
|
|
name: '',
|
|
email: '',
|
|
},
|
|
|
|
error: false,
|
|
message: '',
|
|
|
|
submit() {
|
|
let vm = this;
|
|
|
|
axios.post('/customer', this.customer)
|
|
.then(function (response) {
|
|
window.location.href = '/customer/' + response.data.id + '/edit';
|
|
})
|
|
.catch(function (error) {
|
|
vm.error = true;
|
|
vm.message = error.response.data.message;
|
|
|
|
})
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|