CASH-132: temp updates to enable donation block
This commit is contained in:
parent
cb22453eb0
commit
29b240819f
3 changed files with 144 additions and 82 deletions
|
|
@ -1,5 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="donation-block">
|
<div class="donation-block">
|
||||||
|
<form
|
||||||
|
ref="donationForm"
|
||||||
|
id="donation-form"
|
||||||
|
@submit.prevent="handleDonationAction">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<p class="headline text-center" v-html="DonationHeadline"></p>
|
<p class="headline text-center" v-html="DonationHeadline"></p>
|
||||||
|
|
@ -22,11 +26,11 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="donation-slider my-4">
|
<div class="donation-slider my-4">
|
||||||
<input name="amount" id="one" type="radio" checked />
|
<input name="amount" id="one" type="radio" value=1 checked />
|
||||||
<label for="one" class="label">$1</label>
|
<label for="one" class="label">$1</label>
|
||||||
<input name="amount" id="three" type="radio" />
|
<input name="amount" id="three" type="radio" value=3 />
|
||||||
<label for="three" class="label">$3</label>
|
<label for="three" class="label">$3</label>
|
||||||
<input name="amount" id="five" type="radio" />
|
<input name="amount" id="five" type="radio" value=5 />
|
||||||
<label for="five" class="label">$5</label>
|
<label for="five" class="label">$5</label>
|
||||||
<div class="indicator-bar"></div>
|
<div class="indicator-bar"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -42,7 +46,7 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div
|
<div
|
||||||
v-if="donationSuccess"
|
v-if="showDonationSuccess"
|
||||||
class="d-flex justify-content-center align-items-center btn-success w-100 mb-2"
|
class="d-flex justify-content-center align-items-center btn-success w-100 mb-2"
|
||||||
v-html="DonationThanksAlertWidget"></div>
|
v-html="DonationThanksAlertWidget"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -50,7 +54,7 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<alert
|
<alert
|
||||||
v-if="donationError"
|
v-if="showDonationError"
|
||||||
cmsWidgetName="DonationErrorWidget"
|
cmsWidgetName="DonationErrorWidget"
|
||||||
alertClass="alert-danger" />
|
alertClass="alert-danger" />
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -60,6 +64,7 @@
|
||||||
<p class="my-4 mx-0 text-center caption" v-html="DonationFooterText"></p>
|
<p class="my-4 mx-0 text-center caption" v-html="DonationFooterText"></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
@ -71,6 +76,8 @@ export default {
|
||||||
props: {
|
props: {
|
||||||
cmsWidgetName: String,
|
cmsWidgetName: String,
|
||||||
modelValue: String,
|
modelValue: String,
|
||||||
|
showDonationSuccess: Boolean,
|
||||||
|
showDonationError: Boolean,
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
DonationHeadline() {
|
DonationHeadline() {
|
||||||
|
|
@ -106,11 +113,17 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data() {
|
// data() {
|
||||||
return {
|
// return {
|
||||||
donationSuccess: true,
|
// donationSuccess: true,
|
||||||
donationError: true,
|
// donationError: true,
|
||||||
};
|
// };
|
||||||
|
// },
|
||||||
|
methods: {
|
||||||
|
handleDonationAction(submitEvent) {
|
||||||
|
console.log("running handleDonationAction(), submitEvent.target.elements.amount.value: ", submitEvent.target.elements.amount.value)
|
||||||
|
this.selectedValue = submitEvent.target.elements.amount.value;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
textLink,
|
textLink,
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,9 @@
|
||||||
<donationBlock
|
<donationBlock
|
||||||
cmsWidgetName="DonationWidget"
|
cmsWidgetName="DonationWidget"
|
||||||
v-model="donationAmount"
|
v-model="donationAmount"
|
||||||
:donationValues="donationValues" />
|
:donationValues="donationValues"
|
||||||
|
:showDonationSuccess="showDonationSuccess"
|
||||||
|
:showDonationError="showDonationError" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h3>donationAmount: {{ donationAmount }}</h3>
|
<h3>donationAmount: {{ donationAmount }}</h3>
|
||||||
|
|
@ -239,7 +241,10 @@ export default {
|
||||||
vaps: [],
|
vaps: [],
|
||||||
submittedOrder: null,
|
submittedOrder: null,
|
||||||
shouldHideRecalibration: null,
|
shouldHideRecalibration: null,
|
||||||
donationAmount: null,
|
donationAmount: 0,
|
||||||
|
showDonationSuccess: null,
|
||||||
|
showDonationError: null,
|
||||||
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
@ -513,21 +518,55 @@ export default {
|
||||||
forwardButtonAction() {
|
forwardButtonAction() {
|
||||||
window.location.assign(location.protocol + "//" + location.host);
|
window.location.assign(location.protocol + "//" + location.host);
|
||||||
},
|
},
|
||||||
async addDonation(amount) {
|
async addDonation(amount, plateTemp) {
|
||||||
// try to call API to add donation to order
|
// try to call API to add donation to order
|
||||||
|
|
||||||
// TODO - change the following to check the response from the call
|
// TEMP DUMMY CALL TO SIMULATE SUCCESS OR ERROR FROM API CALL
|
||||||
|
// TO BE REPLACED BY REAL CALL LATER
|
||||||
|
const donationResponse = await this.dispatchStoreActionWithLogging(
|
||||||
|
storeActions.LOOKUP_VIN_BY_PLATE,
|
||||||
|
{ licensePlate: plateTemp, licenseState: "OH" },
|
||||||
|
"test",
|
||||||
|
false
|
||||||
|
).catch((error) => {
|
||||||
|
// this.$refs.navbar.removeLoader();
|
||||||
|
console.error("Error!!! error: ", error)
|
||||||
|
return error;
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("ran addDonation()... (*fake call*) donationResponse: ", donationResponse)
|
||||||
|
|
||||||
|
if (donationResponse?.status == "200") {
|
||||||
|
this.showDonationSuccess = true;
|
||||||
|
this.showDonationError = false;
|
||||||
const donationResponse = await baseMixin.methods.dispatchStoreAction(
|
const donationResponse = await baseMixin.methods.dispatchStoreAction(
|
||||||
storeActions.ADD_DONATION_TO_SUBMITTED_ORDER,
|
storeActions.ADD_DONATION_TO_SUBMITTED_ORDER,
|
||||||
amount,
|
amount,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
this.showDonationError = true;
|
||||||
|
this.showDonationSuccess = false;
|
||||||
|
const donationResponse = await baseMixin.methods.dispatchStoreAction(
|
||||||
|
storeActions.ADD_DONATION_TO_SUBMITTED_ORDER,
|
||||||
|
0,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
donationAmount(newValue) {
|
donationAmount(newValue) {
|
||||||
console.log("WATCHED donationAmount changed: ", newValue);
|
console.log("WATCHED donationAmount changed: ", newValue);
|
||||||
this.addDonation(newValue);
|
|
||||||
|
// this.addDonation(newValue);
|
||||||
|
// TODO - when backend code is final, then remove the below and restore the line above
|
||||||
|
if (newValue == 5) {
|
||||||
|
this.addDonation(newValue, "FAILING_PLATE"); // throws error
|
||||||
|
} else {
|
||||||
|
this.addDonation(newValue, "2fast"); // should give successful response
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
|
|
||||||
|
|
@ -3161,6 +3161,8 @@ export const actions = {
|
||||||
|
|
||||||
const submittedOrder = deepClone(baseMixin.methods.getSubmittedOrder());
|
const submittedOrder = deepClone(baseMixin.methods.getSubmittedOrder());
|
||||||
|
|
||||||
|
if (donationAmount > 0) {
|
||||||
|
console.log("running addDonationToSubmittedOrder()... adding donation to supportingItems in session storage ")
|
||||||
submittedOrder.lineItems.supportingItems.push({
|
submittedOrder.lineItems.supportingItems.push({
|
||||||
partNumber: "DONATION",
|
partNumber: "DONATION",
|
||||||
description: null,
|
description: null,
|
||||||
|
|
@ -3173,7 +3175,15 @@ export const actions = {
|
||||||
salesTax: null,
|
salesTax: null,
|
||||||
id: "donation-" + donationAmount,
|
id: "donation-" + donationAmount,
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
// filter out all donations
|
||||||
|
console.log("running addDonationToSubmittedOrder()... removing all donation items in supportingItems in session storage ")
|
||||||
|
|
||||||
|
const nonDonationItems = submittedOrder.lineItems.supportingItems.filter(item => {
|
||||||
|
return item.partType !== "DONATION";
|
||||||
|
});
|
||||||
|
submittedOrder.lineItems.supportingItems = nonDonationItems;
|
||||||
|
}
|
||||||
// set to local storage
|
// set to local storage
|
||||||
window.sessionStorage.setItem("submittedOrder", JSON.stringify(submittedOrder));
|
window.sessionStorage.setItem("submittedOrder", JSON.stringify(submittedOrder));
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue