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 { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||||
import { settleAllPromises } from "@/helpers/layout-helper";
|
import { settleAllPromises } from "@/helpers/layout-helper";
|
||||||
import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
|
import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
|
||||||
|
import {
|
||||||
|
getAlertReasons,
|
||||||
|
} from "@/layouts/schedule/helpers/schedule-helper";
|
||||||
import {
|
import {
|
||||||
doesCopyContainRouterLink,
|
doesCopyContainRouterLink,
|
||||||
splitCopyOnCMSPlaceHolder,
|
splitCopyOnCMSPlaceHolder,
|
||||||
|
|
@ -75,6 +78,7 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
selectedDate: null,
|
selectedDate: null,
|
||||||
|
alertReasons: [],
|
||||||
weatherAlerts: [],
|
weatherAlerts: [],
|
||||||
mockSelectableDatesData: [
|
mockSelectableDatesData: [
|
||||||
{ year: 2023, month: 4, date: 13 },
|
{ year: 2023, month: 4, date: 13 },
|
||||||
|
|
@ -94,19 +98,26 @@ export default {
|
||||||
// Call APIs
|
// Call APIs
|
||||||
const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage);
|
const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage);
|
||||||
|
|
||||||
|
const alertReasonsPromise = getAlertReasons(store.getters.order.serviceLocation.zipCodeCtu);
|
||||||
|
|
||||||
// Settle promises and get results
|
// Settle promises and get results
|
||||||
const promiseResultMap = [
|
const promiseResultMap = [
|
||||||
{
|
{
|
||||||
resultKey: "cmsContent",
|
resultKey: "cmsContent",
|
||||||
promise: cmsContentPromise,
|
promise: cmsContentPromise,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
resultKey: "alertReasons",
|
||||||
|
promise: alertReasonsPromise,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const resultMap = await settleAllPromises(promiseResultMap);
|
const resultMap = await settleAllPromises(promiseResultMap);
|
||||||
|
|
||||||
// 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) => {
|
||||||
vm.setCmsContent(resultMap.cmsContent);
|
vm.setCmsContent(resultMap.cmsContent);
|
||||||
|
vm.setData(resultMap.alertReasons);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
@ -130,25 +141,28 @@ export default {
|
||||||
return true;
|
return true;
|
||||||
// NEED TODO - WHAT ARE PAGE REQ'S FOR THIS PAGE?
|
// NEED TODO - WHAT ARE PAGE REQ'S FOR THIS PAGE?
|
||||||
},
|
},
|
||||||
|
setData(alertReasonsData) {
|
||||||
|
if (alertReasonsData) {
|
||||||
|
this.convertReasonsToCmsAlerts(alertReasonsData);
|
||||||
|
}
|
||||||
|
},
|
||||||
cmsHeadlineTextFound(widgetName) {
|
cmsHeadlineTextFound(widgetName) {
|
||||||
return this.getCmsContent(widgetName, "HeadlineText") !== ""
|
return this.getCmsContent(widgetName, "HeadlineText") !== ""
|
||||||
},
|
},
|
||||||
async getAlertReasons(ctu) {
|
convertReasonsToCmsAlerts(data) {
|
||||||
await this.dispatchStoreAction(
|
this.weatherAlerts = data.reduce((newObj, alert) => {
|
||||||
storeActions.GET_ALERT_REASONS_BY_CTU,
|
newObj.push({
|
||||||
{
|
cmsWidgetName: `LocationAlert-${alert}`,
|
||||||
ctu: ctu,
|
alertReason: alert,
|
||||||
}
|
});
|
||||||
)
|
return newObj;
|
||||||
|
}, []);
|
||||||
|
},
|
||||||
|
async getWeatherAlertReasons(ctu) {
|
||||||
|
await getAlertReasons(ctu)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
this.weatherAlerts = response.data.reduce((newObj, alert) => {
|
this.convertReasonsToCmsAlerts(response.data);
|
||||||
newObj.push({
|
|
||||||
cmsWidgetName: `LocationAlert-${alert}`,
|
|
||||||
alertReason: alert,
|
|
||||||
});
|
|
||||||
return newObj;
|
|
||||||
}, []);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
|
@ -178,7 +192,6 @@ export default {
|
||||||
datePicker,
|
datePicker,
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.getAlertReasons(this.getServiceZipCtuCodeFromStore());
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue