-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(IT Wallet): [SIW-1313] Add IT Wallet trial system status (#5932)
## Short description This PR allows the app to know if the user is enabled to use the IT Wallet experimental features ## List of changes proposed in this pull request - Fixed `trial_system` typo in type definitions script - Added IT Wallet trial system status read at app boot - Added IT Wallet trial system playgrounds ## How to test With the `io-dev-api-server`, go to **Profile > Playgrounds > IT Wallet > Trial**. You should be able to enable, refresh and reset the IT Wallet trial system. ## Preview https://github.com/pagopa/io-app/assets/6160324/1c638850-2fda-42b9-9c8b-6a53b137dce6 --------- Co-authored-by: Mario Perrotta <[email protected]>
- Loading branch information
Showing
9 changed files
with
109 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { TrialId } from "../../../../../definitions/trial_system/TrialId"; | ||
|
||
export const ITW_TRIAL_ID = "01J2GN4TA8FB6DPTAX3T3YD6M1" as TrialId; |
85 changes: 85 additions & 0 deletions
85
ts/features/itwallet/playgrounds/components/ItwTrialSystemSection.tsx
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,85 @@ | ||
import { | ||
ButtonSolid, | ||
ListItemHeader, | ||
ListItemInfo, | ||
VSpacer | ||
} from "@pagopa/io-app-design-system"; | ||
import { constNull } from "fp-ts/lib/function"; | ||
import * as React from "react"; | ||
import { SubscriptionStateEnum } from "../../../../../definitions/trial_system/SubscriptionState"; | ||
import I18n from "../../../../i18n"; | ||
import { useIODispatch, useIOSelector } from "../../../../store/hooks"; | ||
import { | ||
trialSystemActivationStatus, | ||
trialSystemActivationStatusReset, | ||
trialSystemActivationStatusUpsert | ||
} from "../../../trialSystem/store/actions"; | ||
import { | ||
isLoadingTrialStatusSelector, | ||
isUpdatingTrialStatusSelector, | ||
trialStatusSelector | ||
} from "../../../trialSystem/store/reducers"; | ||
import { ITW_TRIAL_ID } from "../../common/utils/itwTrialUtils"; | ||
|
||
export const ItwTrialSystemSection = () => { | ||
const dispatch = useIODispatch(); | ||
const status = useIOSelector(trialStatusSelector(ITW_TRIAL_ID)); | ||
const isLoading = useIOSelector(isLoadingTrialStatusSelector(ITW_TRIAL_ID)); | ||
const isUpdating = useIOSelector(isUpdatingTrialStatusSelector(ITW_TRIAL_ID)); | ||
|
||
const subscribe = () => { | ||
dispatch(trialSystemActivationStatusUpsert.request(ITW_TRIAL_ID)); | ||
}; | ||
|
||
const refresh = () => { | ||
dispatch(trialSystemActivationStatus.request(ITW_TRIAL_ID)); | ||
}; | ||
|
||
const reset = () => { | ||
dispatch(trialSystemActivationStatusReset(ITW_TRIAL_ID)); | ||
}; | ||
|
||
return ( | ||
<> | ||
<ListItemHeader label="Trial" /> | ||
<ListItemInfo label="Current status" value={status ?? "Not present"} /> | ||
<VSpacer size={8} /> | ||
<> | ||
{status === undefined || | ||
status === SubscriptionStateEnum.UNSUBSCRIBED ? ( | ||
<ButtonSolid | ||
loading={isUpdating} | ||
disabled={isLoading} | ||
fullWidth={true} | ||
label={I18n.t("profile.main.trial.titleSection")} | ||
onPress={subscribe} | ||
/> | ||
) : ( | ||
<ButtonSolid | ||
disabled={isLoading} | ||
fullWidth={true} | ||
color="danger" | ||
label={"Unsubscribe"} | ||
onPress={constNull} | ||
/> | ||
)} | ||
</> | ||
<VSpacer size={8} /> | ||
<ButtonSolid | ||
loading={isUpdating} | ||
disabled={isLoading} | ||
fullWidth={true} | ||
label={"Refresh"} | ||
onPress={refresh} | ||
/> | ||
<VSpacer size={8} /> | ||
<ButtonSolid | ||
loading={isUpdating} | ||
disabled={isLoading} | ||
fullWidth={true} | ||
label={"Reset"} | ||
onPress={reset} | ||
/> | ||
</> | ||
); | ||
}; |
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