From b26840e0d9687724bdf1b131f096948c6dc65880 Mon Sep 17 00:00:00 2001 From: Tim Cosgrove Date: Thu, 19 Dec 2024 10:10:20 -0800 Subject: [PATCH] Revert "Revert "VACMS-18457 Implement action links on Event CTAs" (#851)" This reverts commit fd39f656057c4e65c99ebb76a9ded87d2a371e40. --- additional.d.ts | 35 +++++++++++----------- src/lib/utils/events.test.ts | 7 +++++ src/lib/utils/events.ts | 4 +++ src/templates/layouts/event/index.tsx | 43 ++++++++++++--------------- 4 files changed, 48 insertions(+), 41 deletions(-) diff --git a/additional.d.ts b/additional.d.ts index dc6917c89..620e04da0 100644 --- a/additional.d.ts +++ b/additional.d.ts @@ -1,35 +1,36 @@ /// -declare module 'nock' -declare module 'test-utils' -declare module '@testing-library/react' declare module '@department-of-veterans-affairs/component-library' -declare module '@department-of-veterans-affairs/component-library/Table' -declare module '@department-of-veterans-affairs/component-library/LoadingIndicator' declare module '@department-of-veterans-affairs/component-library/AlertBox' -declare module '@department-of-veterans-affairs/component-library/DropDownPanel' -declare module '@department-of-veterans-affairs/component-library/Breadcrumbs' declare module '@department-of-veterans-affairs/component-library/Banner' -declare module '@department-of-veterans-affairs/component-library/TextInput' -declare module '@department-of-veterans-affairs/component-library/TextArea' +declare module '@department-of-veterans-affairs/component-library/Breadcrumbs' +declare module '@department-of-veterans-affairs/component-library/dist/react-bindings' +declare module '@department-of-veterans-affairs/component-library/DropDownPanel' +declare module '@department-of-veterans-affairs/component-library/LoadingIndicator' declare module '@department-of-veterans-affairs/component-library/Modal' declare module '@department-of-veterans-affairs/component-library/Pagination' declare module '@department-of-veterans-affairs/component-library/ProgressButton' declare module '@department-of-veterans-affairs/component-library/PromoBanner' -declare module '@department-of-veterans-affairs/component-library/dist/react-bindings' -declare module 'mq-polyfill' +declare module '@department-of-veterans-affairs/component-library/Table' +declare module '@department-of-veterans-affairs/component-library/TextArea' +declare module '@department-of-veterans-affairs/component-library/TextInput' +declare module '@testing-library/react' declare module 'debug' +declare module 'mq-polyfill' +declare module 'nock' +declare module 'test-utils' declare namespace JSX { interface IntrinsicElements { + 'va-accordion-item' + 'va-accordion' 'va-alert' - 'va-link' - 'va-icon' - 'va-button' + 'va-back-to-top' 'va-breadcrumbs' - 'va-accordion' - 'va-accordion-item' + 'va-button' + 'va-icon' + 'va-link' + 'va-link-action' 'va-on-this-page' - 'va-back-to-top' } } diff --git a/src/lib/utils/events.test.ts b/src/lib/utils/events.test.ts index 662594d2f..cc90b3e93 100644 --- a/src/lib/utils/events.test.ts +++ b/src/lib/utils/events.test.ts @@ -2,6 +2,13 @@ import { formatEventCTA, createMailToLink } from './events' describe('formatEventCTA', () => { describe('formatEventCTA', () => { + it('should format "rsvp" as "RSVP"', () => { + const input = 'rsvp' + const expected = 'RSVP' + const result = formatEventCTA(input) + expect(result).toBe(expected) + }) + it('should format "register_now" as "Register now"', () => { const input = 'register_now' const expected = 'Register now' diff --git a/src/lib/utils/events.ts b/src/lib/utils/events.ts index b7f58463f..cd33ddfbf 100644 --- a/src/lib/utils/events.ts +++ b/src/lib/utils/events.ts @@ -1,6 +1,10 @@ import { deriveFormattedTimestamp } from './date' export function formatEventCTA(input: string): string { + if (input.toLowerCase() === 'rsvp') { + return 'RSVP' + } + const words: string[] = input.split('_') const formattedString: string = words diff --git a/src/templates/layouts/event/index.tsx b/src/templates/layouts/event/index.tsx index 05e3cccba..f854fa64e 100644 --- a/src/templates/layouts/event/index.tsx +++ b/src/templates/layouts/event/index.tsx @@ -75,6 +75,8 @@ export const Event = ({ .filter(Boolean) .join(', ') + const eventCTAText = formatEventCTA(eventCTA) + return (
@@ -228,33 +230,26 @@ export const Event = ({

) : ( <> - {link && ( -

- - {eventCTA && eventCTA != 'more_details' - ? eventCTA.toLowerCase() === 'rsvp' - ? eventCTA.toUpperCase() - : eventCTA.charAt(0).toUpperCase() + eventCTA.slice(1) - : 'More details'} - -

+ {link && eventCTAText && ( + )} {howToSignUp === 'email' && ( <> - {mostRecentDate && ( -

- - {eventCTA && formatEventCTA(eventCTA)} - -

+ {mostRecentDate && eventCTAText && ( + )} )}