Skip to content

Commit

Permalink
VACMS-18457 Convert Event CTAs to DS action links (#853)
Browse files Browse the repository at this point in the history
  • Loading branch information
randimays authored Dec 20, 2024
1 parent fd39f65 commit c160127
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 41 deletions.
35 changes: 18 additions & 17 deletions additional.d.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
/// <reference types="react-scripts" />

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'
}
}
7 changes: 7 additions & 0 deletions src/lib/utils/events.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
8 changes: 8 additions & 0 deletions src/lib/utils/events.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { deriveFormattedTimestamp } from './date'

export function formatEventCTA(input: string): string {
if (!input) {
return
}

if (input.toLowerCase() === 'rsvp') {
return 'RSVP'
}

const words: string[] = input.split('_')

const formattedString: string = words
Expand Down
47 changes: 23 additions & 24 deletions src/templates/layouts/event/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ export const Event = ({
.filter(Boolean)
.join(', ')

let eventCTAText = null

if (eventCTA) {
eventCTAText = formatEventCTA(eventCTA)
}

return (
<div className="va-l-detail-page va-facility-page">
<div className="usa-grid usa-grid-full">
Expand Down Expand Up @@ -228,33 +234,26 @@ export const Event = ({
</p>
) : (
<>
{link && (
<p className="vads-u-margin--0">
<a className="vads-c-action-link--green" href={link?.uri}>
{eventCTA && eventCTA != 'more_details'
? eventCTA.toLowerCase() === 'rsvp'
? eventCTA.toUpperCase()
: eventCTA.charAt(0).toUpperCase() + eventCTA.slice(1)
: 'More details'}
</a>
</p>
{link && eventCTAText && (
<va-link-action
class="vads-u-display--block"
href={link?.uri}
text={eventCTAText}
/>
)}
{howToSignUp === 'email' && (
<>
{mostRecentDate && (
<p className="vads-u-margin--0">
<a
className="vads-c-action-link--green"
href={createMailToLink(
emailCTA,
title,
mostRecentDate,
link?.uri
)}
>
{eventCTA && formatEventCTA(eventCTA)}
</a>
</p>
{mostRecentDate && eventCTAText && (
<va-link-action
class="vads-u-display--block"
href={createMailToLink(
emailCTA,
title,
mostRecentDate,
link?.uri
)}
text={eventCTAText}
/>
)}
</>
)}
Expand Down

0 comments on commit c160127

Please sign in to comment.