updates to cached siteHeader to be more inline with card

This commit is contained in:
Bill Richardson 2023-12-08 16:29:27 -05:00
parent fb8799fe6b
commit 005b97fcbf
5 changed files with 61 additions and 34 deletions

View file

@ -1,3 +1,8 @@
/* eslint-disable no-use-before-define */
/* eslint-disable no-param-reassign */
/* eslint-disable jsdoc/require-param-type */
/* eslint-disable jsdoc/require-param-description */
/* eslint-disable jsdoc/require-returns */
import dynamicStrings from '@/constants/dynamic-strings'; import dynamicStrings from '@/constants/dynamic-strings';
import { useMainStore } from '@/store'; import { useMainStore } from '@/store';
@ -174,6 +179,45 @@ export function fetchCmsContentForPage(issPage) {
); );
} }
export function fetchGlobalCmsContent(issComponent) {
const store = useMainStore();
return (
store.getPageData(issComponent)
.then((baseResponse) => processPageData(baseResponse, null)));
}
export function updateCmsSiteHeader(cmsResponse) {
const clientCmsSiteHeader = getCmsSiteHeader(cmsResponse);
useMainStore().issConfig.clientHeader = clientCmsSiteHeader;
}
function getCmsSiteHeader(cmsResponse) {
if (cmsResponse?.SiteHeaderWidget) {
const siteHeader = cmsResponse?.SiteHeaderWidget;
if (siteHeader.Answers) {
const { parentAccountNumber } = useMainStore().issConfig;
let headerAnswersToUse = siteHeader.Answers
.find((answer) => answer.AccountNumber === parentAccountNumber.toString());
if (headerAnswersToUse === null) {
headerAnswersToUse = siteHeader.Answers
.find((answer) => answer.AccountNumber === '0');
}
if (headerAnswersToUse) {
return {
altText: headerAnswersToUse.AltText,
clientName: headerAnswersToUse.ClientName,
hexCode: headerAnswersToUse.HexCode,
imageId: headerAnswersToUse.ImageId,
imageUrl: headerAnswersToUse.AnswerImageUrl
};
}
}
}
return {};
}
/** /**
* @function mapStringToModal * @function mapStringToModal
* @param str * @param str
@ -476,6 +520,7 @@ export function doesCopyContainTextLink(copy) {
export function setupModalLinks(context) { export function setupModalLinks(context) {
context.$nextTick(() => { context.$nextTick(() => {
const elements = document.getElementsByClassName('modal-text'); const elements = document.getElementsByClassName('modal-text');
// eslint-disable-next-line no-restricted-syntax
for (const element of elements) { for (const element of elements) {
const target = element.getAttribute('modalTarget'); const target = element.getAttribute('modalTarget');
if (target) { if (target) {

View file

@ -46,19 +46,19 @@ export default ({
messageHeadline: '', messageHeadline: '',
type: '' type: ''
}, },
headerAnswers: null cmsClientHeader: null
}; };
}, },
computed: { computed: {
imageSrc() { imageSrc() {
return this.headerAnswers ? this.headerAnswers.AnswerImageUrl : ''; return this.cmsClientHeader ? this.cmsClientHeader.imageUrl : '';
}, },
altText() { altText() {
return this.headerAnswers ? this.headerAnswers.AltText : ''; return this.cmsClientHeader ? this.cmsClientHeader.altText : '';
}, },
logoBackgroundStyle() { logoBackgroundStyle() {
return { return {
'background-color': this.headerAnswers ? this.headerAnswers.HexCode : '#FFFFFF' 'background-color': this.cmsClientHeader ? this.cmsClientHeader.hexCode : '#FFFFFF'
}; };
} }
}, },
@ -86,10 +86,9 @@ export default ({
}, },
methods: { methods: {
setupHeader() { setupHeader() {
const answers = useMainStore().issConfig.issCmsContent.SiteHeaderWidget.Answers; const { clientHeader } = useMainStore().issConfig;
if (Array.isArray(answers)) { if (clientHeader) {
this.headerAnswers = answers.filter((x) => x.AccountNumber == this.mainStore.issConfig.parentAccountNumber)[0]; this.cmsClientHeader = clientHeader;
this.headerAnswers = !this.headerAnswers ? answers.filter((x) => x.AccountNumber === '0')[0] : this.headerAnswers;
} }
} }
} }

View file

@ -9,8 +9,6 @@
<script> <script>
// Supporting files // Supporting files
import issPageValues from '@/router/router-constants/issPage-values'; import issPageValues from '@/router/router-constants/issPage-values';
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import settleAllPromises from '@/helpers/layout-helper';
import { validateISSClientTag, validateISSClientSignature } from '@/helpers/clientauth-helper'; import { validateISSClientTag, validateISSClientSignature } from '@/helpers/clientauth-helper';
import { useMainStore } from '@/store'; import { useMainStore } from '@/store';
@ -27,7 +25,6 @@ export default {
}, },
data() { data() {
return { return {
issCmsContent: [],
unauthorized: false unauthorized: false
}; };
}, },
@ -97,24 +94,6 @@ export default {
window.location = `/?issPage=${issPageValues.WELCOME_PAGE}`; window.location = `/?issPage=${issPageValues.WELCOME_PAGE}`;
} }
}, },
async populateISSCmsComponents(accountNumber) {
console.log('get global cms components...');
console.log(accountNumber);
const cmsContentPromise = fetchCmsContentForPage('iss-siteheader');
// Settle promises and get results
const promiseResultMap = [
{
resultKey: 'cmsContent',
promise: cmsContentPromise
}
];
// use resultMap to populate layout content.
const resultMap = await settleAllPromises(promiseResultMap);
const issCmsContent = resultMap.cmsContent;
this.mainStore.issConfig.issCmsContent = issCmsContent;
},
async populateISSConfigValues(data) { async populateISSConfigValues(data) {
this.mainStore.issConfig.clientName = data.accountName; this.mainStore.issConfig.clientName = data.accountName;
this.mainStore.issConfig.clientDisplayName = data.accountName; // Defaults to use the client name. this.mainStore.issConfig.clientDisplayName = data.accountName; // Defaults to use the client name.

View file

@ -177,7 +177,7 @@ import dropdownQuestion from '@/digital-components/dropdown-question/dropdown-qu
import textBlock from '@/digital-components/text-block/text-block.vue'; import textBlock from '@/digital-components/text-block/text-block.vue';
// Supporting files // Supporting files
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper'; import { fetchCmsContentForPage, fetchGlobalCmsContent, updateCmsSiteHeader } from '@/helpers/cms-content-helper';
import settleAllPromises from '@/helpers/layout-helper'; import settleAllPromises from '@/helpers/layout-helper';
import { required, regex } from '@/helpers/validation-rules'; import { required, regex } from '@/helpers/validation-rules';
import errorMessages from '@/constants/error-messages'; import errorMessages from '@/constants/error-messages';
@ -226,19 +226,24 @@ export default {
async beforeRouteEnter(to, from, next) { async beforeRouteEnter(to, from, next) {
// Call APIs // Call APIs
const cmsContentPromise = fetchCmsContentForPage(to.query.issPage); const cmsContentPromise = fetchCmsContentForPage(to.query.issPage);
const cmsGlobalSiteHeaderContentPromise = fetchGlobalCmsContent('iss-siteheader');
// Settle promises and get results // Settle promises and get results
const promiseResultMap = [ const promiseResultMap = [
{ {
resultKey: 'cmsContent', resultKey: 'cmsContent',
promise: cmsContentPromise promise: cmsContentPromise
},
{
resultKey: 'globalSiteHeaderCmsContent',
promise: cmsGlobalSiteHeaderContentPromise
} }
]; ];
// use resultMap to populate layout content. // use resultMap to populate layout content.
const resultMap = await settleAllPromises(promiseResultMap); const resultMap = await settleAllPromises(promiseResultMap);
next((vm) => { next((vm) => {
updateCmsSiteHeader(resultMap.globalSiteHeaderCmsContent);
vm.setCmsContent(resultMap.cmsContent); vm.setCmsContent(resultMap.cmsContent);
}); });
}, },
@ -317,7 +322,6 @@ export default {
this.navigateForward(); this.navigateForward();
}); });
}, },
navigateForward() { navigateForward() {
if (this.mainStore.applicationUser.duplicateOrders?.length > 0 ?? false) { if (this.mainStore.applicationUser.duplicateOrders?.length > 0 ?? false) {
this.$router.navigate( this.$router.navigate(
@ -354,7 +358,6 @@ export default {
); );
} }
}, },
getWelcomePageModelFromStore() { getWelcomePageModelFromStore() {
return { return {
policyNumber: this.mainStore.order.policy.policyNumber, policyNumber: this.mainStore.order.policy.policyNumber,

View file

@ -173,7 +173,7 @@ const getDefaultState = () => ({
issConfig: { issConfig: {
clientName: 'Generic Insurance', // this is the default and will be overriden by the client's name clientName: 'Generic Insurance', // this is the default and will be overriden by the client's name
clientDisplayName: 'Generic Insurance', // this is the default and will be overridden by the client's name or client display name. clientDisplayName: 'Generic Insurance', // this is the default and will be overridden by the client's name or client display name.
issCmsContent: [], clientHeader: {},
styleSheet: '', // Stylesheet used by the client. styleSheet: '', // Stylesheet used by the client.
parentAccountNumber: 0, // Parent account number used by the client. parentAccountNumber: 0, // Parent account number used by the client.
isCoverageEnabled: false, // Indicates if we should be calling coverage on this flow. isCoverageEnabled: false, // Indicates if we should be calling coverage on this flow.
@ -1463,6 +1463,7 @@ export const useMainStore = defineStore({
resetISSConfigState() { resetISSConfigState() {
this.issConfig.clientName = 'Generic Insurance'; this.issConfig.clientName = 'Generic Insurance';
this.issConfig.clientDisplayName = 'Generic Insurance'; this.issConfig.clientDisplayName = 'Generic Insurance';
this.issConfig.clientHeader = {};
this.issConfig.parentAccountNumber = 0; this.issConfig.parentAccountNumber = 0;
this.issConfig.styleSheet = ''; this.issConfig.styleSheet = '';
this.issConfig.isCoverageEnabled = false; this.issConfig.isCoverageEnabled = false;