Updated forms

This commit is contained in:
2024-10-24 11:50:58 -04:00
parent c6f806f733
commit cae64eec86
21 changed files with 1186 additions and 924 deletions

View File

@@ -21,22 +21,75 @@
</div>
<div class="grid grid-cols-12">
<div class="col-span-12 xl:col-span-6 rounded-md p-6 ">
<div class="grid grid-cols-12">
<div class="col-span-12 text-[24px]">
Create Oil Delivery
</div>
<div class="col-span-12 py-5">
<div class="grid grid-cols-12 ">
<div class="col-span-12 bg-neutral ">
<div class="col-span-12 py-5 ">
<router-link :to="{ name: 'customerProfile', params: { id: customer['id'] } }"
class="btn btn-secondary btn-sm">
View Profile
</router-link>
class="btn btn-secondary btn-sm">
View Profile
</router-link>
</div>
<div class="grid grid-cols-12">
<div class="col-span-12 font-bold flex pb-5 ">{{ 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-6 rounded-md p-6 ">
<div class="grid grid-cols-12">
<div class="col-span-12 text-[24px] ">
Create Delivery
</div>
<form class="col-span-12 rounded-md px-8 pt-6 pb-8 mb-4 w-full" enctype="multipart/form-data"
@submit.prevent="onSubmit">
@@ -82,27 +135,29 @@
</div>
<div v-if="userCards.length > 0">
<div class="flex-1 mb-4">
<label class="block text-white text-sm font-bold mb-2">Customer Cards Payment</label>
<select class="select select-bordered select-sm w-full max-w-xs" aria-label="Default select example"
id="userCards" v-model="CreateOilOrderForm.basicInfo.userCards">
<option class="text-white" v-for="(card, index) in userCards" :key="index" :value="card['id']">
{{ card['type_of_card'] }} {{ card['card_number'] }}
</option>
</select>
</div>
</div>
<div v-else>
<div class="col-span-12 md:col-span-4 mb-5 md:mb-0 py-5">
No Cards on File!
<router-link :to="{ name: 'cardadd', params: { id: customer.id } }">
<button class="btn btn-sm bg-blue-700 text-white">Add CreditCard</button>
</router-link>
</div>
</div>
<div v-if="userCards.length > 0">
<div class="flex-1 mb-4">
<label class="block text-white text-sm font-bold mb-2">Customer Cards Payment</label>
<select class="select select-bordered select-sm w-full max-w-xs" aria-label="Default select example"
id="userCards" v-model="CreateOilOrderForm.basicInfo.userCards">
<option class="text-white" v-for="(card, index) in userCards" :key="index" :value="card['id']">
{{ card['type_of_card'] }} {{ card['card_number'] }}
</option>
</select>
</div>
</div>
<div v-else>
<div class="col-span-12 md:col-span-4 mb-5 md:mb-0 py-5">
No Cards on File!
<a @click.prevent="test()" class="cursor-pointer underline hover:text-blue-300">
Edit Card
</a>
<!-- <router-link :to="{ name: 'cardadd', params: { id: customer.id } }">
<button class="btn btn-sm bg-blue-700 text-white">Add Credit Card</button>
</router-link> -->
</div>
</div>
<div class="flex-1 mb-4">
<label class="block text-white text-sm font-bold mb-2">Delivery Driver </label>
@@ -123,18 +178,18 @@
type="checkbox" />
</div>
<div v-if="userCards.length > 0">
<div class="col-span-12 md:col-span-4 mb-5 md:mb-0 gap-10">
<label class="block text-white text-sm font-bold cursor-pointer label">Credit </label>
<input v-model="CreateOilOrderForm.basicInfo.credit" class="checkbox checkbox-xs" id="Credit"
type="checkbox" />
</div>
<div class="col-span-12 md:col-span-4 mb-5 md:mb-0 gap-10">
<label class="block text-white text-sm font-bold cursor-pointer label">Credit </label>
<input v-model="CreateOilOrderForm.basicInfo.credit" class="checkbox checkbox-xs" id="Credit"
type="checkbox" />
</div>
</div>
<div v-if="userCards.length > 0">
<div class="col-span-12 md:col-span-4 mb-5 md:mb-0 gap-10">
<label class="block text-white text-sm font-bold cursor-pointer label">Check </label>
<input v-model="CreateOilOrderForm.basicInfo.check" class="checkbox checkbox-xs" id="Check"
type="checkbox" />
</div>
<div class="col-span-12 md:col-span-4 mb-5 md:mb-0 gap-10">
<label class="block text-white text-sm font-bold cursor-pointer label">Check </label>
<input v-model="CreateOilOrderForm.basicInfo.check" class="checkbox checkbox-xs" id="Check"
type="checkbox" />
</div>
</div>
<div class="col-span-12 md:col-span-4 mb-5 md:mb-0 gap-10">
<label class="block text-white text-sm font-bold cursor-pointer label">Other </label>
@@ -161,97 +216,129 @@
</div>
</div>
<div class="col-span-12 xl:col-span-6 p-5">
<div class="grid grid-cols-12">
<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 class="grid grid-cols-12 ">
<div class="col-span-12 text-2xl">Add a Credit Card</div>
<div class="col-span-12">
<form class="rounded-md px-8 pt-6 pb-8 mb-4 w-full" enctype="multipart/form-data"
@submit.prevent="onSubmitCard">
<div class="col-span-12 md:col-span-4 mb-5 md:mb-0 gap-10">
<label class="block text-white text-sm font-bold cursor-pointer label">Main Card</label>
<input v-model="CreateCardForm.basicInfo.main_card" class="checkbox" id="fill" type="checkbox" />
</div>
<div class="mb-4">
<label class="block text-white text-sm font-bold mb-2">Name on Card</label>
<input v-model="CreateCardForm.basicInfo.card_name"
class="input input-bordered input-sm w-full max-w-xs" id="title" type="text"
placeholder="Name on Card" />
<span v-if="v$.CreateCardForm.basicInfo.card_name.$error" class="text-red-600 text-center">
{{ v$.CreateCardForm.basicInfo.card_name.$errors[0].$message }}
</span>
</div>
<div class="mb-4">
<label class="block text-white text-sm font-bold mb-2">Card Number</label>
<input v-model="CreateCardForm.basicInfo.card_number"
class="input input-bordered input-sm w-full max-w-xs" id="title" type="text"
placeholder="Card Number" />
<span v-if="v$.CreateCardForm.basicInfo.card_number.$error" class="text-red-600 text-center">
{{ v$.CreateCardForm.basicInfo.card_number.$errors[0].$message }}
</span>
</div>
<div class="mb-4">
<label class="block text-white text-sm font-bold mb-2">Expiration Month</label>
<select v-model="CreateCardForm.basicInfo.expiration_month"
class="input input-bordered input-sm w-full max-w-xs" id="Month">
<option>01</option>
<option>02</option>
<option>03</option>
<option>04</option>
<option>05</option>
<option>06</option>
<option>07</option>
<option>08</option>
<option>09</option>
<option>10</option>
<option>11</option>
<option>12</option>
</select>
</div>
<div class="mb-4">
<label class="block text-white text-sm font-bold mb-2">Expiration Year</label>
<select v-model="CreateCardForm.basicInfo.expiration_year"
class="input input-bordered input-sm w-full max-w-xs" id="Month">
<option>2024</option>
<option>2025</option>
<option>2026</option>
<option>2027</option>
<option>2028</option>
<option>2029</option>
<option>2030</option>
</select>
<span v-if="v$.CreateCardForm.basicInfo.expiration_year.$error" class="text-red-600 text-center">
{{ v$.CreateCardForm.basicInfo.expiration_year.$errors[0].$message }}
</span>
</div>
<div class="mb-4">
<label class="block text-white text-sm font-bold mb-2">Type of Card</label>
<select v-model="CreateCardForm.basicInfo.type_of_card"
class="input input-bordered input-sm w-full max-w-xs" id="Month">
<option>Visa</option>
<option>MasterCard</option>
<option>Discover</option>
<option>American Express</option>
</select>
<span v-if="v$.CreateCardForm.basicInfo.type_of_card.$error" class="text-red-600 text-center">
{{ v$.CreateCardForm.basicInfo.type_of_card.$errors[0].$message }}
</span>
</div>
<div class="mb-4">
<label class="block text-white text-sm font-bold mb-2">Security Number</label>
<input v-model="CreateCardForm.basicInfo.security_number"
class="input input-bordered input-sm w-full max-w-xs" id="title" type="text"
placeholder="Back of card" />
<span v-if="v$.CreateCardForm.basicInfo.security_number.$error" class="text-red-600 text-center">
{{ v$.CreateCardForm.basicInfo.security_number.$errors[0].$message }}
</span>
</div>
<div class="mb-4">
<label class="block text-white text-sm font-bold mb-2">Zip Code</label>
<input v-model="CreateCardForm.basicInfo.zip_code"
class="input input-bordered input-sm w-full max-w-xs" id="title" type="text"
placeholder="Zip Code" />
</div>
<div class="col-span-12 md:col-span-12 flex mt-5 mb-5">
<button class="btn-sm btn bg-orange-600 text-white">
Save Credit Card
</button>
</div>
</form>
</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>
<table class="table col-span-12">
<!-- head -->
<thead>
<tr>
<th>id</th>
<th>Date</th>
<th>Gallons</th>
<th>Status</th>
<th>Prime</th>
<th>Same Day</th>
</tr>
</thead>
<tbody>
<!-- row 1 -->
<tr v-for="oil in deliveries" :key="oil['id']">
<td>{{ oil['id'] }}</td>
<td>{{ oil['expected_delivery_date'] }}</td>
<td>
<div v-if="oil['customer_asked_for_fill'] == 1">Fill</div>
<div v-else> {{ oil['gallons_ordered'] }}</div>
</td>
<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>
<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 btn-sm btn-secondary">Edit</button>
</router-link>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="grid grid-cols-12 ">
<div class="col-span-12 text-center font-bold text-3xl">Remind customer of tank Inspection</div>
<div class="col-span-12 text-center font-bold text-3xl">Ask how they heard about us</div>
</div>
</div>
</div>
@@ -307,6 +394,18 @@ export default defineComponent({
driver_driver: '',
},
},
CreateCardForm: {
basicInfo: {
card_name: '',
expiration_month: '',
expiration_year: '',
type_of_card: '',
security_number: '',
card_number: '',
zip_code: '',
main_card: false,
},
},
deliveries: [],
customer: {
id: 0,
@@ -328,6 +427,17 @@ export default defineComponent({
},
validations() {
return {
CreateCardForm: {
basicInfo: {
card_name: { required, minLength: minLength(1) },
expiration_month: { required, minLength: minLength(1) },
expiration_year: { required, minLength: minLength(1) },
security_number: { required, minLength: minLength(1) },
type_of_card: { required, minLength: minLength(1) },
card_number: { required, minLength: minLength(1) },
},
},
CreateOilOrderForm: {
basicInfo: {
gallons_ordered: { required, minLength: minLength(1) },
@@ -350,7 +460,7 @@ export default defineComponent({
},
mounted() {
this.getCustomer(this.$route.params.id)
this.getPaymentCards(this.$route.params.id);
this.getCustomerDelivery(this.$route.params.id)
},
@@ -392,6 +502,9 @@ export default defineComponent({
});
});
},
test() {
this.CreateOilOrderForm.basicInfo.gallons_ordered = '100'
},
getCustomerDelivery(userid: any) {
let path = import.meta.env.VITE_BASE_URL + '/delivery/customer/' + userid + '/1';
axios({
@@ -412,12 +525,13 @@ export default defineComponent({
})
.then((response: any) => {
this.userCards = response.data;
})
.catch(() => {
});
},
getPromos() {
let path = import.meta.env.VITE_BASE_URL + "/promo/all" ;
let path = import.meta.env.VITE_BASE_URL + "/promo/all";
axios({
method: "get",
url: path,
@@ -502,7 +616,7 @@ export default defineComponent({
text: "Did not add a driver",
type: "error",
});
pass += 1;
pass += 1;
}
if (this.CreateOilOrderForm.basicInfo.cash === false && this.CreateOilOrderForm.basicInfo.credit === false && this.CreateOilOrderForm.basicInfo.check === false && this.CreateOilOrderForm.basicInfo.other === false) {
notify({
@@ -510,12 +624,59 @@ export default defineComponent({
text: "Did not select a payment method",
type: "error",
});
pass += 1;
pass += 1;
}
if (pass == 0) {
this.CreateOilOrder(payload);
}
},
CreateCard(payload: {
card_name: string;
expiration_month: string;
expiration_year: string;
type_of_card: string;
security_number: string;
zip_code: string;
card_number: string;
main_card: boolean;
}) {
let path = import.meta.env.VITE_BASE_URL + "/payment/card/create/" + this.customer.id;
axios({
method: "post",
url: path,
data: payload,
withCredentials: true,
headers: authHeader(),
})
.then((response: any) => {
if (response.data.ok) {
this.getPaymentCards(this.$route.params.id)
}
if (response.data.error) {
notify({
title: "Error",
text: "Error adding card",
type: "error",
});
}
})
},
onSubmitCard() {
let payload = {
card_name: this.CreateCardForm.basicInfo.card_name,
card_number: this.CreateCardForm.basicInfo.card_number,
expiration_month: this.CreateCardForm.basicInfo.expiration_month,
expiration_year: this.CreateCardForm.basicInfo.expiration_year,
type_of_card: this.CreateCardForm.basicInfo.type_of_card,
security_number: this.CreateCardForm.basicInfo.security_number,
main_card: this.CreateCardForm.basicInfo.main_card,
zip_code: this.CreateCardForm.basicInfo.zip_code,
};
this.CreateCard(payload);
},
},
})
</script>