Fixed button automatic

This commit is contained in:
2024-07-29 13:46:53 -04:00
parent 47e57f5758
commit 2c6077e0fa
3 changed files with 60 additions and 27 deletions

View File

@@ -62,14 +62,17 @@
<tbody>
<!-- row 1 -->
<tr v-for="oil in deliveries" :key="oil['id']">
<td>
<input type="checkbox" :value="oil['id']" v-model="checkedMaterials">
</td>
<td>{{ oil['estimated_gallons_left'] }}</td>
<td>
<div v-if="oil['auto_status'] === 0"></div>
<div v-else-if="oil['auto_status'] === 1">Waiting on Delivery</div>
<div v-if="oil['auto_status'] === 0">
</div>
<div v-else-if="oil['auto_status'] === 1">Waiting on Delivery </div>
<div v-else-if="oil['auto_status'] === 2">Pending Payment Confirmation </div>
<div v-else></div>
</td>
<td>{{ oil['customer_full_name'] }}</td>
@@ -91,6 +94,7 @@
</router-link>
</td>
</tr>
</tbody>
</table>
</div>
@@ -108,6 +112,8 @@ 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 { notify } from "@kyvg/vue3-notification";
export default defineComponent({
name: 'AutomaticHome',
@@ -138,6 +144,7 @@ export default defineComponent({
created() {
this.userStatus()
this.getDriversList()
this.get_oil_orders()
},
mounted() {
this.get_oil_orders()
@@ -163,6 +170,7 @@ export default defineComponent({
},
get_oil_orders() {
let path = import.meta.env.VITE_AUTO_URL + '/delivery/all/customers';
axios({
method: 'get',
@@ -170,6 +178,7 @@ export default defineComponent({
withCredentials: true,
headers: authHeader(),
}).then((response: any) => {
console.log("here")
this.deliveries = response.data
})
@@ -193,8 +202,7 @@ export default defineComponent({
get_auto_assignment() {
let path = import.meta.env.VITE_AUTO_URL + '/delivery/create/delivery';
let path = import.meta.env.VITE_AUTO_URL + '/delivery/create';
const selectedValues : any[] = [];
for (const id in this.checkedMaterials) {
@@ -213,6 +221,23 @@ export default defineComponent({
withCredentials: true,
headers: authHeader(),
}).then((response: any) => {
console.log(response.data.count)
if (response.data.count > 0) {
notify({
title: "Success",
text: "Added automatics to delivery",
type: "success",
});
} else {
notify({
title: "Failure",
text: "Incorrect driver or no auto selection.",
type: "error",
});
}
this.get_oil_orders()
})
},

View File

@@ -40,18 +40,20 @@
</router-link>
<div v-if="automatic_status === 0">
<button :innerText="buttonText" v-on:click="userAutomatic(customer.id)" class="btn btn-accent btn-sm">
<button v-on:click="userAutomatic(customer.id)" class="btn btn-accent btn-sm">
Become Automatic Customer
</button>
</div>
<div v-else>
<button :innerText="buttonText" v-on:click="userAutomatic(customer.id)" class="btn btn-accent btn-sm">
<button v-on:click="userAutomatic(customer.id)" class="btn btn-accent btn-sm">
Become Will Call Customer
</button>
</div>
</div>
<div class="col-span-12 font-bold flex pb-5 text-lg" v-if="automatic_status === 1" :innerText="autoText">Automatic </div>
<div class="col-span-12 font-bold flex pb-5 text-lg" v-if="automatic_status === 1" >Automatic </div>
<div class="col-span-12 font-bold flex pb-5 text-lg" :innerText="autoText" v-else>Will Call</div>
<div class="col-span-12 font-bold flex pb-5 text-lg" v-else>Will Call</div>
<div class="col-span-12 font-bold flex">
{{ customer.customer_first_name }}
@@ -359,12 +361,7 @@ export default defineComponent({
this.getPage(this.delivery_page)
},
computed: {
buttonText() {
return this.isTrue ? 'Become WillCall Customer' : 'Become Automatic Customer';
},
autoText() {
return this.isTrue? 'Automatic' : 'Will Call';
}
},
watch: {
$route() {
@@ -402,7 +399,6 @@ export default defineComponent({
headers: authHeader(),
}).then((response: any) => {
this.automatic_status = response.data.status
console.log(this.automatic_status)
})
},
@@ -415,24 +411,37 @@ export default defineComponent({
url: path,
headers: authHeader(),
}).then((response: any) => {
this.isTrue = !this.isTrue;
this.automatic_response = response.data.status
if (this.automatic_response == 1) {
this.$notify({
title: "Automatic Status",
text: 'Customer is now Automatic Customer',
type: 'Success'
})
} else {
});
} else if (this.automatic_response == 2) {
this.$notify({
title: "Automatic Status",
text: 'Customer is now will call',
type: 'Success'
})
text: 'Customer does not have a main credit card. Can not make automatic.',
type: 'Error'
});
} else if (this.automatic_response == 3) {
this.$notify({
title: "Automatic Status",
text: 'Customer is now a Call in ',
type: 'Info' // Adjust type if needed
});
} else {
this.$notify({
title: "Automatic Status",
text: 'Customer is now Manual Customer',
type: 'Warning' // Adjust type if needed
});
}
this.getCustomer(this.$route.params.id);
this.getCreditCards(this.$route.params.id)
this.getCreditCardsCount(this.$route.params.id)
})
},

View File

@@ -594,7 +594,6 @@ export default defineComponent({
type: "error",
});
});
},
editOilOrder(payload: {
@@ -636,7 +635,7 @@ export default defineComponent({
gallons: string,
delivery_id: string,
}) {
let path = import.meta.env.VITE_AUTO_URL + "/delivery/add/delivery"
let path = import.meta.env.VITE_AUTO_URL + "/confirm/delivery"
axios({
method: "put",
url: path,
@@ -651,7 +650,7 @@ export default defineComponent({
type: 'postive',
title: 'top'
})
this.$router.push({ name: "DeliveryHome" });
}
else {
notify({