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

55 lines
1.5 KiB
TypeScript
Raw Normal View History

2021-11-10 14:20:52 +01:00
import { bytesToString, decodeCrock } from "@gnu-taler/taler-util";
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 RecoveryFinishedScreen(): VNode {
2021-11-10 14:20:52 +01:00
const reducer = useAnastasisContext();
2021-10-22 06:31:46 +02:00
if (!reducer) {
2021-11-10 14:20:52 +01:00
return <div>no reducer in context</div>;
2021-10-22 06:31:46 +02:00
}
2021-11-10 14:20:52 +01:00
if (
!reducer.currentReducerState ||
reducer.currentReducerState.recovery_state === undefined
) {
return <div>invalid state</div>;
2021-10-22 06:31:46 +02:00
}
2021-11-10 14:20:52 +01:00
const encodedSecret = reducer.currentReducerState.core_secret;
2021-10-22 06:31:46 +02:00
if (!encodedSecret) {
2021-11-10 14:20:52 +01:00
return (
<AnastasisClientFrame title="Recovery Problem" hideNav>
<p>Secret not found</p>
<div
style={{
marginTop: "2em",
display: "flex",
justifyContent: "space-between",
}}
>
<button class="button" onClick={() => reducer.back()}>
Back
</button>
</div>
</AnastasisClientFrame>
);
2021-10-22 06:31:46 +02:00
}
2021-11-10 14:20:52 +01:00
const secret = bytesToString(decodeCrock(encodedSecret.value));
2021-10-19 15:56:52 +02:00
return (
<AnastasisClientFrame title="Recovery Finished" hideNav>
2021-11-10 14:20:52 +01:00
<p>Your secret: {secret}</p>
<div
style={{
marginTop: "2em",
display: "flex",
justifyContent: "space-between",
}}
>
<button class="button" onClick={() => reducer.back()}>
Back
</button>
2021-11-04 19:17:57 +01:00
</div>
2021-10-19 15:56:52 +02:00
</AnastasisClientFrame>
);
}