Skip to content

Add email and phone contact fields to the review step with validation. - #1108

Merged
veenupunyani merged 3 commits into
developfrom
dev-33-provide-contact-info
Sep 1, 2026
Merged

Add email and phone contact fields to the review step with validation.#1108
veenupunyani merged 3 commits into
developfrom
dev-33-provide-contact-info

Conversation

@veenupunyani

Copy link
Copy Markdown
Collaborator

Summary

  • Added email and phone fields to the review step with client-side validation.
  • Pre-filled contact details from user profile, with session email as fallback.
  • UI only , no confirm, profile save, or notifications yet.

isInvalid={contactTouched && !!validation.phoneError}
errorMessage={contactTouched ? (validation.phoneError ?? undefined) : undefined}
// @ts-expect-error placeholder is supported by underlying react-aria TextField
placeholder="250-555-0100"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should leave the placeholders off these fields (phone and email) to avoid any confusion on the user's part.

Comment thread appointment-booking/app/api/users.ts Outdated
Comment on lines +6 to +7
email: string
telephone: string

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

telephone and email can both be null from the API, e.g. when I sign in to prod using my BCSC, email is populated but telephone is null.

Suggested change
email: string
telephone: string
email: string | null
telephone: string | null

Comment on lines +49 to +50
const email = contactEmail ?? (profile?.email?.trim() || session?.email?.trim() || '')
const phone = contactPhone ?? (profile?.telephone?.trim() || '')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, but do contactEmail and contactPhone need to be trimmed here as well?


export function isValidPhone(phone: string): boolean {
const normalized = phone.trim().replace(/[ ()]/g, '')
return normalized.length > 0 && /^\+?1?[-.]?\d{3}[-.]?\d{3}[-.]?\d{4}$/.test(normalized)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize the current app uses a regex. I think this is a good opportunity for us to move to a library like https://github.com/google/libphonenumber and do this properly. e.g. (250) 387-7000 isn't a valid number with that regex, neither is 306 555 1212, etc.

Added libphonenumber-js for phone validation, allow nullable email/telephone, trim resolved contact values, and removed field placeholders.
@sonarqubecloud

sonarqubecloud Bot commented Sep 1, 2026

Copy link
Copy Markdown

@veenupunyani
veenupunyani requested a review from chrsamp September 1, 2026 19:59

@chrsamp chrsamp left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @veenupunyani!

@veenupunyani
veenupunyani merged commit f663913 into develop Sep 1, 2026
3 checks passed
@veenupunyani
veenupunyani deleted the dev-33-provide-contact-info branch September 1, 2026 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants