wallet-core/packages/anastasis-webui/src/pages/home/BackupFinishedScreen.tsx

42 lines
1.3 KiB
TypeScript
Raw Normal View History

import { format } from "date-fns";
2021-10-19 15:56:52 +02:00
import { h, VNode } from "preact";
2021-10-22 06:31:46 +02:00
import { useAnastasisContext } from "../../context/anastasis";
import { AnastasisClientFrame } from "./index";
2021-10-19 15:56:52 +02:00
2021-10-22 06:31:46 +02:00
export function BackupFinishedScreen(): VNode {
const reducer = useAnastasisContext()
if (!reducer) {
return <div>no reducer in context</div>
}
if (!reducer.currentReducerState || reducer.currentReducerState.backup_state === undefined) {
return <div>invalid state</div>
}
const details = reducer.currentReducerState.success_details
return (<AnastasisClientFrame hideNav title="Backup finished">
{reducer.currentReducerState.secret_name ? <p>
Your backup of secret <b>"{reducer.currentReducerState.secret_name}"</b> was
2021-10-19 15:56:52 +02:00
successful.
</p> :
<p>
Your secret was successfully backed up.
</p>}
2021-10-22 06:31:46 +02:00
{details && <div class="block">
<p>The backup is stored by the following providers:</p>
2021-10-22 06:31:46 +02:00
{Object.keys(details).map((x, i) => {
const sd = details[x];
2021-10-19 15:56:52 +02:00
return (
<div key={i} class="box">
{x}
<p>
version {sd.policy_version}
{sd.policy_expiration.t_ms !== 'never' ? ` expires at: ${format(sd.policy_expiration.t_ms, 'dd/MM/yyyy')}` : ' without expiration date'}
</p>
</div>
2021-10-19 15:56:52 +02:00
);
})}
</div>}
2021-10-19 15:56:52 +02:00
</AnastasisClientFrame>);
}