more inline with other page patterns
This commit is contained in:
parent
1a47f83301
commit
8a55e1dbdd
2 changed files with 42 additions and 16 deletions
13
src/layouts/schedule/helpers/schedule-helper.js
Normal file
13
src/layouts/schedule/helpers/schedule-helper.js
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import { storeActions } from "@/constants/store-actions";
|
||||
import baseMixin from "@/mixins/base-mixin.js";
|
||||
|
||||
export async function getAlertReasons(ctu) {
|
||||
const alertReasons = await baseMixin.methods.dispatchStoreAction(
|
||||
storeActions.GET_ALERT_REASONS_BY_CTU,
|
||||
{
|
||||
ctu: ctu,
|
||||
}
|
||||
)
|
||||
|
||||
return Promise.resolve(alertReasons);
|
||||
}
|
||||
|
|
@ -57,6 +57,9 @@ import datePicker from "@/digital-components/date-picker/date-picker";
|
|||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||
import { settleAllPromises } from "@/helpers/layout-helper";
|
||||
import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
|
||||
import {
|
||||
getAlertReasons,
|
||||
} from "@/layouts/schedule/helpers/schedule-helper";
|
||||
import {
|
||||
doesCopyContainRouterLink,
|
||||
splitCopyOnCMSPlaceHolder,
|
||||
|
|
@ -75,6 +78,7 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
selectedDate: null,
|
||||
alertReasons: [],
|
||||
weatherAlerts: [],
|
||||
mockSelectableDatesData: [
|
||||
{ year: 2023, month: 4, date: 13 },
|
||||
|
|
@ -94,19 +98,26 @@ export default {
|
|||
// Call APIs
|
||||
const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage);
|
||||
|
||||
const alertReasonsPromise = getAlertReasons(store.getters.order.serviceLocation.zipCodeCtu);
|
||||
|
||||
// Settle promises and get results
|
||||
const promiseResultMap = [
|
||||
{
|
||||
resultKey: "cmsContent",
|
||||
promise: cmsContentPromise,
|
||||
},
|
||||
{
|
||||
resultKey: "alertReasons",
|
||||
promise: alertReasonsPromise,
|
||||
},
|
||||
];
|
||||
|
||||
const resultMap = await settleAllPromises(promiseResultMap);
|
||||
|
||||
|
||||
// Call the "next" function to complete the transition to this page.
|
||||
next((vm) => {
|
||||
vm.setCmsContent(resultMap.cmsContent);
|
||||
vm.setData(resultMap.alertReasons);
|
||||
});
|
||||
},
|
||||
computed: {
|
||||
|
|
@ -130,25 +141,28 @@ export default {
|
|||
return true;
|
||||
// NEED TODO - WHAT ARE PAGE REQ'S FOR THIS PAGE?
|
||||
},
|
||||
setData(alertReasonsData) {
|
||||
if (alertReasonsData) {
|
||||
this.convertReasonsToCmsAlerts(alertReasonsData);
|
||||
}
|
||||
},
|
||||
cmsHeadlineTextFound(widgetName) {
|
||||
return this.getCmsContent(widgetName, "HeadlineText") !== ""
|
||||
},
|
||||
async getAlertReasons(ctu) {
|
||||
await this.dispatchStoreAction(
|
||||
storeActions.GET_ALERT_REASONS_BY_CTU,
|
||||
{
|
||||
ctu: ctu,
|
||||
}
|
||||
)
|
||||
convertReasonsToCmsAlerts(data) {
|
||||
this.weatherAlerts = data.reduce((newObj, alert) => {
|
||||
newObj.push({
|
||||
cmsWidgetName: `LocationAlert-${alert}`,
|
||||
alertReason: alert,
|
||||
});
|
||||
return newObj;
|
||||
}, []);
|
||||
},
|
||||
async getWeatherAlertReasons(ctu) {
|
||||
await getAlertReasons(ctu)
|
||||
.then((response) => {
|
||||
if (response.data) {
|
||||
this.weatherAlerts = response.data.reduce((newObj, alert) => {
|
||||
newObj.push({
|
||||
cmsWidgetName: `LocationAlert-${alert}`,
|
||||
alertReason: alert,
|
||||
});
|
||||
return newObj;
|
||||
}, []);
|
||||
this.convertReasonsToCmsAlerts(response.data);
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
|
|
@ -178,7 +192,6 @@ export default {
|
|||
datePicker,
|
||||
},
|
||||
mounted() {
|
||||
this.getAlertReasons(this.getServiceZipCtuCodeFromStore());
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in a new issue