-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(IT Wallet): [SIW-1918] Add iPatente CTA in MDL details screen (#…
…6577) ## Short description This PR adds the iPatente service CTA in the MDL details screen ## List of changes proposed in this pull request - Bumped `IO_SERVICES_METADATA_VERSION` to version `1.0.52` - Moved ITW remote config selectors to `features/itWallet/common/store/selectors/remoteConfig.ts` - Added `itwIsIPatenteCtaEnabledSelector` selector - Added iPatente CTA in the MDL details screen ## How to test Navigate to the MDL details screen, check that the iPatente CTA is visible. Mock the `/status/backend` response setting itw.`ipatente_cta_enabled` to `false` and check that the CTA is not visibile. --------- Co-authored-by: Jacopo Pompilii <[email protected]> Co-authored-by: RiccardoMolinari95 <[email protected]>
- Loading branch information
1 parent
c42e492
commit 40f6224
Showing
17 changed files
with
285 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
ts/features/itwallet/common/store/selectors/remoteConfig.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import * as O from "fp-ts/lib/Option"; | ||
import { pipe } from "fp-ts/lib/function"; | ||
import { Platform } from "react-native"; | ||
import { createSelector } from "reselect"; | ||
import { GlobalState } from "../../../../../store/reducers/types"; | ||
import { | ||
getAppVersion, | ||
isVersionSupported | ||
} from "../../../../../utils/appVersion"; | ||
|
||
const emptyArray: ReadonlyArray<string> = []; // to avoid unnecessary rerenders | ||
|
||
const itwRemoteConfigSelector = (state: GlobalState) => | ||
pipe( | ||
state.remoteConfig, | ||
O.map(config => config.itw) | ||
); | ||
|
||
/** | ||
* Return the remote config about IT-WALLET enabled/disabled | ||
* if there is no data or the local Feature Flag is disabled, | ||
* false is the default value -> (IT-WALLET disabled) | ||
*/ | ||
export const isItwEnabledSelector = createSelector( | ||
itwRemoteConfigSelector, | ||
(itwConfig): boolean => | ||
pipe( | ||
itwConfig, | ||
O.map( | ||
itw => | ||
isVersionSupported( | ||
Platform.OS === "ios" | ||
? itw.min_app_version.ios | ||
: itw.min_app_version.android, | ||
getAppVersion() | ||
) && itw.enabled | ||
), | ||
O.getOrElse(() => false) | ||
) | ||
); | ||
|
||
/** | ||
* Returns the authentication methods that are disabled. | ||
* If there is no data, an empty array is returned as the default value. | ||
*/ | ||
export const itwDisabledIdentificationMethodsSelector = createSelector( | ||
itwRemoteConfigSelector, | ||
(itwConfig): ReadonlyArray<string> => | ||
pipe( | ||
itwConfig, | ||
O.chainNullableK(itw => itw.disabled_identification_methods), | ||
O.getOrElse(() => emptyArray) | ||
) | ||
); | ||
|
||
/** | ||
* Return whether the IT Wallet feedback banner is remotely enabled. | ||
*/ | ||
export const isItwFeedbackBannerEnabledSelector = createSelector( | ||
itwRemoteConfigSelector, | ||
itwConfig => | ||
pipe( | ||
itwConfig, | ||
O.map(itw => itw.feedback_banner_visible), | ||
O.getOrElse(() => false) | ||
) | ||
); | ||
|
||
/** | ||
* Return whether the Wallet activation is disabled. | ||
* This is purely a "cosmetic" configuration to disable UI elements, | ||
* it does not disable the entire IT Wallet feature. | ||
*/ | ||
export const itwIsActivationDisabledSelector = createSelector( | ||
itwRemoteConfigSelector, | ||
itwConfig => | ||
pipe( | ||
itwConfig, | ||
O.chainNullableK(itw => itw.wallet_activation_disabled), | ||
O.getOrElse(() => false) | ||
) | ||
); | ||
|
||
/** | ||
* Return IT Wallet credentials that have been disabled remotely. | ||
*/ | ||
export const itwDisabledCredentialsSelector = createSelector( | ||
itwRemoteConfigSelector, | ||
itwConfig => | ||
pipe( | ||
itwConfig, | ||
O.chainNullableK(itw => itw.disabled_credentials), | ||
O.getOrElse(() => emptyArray) | ||
) | ||
); | ||
|
||
/** | ||
* Return the remote config content for the deferred issuance screen content. | ||
*/ | ||
export const itwDeferredIssuanceScreenContentSelector = createSelector( | ||
itwRemoteConfigSelector, | ||
itwConfig => | ||
pipe( | ||
itwConfig, | ||
O.map(itw => itw.deferred_issuance_screen_content), | ||
O.toUndefined | ||
) | ||
); | ||
|
||
/** | ||
* Return the remote config content for the deferred issuance screen content. | ||
*/ | ||
export const itwIsIPatenteCtaEnabledSelector = createSelector( | ||
itwRemoteConfigSelector, | ||
itwConfig => | ||
pipe( | ||
itwConfig, | ||
O.map(itw => itw.ipatente_cta_visible), | ||
O.getOrElse(() => false) | ||
) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.