cleaning up hard coded parent accounts
cleaning up hard coded parent accounts and using config from the cms instead
This commit is contained in:
parent
1a952b764b
commit
67f7d42fc6
2 changed files with 7 additions and 44 deletions
|
|
@ -13,17 +13,6 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import buttonQuestion from "@/digital-components/button-question/button-question";
|
import buttonQuestion from "@/digital-components/button-question/button-question";
|
||||||
import store from "@/store";
|
|
||||||
import { PARENT_ACCOUNT_NUMBERS } from "@/constants/insurance";
|
|
||||||
|
|
||||||
const STATE_FARM_ONLY_ANSWER_NAMES = new Set(["ThirdPartyVehicle", "Injuries"]);
|
|
||||||
const HIDDEN_FOR_STATE_FARM_ANSWER_NAMES = new Set(["OtherResponsibleParty"]);
|
|
||||||
// Maps an answer's Name to the CMS widget that supplies a State Farm-specific
|
|
||||||
// label override. The widget's "Text" property replaces the answer's Text.
|
|
||||||
const STATE_FARM_TEXT_OVERRIDES = {
|
|
||||||
AdditionalDamage: "AdditionalDamageStateFarmWidget",
|
|
||||||
Rental: "RentalStateFarmWidget",
|
|
||||||
};
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "morePolicyQuestions",
|
name: "morePolicyQuestions",
|
||||||
|
|
@ -39,40 +28,10 @@ export default {
|
||||||
answersFromCms() {
|
answersFromCms() {
|
||||||
return this.getCmsContent(this.cmsWidgetName, "Answers");
|
return this.getCmsContent(this.cmsWidgetName, "Answers");
|
||||||
},
|
},
|
||||||
isStateFarm() {
|
|
||||||
return (
|
|
||||||
store.getters.order?.payment?.parentAccountNumber?.toString() ===
|
|
||||||
PARENT_ACCOUNT_NUMBERS.STATE_FARM
|
|
||||||
);
|
|
||||||
},
|
|
||||||
stateFarmTextOverrides() {
|
|
||||||
return Object.fromEntries(
|
|
||||||
Object.entries(STATE_FARM_TEXT_OVERRIDES).map(([name, widget]) => [
|
|
||||||
name,
|
|
||||||
this.getCmsContent(widget, "Text"),
|
|
||||||
])
|
|
||||||
);
|
|
||||||
},
|
|
||||||
answersToDisplay() {
|
answersToDisplay() {
|
||||||
if (!Array.isArray(this.answersFromCms)) return [];
|
if (!Array.isArray(this.answersFromCms)) return [];
|
||||||
return this.answersFromCms
|
return this.answersFromCms;
|
||||||
.filter((ans) => {
|
|
||||||
if (STATE_FARM_ONLY_ANSWER_NAMES.has(ans?.Name)) {
|
|
||||||
return this.isStateFarm;
|
|
||||||
}
|
|
||||||
if (HIDDEN_FOR_STATE_FARM_ANSWER_NAMES.has(ans?.Name)) {
|
|
||||||
return !this.isStateFarm;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
})
|
|
||||||
.map((ans) => {
|
|
||||||
if (!this.isStateFarm) return ans;
|
|
||||||
const overrideText = this.stateFarmTextOverrides[ans?.Name];
|
|
||||||
if (overrideText) {
|
|
||||||
return { ...ans, Text: overrideText };
|
|
||||||
}
|
|
||||||
return ans;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
selectedValues: {
|
selectedValues: {
|
||||||
get() {
|
get() {
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,7 @@
|
||||||
|
|
||||||
<morePolicyQuestions
|
<morePolicyQuestions
|
||||||
ref="morePolicyQuestions"
|
ref="morePolicyQuestions"
|
||||||
cmsWidgetName="MorePolicyQuestionsWidget"
|
:cmsWidgetName="morePolicyQuestionsWidgetName"
|
||||||
v-model="morePolicyQuestions"
|
v-model="morePolicyQuestions"
|
||||||
groupName="MorePolicyQuestionsQuestion" />
|
groupName="MorePolicyQuestionsQuestion" />
|
||||||
|
|
||||||
|
|
@ -386,6 +386,10 @@ export default {
|
||||||
lossLocationQuestionText() {
|
lossLocationQuestionText() {
|
||||||
return this.getCmsContent("LossLocationQuestionWidget", "QuestionText");
|
return this.getCmsContent("LossLocationQuestionWidget", "QuestionText");
|
||||||
},
|
},
|
||||||
|
morePolicyQuestionsWidgetName() {
|
||||||
|
// State Farm may be the only one who uses this
|
||||||
|
return this.parsedClientConfig.OverrideMorePolicyQuestions ? "MorePolicyQuestionsOverrideWidget" : "MorePolicyQuestionsWidget";
|
||||||
|
},
|
||||||
},
|
},
|
||||||
// Ensure CMS content is fetched during route navigation without depending on `to`/`from`
|
// Ensure CMS content is fetched during route navigation without depending on `to`/`from`
|
||||||
async beforeRouteEnter(to, from, next) {
|
async beforeRouteEnter(to, from, next) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue