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

@@ -68,8 +68,11 @@
</td> </td>
<td>{{ oil['estimated_gallons_left'] }}</td> <td>{{ oil['estimated_gallons_left'] }}</td>
<td> <td>
<div v-if="oil['auto_status'] === 0"></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'] === 1">Waiting on Delivery </div>
<div v-else-if="oil['auto_status'] === 2">Pending Payment Confirmation </div>
<div v-else></div> <div v-else></div>
</td> </td>
<td>{{ oil['customer_full_name'] }}</td> <td>{{ oil['customer_full_name'] }}</td>
@@ -91,6 +94,7 @@
</router-link> </router-link>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
@@ -108,6 +112,8 @@ import authHeader from '../../services/auth.header'
import Header from '../../layouts/headers/headerauth.vue' import Header from '../../layouts/headers/headerauth.vue'
import SideBar from '../../layouts/sidebar/sidebar.vue' import SideBar from '../../layouts/sidebar/sidebar.vue'
import Footer from '../../layouts/footers/footer.vue' import Footer from '../../layouts/footers/footer.vue'
import { notify } from "@kyvg/vue3-notification";
export default defineComponent({ export default defineComponent({
name: 'AutomaticHome', name: 'AutomaticHome',
@@ -138,6 +144,7 @@ export default defineComponent({
created() { created() {
this.userStatus() this.userStatus()
this.getDriversList() this.getDriversList()
this.get_oil_orders()
}, },
mounted() { mounted() {
this.get_oil_orders() this.get_oil_orders()
@@ -163,6 +170,7 @@ export default defineComponent({
}, },
get_oil_orders() { get_oil_orders() {
let path = import.meta.env.VITE_AUTO_URL + '/delivery/all/customers'; let path = import.meta.env.VITE_AUTO_URL + '/delivery/all/customers';
axios({ axios({
method: 'get', method: 'get',
@@ -170,6 +178,7 @@ export default defineComponent({
withCredentials: true, withCredentials: true,
headers: authHeader(), headers: authHeader(),
}).then((response: any) => { }).then((response: any) => {
console.log("here")
this.deliveries = response.data this.deliveries = response.data
}) })
@@ -193,8 +202,7 @@ export default defineComponent({
get_auto_assignment() { 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[] = []; const selectedValues : any[] = [];
for (const id in this.checkedMaterials) { for (const id in this.checkedMaterials) {
@@ -213,6 +221,23 @@ export default defineComponent({
withCredentials: true, withCredentials: true,
headers: authHeader(), headers: authHeader(),
}).then((response: any) => { }).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() this.get_oil_orders()
}) })
}, },

View File

@@ -40,18 +40,20 @@
</router-link> </router-link>
<div v-if="automatic_status === 0"> <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> </button>
</div> </div>
<div v-else> <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> </button>
</div> </div>
</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"> <div class="col-span-12 font-bold flex">
{{ customer.customer_first_name }} {{ customer.customer_first_name }}
@@ -359,12 +361,7 @@ export default defineComponent({
this.getPage(this.delivery_page) this.getPage(this.delivery_page)
}, },
computed: { computed: {
buttonText() {
return this.isTrue ? 'Become WillCall Customer' : 'Become Automatic Customer';
},
autoText() {
return this.isTrue? 'Automatic' : 'Will Call';
}
}, },
watch: { watch: {
$route() { $route() {
@@ -402,7 +399,6 @@ export default defineComponent({
headers: authHeader(), headers: authHeader(),
}).then((response: any) => { }).then((response: any) => {
this.automatic_status = response.data.status this.automatic_status = response.data.status
console.log(this.automatic_status)
}) })
}, },
@@ -415,24 +411,37 @@ export default defineComponent({
url: path, url: path,
headers: authHeader(), headers: authHeader(),
}).then((response: any) => { }).then((response: any) => {
this.isTrue = !this.isTrue;
this.automatic_response = response.data.status this.automatic_response = response.data.status
if (this.automatic_response == 1) { if (this.automatic_response == 1) {
this.$notify({ this.$notify({
title: "Automatic Status", title: "Automatic Status",
text: 'Customer is now Automatic Customer', text: 'Customer is now Automatic Customer',
type: 'Success' type: 'Success'
}) });
} else { } else if (this.automatic_response == 2) {
this.$notify({ this.$notify({
title: "Automatic Status", title: "Automatic Status",
text: 'Customer is now will call', text: 'Customer does not have a main credit card. Can not make automatic.',
type: 'Success' 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", type: "error",
}); });
}); });
}, },
editOilOrder(payload: { editOilOrder(payload: {
@@ -636,7 +635,7 @@ export default defineComponent({
gallons: string, gallons: string,
delivery_id: 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({ axios({
method: "put", method: "put",
url: path, url: path,
@@ -651,7 +650,7 @@ export default defineComponent({
type: 'postive', type: 'postive',
title: 'top' title: 'top'
}) })
this.$router.push({ name: "DeliveryHome" });
} }
else { else {
notify({ notify({