first commit
This commit is contained in:
328
src/pages/customer/create.vue
Normal file
328
src/pages/customer/create.vue
Normal file
@@ -0,0 +1,328 @@
|
||||
<template>
|
||||
<Header/>
|
||||
<div v-if="user">
|
||||
<div class="flex">
|
||||
<div class="">
|
||||
<SideBar/>
|
||||
</div>
|
||||
<div class="w-full px-10">
|
||||
<div class="text-sm breadcrumbs">
|
||||
<ul>
|
||||
<li>
|
||||
<router-link :to="{ name: 'home' }">
|
||||
Home
|
||||
</router-link>
|
||||
</li>
|
||||
<li>
|
||||
<router-link :to="{ name: 'customer' }">
|
||||
Customers
|
||||
</router-link>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 rounded-md p-6 ">
|
||||
<div class="text-[24px]">Create a customer</div>
|
||||
<form class="rounded-md px-8 pt-6 pb-8 mb-4 w-full" enctype="multipart/form-data" @submit.prevent="onSubmit">
|
||||
<div class="text-[18px] mt-5 mb-5">General Info</div>
|
||||
<div class="mb-4">
|
||||
<label class="block text-white text-sm font-bold mb-2"> First Name</label>
|
||||
<input v-model="CreateCustomerForm.basicInfo.customer_first_name"
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
id="title" type="text" placeholder="First Name"/>
|
||||
<span v-if="v$.CreateCustomerForm.basicInfo.customer_first_name.$error" class="text-red-600 text-center">
|
||||
{{ v$.CreateCustomerForm.basicInfo.customer_first_name.$errors[0].$message }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label class="block text-white text-sm font-bold mb-2"> Last Name</label>
|
||||
<input v-model="CreateCustomerForm.basicInfo.customer_last_name"
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
id="title" type="text" placeholder="Last Name"/>
|
||||
<span v-if="v$.CreateCustomerForm.basicInfo.customer_last_name.$error" class="text-red-600 text-center">
|
||||
{{ v$.CreateCustomerForm.basicInfo.customer_last_name.$errors[0].$message }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-5">
|
||||
<div class="flex-1 mb-4">
|
||||
<label class="block text-white text-sm font-bold mb-2">Customer Type</label>
|
||||
<select
|
||||
class="select select-bordered w-full max-w-xs"
|
||||
aria-label="Default select example" id="customer_type"
|
||||
v-model="CreateCustomerForm.basicInfo.customer_home_type">
|
||||
<option class="text-white" v-for="(customer, index) in custList"
|
||||
:key="index"
|
||||
:value="customer['value']">
|
||||
{{ customer['text'] }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-[18px] mt-5 mb-5">Customer Address</div>
|
||||
<div class="col-span-12 md:col-span-4 mb-5 md:mb-5">
|
||||
<label class="block text-white text-sm font-bold mb-2">Phone Number</label>
|
||||
<input v-model="CreateCustomerForm.basicInfo.customer_phone_number"
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
id="phone number" type="tel" placeholder="Phone Number" @input="acceptNumber()" />
|
||||
<span v-if="v$.CreateCustomerForm.basicInfo.customer_phone_number.$error"
|
||||
class="text-red-600 text-center">
|
||||
{{ v$.CreateCustomerForm.basicInfo.customer_phone_number.$errors[0].$message }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="col-span-12 mb-5 md:mb-5">
|
||||
<label class="block text-white text-sm font-bold mb-2">Street Address</label>
|
||||
<input v-model="CreateCustomerForm.basicInfo.customer_address"
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
id="address" type="text" placeholder="Address"/>
|
||||
<span v-if="v$.CreateCustomerForm.basicInfo.customer_address.$error"
|
||||
class="text-red-600 text-center">
|
||||
{{ v$.CreateCustomerForm.basicInfo.customer_address.$errors[0].$message }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="col-span-12 mb-5 md:mb-5">
|
||||
<input v-model="CreateCustomerForm.basicInfo.customer_apt"
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
id="apt" type="text" placeholder="Apt, suite, unit, building, floor, etc"/>
|
||||
</div>
|
||||
<div class="col-span-12 md:col-span-4 mb-20 md:mb-5 ">
|
||||
<label class="block text-white text-sm font-bold mb-2">Town</label>
|
||||
<input v-model="CreateCustomerForm.basicInfo.customer_town"
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
id="town" type="text" placeholder="Town"/>
|
||||
<span v-if="v$.CreateCustomerForm.basicInfo.customer_town.$error" class="text-red-600 text-center">
|
||||
{{ v$.CreateCustomerForm.basicInfo.customer_town.$errors[0].$message }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="flex-1 mb-4">
|
||||
<label class="block text-white text-sm font-bold mb-2">State</label>
|
||||
<select
|
||||
class="select select-bordered w-full max-w-xs"
|
||||
aria-label="Default select example" id="customer_state"
|
||||
v-model="CreateCustomerForm.basicInfo.customer_state">
|
||||
<option class="text-white" v-for="(state, index) in stateList"
|
||||
:key="index"
|
||||
:value="state['value']">
|
||||
{{ state['text'] }}
|
||||
</option>
|
||||
</select>
|
||||
<span v-if="v$.CreateCustomerForm.basicInfo.customer_state.$error" class="text-red-600 text-center">
|
||||
{{ v$.CreateCustomerForm.basicInfo.customer_state.$errors[0].$message }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="col-span-12 md:col-span-4 mb-5 md:mb-5">
|
||||
<label class="block text-white text-sm font-bold mb-2">Zip Code</label>
|
||||
<input v-model="CreateCustomerForm.basicInfo.customer_zip"
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
id="zip" type="text" placeholder="Zip"/>
|
||||
<span v-if="v$.CreateCustomerForm.basicInfo.customer_zip.$error" class="text-red-600 text-center">
|
||||
{{ v$.CreateCustomerForm.basicInfo.customer_zip.$errors[0].$message }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="col-span-12 md:col-span-4 mb-5 md:mb-0">
|
||||
<label class="block text-white text-sm font-bold mb-2">Email</label>
|
||||
<input v-model="CreateCustomerForm.basicInfo.customer_email"
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
id="email" type="text" placeholder="Email"/>
|
||||
<span v-if="v$.CreateCustomerForm.basicInfo.customer_email.$error" class="text-red-600 text-center">
|
||||
{{ v$.CreateCustomerForm.basicInfo.customer_email.$errors[0].$message }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="col-span-12 md:col-span-4 mb-5 md:mb-0">
|
||||
<label class="block text-white text-sm font-bold mb-2">Automatic</label>
|
||||
<input v-model="CreateCustomerForm.basicInfo.customer_automatic"
|
||||
class="checkbox"
|
||||
id="automatic"
|
||||
type="checkbox"/>
|
||||
</div>
|
||||
<div class="col-span-12 md:col-span-12 flex mt-5 mb-5">
|
||||
<button
|
||||
class="btn">
|
||||
Create Customer
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<Footer/>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import {defineComponent} from 'vue'
|
||||
import axios from 'axios'
|
||||
import authHeader from '../../services/auth.header'
|
||||
import Header from '../../layouts/headers/headerauth.vue'
|
||||
import SideBar from '../../layouts/sidebar/sidebar.vue'
|
||||
import Footer from '../../layouts/footers/footer.vue'
|
||||
import useValidate from "@vuelidate/core";
|
||||
import {email, minLength, required} from "@vuelidate/validators";
|
||||
|
||||
export default defineComponent({
|
||||
name: 'CustomerCreate',
|
||||
|
||||
components: {
|
||||
Header,
|
||||
SideBar,
|
||||
Footer,
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
v$: useValidate(),
|
||||
user: null,
|
||||
stateList: [],
|
||||
x: '',
|
||||
custList: [],
|
||||
new_user_id: 0,
|
||||
CreateCustomerForm: {
|
||||
basicInfo: {
|
||||
customer_last_name: "",
|
||||
customer_first_name: "",
|
||||
customer_town: "",
|
||||
customer_apt: "",
|
||||
customer_home_type: "",
|
||||
customer_zip: "",
|
||||
customer_automatic: "",
|
||||
customer_email: "",
|
||||
customer_phone_number: "",
|
||||
customer_state: "",
|
||||
customer_address: "",
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
validations() {
|
||||
return {
|
||||
CreateCustomerForm: {
|
||||
basicInfo: {
|
||||
customer_last_name: {required, minLength: minLength(1)},
|
||||
customer_first_name: {required, minLength: minLength(1)},
|
||||
customer_town: {required, minLength: minLength(1)},
|
||||
customer_home_type: {required},
|
||||
customer_zip: {required, minLength: minLength(5)},
|
||||
customer_email: {email, required},
|
||||
customer_phone_number: {required},
|
||||
customer_state: {required},
|
||||
customer_address: {required},
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.userStatus()
|
||||
},
|
||||
mounted() {
|
||||
this.getCustomerTypeList();
|
||||
this.getStatesList();
|
||||
},
|
||||
methods: {
|
||||
acceptNumber() {
|
||||
let x = this.CreateCustomerForm.basicInfo.customer_phone_number.replace(/\D/g, '').match(/(\d{0,3})(\d{0,3})(\d{0,4})/);
|
||||
if (x){
|
||||
this.CreateCustomerForm.basicInfo.customer_phone_number = !x[2] ? x[1] : '(' + x[1] + ') ' + x[2] + (x[3] ? '-' + x[3] : '');
|
||||
}
|
||||
else {
|
||||
this.CreateCustomerForm.basicInfo.customer_phone_number = ''
|
||||
}
|
||||
},
|
||||
userStatus() {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/auth/whoami';
|
||||
axios({
|
||||
method: 'get',
|
||||
url: path,
|
||||
withCredentials: true,
|
||||
headers: authHeader(),
|
||||
})
|
||||
.then((response: any) => {
|
||||
if (response.data.ok) {
|
||||
this.user = response.data.user;
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
this.user = null
|
||||
})
|
||||
},
|
||||
CreateCustomer(payload: {
|
||||
customer_last_name: string;
|
||||
customer_first_name: string;
|
||||
customer_town: string;
|
||||
customer_zip: string;
|
||||
customer_email: string;
|
||||
customer_phone_number: string;
|
||||
customer_address: string;
|
||||
customer_apt: string;
|
||||
customer_automatic: string;
|
||||
customer_home_type: string,
|
||||
customer_state: string;
|
||||
}) {
|
||||
let path = import.meta.env.VITE_BASE_URL + "/customer/create";
|
||||
axios({
|
||||
method: "post",
|
||||
url: path,
|
||||
data: payload,
|
||||
withCredentials: true,
|
||||
headers: authHeader(),
|
||||
})
|
||||
.then((response: any) => {
|
||||
if (response.data.ok) {
|
||||
this.new_user_id = response.data.user.user_id
|
||||
this.$router.push({ name: 'customerProfile', params: { id: this.new_user_id } });
|
||||
}
|
||||
if (response.data.error) {
|
||||
this.$router.push("/");
|
||||
}
|
||||
})
|
||||
},
|
||||
onSubmit() {
|
||||
let payload = {
|
||||
customer_last_name: this.CreateCustomerForm.basicInfo.customer_last_name,
|
||||
customer_first_name: this.CreateCustomerForm.basicInfo.customer_first_name,
|
||||
customer_town: this.CreateCustomerForm.basicInfo.customer_town,
|
||||
customer_zip: this.CreateCustomerForm.basicInfo.customer_zip,
|
||||
customer_email: this.CreateCustomerForm.basicInfo.customer_email,
|
||||
customer_phone_number: this.CreateCustomerForm.basicInfo.customer_phone_number,
|
||||
customer_automatic: this.CreateCustomerForm.basicInfo.customer_automatic,
|
||||
customer_home_type: this.CreateCustomerForm.basicInfo.customer_home_type,
|
||||
customer_state: this.CreateCustomerForm.basicInfo.customer_state,
|
||||
customer_apt: this.CreateCustomerForm.basicInfo.customer_apt,
|
||||
customer_address: this.CreateCustomerForm.basicInfo.customer_address,
|
||||
};
|
||||
this.CreateCustomer(payload);
|
||||
},
|
||||
getCustomerTypeList() {
|
||||
let path = import.meta.env.VITE_BASE_URL + "/query/customertype";
|
||||
axios({
|
||||
method: "get",
|
||||
url: path,
|
||||
withCredentials: true,
|
||||
})
|
||||
.then((response: any) => {
|
||||
this.custList = response.data;
|
||||
})
|
||||
.catch(() => {
|
||||
});
|
||||
},
|
||||
getStatesList() {
|
||||
let path = import.meta.env.VITE_BASE_URL + "/query/states";
|
||||
axios({
|
||||
method: "get",
|
||||
url: path,
|
||||
withCredentials: true,
|
||||
})
|
||||
.then((response: any) => {
|
||||
this.stateList = response.data;
|
||||
})
|
||||
.catch(() => {
|
||||
});
|
||||
},
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
371
src/pages/customer/edit.vue
Normal file
371
src/pages/customer/edit.vue
Normal file
@@ -0,0 +1,371 @@
|
||||
<template>
|
||||
<Header/>
|
||||
<div v-if="user">
|
||||
<div class="flex">
|
||||
<div class="">
|
||||
<SideBar/>
|
||||
</div>
|
||||
<div class="w-full px-10">
|
||||
<div class="text-sm breadcrumbs">
|
||||
<ul>
|
||||
<li>
|
||||
<router-link :to="{ name: 'home' }">
|
||||
Home
|
||||
</router-link>
|
||||
</li>
|
||||
<li>
|
||||
<router-link :to="{ name: 'customer' }">
|
||||
Customers
|
||||
</router-link>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 rounded-md p-6 ">
|
||||
<div class="text-[24px]">Edit customer: {{ customer.account_number }}</div>
|
||||
<form class="rounded-md px-8 pt-6 pb-8 mb-4 w-full" enctype="multipart/form-data" @submit.prevent="onSubmit">
|
||||
<div class="text-[18px] mt-5 mb-5">General Info</div>
|
||||
<div class="mb-4">
|
||||
<label class="block text-white text-sm font-bold mb-2"> First Name</label>
|
||||
<input v-model="CreateCustomerForm.basicInfo.customer_first_name"
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
id="title" type="text" placeholder="First Name"/>
|
||||
<span v-if="v$.CreateCustomerForm.basicInfo.customer_first_name.$error" class="text-red-600 text-center">
|
||||
{{ v$.CreateCustomerForm.basicInfo.customer_first_name.$errors[0].$message }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label class="block text-white text-sm font-bold mb-2"> Last Name</label>
|
||||
<input v-model="CreateCustomerForm.basicInfo.customer_last_name"
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
id="title" type="text" placeholder="Last Name"/>
|
||||
<span v-if="v$.CreateCustomerForm.basicInfo.customer_last_name.$error" class="text-red-600 text-center">
|
||||
{{ v$.CreateCustomerForm.basicInfo.customer_last_name.$errors[0].$message }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-5">
|
||||
<div class="flex-1 mb-4">
|
||||
<label class="block text-white text-sm font-bold mb-2">Customer Type</label>
|
||||
<select
|
||||
class="select select-bordered w-full max-w-xs"
|
||||
aria-label="Default select example" id="customer_type"
|
||||
v-model="CreateCustomerForm.basicInfo.customer_home_type">
|
||||
<option class="text-white" v-for="(customer, index) in custList"
|
||||
:key="index"
|
||||
:value="customer['value']">
|
||||
{{ customer['text'] }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-[18px] mt-5 mb-5">Customer Address</div>
|
||||
<div class="col-span-12 md:col-span-4 mb-5 md:mb-5">
|
||||
<label class="block text-white text-sm font-bold mb-2">Phone Number</label>
|
||||
<input v-model="CreateCustomerForm.basicInfo.customer_phone_number"
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
id="phone number" type="text" placeholder="Phone Number" @input="acceptNumber()"/>
|
||||
<span v-if="v$.CreateCustomerForm.basicInfo.customer_phone_number.$error"
|
||||
class="text-red-600 text-center">
|
||||
{{ v$.CreateCustomerForm.basicInfo.customer_phone_number.$errors[0].$message }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="col-span-12 mb-5 md:mb-5">
|
||||
<label class="block text-white text-sm font-bold mb-2">Street Address</label>
|
||||
<input v-model="CreateCustomerForm.basicInfo.customer_address"
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
id="address" type="text" placeholder="Address"/>
|
||||
<span v-if="v$.CreateCustomerForm.basicInfo.customer_address.$error"
|
||||
class="text-red-600 text-center">
|
||||
{{ v$.CreateCustomerForm.basicInfo.customer_address.$errors[0].$message }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="col-span-12 mb-5 md:mb-5">
|
||||
<input v-model="CreateCustomerForm.basicInfo.customer_apt"
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
id="apt" type="text" placeholder="Apt, suite, unit, building, floor, etc"/>
|
||||
</div>
|
||||
<div class="col-span-12 md:col-span-4 mb-20 md:mb-5 ">
|
||||
<label class="block text-white text-sm font-bold mb-2">Town</label>
|
||||
<input v-model="CreateCustomerForm.basicInfo.customer_town"
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
id="town" type="text" placeholder="town"/>
|
||||
<span v-if="v$.CreateCustomerForm.basicInfo.customer_town.$error" class="text-red-600 text-center">
|
||||
{{ v$.CreateCustomerForm.basicInfo.customer_town.$errors[0].$message }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="flex-1 mb-4">
|
||||
<label class="block text-white text-sm font-bold mb-2">State</label>
|
||||
<select
|
||||
class="select select-bordered w-full max-w-xs"
|
||||
aria-label="Default select example" id="customer_state"
|
||||
v-model="CreateCustomerForm.basicInfo.customer_state">
|
||||
<option class="text-white" v-for="(state, index) in stateList"
|
||||
:key="index"
|
||||
:value="state['value']">
|
||||
{{ state['text'] }}
|
||||
</option>
|
||||
</select>
|
||||
<span v-if="v$.CreateCustomerForm.basicInfo.customer_state.$error" class="text-red-600 text-center">
|
||||
{{ v$.CreateCustomerForm.basicInfo.customer_state.$errors[0].$message }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="col-span-12 md:col-span-4 mb-5 md:mb-5">
|
||||
<label class="block text-white text-sm font-bold mb-2">Zip Code</label>
|
||||
<input v-model="CreateCustomerForm.basicInfo.customer_zip"
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
id="zip" type="text" placeholder="Zip"/>
|
||||
<span v-if="v$.CreateCustomerForm.basicInfo.customer_zip.$error" class="text-red-600 text-center">
|
||||
{{ v$.CreateCustomerForm.basicInfo.customer_zip.$errors[0].$message }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="col-span-12 md:col-span-4 mb-5 md:mb-0">
|
||||
<label class="block text-white text-sm font-bold mb-2">Email</label>
|
||||
<input v-model="CreateCustomerForm.basicInfo.customer_email"
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
id="email" type="text" placeholder="Email"/>
|
||||
<span v-if="v$.CreateCustomerForm.basicInfo.customer_email.$error" class="text-red-600 text-center">
|
||||
{{ v$.CreateCustomerForm.basicInfo.customer_email.$errors[0].$message }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="col-span-12 md:col-span-4 mb-5 md:mb-0">
|
||||
<label class="block text-white text-sm font-bold mb-2">Automatic</label>
|
||||
<input v-model="CreateCustomerForm.basicInfo.customer_automatic"
|
||||
class="checkbox"
|
||||
id="automatic"
|
||||
type="checkbox"/>
|
||||
</div>
|
||||
<div class="col-span-12 md:col-span-12 flex mt-5 mb-5">
|
||||
<button class="btn">
|
||||
Edit Customer
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<Footer/>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import {defineComponent} from 'vue'
|
||||
import axios from 'axios'
|
||||
import authHeader from '../../services/auth.header'
|
||||
import Header from '../../layouts/headers/headerauth.vue'
|
||||
import SideBar from '../../layouts/sidebar/sidebar.vue'
|
||||
import Footer from '../../layouts/footers/footer.vue'
|
||||
import useValidate from "@vuelidate/core";
|
||||
import {email, minLength, required} from "@vuelidate/validators";
|
||||
|
||||
export default defineComponent({
|
||||
name: 'CustomerEdit',
|
||||
|
||||
components: {
|
||||
Header,
|
||||
SideBar,
|
||||
Footer,
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
v$: useValidate(),
|
||||
user: null,
|
||||
stateList: [],
|
||||
custList: [],
|
||||
customer: {
|
||||
id: 0,
|
||||
user_id: 0,
|
||||
customer_first_name: '',
|
||||
customer_last_name: '',
|
||||
customer_town: '',
|
||||
customer_state: 0,
|
||||
customer_zip: '',
|
||||
customer_apt: '',
|
||||
customer_address: '',
|
||||
customer_home_type: 0,
|
||||
customer_phone_number: '',
|
||||
account_number: '',
|
||||
},
|
||||
CreateCustomerForm: {
|
||||
basicInfo: {
|
||||
customer_last_name: "",
|
||||
customer_first_name: "",
|
||||
customer_town: "",
|
||||
customer_apt: "",
|
||||
customer_home_type: "",
|
||||
customer_zip: "",
|
||||
customer_automatic: "",
|
||||
customer_email: "",
|
||||
customer_phone_number: "",
|
||||
customer_state: "",
|
||||
customer_address: "",
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
validations() {
|
||||
return {
|
||||
CreateCustomerForm: {
|
||||
basicInfo: {
|
||||
customer_last_name: {required, minLength: minLength(1)},
|
||||
customer_first_name: {required, minLength: minLength(1)},
|
||||
customer_town: {required, minLength: minLength(1)},
|
||||
customer_home_type: {required},
|
||||
customer_zip: {required, minLength: minLength(5)},
|
||||
customer_email: {email, required},
|
||||
customer_phone_number: {required},
|
||||
customer_state: {required},
|
||||
customer_address: {required},
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.userStatus()
|
||||
this.getCustomer(this.$route.params.id)
|
||||
},
|
||||
mounted() {
|
||||
this.getCustomerTypeList();
|
||||
this.getStatesList();
|
||||
},
|
||||
methods: {
|
||||
acceptNumber() {
|
||||
let x = this.CreateCustomerForm.basicInfo.customer_phone_number.replace(/\D/g, '').match(/(\d{0,3})(\d{0,3})(\d{0,4})/);
|
||||
if (x) {
|
||||
this.CreateCustomerForm.basicInfo.customer_phone_number = !x[2] ? x[1] : '(' + x[1] + ') ' + x[2] + (x[3] ? '-' + x[3] : '');
|
||||
} else {
|
||||
this.CreateCustomerForm.basicInfo.customer_phone_number = '';
|
||||
}
|
||||
|
||||
},
|
||||
userStatus() {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/auth/whoami';
|
||||
axios({
|
||||
method: 'get',
|
||||
url: path,
|
||||
withCredentials: true,
|
||||
headers: authHeader(),
|
||||
})
|
||||
.then((response: any) => {
|
||||
if (response.data.ok) {
|
||||
this.user = response.data.user;
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
this.user = null
|
||||
})
|
||||
},
|
||||
|
||||
// gets the item from parameter router
|
||||
getCustomer(userid: any) {
|
||||
let path = import.meta.env.VITE_BASE_URL + "/customer/" + userid;
|
||||
axios({
|
||||
method: "get",
|
||||
url: path,
|
||||
withCredentials: true,
|
||||
headers: authHeader(),
|
||||
})
|
||||
.then((response: any) => {
|
||||
if (response.data) {
|
||||
this.customer = response.data;
|
||||
this.CreateCustomerForm.basicInfo.customer_last_name = response.data.customer_last_name;
|
||||
this.CreateCustomerForm.basicInfo.customer_first_name = response.data.customer_first_name;
|
||||
this.CreateCustomerForm.basicInfo.customer_town = response.data.customer_town;
|
||||
this.CreateCustomerForm.basicInfo.customer_state = response.data.customer_state;
|
||||
this.CreateCustomerForm.basicInfo.customer_zip = response.data.customer_zip;
|
||||
this.CreateCustomerForm.basicInfo.customer_automatic = response.data.customer_automatic;
|
||||
this.CreateCustomerForm.basicInfo.customer_phone_number = response.data.customer_phone_number;
|
||||
this.CreateCustomerForm.basicInfo.customer_home_type = response.data.customer_home_type;
|
||||
this.CreateCustomerForm.basicInfo.customer_apt = response.data.customer_apt;
|
||||
this.CreateCustomerForm.basicInfo.customer_email = response.data.customer_email;
|
||||
this.CreateCustomerForm.basicInfo.customer_address = response.data.customer_address;
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
editItem(payload: {
|
||||
customer_last_name: string;
|
||||
customer_first_name: string;
|
||||
customer_town: string;
|
||||
customer_zip: string;
|
||||
customer_email: string;
|
||||
customer_phone_number: string;
|
||||
customer_automatic: string;
|
||||
customer_home_type: string,
|
||||
customer_state: string;
|
||||
customer_address: string;
|
||||
}) {
|
||||
let path = import.meta.env.VITE_BASE_URL + "/customer/edit/" + this.customer.id;
|
||||
axios({
|
||||
method: "put",
|
||||
url: path,
|
||||
data: payload,
|
||||
withCredentials: true,
|
||||
headers: authHeader(),
|
||||
})
|
||||
.then((response: any) => {
|
||||
if (response.data.ok) {
|
||||
this.$router.push({name: "customerProfile", params: {id: this.customer.id}});
|
||||
}
|
||||
;
|
||||
if (response.data.error) {
|
||||
this.$router.push("/");
|
||||
}
|
||||
;
|
||||
})
|
||||
},
|
||||
onSubmit() {
|
||||
let payload = {
|
||||
customer_last_name: this.CreateCustomerForm.basicInfo.customer_last_name,
|
||||
customer_first_name: this.CreateCustomerForm.basicInfo.customer_first_name,
|
||||
customer_town: this.CreateCustomerForm.basicInfo.customer_town,
|
||||
customer_zip: this.CreateCustomerForm.basicInfo.customer_zip,
|
||||
customer_email: this.CreateCustomerForm.basicInfo.customer_email,
|
||||
customer_phone_number: this.CreateCustomerForm.basicInfo.customer_phone_number,
|
||||
customer_automatic: this.CreateCustomerForm.basicInfo.customer_automatic,
|
||||
customer_home_type: this.CreateCustomerForm.basicInfo.customer_home_type,
|
||||
customer_state: this.CreateCustomerForm.basicInfo.customer_state,
|
||||
customer_address: this.CreateCustomerForm.basicInfo.customer_address,
|
||||
};
|
||||
this.editItem(payload);
|
||||
},
|
||||
getCustomerTypeList() {
|
||||
let path = import.meta.env.VITE_BASE_URL + "/query/customertype";
|
||||
axios({
|
||||
method: "get",
|
||||
url: path,
|
||||
withCredentials: true,
|
||||
})
|
||||
.then((response: any) => {
|
||||
this.custList = response.data;
|
||||
})
|
||||
.catch(() => {
|
||||
});
|
||||
},
|
||||
getStatesList() {
|
||||
let path = import.meta.env.VITE_BASE_URL + "/query/states";
|
||||
axios({
|
||||
method: "get",
|
||||
url: path,
|
||||
withCredentials: true,
|
||||
})
|
||||
.then((response: any) => {
|
||||
this.stateList = response.data;
|
||||
})
|
||||
.catch(() => {
|
||||
});
|
||||
},
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
<script setup lang="ts">
|
||||
</script>
|
||||
186
src/pages/customer/home.vue
Normal file
186
src/pages/customer/home.vue
Normal file
@@ -0,0 +1,186 @@
|
||||
<template>
|
||||
<Header/>
|
||||
<div class="flex">
|
||||
<div class="">
|
||||
<SideBar/>
|
||||
</div>
|
||||
<div class=" w-full px-10 ">
|
||||
<div class="text-sm breadcrumbs">
|
||||
<ul>
|
||||
<li>
|
||||
<router-link :to="{ name: 'home' }">
|
||||
Home
|
||||
</router-link>
|
||||
</li>
|
||||
<li>
|
||||
<router-link :to="{ name: 'customer' }">
|
||||
Customers
|
||||
</router-link>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="flex justify-end">
|
||||
|
||||
</div>
|
||||
|
||||
<div class="overflow-x-auto">
|
||||
<table class="table">
|
||||
<!-- head -->
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Town</th>
|
||||
<th>Automatic</th>
|
||||
<th>Phone Number</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- row 1 -->
|
||||
<tr v-for="person in customers" :key="person['id']">
|
||||
|
||||
<td>
|
||||
<router-link :to="{ name: 'customerProfile', params: { id: person['id'] } }">
|
||||
{{ person['customer_first_name'] }} {{ person['customer_last_name'] }}
|
||||
</router-link>
|
||||
</td>
|
||||
<td>{{ person['customer_town'] }}</td>
|
||||
<td>
|
||||
<div v-if="person['customer_automatic'] == 0">No</div>
|
||||
<div v-else>Yes</div>
|
||||
</td>
|
||||
<td>{{ person['customer_phone_number'] }}</td>
|
||||
|
||||
<td class="flex gap-5">
|
||||
|
||||
<router-link :to="{ name: 'deliveryCreate', params: { id: person['id'] } }" class="cursor-pointer underline hover:text-blue-300">
|
||||
Oil
|
||||
</router-link>
|
||||
<router-link :to="{ name: 'serviceCreate', params: { id: person['id'] } }" class="cursor-pointer underline hover:text-blue-300">
|
||||
Service
|
||||
</router-link>
|
||||
|
||||
<router-link :to="{ name: 'customerEdit', params: { id: person['id'] } }" class="cursor-pointer underline hover:text-blue-300">
|
||||
Edit
|
||||
</router-link>
|
||||
<router-link :to="{ name: 'customerProfile', params: { id: person['id'] } }" class="cursor-pointer underline hover:text-blue-300">
|
||||
View
|
||||
</router-link>
|
||||
<a @click.prevent="deleteCustomer(person['id'])" class="cursor-pointer underline hover:text-blue-300">
|
||||
Delete
|
||||
</a>
|
||||
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="flex justify-center" v-if="recordsLength > 9">
|
||||
<pagination @paginate="getPage" :records="recordsLength" v-model="page" :per-page="perPage"
|
||||
:options="options">
|
||||
</pagination>
|
||||
<div class="flex justify-center mb-10"> {{ recordsLength }} items Found</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Footer/>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import {defineComponent} from 'vue'
|
||||
import axios from 'axios'
|
||||
|
||||
import authHeader from '../../services/auth.header'
|
||||
import Header from '../../layouts/headers/headerauth.vue'
|
||||
import PaginationComp from '../../components/pagination.vue'
|
||||
import SideBar from '../../layouts/sidebar/sidebar.vue'
|
||||
import Footer from '../../layouts/footers/footer.vue'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'CustomerHome',
|
||||
|
||||
components: {
|
||||
Header,
|
||||
SideBar,
|
||||
Footer,
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
token: null,
|
||||
user: null,
|
||||
customers: [],
|
||||
page: 1,
|
||||
perPage: 50,
|
||||
recordsLength: 0,
|
||||
|
||||
options: {
|
||||
edgeNavigation: false,
|
||||
format: false,
|
||||
template: PaginationComp
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
created() {
|
||||
this.userStatus()
|
||||
},
|
||||
mounted() {
|
||||
this.getPage(this.page)
|
||||
|
||||
},
|
||||
methods: {
|
||||
getPage: function (page: any) {
|
||||
// we simulate an api call that fetch the records from a backend
|
||||
this.customers = [];
|
||||
this.get_customers(page)
|
||||
},
|
||||
userStatus() {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/auth/whoami';
|
||||
axios({
|
||||
method: 'get',
|
||||
url: path,
|
||||
withCredentials: true,
|
||||
headers: authHeader(),
|
||||
})
|
||||
.then((response: any) => {
|
||||
if (response.data.ok) {
|
||||
this.user = response.data.user;
|
||||
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
this.user = null
|
||||
})
|
||||
},
|
||||
get_customers(page: any) {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/customer/all/' + page;
|
||||
axios({
|
||||
method: 'get',
|
||||
url: path,
|
||||
headers: authHeader(),
|
||||
}).then((response: any) => {
|
||||
this.customers = response.data
|
||||
})
|
||||
},
|
||||
deleteCustomer(user_id: any) {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/customer/delete/' + user_id;
|
||||
axios({
|
||||
method: 'delete',
|
||||
url: path,
|
||||
headers: authHeader(),
|
||||
}).then(() => {
|
||||
|
||||
this.get_customers(1)
|
||||
})
|
||||
},
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
553
src/pages/customer/profile/home.vue
Normal file
553
src/pages/customer/profile/home.vue
Normal file
@@ -0,0 +1,553 @@
|
||||
<template>
|
||||
<Header/>
|
||||
|
||||
<div class="flex">
|
||||
<div class="">
|
||||
<SideBar/>
|
||||
</div>
|
||||
<div class=" w-full px-10 ">
|
||||
<div class="text-sm breadcrumbs">
|
||||
<ul>
|
||||
<li>
|
||||
<router-link :to="{ name: 'home' }">
|
||||
Home
|
||||
</router-link>
|
||||
</li>
|
||||
<li>
|
||||
<router-link :to="{ name: 'customer' }">
|
||||
Customers
|
||||
</router-link>
|
||||
</li>
|
||||
</ul>
|
||||
<div class=" w-full mt-10" v-if="customer !== null">
|
||||
|
||||
<div class="grid grid-cols-12 gap-5">
|
||||
<div class="col-span-4 bg-neutral p-5 ">
|
||||
<img src="../../../assets/images/user_placeholder.png"
|
||||
alt="Drone Image"
|
||||
width="200"
|
||||
height="250"/>
|
||||
</div>
|
||||
<div class="col-span-8 bg-neutral p-5">
|
||||
<div class="grid grid-cols-12">
|
||||
<div class="col-span-12 font-bold flex justify-evenly pb-5">
|
||||
<div class="btn">
|
||||
<router-link :to="{ name: 'deliveryCreate', params: { id: customer.id } }"
|
||||
class="cursor-pointer underline hover:text-blue-300">
|
||||
Create Delivery
|
||||
</router-link>
|
||||
</div>
|
||||
<div class="btn">
|
||||
<router-link :to="{ name: 'serviceCreate', params: { id: customer.id } }"
|
||||
class="cursor-pointer underline hover:text-blue-300">
|
||||
Create Service
|
||||
</router-link>
|
||||
</div>
|
||||
<div class="btn">
|
||||
<router-link :to="{ name: 'customerEdit', params: { id: customer.id } }" class="">
|
||||
Edit Customer
|
||||
</router-link>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-span-12 font-bold flex pb-5 text-lg">{{ customer.account_number }}</div>
|
||||
<div class="col-span-12 font-bold flex">
|
||||
{{ customer.customer_first_name }}
|
||||
{{ customer.customer_last_name }}
|
||||
</div>
|
||||
<div class="col-span-12 font-bold flex">
|
||||
|
||||
{{ customer.customer_address }}
|
||||
<div v-if="customer.customer_apt != 'None'">
|
||||
{{ customer.customer_apt }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col-span-12 font-bold flex">
|
||||
<div class="pr-2">
|
||||
{{ customer.customer_town }},
|
||||
</div>
|
||||
<div class="pr-2">
|
||||
|
||||
<div v-if="customer.customer_state == 0">Massachusetts</div>
|
||||
<div v-else-if="customer.customer_state == 1">Rhode Island</div>
|
||||
<div v-else-if="customer.customer_state == 2">New Hampshire</div>
|
||||
<div v-else-if="customer.customer_state == 3">Maine</div>
|
||||
<div v-else-if="customer.customer_state == 4">Vermont</div>
|
||||
<div v-else-if="customer.customer_state == 5">Maine</div>
|
||||
<div v-else-if="customer.customer_state == 6">New York</div>
|
||||
<div v-else>Unknown state</div>
|
||||
</div>
|
||||
<div class="pr-2">
|
||||
{{ customer.customer_zip }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-span-12 font-bold flex" v-if="customer.customer_apt !== 'None'">
|
||||
{{ customer.customer_apt }}
|
||||
</div>
|
||||
<div class="col-span-12 font-bold flex">
|
||||
<div v-if="customer.customer_home_type == 0">Residential</div>
|
||||
<div v-else-if="customer.customer_home_type == 1">apartment</div>
|
||||
<div v-else-if="customer.customer_home_type == 2">condo</div>
|
||||
<div v-else-if="customer.customer_home_type == 3">commercial</div>
|
||||
<div v-else-if="customer.customer_home_type == 4">business</div>
|
||||
<div v-else-if="customer.customer_home_type == 5">construction</div>
|
||||
<div v-else-if="customer.customer_home_type == 6">container</div>
|
||||
</div>
|
||||
<div class="col-span-12 font-bold flex">
|
||||
{{ customer.customer_phone_number }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-span-12 bg-neutral p-5">
|
||||
<div class="grid grid-cols-12">
|
||||
<div class="col-span-12 font-bold flex text-2xl">
|
||||
Stats
|
||||
</div>
|
||||
<div class="col-span-6">
|
||||
<div class="col-span-12 py-2 font-bold">Delivery</div>
|
||||
<div class="col-span-12 py-2">
|
||||
Total Delivery Orders: 0
|
||||
</div>
|
||||
<div class="col-span-12 py-2">
|
||||
Total Gallons: 0
|
||||
</div>
|
||||
<div class="col-span-12 py-2">
|
||||
Last Delivery: 0
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col-span-6">
|
||||
<div class="col-span-12 py-2 font-bold">Service</div>
|
||||
<div class="col-span-12 py-2">
|
||||
Total Service Calls: 0
|
||||
</div>
|
||||
<div class="col-span-12 py-2">
|
||||
Last Service Call: 0
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-span-12 bg-neutral p-5">
|
||||
<div class="grid grid-cols-12">
|
||||
<div class="col-span-6 font-bold flex text-2xl">
|
||||
Credit Cards
|
||||
</div>
|
||||
<div class="col-span-6 font-bold flex ">
|
||||
|
||||
<router-link :to="{ name: 'cardadd', params: { id: customer.user_id } }">
|
||||
<button class="btn">Add Credit Card</button>
|
||||
</router-link>
|
||||
</div>
|
||||
<div class="col-span-12 font-bold flex">
|
||||
<div class="text-red-600" v-if="credit_cards_count == 0">
|
||||
No Cards on File! Cash Customer till card added.
|
||||
</div>
|
||||
<div v-else>
|
||||
{{ credit_cards_count }} credit card(s) on file.
|
||||
</div>
|
||||
</div>
|
||||
<div v-for="card in credit_cards" class="col-span-12">
|
||||
|
||||
<div class="flex flex-row ">
|
||||
<div v-if="card.main_card" class="basis-1/3 p-2">
|
||||
<div class="bg-accent rounded-md border-2 ">
|
||||
<div class="flex p-3">
|
||||
{{ card.type_of_card }}
|
||||
</div>
|
||||
<div class="flex p-1 pl-4">
|
||||
{{ card.name_on_card }}
|
||||
</div>
|
||||
<div class="flex p-1 pl-4">
|
||||
****-****-****-{{ card.last_four_digits }}
|
||||
</div>
|
||||
<div class="flex p-1 pl-4">
|
||||
{{ card.expiration_month }}/ {{ card.expiration_year }}
|
||||
</div>
|
||||
<div class="flex justify-between">
|
||||
|
||||
<a @click.prevent="editCard(card.id)" class="cursor-pointer underline hover:text-blue-300">Edit
|
||||
Card</a>
|
||||
<a @click.prevent="removeCard(card.id)" class="cursor-pointer underline hover:text-blue-300">Remove
|
||||
Card</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="basis-1/3 p-2">
|
||||
<div class="bg-neutral rounded-md border-2 ">
|
||||
<div class="flex p-3">
|
||||
{{ card.type_of_card }}
|
||||
</div>
|
||||
<div class="flex p-1 pl-4">
|
||||
{{ card.name_on_card }}
|
||||
</div>
|
||||
<div class="flex p-1 pl-4">
|
||||
****-****-****-{{ card.last_four_digits }}
|
||||
</div>
|
||||
<div class="flex p-1 pl-4">
|
||||
{{ card.expiration_month }}/ {{ card.expiration_year }}
|
||||
</div>
|
||||
<div class="flex justify-between">
|
||||
<a @click.prevent="editCard(card.id)" class="cursor-pointer underline hover:text-blue-300">Edit
|
||||
Card</a>
|
||||
<a @click.prevent="removeCard(card.id)" class="cursor-pointer underline hover:text-blue-300">Remove
|
||||
Card</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-span-12 bg-neutral p-5">
|
||||
<div class="grid grid-cols-12">
|
||||
<div class="col-span-6 font-bold flex text-2xl">
|
||||
Financial
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-span-12 bg-neutral p-5">
|
||||
<div class="grid grid-cols-12">
|
||||
<div class="col-span-12 font-bold flex text-2xl">Orders</div>
|
||||
</div>
|
||||
<div class="grid grid-cols-12 ">
|
||||
<div role="tablist" class="tabs tabs-bordered">
|
||||
<input type="radio" name="my_tabs_1" role="tab" class="tab" aria-label="Deliveries" checked/>
|
||||
<div role="tabpanel" class="tab-content pt-10">
|
||||
<table class="table">
|
||||
<!-- head -->
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Status</th>
|
||||
<th>Town</th>
|
||||
<th>Name</th>
|
||||
<th>Address</th>
|
||||
<th>Gallons</th>
|
||||
<th>Date</th>
|
||||
<th>Automatic</th>
|
||||
<th>Prime</th>
|
||||
<th>Same Day</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- row 1 -->
|
||||
<tr v-for="oil in deliveries" :key="oil['id']">
|
||||
<td>
|
||||
<div v-if="oil['delivery_status'] == 0">Waiting</div>
|
||||
<div v-else-if="oil['delivery_status'] == 1">delivered</div>
|
||||
<div v-else-if="oil['delivery_status'] == 2">Out for Delivery</div>
|
||||
<div v-else-if="oil['delivery_status'] == 3">Cancelled</div>
|
||||
<div v-else-if="oil['delivery_status'] == 4">Partial Delivery</div>
|
||||
<div v-else-if="oil['delivery_status'] == 5">Issue</div>
|
||||
<div v-else-if="oil['delivery_status'] == 10">Finalized</div>
|
||||
<div v-else></div>
|
||||
</td>
|
||||
<td>{{ oil['customer_town'] }}</td>
|
||||
<td>{{ oil['customer_name'] }}</td>
|
||||
<td>{{ oil['customer_address'] }}</td>
|
||||
|
||||
<td>
|
||||
<div v-if="oil['customer_asked_for_fill'] == 1">Fill</div>
|
||||
<div v-else> {{ oil['gallons_ordered'] }}</div>
|
||||
|
||||
</td>
|
||||
|
||||
<td>{{ oil['expected_delivery_date'] }}</td>
|
||||
<td>
|
||||
<div v-if="oil['automatic'] == 0">No</div>
|
||||
<div v-else>Yes</div>
|
||||
</td>
|
||||
<td>
|
||||
<div v-if="oil['prime'] == 0">No</div>
|
||||
<div v-else>Yes</div>
|
||||
</td>
|
||||
<td>
|
||||
<div v-if="oil['same_day'] == 0">No</div>
|
||||
<div v-else>Yes</div>
|
||||
</td>
|
||||
|
||||
<td class="flex gap-5">
|
||||
<router-link :to="{ name: 'deliveryEdit', params: { id: oil['id'] } }">
|
||||
<button class="btn">Edit</button>
|
||||
</router-link>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<input type="radio" name="my_tabs_1" role="tab" class="tab" aria-label="Service"/>
|
||||
<div role="tabpanel" class="tab-content pt-10">
|
||||
<table class="table">
|
||||
<!-- head -->
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Customer Name</th>
|
||||
<th>Status</th>
|
||||
<th>Service Type</th>
|
||||
<th>Scheduled Date</th>
|
||||
<th>Tech Name</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- row 1 -->
|
||||
<tr v-for="service in service_orders" :key="service['id']">
|
||||
|
||||
<td>
|
||||
{{ service['customer_first_name'] }} {{ service['customer_last_name'] }}
|
||||
</td>
|
||||
<td>
|
||||
<div v-if="service['status'] == 0">Waiting/not paid</div>
|
||||
<div v-else-if="service['status'] == 1">Paid /waiting</div>
|
||||
<div v-else-if="service['status'] == 2">Scheduled Today</div>
|
||||
<div v-else-if="service['status'] == 3">Completed/Unpaid</div>
|
||||
<div v-else-if="service['status'] == 4">Completed/Paid</div>
|
||||
|
||||
<div v-else></div>
|
||||
</td>
|
||||
<td>
|
||||
<div v-if="service['service_type'] == 0">General</div>
|
||||
<div v-else-if="service['service_type'] == 1">Cleaning / Tuneup</div>
|
||||
<div v-else-if="service['service_type'] == 2">No Heat</div>
|
||||
<div v-else-if="service['service_type'] == 3">Install</div>
|
||||
<div v-else-if="service['service_type'] == 4">Call Back</div>
|
||||
<div v-else-if="service['service_type'] == 5">Quote</div>
|
||||
<div v-else-if="service['service_type'] == 6">Emergency</div>
|
||||
<div v-else></div>
|
||||
</td>
|
||||
<td>{{ service['scheduled_date'] }}</td>
|
||||
<td>
|
||||
<div v-if="service['payment_type'] == 0">Cash C.O.D</div>
|
||||
<div v-else-if="service['payment_type'] == 1">Credit</div>
|
||||
<div v-else-if="service['payment_type'] == 2">Stripe</div>
|
||||
<div v-else-if="service['payment_type'] == 3">Cash/Credit</div>
|
||||
|
||||
<div v-else></div>
|
||||
</td>
|
||||
<td>
|
||||
{{ service['tech_first_name'] }} {{ service['tech_last_name'] }}
|
||||
</td>
|
||||
<td class="flex gap-5">
|
||||
<router-link :to="{ name: 'serviceEdit', params: { id: service['id'] } }">
|
||||
<button class="btn">Edit</button>
|
||||
</router-link>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<Footer/>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import {defineComponent} from 'vue'
|
||||
import axios from 'axios'
|
||||
import authHeader from '../../../services/auth.header'
|
||||
import Header from '../../../layouts/headers/headerauth.vue'
|
||||
import SideBar from '../../../layouts/sidebar/sidebar.vue'
|
||||
import Footer from '../../../layouts/footers/footer.vue'
|
||||
import PaginationComp from "../../../components/pagination.vue";
|
||||
import {notify} from "@kyvg/vue3-notification";
|
||||
|
||||
export default defineComponent({
|
||||
name: 'CustomerProfile',
|
||||
|
||||
components: {
|
||||
Header,
|
||||
SideBar,
|
||||
Footer,
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
token: null,
|
||||
user: null,
|
||||
credit_cards: [
|
||||
{
|
||||
id: 0,
|
||||
name_on_card: '',
|
||||
main_card: false,
|
||||
card_number: '',
|
||||
expiration_month: '',
|
||||
type_of_card: '',
|
||||
last_four_digits: '',
|
||||
expiration_year: '',
|
||||
|
||||
}
|
||||
],
|
||||
credit_cards_count: 0,
|
||||
customer: {
|
||||
id: 0,
|
||||
user_id: 0,
|
||||
customer_first_name: '',
|
||||
customer_last_name: '',
|
||||
customer_town: '',
|
||||
customer_address: '',
|
||||
customer_state: 0,
|
||||
customer_zip: '',
|
||||
customer_apt: '',
|
||||
customer_home_type: 0,
|
||||
customer_phone_number: '',
|
||||
account_number: '',
|
||||
},
|
||||
deliveries: [],
|
||||
service_orders: [],
|
||||
delivery_page: 1,
|
||||
delivery_perPage: 50,
|
||||
delivery_recordsLength: 0,
|
||||
delivery_options: {
|
||||
delivery_edgeNavigation: false,
|
||||
delivery_format: false,
|
||||
delivery_template: PaginationComp
|
||||
},
|
||||
|
||||
service_page: 1,
|
||||
service_perPage: 50,
|
||||
service_recordsLength: 0,
|
||||
service_options: {
|
||||
service_edgeNavigation: false,
|
||||
service_format: false,
|
||||
service_template: PaginationComp
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.userStatus()
|
||||
this.getCreditCards(this.$route.params.id)
|
||||
this.getCreditCardsCount(this.$route.params.id)
|
||||
},
|
||||
mounted() {
|
||||
this.getCustomer(this.$route.params.id)
|
||||
this.getCustomerService(this.$route.params.id, this.service_page)
|
||||
this.getCustomerDelivery(this.$route.params.id, this.delivery_page)
|
||||
|
||||
},
|
||||
|
||||
watch: {
|
||||
$route() {
|
||||
this.getCustomer(this.$route.params.id);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
getPage: function (page: any) {
|
||||
// we simulate an api call that fetch the records from a backend
|
||||
this.getCustomer(page)
|
||||
},
|
||||
userStatus() {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/auth/whoami';
|
||||
axios({
|
||||
method: 'get',
|
||||
url: path,
|
||||
withCredentials: true,
|
||||
headers: authHeader(),
|
||||
})
|
||||
.then((response: any) => {
|
||||
if (response.data.ok) {
|
||||
this.user = response.data.user;
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
this.user = null
|
||||
})
|
||||
},
|
||||
|
||||
getCustomer(userid: any) {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/customer/' + userid;
|
||||
axios({
|
||||
method: 'get',
|
||||
url: path,
|
||||
headers: authHeader(),
|
||||
}).then((response: any) => {
|
||||
|
||||
this.customer = response.data
|
||||
})
|
||||
},
|
||||
|
||||
getCreditCards(user_id: any) {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/payment/cards/' + user_id;
|
||||
axios({
|
||||
method: 'get',
|
||||
url: path,
|
||||
headers: authHeader(),
|
||||
}).then((response: any) => {
|
||||
|
||||
this.credit_cards = response.data
|
||||
})
|
||||
},
|
||||
|
||||
getCreditCardsCount(user_id: any) {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/payment/cards/onfile/' + user_id;
|
||||
axios({
|
||||
method: 'get',
|
||||
url: path,
|
||||
headers: authHeader(),
|
||||
}).then((response: any) => {
|
||||
|
||||
this.credit_cards_count = response.data.cards
|
||||
})
|
||||
},
|
||||
|
||||
getCustomerService(userid: any, service_page: any) {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/service/customer/' + userid + '/' + service_page;
|
||||
axios({
|
||||
method: 'get',
|
||||
url: path,
|
||||
headers: authHeader(),
|
||||
}).then((response: any) => {
|
||||
this.service_orders = response.data
|
||||
})
|
||||
},
|
||||
|
||||
getCustomerDelivery(userid: any, delivery_page: any) {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/delivery/customer/' + userid + '/' + delivery_page;
|
||||
axios({
|
||||
method: 'get',
|
||||
url: path,
|
||||
headers: authHeader(),
|
||||
}).then((response: any) => {
|
||||
this.deliveries = response.data
|
||||
})
|
||||
},
|
||||
|
||||
editCard(card_id: any) {
|
||||
this.$router.push({name: "cardedit", params: {id: card_id}});
|
||||
},
|
||||
|
||||
|
||||
removeCard(card_id: any) {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/payment/card/remove/' + card_id;
|
||||
axios({
|
||||
method: 'delete',
|
||||
url: path,
|
||||
headers: authHeader(),
|
||||
}).then(() => {
|
||||
this.getCreditCards(this.$route.params.id)
|
||||
this.getCreditCardsCount(this.$route.params.id)
|
||||
notify({
|
||||
title: "Card Status",
|
||||
text: "Card Removed",
|
||||
type: "Success",
|
||||
});
|
||||
})
|
||||
},
|
||||
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped></style>
|
||||
33
src/pages/customer/routes.ts
Normal file
33
src/pages/customer/routes.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
|
||||
import CustomerHome from '../customer/home.vue';
|
||||
import CustomerCreate from '../customer/create.vue';
|
||||
import CustomerEdit from "../customer/edit.vue";
|
||||
import CustomerProfile from "./profile/home.vue"
|
||||
|
||||
const customerRoutes = [
|
||||
{
|
||||
path: '/customer',
|
||||
name: 'customer',
|
||||
component: CustomerHome,
|
||||
},
|
||||
|
||||
{
|
||||
path: '/customer/create',
|
||||
name: 'customerCreate',
|
||||
component: CustomerCreate,
|
||||
},
|
||||
{
|
||||
path: '/customer/edit/:id',
|
||||
name: 'customerEdit',
|
||||
component: CustomerEdit,
|
||||
},
|
||||
{
|
||||
path: '/customer/:id',
|
||||
name: 'customerProfile',
|
||||
component: CustomerProfile,
|
||||
},
|
||||
]
|
||||
|
||||
export default customerRoutes
|
||||
//sourceMappingURL=index.ts.map
|
||||
Reference in New Issue
Block a user