diff --git a/docs/porting-embed.md b/docs/porting-embed.md index 61e199b..9782fea 100644 --- a/docs/porting-embed.md +++ b/docs/porting-embed.md @@ -51,12 +51,19 @@ The ID of your Gigs Project. Callback triggered when the number porting is completed. `porting` - The whole porting object. -### Optional props - #### `onError` -`(error: Error) => unknown` -Callback triggered when there is an error initializing the porting form. The error may stem from an invalid session, in which case recovery can be attempted by generating and passing a new Connect session to the embed. Alternatively, the error may derive from a failed attempt to retrieve a subscription, in which case it is advisable to inform the user to try again later or to contact customer support for assistance. +`(error: Error, meta: Metadata) => unknown` + +Callback triggered when the embed is in an error state. The `metadata` object includes a `code` field for the error, which gives more context about the error, and an optional `porting` field. The callback is triggered when: + +- There is an error initializing the porting form (code `'initializationError'`). The error may stem from an invalid session, in which case recovery can be attempted by generating and passing a new Connect session to the embed. The `porting` object is passed if present. +- There is an error retrieving the authorization token (code `'tokenFetchingError'`). +- There is a failed attempt to retrieve a subscription (the code is passed from the [Gigs API Error codes](https://developers.gigs.com/docs/concepts/error-codes)). In this case it is advisable to inform the user to try again later or to contact customer support for assistance. The `error` is passed as an argument to the callback. +- There is an error fetching service providers in the donor providers form (`'providersNotFound'`). +- The porting has been declined. The `porting` object and the error code `portingDeclined` are passed as arguments to the callback. + +### Optional props #### `onInitialized` @@ -73,11 +80,6 @@ Callback triggered when the embed form is loaded with a subscription and the rel `(step: PortingStep) => unknown` Callback that returns the current porting step. Useful to display custom headlines and information in your app depending on the step. -#### `onSupportRequested` - -`() => unknown` -Callback triggered when the user has clicked the "Customer support" button. You can use it, for example, to open your own Customer support page. - #### `renderTitle` `(step: PortingStep) => unknown` @@ -210,7 +212,6 @@ Returns a React node representing the customized secondary button component. ```jsx const titles: Record = { 'protectionDisabling.button': 'Request Porting Again', - 'portingDeclined.button': 'Contact Customer support', } ( `(variant: 'error' | 'info', message: string) => React.ReactNode` Render prop function that can be used to customize the rendering of alert banners in the embed. -Alert banners are used either to convey information or to display errors. +Alert banners are used either to convey information or to display errors. The `'info'` type appears in the `holderDetails` and `address` steps as follows: Account holder info alert banner Address info alert banner -The `'error'` type appears whenever there is an error after submitting a porting step, or if the porting has been declined (see all the declined messages [here](https://github.com/gigs/embeds-react-native/blob/main/src/PortingEmbed/util/portingUtils.tsx#L96)). +The `'error'` type appears whenever there is an error after submitting a porting step, or if the porting has been declined (see all the declined messages [here](https://github.com/gigs/embeds-react-native/blob/main/src/PortingEmbed/util/portingUtils.tsx#L96)). `variant` - The variant of the alert banner (either 'error' or 'info'). `message` - The message to be displayed in the alert banner. @@ -249,24 +250,24 @@ Returns a React node representing the customized alert banner component. ```jsx ( - - - {message} - - - )} + //... + renderAlertBanner={(variant, message) => ( + + + {message} + + + )} /> ``` @@ -314,29 +315,31 @@ If no `renderPortingProtectionDisabledConfirmation` prop is passed to the compon ```jsx ( - - - After you have received confirmation that port protection has - been deactivated and your number is prepared for porting, kindly - inform us by clicking the button below to confirm. - -