Move hard-coded values to constants file
This commit is contained in:
parent
1f459e9cca
commit
57e520d2c4
3 changed files with 23 additions and 21 deletions
13
src/constants/payment-method-constants.js
Normal file
13
src/constants/payment-method-constants.js
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
export const paymentMethods = {
|
||||||
|
NONE: null,
|
||||||
|
LATER: "Later",
|
||||||
|
CREDIT_CARD: "CreditCard",
|
||||||
|
PAYPAL: "Paypal",
|
||||||
|
AFTERPAY: "Afterpay",
|
||||||
|
};
|
||||||
|
|
||||||
|
export const paymentTimes = {
|
||||||
|
NONE: null,
|
||||||
|
ADVANCE: "Advance",
|
||||||
|
LATER: "Later",
|
||||||
|
};
|
||||||
|
|
@ -23,19 +23,7 @@
|
||||||
<script>
|
<script>
|
||||||
import buttonQuestion from "@/digital-components/button-question/button-question";
|
import buttonQuestion from "@/digital-components/button-question/button-question";
|
||||||
|
|
||||||
const paymentMethods = {
|
import { paymentMethods, paymentTimes } from "@/constants/payment-method-constants";
|
||||||
NONE: null,
|
|
||||||
LATER: "Later",
|
|
||||||
CREDIT_CARD: "CreditCard",
|
|
||||||
PAYPAL: "Paypal",
|
|
||||||
AFTERPAY: "Afterpay",
|
|
||||||
};
|
|
||||||
|
|
||||||
const payTimes = {
|
|
||||||
NONE: null,
|
|
||||||
ADVANCE: "Advance",
|
|
||||||
LATER: "Later",
|
|
||||||
};
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "payment-method-question",
|
name: "payment-method-question",
|
||||||
|
|
@ -50,14 +38,14 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
inferPayInAdvanceValue() {
|
inferPayInAdvanceValue() {
|
||||||
if (this.modelValue === paymentMethods.NONE) {
|
if (this.modelValue === paymentMethods.NONE) {
|
||||||
return payTimes.NONE;
|
return paymentTimes.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.modelValue === paymentMethods.LATER) {
|
if (this.modelValue === paymentMethods.LATER) {
|
||||||
return payTimes.LATER;
|
return paymentTimes.LATER;
|
||||||
}
|
}
|
||||||
|
|
||||||
return payTimes.ADVANCE;
|
return paymentTimes.ADVANCE;
|
||||||
},
|
},
|
||||||
getAnswersNullSafe(widgetName) {
|
getAnswersNullSafe(widgetName) {
|
||||||
const rawData = this.getCmsContent(widgetName, "Answers");
|
const rawData = this.getCmsContent(widgetName, "Answers");
|
||||||
|
|
@ -79,7 +67,7 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
shouldDisplaySecondaryQuestion() {
|
shouldDisplaySecondaryQuestion() {
|
||||||
return this.paymentTime === payTimes.ADVANCE;
|
return this.paymentTime === paymentTimes.ADVANCE;
|
||||||
},
|
},
|
||||||
paymentTimeQuestionText() {
|
paymentTimeQuestionText() {
|
||||||
return this.getCmsContent("PaymentTimeWidget", "QuestionText");
|
return this.getCmsContent("PaymentTimeWidget", "QuestionText");
|
||||||
|
|
@ -114,7 +102,7 @@ export default {
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
paymentTime(newValue) {
|
paymentTime(newValue) {
|
||||||
if (newValue === payTimes.LATER) {
|
if (newValue === paymentTimes.LATER) {
|
||||||
this.selectedMethod = paymentMethods.LATER;
|
this.selectedMethod = paymentMethods.LATER;
|
||||||
} else {
|
} else {
|
||||||
this.selectedMethod = paymentMethods.NONE;
|
this.selectedMethod = paymentMethods.NONE;
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import paymentMethodQuestion from "@/layouts/payment-method/payment-method-quest
|
||||||
|
|
||||||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||||
import { settleAllPromises } from "@/helpers/layout-helper";
|
import { settleAllPromises } from "@/helpers/layout-helper";
|
||||||
|
import { paymentMethods } from "@/constants/payment-method-constants";
|
||||||
|
|
||||||
// Validation
|
// Validation
|
||||||
import { Form } from "vee-validate";
|
import { Form } from "vee-validate";
|
||||||
|
|
@ -68,11 +69,11 @@ export default {
|
||||||
computed: {
|
computed: {
|
||||||
customCtaCopy() {
|
customCtaCopy() {
|
||||||
switch (this.paymentMethod) {
|
switch (this.paymentMethod) {
|
||||||
case "CreditCard":
|
case paymentMethods.CREDIT_CARD:
|
||||||
return "Continue to checkout";
|
return "Continue to checkout";
|
||||||
case "Paypal":
|
case paymentMethods.PAYPAL:
|
||||||
return "Continue to Paypal";
|
return "Continue to Paypal";
|
||||||
case "Afterpay":
|
case paymentMethods.AFTERPAY:
|
||||||
return "Continue to Afterpay";
|
return "Continue to Afterpay";
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue