This commit is contained in:
Bryan Mauger 2025-02-19 10:18:48 -05:00
parent 29b240819f
commit 19eb891ca9
3 changed files with 30 additions and 27 deletions

View file

@ -1,9 +1,6 @@
<template> <template>
<div class="donation-block"> <div class="donation-block">
<form <form ref="donationForm" id="donation-form" @submit.prevent="handleDonationAction">
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>
@ -26,11 +23,16 @@
<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" value=1 checked /> <input
name="amount"
id="one"
type="radio"
:value="donationValues[0]"
checked />
<label for="one" class="label">$1</label> <label for="one" class="label">$1</label>
<input name="amount" id="three" type="radio" value=3 /> <input name="amount" id="three" type="radio" :value="donationValues[1]" />
<label for="three" class="label">$3</label> <label for="three" class="label">$3</label>
<input name="amount" id="five" type="radio" value=5 /> <input name="amount" id="five" type="radio" :value="donationValues[2]" />
<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>
@ -78,6 +80,7 @@ export default {
modelValue: String, modelValue: String,
showDonationSuccess: Boolean, showDonationSuccess: Boolean,
showDonationError: Boolean, showDonationError: Boolean,
donationValues: Array,
}, },
computed: { computed: {
DonationHeadline() { DonationHeadline() {
@ -113,17 +116,14 @@ export default {
}, },
}, },
}, },
// data() {
// return {
// donationSuccess: true,
// donationError: true,
// };
// },
methods: { methods: {
handleDonationAction(submitEvent) { handleDonationAction(submitEvent) {
console.log("running handleDonationAction(), submitEvent.target.elements.amount.value: ", submitEvent.target.elements.amount.value) console.log(
"running handleDonationAction(), submitEvent.target.elements.amount.value: ",
submitEvent.target.elements.amount.value
);
this.selectedValue = submitEvent.target.elements.amount.value; this.selectedValue = submitEvent.target.elements.amount.value;
} },
}, },
components: { components: {
textLink, textLink,

View file

@ -223,7 +223,7 @@ export default {
const donationItems = lineItemsFromSubmittedOrder.supportingItems?.filter( const donationItems = lineItemsFromSubmittedOrder.supportingItems?.filter(
(item) => item.partNumber === "DONATION" (item) => item.partNumber === "DONATION"
); );
const donationAmount = (donationItems?.length > 0) ? donationItems[0].sellingPrice : 0; const donationAmount = donationItems?.length > 0 ? donationItems[0].sellingPrice : 0;
// Call the "next" function to complete the transition to this page. // Call the "next" function to complete the transition to this page.
next((vm) => { next((vm) => {
@ -244,7 +244,6 @@ export default {
donationAmount: 0, donationAmount: 0,
showDonationSuccess: null, showDonationSuccess: null,
showDonationError: null, showDonationError: null,
}; };
}, },
computed: { computed: {
@ -530,11 +529,11 @@ export default {
false false
).catch((error) => { ).catch((error) => {
// this.$refs.navbar.removeLoader(); // this.$refs.navbar.removeLoader();
console.error("Error!!! error: ", error) console.error("Error!!! error: ", error);
return error; return error;
}); });
console.log("ran addDonation()... (*fake call*) donationResponse: ", donationResponse) console.log("ran addDonation()... (*fake call*) donationResponse: ", donationResponse);
if (donationResponse?.status == "200") { if (donationResponse?.status == "200") {
this.showDonationSuccess = true; this.showDonationSuccess = true;
@ -553,16 +552,16 @@ export default {
false false
); );
} }
}, },
}, },
watch: { watch: {
donationAmount(newValue) { donationAmount(newValue) {
newValue = parseInt(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 // TODO - when backend code is final, then remove the below and restore the line above
if (newValue == 5) { if (newValue === 5) {
this.addDonation(newValue, "FAILING_PLATE"); // throws error this.addDonation(newValue, "FAILING_PLATE"); // throws error
} else { } else {
this.addDonation(newValue, "2fast"); // should give successful response this.addDonation(newValue, "2fast"); // should give successful response

View file

@ -3158,11 +3158,13 @@ export const actions = {
addDonationToSubmittedOrder(context, donationAmount) { addDonationToSubmittedOrder(context, donationAmount) {
console.log("running addDonationToSubmittedOrder()... donationAmount: ", donationAmount); console.log("running addDonationToSubmittedOrder()... donationAmount: ", donationAmount);
const submittedOrder = deepClone(baseMixin.methods.getSubmittedOrder()); const submittedOrder = deepClone(baseMixin.methods.getSubmittedOrder());
if (donationAmount > 0) { if (donationAmount > 0) {
console.log("running addDonationToSubmittedOrder()... adding donation to supportingItems in session storage ") 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,
@ -3177,9 +3179,11 @@ export const actions = {
}); });
} else { } else {
// filter out all donations // filter out all donations
console.log("running addDonationToSubmittedOrder()... removing all donation items in supportingItems in session storage ") console.log(
"running addDonationToSubmittedOrder()... removing all donation items in supportingItems in session storage "
);
const nonDonationItems = submittedOrder.lineItems.supportingItems.filter(item => { const nonDonationItems = submittedOrder.lineItems.supportingItems.filter((item) => {
return item.partType !== "DONATION"; return item.partType !== "DONATION";
}); });
submittedOrder.lineItems.supportingItems = nonDonationItems; submittedOrder.lineItems.supportingItems = nonDonationItems;