This commit is contained in:
Leah Schumann 2023-04-11 12:41:56 -04:00
parent 634c86bd4f
commit 96133bc8ec

View file

@ -1,12 +1,18 @@
<template> <template>
<transition name="fade" mode="out-in"> <transition name="fade" mode="out-in">
<div class="shop-question" aria-live="polite"> <div class="shop-question" aria-live="polite">
<alert
ref="alertDropoffInformation"
v-if="displayDropoffInformation"
class="mb-4 drop-off-alert"
cmsWidgetName="AlertDropoffInformationWidget"
alertClass="alert-info"
v-bind:isDismissible="false" />
<buttonQuestion <buttonQuestion
class="radioQuestion" class="radioQuestion"
isOverflowScrollable isOverflowScrollable
selectingInitiatesLoad
:questionText="questionText" :questionText="questionText"
:answers="shops" :answers="answers"
groupName="ChooseShop" groupName="ChooseShop"
textPosition="text-start" textPosition="text-start"
v-model="selectedValue" v-model="selectedValue"
@ -16,21 +22,27 @@
</template> </template>
<script> <script>
import alert from "@/ux-components/alert/alert";
import buttonQuestion from "@/digital-components/button-question/button-question"; import buttonQuestion from "@/digital-components/button-question/button-question";
import { storeActions } from "@/constants/store-actions.js";
import store from "@/store";
// Supporting files // Supporting files
import { defineRule } from "vee-validate"; import { defineRule } from "vee-validate";
import { required } from "@/helpers/validation-rules"; import { required } from "@/helpers/validation-rules";
import { errorMessages } from "@/constants/error-messages"; import { errorMessages } from "@/constants/error-messages";
import baseMixin from "@/mixins/base-mixin.js";
defineRule("option-required", required(errorMessages.OPTION_REQUIRED)); defineRule("option-required", required(errorMessages.OPTION_REQUIRED));
export default { export default {
name: "shop-question", name: "shop-question",
mixins: [baseMixin],
data() { data() {
return { return {
shops: [], shops: [],
} };
}, },
props: { props: {
modelValue: String, modelValue: String,
@ -40,6 +52,7 @@ export default {
validationRules: String, validationRules: String,
}, },
components: { components: {
alert,
buttonQuestion, buttonQuestion,
}, },
computed: { computed: {
@ -55,28 +68,90 @@ export default {
}, },
}, },
answers() { answers() {
return this.getCmsContent(this.cmsWidgetName, "Answers"); // Map API result data, to address-vehicles data structure
const mappedData = this.shops.map((s) => {
return {
Name: s.providerNumber,
Text: `${s.city}<span class='distance'>${s.distance} mi</span>`,
SubText: `${s.streetAddress}, ${s.city}, ${s.state} ${s.zipCode}`,
};
});
return mappedData;
},
displayDropoffInformation() {
return this.isDropoff;
}, },
}, },
methods: { methods: {
loadInitialData() { loadInitialData() {
return this.dispatchStoreAction(storeActions.GET_VEHICLE_MAKES, { return baseMixin.methods.dispatchStoreAction(storeActions.GET_PROVIDER_LOCATIONS, {
year: store.getters.vehicle.year, serviceZipCode: this.serviceZipCode,
}); });
}, },
initializeComponent(initialData) { initializeComponent(initialData) {
this.makes = initialData; this.shops = initialData;
},
async updateShopList() {
const result = await this.dispatchStoreAction(storeActions.GET_PROVIDER_LOCATIONS, {
serviceZipCode: this.serviceZipCode,
});
return result.data;
},
},
watch: {
serviceZipCode: {
async handler() {
this.shops = await this.updateShopList();
},
}, },
}, },
}; };
</script> </script>
<style lang="scss"> <style lang="scss">
.modal-dialog { .shop-question {
margin-top: 1rem !important;
.question-text { .question-text {
& > span { margin-top: 0.5rem !important;
text-align: left; }
.button-content {
.button-label-copy {
display: flex;
font-weight: 500;
line-height: 1.5rem;
align-items: center;
margin-bottom: 0.25rem !important;
.distance {
color: #727676;
margin-left: 0.25rem;
font-weight: 400;
line-height: 1.25rem;
font-size: 0.75rem;
}
}
.button-label-sub-copy {
font-weight: 400;
margin-bottom: 0rem !important;
} }
} }
} }
.drop-off-alert {
.alert-heading {
text-align: left;
font-size: 0.75rem !important;
line-height: 1.25rem !important;
}
margin-top: 0.5rem !important;
padding-left: 1.5rem !important;
padding-right: 0.5rem !important;
}
</style> </style>