diff --git a/src/views/ClaimView.vue b/src/views/ClaimView.vue index 76b283f9..29895e67 100644 --- a/src/views/ClaimView.vue +++ b/src/views/ClaimView.vue @@ -106,69 +106,87 @@ +
+ +
+ + This fulfills a bigger plan + + +
- -
- - Fulfills a bigger plan... - -
- -
- - - Fulfills - {{ - capitalizeAndInsertSpacesBeforeCaps( - offerFulfillment.offerType || "Offer", - ) - }}... - -
- - -
- - Offered to a bigger plan... - -
+ +
+ + + This fulfills + {{ + capitalizeAndInsertSpacesBeforeCapsWithAPrefix( + offerFulfillment.offerType || "Offer", + ) + }} + + +
- -
- Other assistance provided by: - + + +
@@ -789,6 +807,27 @@ export default class ClaimView extends Vue { this.canShare = !!navigator.share; } + /** + * Formats type string for display by adding spaces before capitals + * Optionally adds a prefix + * + * @param text - Text to format + * @param prefix - Optional prefix to add + * @returns Formatted string + */ + capitalizeAndInsertSpacesBeforeCapsWithAPrefix(text: string): string { + const word = this.capitalizeAndInsertSpacesBeforeCaps(text); + if (word) { + // if the word starts with a vowel, use "an" instead of "a" + const firstLetter = word[0].toLowerCase(); + const vowels = ["a", "e", "i", "o", "u"]; + const particle = vowels.includes(firstLetter) ? "an" : "a"; + return particle + " " + word; + } else { + return ""; + } + } + // insert a space before any capital letters except the initial letter // (and capitalize initial letter, just in case) capitalizeAndInsertSpacesBeforeCaps(text: string): string { diff --git a/src/views/ConfirmGiftView.vue b/src/views/ConfirmGiftView.vue index cf3f3a0c..244631bc 100644 --- a/src/views/ConfirmGiftView.vue +++ b/src/views/ConfirmGiftView.vue @@ -96,44 +96,46 @@ - - -
- - This fulfills a bigger plan - - -
- -
- - - This fulfills - {{ - capitalizeAndInsertSpacesBeforeCapsWithAPrefix( - offerFulfillment.offerType || "Offer", - ) - }} - - +
+ +
+ + This fulfills a bigger plan + + +
+ + +
+ + + This fulfills + {{ + capitalizeAndInsertSpacesBeforeCapsWithAPrefix( + offerFulfillment.offerType || "Offer", + ) + }} + + +