first commit

This commit is contained in:
2024-02-28 16:03:19 -05:00
commit 54ee44ba66
84 changed files with 15919 additions and 0 deletions

446
src/pages/pay/pay_oil.vue Normal file
View File

@@ -0,0 +1,446 @@
<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>
</li>
</ul>
</div>
<div class="grid grid-cols-1 rounded-md p-6 mb-5">
<div class=" col-span-12 text-[24px]">
Confirm Payment Oil Delivery {{ delivery.id }}
</div>
<div class="grid grid-cols-12 bg-neutral mb-5">
<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 class="col-span-12 ">
<div class="grid grid-cols-12 mb-5 bg-neutral">
<div class="col-span-12 py-3">
<div v-if="delivery.delivery_status == 0"> Delivery Status: Waiting</div>
<div v-else-if="delivery.delivery_status == 1">Delivery Status: delivered</div>
<div v-else-if="delivery.delivery_status == 2">Delivery Status: Out for Delivery</div>
<div v-else-if="delivery.delivery_status == 3">Delivery Status: Cancelled</div>
<div v-else-if="delivery.delivery_status == 4">Delivery Status: Partial Delivery</div>
<div v-else-if="delivery.delivery_status == 5">Delivery Status: Issue</div>
<div v-else></div>
</div>
<div class="col-span-12 py-3">Expected Delivery: {{ delivery.expected_delivery_date }}</div>
</div>
<div class="grid grid-cols-12 mb-5 bg-neutral">
<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.card_number }}
</div>
<div class="flex p-1 pl-4">
{{ card.expiration_month }}/ {{ card.expiration_year }}
</div>
<div class="flex p-1 pl-4">
{{ card.security_number }}
</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.card_number }}
</div>
<div class="flex p-1 pl-4">
{{ card.expiration_month }}/ {{ card.expiration_year }}
</div>
<div class="flex p-1 pl-4">
{{ card.security_number }}
</div>
</div>
</div>
</div>
</div>
</div>
<div class="grid grid-cols-12 mb-5 bg-neutral">
<div class="col-span-12 py-3">Price / Gallon: {{ delivery.customer_price }}</div>
<div class="col-span-12 py-3">
<div v-if="delivery.customer_asked_for_fill == 1"> Gallons Ordered: FILL (250)</div>
<div v-else> Gallons Ordered: {{ delivery.gallons_ordered }}</div>
</div>
<div class="col-span-12 py-3" v-if="delivery.prime == 1">
Prime Fee: {{ delivery.prime }}
</div>
<div class="col-span-12 py-3" v-if="delivery.same_day == 1">
Same Day: {{ delivery.same_day }}
</div>
<div class="col-span-12 font-bold py-5 text-lg">Total: {{ delivery.total_price }}</div>
</div>
</div>
<div class="flex justify-between">
<!-- <button class="btn" @click="checkoutOilCreditStripe()">-->
<!-- Pay Credit Card (Stripe)-->
<!-- </button>-->
<button class="btn" @click="checkoutOilUpdatePayment(0)">
Cash Payment
</button>
<button class="btn" @click="checkoutOilUpdatePayment(1)">
Pay Credit Terminal
</button>
</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 {notify} from "@kyvg/vue3-notification"
import {minLength, required} from "@vuelidate/validators";
export default defineComponent({
name: 'PayOil',
components: {
Header,
SideBar,
Footer,
},
data() {
return {
v$: useValidate(),
user: {
user_id: 0,
},
delivery: {
id: 0,
customer_id: 0,
customer_name: '',
customer_address: '',
customer_town: '',
customer_state: 0,
customer_zip: '',
gallons_ordered: 0,
customer_asked_for_fill: 0,
gallons_delivered: 0,
customer_filled: 0,
delivery_status: 0,
when_ordered: '',
when_delivered: '',
expected_delivery_date: '',
automatic: 0,
oil_id: 0,
supplier_price: 0,
customer_price: 0,
customer_temperature: 0,
dispatcher_notes: '',
prime: 0,
same_day: 0,
payment_type: 0,
payment_card_id: 0,
driver_employee_id: 0,
driver_first_name: '',
driver_last_name: '',
pre_charge_amount: 0,
total_price: 0,
},
credit_cards: [
{
id: 0,
name_on_card: '',
main_card: false,
card_number: '',
expiration_month: '',
type_of_card: '',
last_four_digits: '',
expiration_year: '',
security_number: 0,
}
],
stripe: null,
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: '',
},
}
},
validations() {
return {
CreateOilOrderForm: {
basicInfo: {
gallons_ordered: {required, minLength: minLength(1)},
expected_delivery_date: {required},
},
},
};
},
created() {
this.userStatus()
},
watch: {
$route() {
},
},
mounted() {
this.getOilOrder(this.$route.params.id)
// this.getStripePublishableKey();
},
methods: {
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;
}
})
},
getOilOrder(delivery_id: any) {
let path = import.meta.env.VITE_BASE_URL + "/delivery/order/" + delivery_id;
axios({
method: "get",
url: path,
withCredentials: true,
})
.then((response: any) => {
this.delivery = response.data;
this.getCustomer(this.delivery.customer_id)
this.getCreditCards(this.delivery.customer_id)
})
.catch(() => {
notify({
title: "Error",
text: "Could not get oil order",
type: "error",
});
});
},
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
})
},
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
})
},
checkoutOilUpdateCreditStripe() {
let path = import.meta.env.VITE_BASE_URL + "/delivery/cash/" + this.delivery.id + '/2';
axios({
method: "PUT",
url: path,
})
.then((response: any) => {
if (response.data.ok) {
notify({
title: "Success",
text: "marked payment as STRIPE credit card",
type: "error",
});
}
})
.catch(() => {
notify({
title: "Error",
text: "Could not update with credit card",
type: "error",
});
});
},
checkoutOilUpdatePayment(payment_type: number) {
let path = import.meta.env.VITE_BASE_URL + "/delivery/cash/" + this.delivery.id + '/' + payment_type;
axios({
method: "PUT",
url: path,
})
.then((response: any) => {
if (response.data.ok) {
if (payment_type == 1) {
notify({
title: "Success",
text: "marked payment as credit (bank terminal)",
type: "success",
});
}
if (payment_type == 0) {
notify({
title: "Success",
text: "marked payment as cash (COD)",
type: "success",
});
}
this.$router.push({name: "customerProfile", params: {id: this.customer.id}});
}
})
.catch(() => {
notify({
title: "Error",
text: "Could not update wth cash",
type: "error",
});
});
},
// checkoutOilCreditStripe() {
//
// let path = import.meta.env.VITE_PAY_URL + "/pay/charge";
// axios({
// method: "get",
// url: path,
// })
// .then((response: any) => {
// this.checkoutOilUpdateCreditStripe();
// // Redirect to Stripe Checkout
// return this.stripe.redirectToCheckout({sessionId: response.data.sessionId});
// })
// .catch(() => {
// notify({
// title: "Error",
// text: "Could not find customer",
// type: "error",
// });
// });
// },
// getStripePublishableKey() {
// let path = import.meta.env.VITE_PAY_URL + "/pay/config";
// axios({
// method: "get",
// url: path,
// })
// .then((response: any) => {
// this.stripe = Stripe(response.data.publicKey);
// })
// .catch(() => {
// notify({
// title: "Error",
// text: "Could not find customer",
// type: "error",
// });
// });
// },
//
},
})
</script>
<style scoped></style>