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

Improve handling of declined portings #14

Merged
merged 7 commits into from
May 28, 2024

Conversation

dharmadeveloper108
Copy link
Contributor

@dharmadeveloper108 dharmadeveloper108 commented May 10, 2024

When a porting is declined, instead of showing a dead end error state in the embed with no available actions the user can take, we are triggering onError.

  • Updates onError to accept metadata with code and optional porting params
  • Makes onError a required prop to initialize PortingEmbed
  • Triggers onError from the porting form when a porting is declined
  • Removed unused GenericPortingDeclined component
  • Removed unused onSupportRequested

@dharmadeveloper108 dharmadeveloper108 marked this pull request as ready for review May 10, 2024 15:18
Copy link

@3nvi 3nvi left a comment

Choose a reason for hiding this comment

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

Looks good barring the new onError signature which might constitute a breaking change and may limit us down the line.

Other than that it LGTM!

Comment on lines 11 to 12
porting?: Porting,
errorCode?: PortingEmbedError
Copy link

Choose a reason for hiding this comment

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

nit: not sure if it's right to make the error optional. I think that we should always throw an error to avoid having a breaking change for the customer.

P.S. I'd consider bagging all the custom staff into an object so we can add more things in the future without issuing a breaking change.

Something like

onError: (error: Error, meta: Metadata)

where:

type Metadata = PortingEmbedErrorMetadata | OtherErrorMetadata | ...

type PortingEmbedErrorMetadata = {
  code: 'portingDeclined' // all should have a `code` field
  porting: Porting
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thank you!! I agree, makes sense 💯 🙏

src/PortingEmbed/PortingFormContainer.tsx Outdated Show resolved Hide resolved
src/PortingEmbed/PortingFormContainer.tsx Outdated Show resolved Hide resolved
src/PortingEmbed/PortingFormContainer.tsx Outdated Show resolved Hide resolved
Copy link

@3nvi 3nvi left a comment

Choose a reason for hiding this comment

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

Just some final touches and we're good!

docs/porting-embed.md Outdated Show resolved Hide resolved
src/PortingEmbed/CustomOptionsProvider.tsx Show resolved Hide resolved
src/PortingEmbed/PortingEmbed.tsx Outdated Show resolved Hide resolved
src/PortingEmbed/PortingFormContainer.tsx Outdated Show resolved Hide resolved
Copy link

@3nvi 3nvi left a comment

Choose a reason for hiding this comment

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

LGTM thanks @dharmadeveloper108 !

src/PortingEmbed/PortingFormContainer.tsx Outdated Show resolved Hide resolved
if (e instanceof ApiError) {
onError(e, {
code: e.code,
porting: subscription?.porting || undefined,
Copy link

Choose a reason for hiding this comment

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

optional: same thing :)

Suggested change
porting: subscription?.porting || undefined,
porting: subscription?.porting,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah that's because porting can be undefined or null here

} else {
onError(new Error('Something went wrong.'), {
code: 'unexpectedError',
porting: subscription?.porting || undefined,
Copy link

Choose a reason for hiding this comment

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

Suggested change
porting: subscription?.porting || undefined,
porting: subscription?.porting,

@dharmadeveloper108 dharmadeveloper108 merged commit 50e339b into main May 28, 2024
3 checks passed
@dharmadeveloper108 dharmadeveloper108 deleted the improve-declined-porting-handling branch May 28, 2024 20:03
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