From 9f5bb243a96dd3e47984186de821af37e4af1828 Mon Sep 17 00:00:00 2001 From: Michaela Brydon Date: Mon, 16 Oct 2023 15:22:51 -0400 Subject: [PATCH] Moved toTitleCase to text-helper --- src/helpers/text-helper.js | 16 +++++++++++++++- src/layouts/duplicate-check/duplicate-check.vue | 10 ++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/helpers/text-helper.js b/src/helpers/text-helper.js index 01d18309..8dffeb12 100644 --- a/src/helpers/text-helper.js +++ b/src/helpers/text-helper.js @@ -5,7 +5,21 @@ * @param {string} stringWithStyleTag * @returns {string} */ -export default function stripRteStyle(stringWithStyleTag) { +export function stripRteStyle(stringWithStyleTag) { const regexExp = /[\s*]style="(.*?)"/g; return stringWithStyleTag.replace(regexExp, ''); } + +/** + * @function t0TitleCase + * @summary Returns title cased string version of 'text' + * @param {string} text + * @returns {string} + */ +export function toTitleCase(text) { + const temp = text.toLowerCase().split(' '); + for (let i = 0; i < temp.length; i++) { + temp[i] = temp[i].charAt(0).toUpperCase() + temp[i].slice(1); + } + return temp.join(' '); +} diff --git a/src/layouts/duplicate-check/duplicate-check.vue b/src/layouts/duplicate-check/duplicate-check.vue index 6304399c..56e888cc 100644 --- a/src/layouts/duplicate-check/duplicate-check.vue +++ b/src/layouts/duplicate-check/duplicate-check.vue @@ -53,6 +53,7 @@ import { fetchCmsContentForPage } from '@/helpers/cms-content-helper.js'; import BaseFormMixin from '@/mixins/base-form-mixin.js'; import { useMainStore } from '@/store/index.js'; import globalRules from '@/constants/global-rules.js'; +import { toTitleCase } from '@/helpers/text-helper.js'; export default { name: 'duplicate-check', @@ -111,7 +112,7 @@ export default { return { Text: duplicateOrderText, Name: o.referralNumber, - SubText: this.titleCase(subtext) + SubText: toTitleCase(subtext) }; }) ?? []; }, @@ -172,13 +173,6 @@ export default { : yyyyMmDd[1]; const day = yyyyMmDd[2]; return `${month}/${day}/${year}`; - }, - titleCase(str) { - const temp = str.toLowerCase().split(' '); - for (let i = 0; i < temp.length; i++) { - temp[i] = temp[i].charAt(0).toUpperCase() + temp[i].slice(1); - } - return temp.join(' '); } } };