Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): Format safe identifier phone number during sign in verification step #3751

Conversation

alexcarpenter
Copy link
Member

@alexcarpenter alexcarpenter commented Jul 17, 2024

Description

Add formatSafeIdentifier util to format phone number during sign in verification step

BEFORE:
Screenshot 2024-07-17 at 5 29 29 PM

AFTER:
Screenshot 2024-07-17 at 5 29 13 PM

https://linear.app/clerk/issue/SDKI-121/signin-verifications-phone-number-should-be-formatted-according-to

Checklist

  • npm test runs as expected.
  • npm run build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Copy link

changeset-bot bot commented Jul 17, 2024

⚠️ No Changeset found

Latest commit: 55428b6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@alexcarpenter alexcarpenter requested a review from dstaley July 17, 2024 21:30
@alexcarpenter alexcarpenter marked this pull request as ready for review July 17, 2024 21:30
Copy link
Member

@dstaley dstaley left a comment

Choose a reason for hiding this comment

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

approved, but if you want to get rid of that logical OR we can by adding a few overloads to formatSafeIdentifier

<SignIn.SafeIdentifier />
<SignIn.SafeIdentifier
transform={val => {
return formatSafeIdentifier(val) || val;
Copy link
Member

Choose a reason for hiding this comment

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

If we add some overloads to the formatSafeIdentifier function to tell TypeScript that it will always return a string if provided a string, we can remove this logical OR which won't ever be invoked since SafeIdentifier falls back to an empty string in the worse case.

TS Playground

@@ -0,0 +1,15 @@
import { stringToFormattedPhoneString } from '~/common/phone-number-field/utils';
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I think we should move this to ~/utils if it's something we plan to use across different areas of the codebase; this'll avoid the likelihood of circular imports (and just a little tidier)

I may go ahead and just make this change to avoid the back-and-forth

Copy link
Contributor

Choose a reason for hiding this comment

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

Ooof actually just seen how this also relies on data etc. too. Let's come back to this

@nikosdouvlis nikosdouvlis merged commit a0f37ef into ds.feat/safeidentifier-for-strategy Jul 18, 2024
3 checks passed
@nikosdouvlis nikosdouvlis deleted the alexcarpenter/sdki-121-signin-verifications-phone-number-should-be-formatted branch July 18, 2024 07:53
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.

4 participants