-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: [IOPLT-516] Add CTA to enroll to a trial on Profile section (#…
…5794) > [!warning] > This PR depends on #5777 ## Short description This PR aims to add a new screen with CTA to handle the loading status of a specific trial under profile section ## List of changes proposed in this pull request - Adds the TrialSystemPlayground under Playground section of Profile/DeveloperSection ## How to test Try to start the subscription by using this PR code on dev-server pagopa/io-dev-api-server#378 --------- Co-authored-by: Mario Perrotta <[email protected]>
- Loading branch information
1 parent
5538ed0
commit 469e872
Showing
12 changed files
with
191 additions
and
4 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
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
Empty file.
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
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,98 @@ | ||
import { | ||
Body, | ||
ButtonSolid, | ||
ContentWrapper, | ||
H3, | ||
VSpacer | ||
} from "@pagopa/io-app-design-system"; | ||
import * as React from "react"; | ||
import { SafeAreaView, StyleSheet, View } from "react-native"; | ||
import { useEffect } from "react"; | ||
import { constNull } from "fp-ts/lib/function"; | ||
import { IOStyles } from "../../components/core/variables/IOStyles"; | ||
import { useHeaderSecondLevel } from "../../hooks/useHeaderSecondLevel"; | ||
import { useIODispatch, useIOSelector } from "../../store/hooks"; | ||
import { | ||
isLoadingTrialStatusSelector, | ||
trialStatusSelector | ||
} from "../../features/trialSystem/store/reducers"; | ||
import { TrialId } from "../../../definitions/trial_systwem/TrialId"; | ||
import { | ||
trialSystemActivationStatus, | ||
trialSystemActivationStatusUpsert | ||
} from "../../features/trialSystem/store/actions"; | ||
import I18n from "../../i18n"; | ||
import { SubscriptionStateEnum } from "../../../definitions/trial_systwem/SubscriptionState"; | ||
|
||
const styles = StyleSheet.create({ | ||
row: { | ||
flexDirection: "row", | ||
alignItems: "center" | ||
} | ||
}); | ||
|
||
const TRIAL_ID = "test-trial-id" as TrialId; | ||
|
||
const TrialSystemPlayground = () => { | ||
const dispatch = useIODispatch(); | ||
const trialStatus = useIOSelector(trialStatusSelector(TRIAL_ID)); | ||
const isTrialStatusLoading = useIOSelector( | ||
isLoadingTrialStatusSelector(TRIAL_ID) | ||
); | ||
|
||
const isTrialStatusUpdating = useIOSelector( | ||
isLoadingTrialStatusSelector(TRIAL_ID) | ||
); | ||
|
||
useEffect(() => { | ||
dispatch(trialSystemActivationStatus.request(TRIAL_ID)); | ||
}, [dispatch]); | ||
|
||
useHeaderSecondLevel({ | ||
title: "Sistema di Sperimentazione Playground", | ||
canGoBack: true | ||
}); | ||
|
||
return ( | ||
<SafeAreaView style={IOStyles.flex}> | ||
<ContentWrapper> | ||
<H3>{"Sperimentazione di IT-Wallet"}</H3> | ||
<VSpacer /> | ||
<View style={styles.row}> | ||
<Body color="black" weight="Semibold"> | ||
{"Stato attuale: "} | ||
</Body> | ||
<Body color="black" weight="Bold"> | ||
{trialStatus ? trialStatus : "Non presente"} | ||
</Body> | ||
</View> | ||
<VSpacer /> | ||
|
||
{!isTrialStatusLoading && ( | ||
<> | ||
{trialStatus === undefined || | ||
trialStatus === SubscriptionStateEnum.UNSUBSCRIBED ? ( | ||
<ButtonSolid | ||
loading={isTrialStatusUpdating} | ||
fullWidth | ||
label={I18n.t("profile.main.trial.titleSection")} | ||
onPress={() => | ||
dispatch(trialSystemActivationStatusUpsert.request(TRIAL_ID)) | ||
} | ||
/> | ||
) : ( | ||
<ButtonSolid | ||
fullWidth | ||
color="danger" | ||
label={"Disiscriviti"} | ||
onPress={constNull} | ||
/> | ||
)} | ||
</> | ||
)} | ||
</ContentWrapper> | ||
</SafeAreaView> | ||
); | ||
}; | ||
|
||
export default TrialSystemPlayground; |