Fixed problem

This commit is contained in:
Michaela Brydon 2024-08-07 17:23:20 -04:00
parent ca97fbd658
commit f68eefcff2
3 changed files with 12 additions and 10 deletions

View file

@ -97,7 +97,7 @@ function findAndReplaceGlobalStateValues(widgetModel, widgetName) {
* @param baseResponse
* @param clientResponse
*/
function processPageData(baseResponse, clientResponse) {
async function processPageData(baseResponse, clientResponse) {
const pageDataFromCms = {};
let widgets = [];
@ -140,6 +140,7 @@ function processPageData(baseResponse, clientResponse) {
widgets.forEach((widget) => {
// Global state value replacement.
console.log(widget);
const widgetWithReplacements = findAndReplaceGlobalStateValues(widget.Model, widget.Name);
// If we already have this widget, push it on the collection
@ -164,20 +165,20 @@ function processPageData(baseResponse, clientResponse) {
*
* @param issPage
*/
export function fetchCmsContentForPage(issPage) {
export async function fetchCmsContentForPage(issPage) {
const store = useMainStore();
const { clientName } = store.issConfig;
const { parentAccountNumber } = store.issConfig;
const clientOverride = clientName.length > 0 && parentAccountNumber > 0;
return (
return await (
store
.getPageData(issPage)
// Get the base/default page first.
.then((baseResponse) => {
.then(async (baseResponse) => {
if (!clientOverride) {
// Return the base page if there are no client override.
return processPageData(baseResponse, null);
return await processPageData(baseResponse, null);
}
// Else get the client override page.
const pageName = `${issPage}_${clientName.toLowerCase().replace(/ /g, '')}`;
@ -186,10 +187,11 @@ export function fetchCmsContentForPage(issPage) {
(clientResponse) =>
// Process the client override if it exists.
processPageData(baseResponse, clientResponse),
(error) => {
async (error) => {
console.error(error);
// Process the just the base if no client override exists.
return processPageData(baseResponse, null);
var x = await processPageData(baseResponse, null);
return x;
}
);
})

View file

@ -105,7 +105,6 @@ import {
import { toTitleCase } from '@/helpers/text-helper.js';
import { AppointmentTypeStrings } from '@/constants/schedule-constants';
import applicationConfig from '@/constants/application-config';
import submitType from '@/constants/submit-type';
export default {
name: 'order-confirmation',
@ -121,7 +120,7 @@ export default {
mixins: [BaseFormMixin],
async beforeRouteEnter(to, from, next) {
// Call APIs
const cmsContentPromise = fetchCmsContentForPage(to.query.issPage);
const cmsContent = fetchCmsContentForPage(to.query.issPage);
// Settle promises and get results
const promiseResultMap = [

View file

@ -419,7 +419,8 @@ export const useMainStore = defineStore({
experimentSettings: (state) => state.applicationUser.experiments
.filter((x) => !!x.isActive)
.map((x) => x.settings)
.reduce((r, c) => Object.assign(r, c), {}) ?? {}
.reduce((r, c) => Object.assign(r, c), {}) ?? {},
submittedOrder: () => JSON.parse(window.sessionStorage.getItem(webStorageConstants.SUBMITTED_ORDER))
},
actions:
{