%PDF- %PDF-
Direktori : /home/forge/takeaseat.eco-n-tech.co.uk/components/blocks/Account/settings/ |
Current File : //home/forge/takeaseat.eco-n-tech.co.uk/components/blocks/Account/settings/AccountBusiness.vue |
<template> <Block title="Business Details"> <ValidationObserver ref="form"> <form @submit.prevent="saveDetails" role="form" method="POST"> <div class="relative mb-4"> <label for="business_type" class="form-label">Business Type</label> <select class="form-select" v-model="business_type" name="business_type" id="business_type"> <option option="Sole Trader">Sole Trader</option> <option option="Limited Business">Limited Business</option> </select> </div> <div class="relative mb-4"> <label for="same_as_personal_address" class="form-label">Business Address</label> <label class="flex items-center px-3"> <t-checkbox v-model="is_personal_same" name="same_as_personal_address" checked /> <span class="block pl-2.5">Same as personal address</span> </label> <template v-if="is_personal_same == false"> <div class="relative mb-4 mt-6"> <label for="business_address" class="form-label">Address</label> <ValidationProvider rules="required" v-slot="{ errors }"> <input class="form-control" v-model="address.address" type="text" id="business_address" name="address" /> <span class="field-invalid" v-if="errors[0]">{{ errors[0] }}</span> </ValidationProvider> </div> <div class="relative mb-4"> <label for="business_town" class="form-label">Town/City</label> <ValidationProvider rules="required" v-slot="{ errors }"> <input class="form-control" v-model="address.town_city" type="text" id="business_town" name="town" /> <span class="field-invalid" v-if="errors[0]">{{ errors[0] }}</span> </ValidationProvider> </div> <div class="relative mb-4"> <label for="business_postcode" class="form-label">Postcode</label> <ValidationProvider rules="required" v-slot="{ errors }"> <input class="form-control" v-model="address.postcode" type="text" id="business_postcode" name="Postcode" /> <span class="field-invalid" v-if="errors[0]">{{ errors[0] }}</span> </ValidationProvider> </div> </template> </div> <div class="flex items-center justify-center"> <button class="btn btn-small btn-primary rounded-full" type="submit"> <span v-if="working == false">Save Changes</span> <span class="flex items-center justify-center" v-else> <svg class="animate-spin -ml-1 mr-3 h-5 w-5 text-current" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"> <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle> <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path> </svg> <span>Saving</span> </span> </button> </div> </form> </ValidationObserver> </Block> </template> <script> export default { data() { return { working: false, business_type: 'Sole Trader', is_personal_same: true, address: { address: '', town_city: '', postcode: '' } } }, async mounted() { await this.$axios.$get('/account/details/business').then((response) => { this.business_type = response.business_type; this.is_personal_same = response.is_personal_same; if(response.address !== null) { this.address = response.address; } }) }, methods: { async saveDetails() { this.$refs.form.validate().then(success => { if (!success) { return; } this.working = true; this.$axios.$post('/account/details/business', { business_type: this.business_type, is_personal_same: this.is_personal_same, address: this.address }).then(() => { this.working = false; this.$store.dispatch('account/progress/get', { slug: 'settings' }) this.$toast.success('Successfully updated your business settings').goAway(3000); }).catch(error => { this.working = false; this.$refs.form.setErrors(error.response.data.errors); }) }) } } } </script>