/* eslint-disable @typescript-eslint/camelcase */ import { BackupStates, RecoveryStates } from "anastasis-core"; import { h, VNode } from "preact"; import { useState } from "preact/hooks"; import { useAnastasisContext } from "../../context/anastasis"; import { AnastasisClientFrame, withProcessLabel } from "./index"; export function ContinentSelectionScreen(): VNode { const reducer = useAnastasisContext(); // FIXME: remove this when #7056 is fixed const countryFromReducer = (reducer?.currentReducerState as any).selected_country || ""; const [countryCode, setCountryCode] = useState(countryFromReducer); if ( !reducer || !reducer.currentReducerState || !("continents" in reducer.currentReducerState) ) { return
; } const selectContinent = (continent: string): void => { reducer.transition("select_continent", { continent }); }; const selectCountry = (country: string): void => { setCountryCode(country); }; const continentList = reducer.currentReducerState.continents || []; const countryList = reducer.currentReducerState.countries || []; const theContinent = reducer.currentReducerState.selected_continent || ""; // const cc = reducer.currentReducerState.selected_country || ""; const theCountry = countryList.find((c) => c.code === countryCode); const selectCountryAction = async () => { //selection should be when the select box changes it value if (!theCountry) return; reducer.transition("select_country", { country_code: countryCode, currencies: [theCountry.currency], }); }; // const step1 = reducer.currentReducerState.backup_state === BackupStates.ContinentSelecting || // reducer.currentReducerState.recovery_state === RecoveryStates.ContinentSelecting; const errors = !theCountry ? "Select a country" : undefined; const handleBack = async () => { // We want to go to the start, even if we already selected // a country. // FIXME: What if we don't want to lose all information here? // Can we do some kind of soft reset? reducer.reset(); }; return (
{/* {theCountry &&
} */}

Your selection will help us ask right information to uniquely identify you when you want to recover your secret again.

Choose the country that issued most of your long-term legal documents or personal identifiers.

If you just want to try out Anastasis, we recomment that you choose Testcontinent with Demoland. For this special country, you will be asked for a simple number and not real, personal identifiable information.

{/*

Because of the diversity of personally identifying information in different countries and cultures, we do not support all countries yet. If you want to improve the supported countries,{" "} contact us.

*/}
); }