major update

This commit is contained in:
2024-10-17 17:01:42 -04:00
parent 9029993c49
commit c6f806f733
41 changed files with 899 additions and 254 deletions

View File

@@ -0,0 +1,283 @@
<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="grid grid-cols-1 rounded-md p-6 ">
<div class="text-[24px]">
Customer: {{ customer.customer_first_name }} {{ customer.customer_last_name }} | {{ 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="mb-4">
<label class="block text-white text-sm font-bold mb-2">Inspection Date </label>
<input v-model="CreateTankForm.basicInfo.last_tank_inspection"
class="input input-bordered input-sm w-full max-w-xs" id="title" type="date"
min="2023-01-01" max="2030-01-01" />
</div>
<div class="mb-4">
<label class="block text-white text-sm font-bold mb-2">Good Or bad Tank</label>
<label>
<input type="radio" name="goodtank1" value="true" class="radio"
v-model="CreateTankForm.basicInfo.tank_status" />
Good
</label>
<label>
<input type="radio" name="goodtank2" value="false" class="radio"
v-model="CreateTankForm.basicInfo.tank_status" />
Bad
</label>
</div>
<div class="mb-4">
<label class="block text-white text-sm font-bold mb-2">Tank Size</label>
<input v-model="CreateTankForm.basicInfo.tank_size"
class="input input-bordered input-sm w-full max-w-xs" id="title" type="text"
placeholder="Gallon size of tank" />
</div>
<div class="mb-4">
<label class="block text-white text-sm font-bold mb-2">Inside or Outside</label>
<label>
<input type="radio" name="insideoutside1" value="true" class="radio"
v-model="CreateTankForm.basicInfo.outside_or_inside" />
Inside
</label>
<label>
<input type="radio" name="insideoutside2" value="false" class="radio"
v-model="CreateTankForm.basicInfo.outside_or_inside" />
Outside
</label>
</div>
<div class="mb-4">
<label class="block text-white text-sm font-bold mb-2">Fill Location</label>
<input v-model="CreateTankForm.basicInfo.fill_location"
class="input input-bordered input-sm w-full max-w-xs" id="title" type="text"
placeholder="Fill Location" />
</div>
<div class="col-span-12 md:col-span-12 flex mt-5 mb-5">
<button class="btn btn-accent btn-sm">
Edit Customer Tank
</button>
</div>
</form>
</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'
export default defineComponent({
name: 'TankEdit',
components: {
Header,
SideBar,
Footer,
},
data() {
return {
user: {
id: '',
},
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: '',
},
tank: {
customer_id: 0,
last_tank_inspection: true,
tank_status: true,
outside_or_inside: true,
tank_size: 0,
},
CreateTankForm: {
basicInfo: {
last_tank_inspection: null,
tank_status: true,
outside_or_inside: true,
tank_size: 0,
fill_location: 0,
},
},
}
},
created() {
this.userStatus()
},
watch: {
$route() {
this.getCustomer(this.$route.params.id);
this.getCustomerDescription(this.$route.params.id);
this.getTank(this.$route.params.id);
},
},
mounted() {
this.getCustomer(this.$route.params.id);
this.getCustomerDescription(this.$route.params.id);
this.getTank(this.$route.params.id);
},
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;
this.user.id = response.data.user.id;
}
})
.catch(() => {
this.user.id = '';
})
},
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
})
},
getCustomerDescription(userid: any) {
let path = import.meta.env.VITE_BASE_URL + '/customer/description/' + userid;
axios({
method: 'get',
url: path,
headers: authHeader(),
}).then((response: any) => {
this.CreateTankForm.basicInfo.fill_location = response.data.fill_location;
})
},
getTank(customer_id: any) {
let path = import.meta.env.VITE_BASE_URL + "/customer/tank/" + customer_id;
axios({
method: "get",
url: path,
withCredentials: true,
headers: authHeader(),
})
.then((response: any) => {
this.tank = response.data
this.CreateTankForm.basicInfo.last_tank_inspection = response.data.last_tank_inspection;
this.CreateTankForm.basicInfo.tank_status = response.data.tank_status;
this.CreateTankForm.basicInfo.outside_or_inside = response.data.outside_or_inside;
this.CreateTankForm.basicInfo.tank_size = response.data.tank_size;
console.log(this.CreateTankForm.basicInfo.outside_or_inside)
console.log(this.CreateTankForm.basicInfo.tank_status)
})
},
editTank(payload: {
last_tank_inspection: any;
tank_status: boolean;
outside_or_inside: boolean;
tank_size: number;
fill_location: number;
}) {
let path = import.meta.env.VITE_BASE_URL + "/customer/edit/tank/" + this.$route.params.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.tank.customer_id } });
}
if (response.data.error) {
this.$router.push("/");
}
})
},
onSubmit() {
console.log(this.CreateTankForm.basicInfo.outside_or_inside)
console.log(this.CreateTankForm.basicInfo.tank_status)
let payload = {
last_tank_inspection: this.CreateTankForm.basicInfo.last_tank_inspection,
tank_status: this.CreateTankForm.basicInfo.tank_status,
outside_or_inside: this.CreateTankForm.basicInfo.outside_or_inside,
tank_size: this.CreateTankForm.basicInfo.tank_size,
fill_location: this.CreateTankForm.basicInfo.fill_location,
};
this.editTank(payload);
},
},
})
</script>
<style scoped></style>