-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into IOPID-2579-add-portal-links
- Loading branch information
Showing
27 changed files
with
444 additions
and
172 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
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
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
52 changes: 52 additions & 0 deletions
52
ts/features/itwallet/trustmark/components/ItwTrustmarkExpirationTimer.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,52 @@ | ||
import { Body, HSpacer, Icon, IOStyles } from "@pagopa/io-app-design-system"; | ||
import { format } from "date-fns"; | ||
import React, { useMemo } from "react"; | ||
import { View } from "react-native"; | ||
import Placeholder from "rn-placeholder"; | ||
import { useDebugInfo } from "../../../../hooks/useDebugInfo"; | ||
import I18n from "../../../../i18n"; | ||
import { ItwTrustmarkMachineContext } from "../machine/provider"; | ||
import { selectExpirationSeconds, selectFailure } from "../machine/selectors"; | ||
import IOMarkdown from "../../../../components/IOMarkdown"; | ||
|
||
/** | ||
* Timer that shows the remaining time before the trustmark expires | ||
*/ | ||
const ItwTrustmarkExpirationTimer = () => { | ||
const expirationSeconds = ItwTrustmarkMachineContext.useSelector( | ||
selectExpirationSeconds | ||
); | ||
const failure = ItwTrustmarkMachineContext.useSelector(selectFailure); | ||
|
||
useDebugInfo({ expirationSeconds, failure }); | ||
|
||
const content = useMemo(() => { | ||
if (failure) { | ||
return <Body>{I18n.t("features.itWallet.trustmark.timer.expired")}</Body>; | ||
} | ||
|
||
if (expirationSeconds === undefined) { | ||
return ( | ||
<Placeholder.Box height={18} width={200} animate="fade" radius={4} /> | ||
); | ||
} | ||
|
||
return ( | ||
<IOMarkdown | ||
content={I18n.t("features.itWallet.trustmark.timer.expiresIn", { | ||
time: format(new Date(expirationSeconds * 1000), "mm:ss") | ||
})} | ||
/> | ||
); | ||
}, [failure, expirationSeconds]); | ||
|
||
return ( | ||
<View style={[IOStyles.row, IOStyles.alignCenter]}> | ||
<Icon name="history" size={24} color="grey-300" /> | ||
<HSpacer size={24} /> | ||
{content} | ||
</View> | ||
); | ||
}; | ||
|
||
export { ItwTrustmarkExpirationTimer }; |
Oops, something went wrong.