Moved toTitleCase to text-helper

This commit is contained in:
Michaela Brydon 2023-10-16 15:22:51 -04:00
parent 70fd08c5ce
commit 9f5bb243a9
2 changed files with 17 additions and 9 deletions

View file

@ -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(' ');
}

View file

@ -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(' ');
}
}
};