From 9f426927b72e689d104c4d4ce9c25176f3fa4f04 Mon Sep 17 00:00:00 2001 From: Kamala Date: Fri, 10 May 2024 17:04:11 +0200 Subject: [PATCH 1/7] Improve handling of declined portings --- docs/porting-embed.md | 120 +++++++++--------- example/app/porting/index.tsx | 27 ++-- src/PortingEmbed/CustomOptionsProvider.tsx | 8 +- src/PortingEmbed/PortingEmbed.tsx | 11 +- src/PortingEmbed/PortingFormContainer.tsx | 54 +++++--- .../__tests__/PortingFormContainer.test.tsx | 45 ++++--- .../DonorProvider/DonorProviderForm.tsx | 2 +- .../features/GenericPortingDeclined.tsx | 51 -------- src/core/ConnectSessionProvider.tsx | 4 +- .../GenericPortingDeclined.stories.tsx | 38 ------ 10 files changed, 159 insertions(+), 201 deletions(-) delete mode 100644 src/PortingEmbed/features/GenericPortingDeclined.tsx delete mode 100644 storybook/stories/PortingEmbed/features/GenericPortingDeclined.stories.tsx diff --git a/docs/porting-embed.md b/docs/porting-embed.md index 61e199b..a5e805d 100644 --- a/docs/porting-embed.md +++ b/docs/porting-embed.md @@ -51,12 +51,16 @@ 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, porting?: Porting, errorCode?: PortingEmbedError) => 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. The `error` is passed as an argument to the callback. +* There is a failed attempt to retrieve a subscription. 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. +* The porting has been declined. The `porting` object and the error code `portingDeclined` are passed as arguments to the callback. + +### Optional props #### `onInitialized` @@ -210,7 +214,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 +252,24 @@ Returns a React node representing the customized alert banner component. ```jsx ( - - - {message} - - - )} + //... + renderAlertBanner={(variant, message) => ( + + + {message} + + + )} /> ``` @@ -314,29 +317,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. - -