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>
|
||||
import buttonQuestion from "@/digital-components/button-question/button-question";
|
||||
|
||||
const paymentMethods = {
|
||||
NONE: null,
|
||||
LATER: "Later",
|
||||
CREDIT_CARD: "CreditCard",
|
||||
PAYPAL: "Paypal",
|
||||
AFTERPAY: "Afterpay",
|
||||
};
|
||||
|
||||
const payTimes = {
|
||||
NONE: null,
|
||||
ADVANCE: "Advance",
|
||||
LATER: "Later",
|
||||
};
|
||||
import { paymentMethods, paymentTimes } from "@/constants/payment-method-constants";
|
||||
|
||||
export default {
|
||||
name: "payment-method-question",
|
||||
|
|
@ -50,14 +38,14 @@ export default {
|
|||
methods: {
|
||||
inferPayInAdvanceValue() {
|
||||
if (this.modelValue === paymentMethods.NONE) {
|
||||
return payTimes.NONE;
|
||||
return paymentTimes.NONE;
|
||||
}
|
||||
|
||||
if (this.modelValue === paymentMethods.LATER) {
|
||||
return payTimes.LATER;
|
||||
return paymentTimes.LATER;
|
||||
}
|
||||
|
||||
return payTimes.ADVANCE;
|
||||
return paymentTimes.ADVANCE;
|
||||
},
|
||||
getAnswersNullSafe(widgetName) {
|
||||
const rawData = this.getCmsContent(widgetName, "Answers");
|
||||
|
|
@ -79,7 +67,7 @@ export default {
|
|||
},
|
||||
},
|
||||
shouldDisplaySecondaryQuestion() {
|
||||
return this.paymentTime === payTimes.ADVANCE;
|
||||
return this.paymentTime === paymentTimes.ADVANCE;
|
||||
},
|
||||
paymentTimeQuestionText() {
|
||||
return this.getCmsContent("PaymentTimeWidget", "QuestionText");
|
||||
|
|
@ -114,7 +102,7 @@ export default {
|
|||
},
|
||||
watch: {
|
||||
paymentTime(newValue) {
|
||||
if (newValue === payTimes.LATER) {
|
||||
if (newValue === paymentTimes.LATER) {
|
||||
this.selectedMethod = paymentMethods.LATER;
|
||||
} else {
|
||||
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 { settleAllPromises } from "@/helpers/layout-helper";
|
||||
import { paymentMethods } from "@/constants/payment-method-constants";
|
||||
|
||||
// Validation
|
||||
import { Form } from "vee-validate";
|
||||
|
|
@ -68,11 +69,11 @@ export default {
|
|||
computed: {
|
||||
customCtaCopy() {
|
||||
switch (this.paymentMethod) {
|
||||
case "CreditCard":
|
||||
case paymentMethods.CREDIT_CARD:
|
||||
return "Continue to checkout";
|
||||
case "Paypal":
|
||||
case paymentMethods.PAYPAL:
|
||||
return "Continue to Paypal";
|
||||
case "Afterpay":
|
||||
case paymentMethods.AFTERPAY:
|
||||
return "Continue to Afterpay";
|
||||
default:
|
||||
return null;
|
||||
|
|
|
|||
Loading…
Reference in a new issue