cleaning up hard coded parent accounts

cleaning up hard coded parent accounts and using config from the cms instead
This commit is contained in:
Carl Nation 2026-07-02 07:48:31 -04:00
parent 1a952b764b
commit 67f7d42fc6
2 changed files with 7 additions and 44 deletions

View file

@ -13,17 +13,6 @@
<script>
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 {
name: "morePolicyQuestions",
@ -39,40 +28,10 @@ export default {
answersFromCms() {
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() {
if (!Array.isArray(this.answersFromCms)) return [];
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;
});
return this.answersFromCms;
},
selectedValues: {
get() {

View file

@ -181,7 +181,7 @@
<morePolicyQuestions
ref="morePolicyQuestions"
cmsWidgetName="MorePolicyQuestionsWidget"
:cmsWidgetName="morePolicyQuestionsWidgetName"
v-model="morePolicyQuestions"
groupName="MorePolicyQuestionsQuestion" />
@ -386,6 +386,10 @@ export default {
lossLocationQuestionText() {
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`
async beforeRouteEnter(to, from, next) {