This commit is contained in:
Jeremy Zimmerman 2022-12-09 16:00:31 -05:00
parent 40fbd295f5
commit 0a3f9c9df4

View file

@ -4,22 +4,31 @@ import { useMainStore } from '@/store';
export function fetchCmsContentForPage(issPage) {
const store = useMainStore()
const clientName = "ClientOverrideTest";//store.issConfig.clientName;
const pageName = issPage + (clientName.length == 0 ? "" : "_" + clientName);
const clientOverride = (clientName.length == 0);
const pageName = issPage + (clientOverride ? "" : "_" + clientName.toLowerCase().replace(/ /g, ""));
return store.getPageData(issPage)
.then(
// Get the base/default page first.
(baseResponse) => {
return store.getPageData(pageName)
.then(
// Get the client override if it exists.
(clientResponse) => {
return processPageData(baseResponse, clientResponse);
},
(error) => {
return processPageData(baseResponse, null);
}
);
(baseResponse) => {
if ( !clientOverride ){
// Return the base page if there are no client override.
return processPageData(baseResponse, null);
}
else {
// Else get the client override page.
return store.getPageData(pageName)
.then(
(clientResponse) => {
// Process the client override if it exists.
return processPageData(baseResponse, clientResponse);
},
(error) => {
// Process the just the base if no client override exists.
return processPageData(baseResponse, null);
}
);
}
}
);
};