From a62deeef5d0cbe5fa98be390eac0e03bcae0f0b5 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 10 Nov 2021 10:20:52 -0300 Subject: prettier --- .../src/pages/home/SecretSelectionScreen.tsx | 185 ++++++++++++++------- 1 file changed, 128 insertions(+), 57 deletions(-) (limited to 'packages/anastasis-webui/src/pages/home/SecretSelectionScreen.tsx') diff --git a/packages/anastasis-webui/src/pages/home/SecretSelectionScreen.tsx b/packages/anastasis-webui/src/pages/home/SecretSelectionScreen.tsx index 398393619..4000f9bfe 100644 --- a/packages/anastasis-webui/src/pages/home/SecretSelectionScreen.tsx +++ b/packages/anastasis-webui/src/pages/home/SecretSelectionScreen.tsx @@ -8,18 +8,23 @@ import { AnastasisClientFrame } from "./index"; export function SecretSelectionScreen(): VNode { const [selectingVersion, setSelectingVersion] = useState(false); - const reducer = useAnastasisContext() + const reducer = useAnastasisContext(); - const [manageProvider, setManageProvider] = useState(false) - const currentVersion = (reducer?.currentReducerState - && ("recovery_document" in reducer.currentReducerState) - && reducer.currentReducerState.recovery_document?.version) || 0; + const [manageProvider, setManageProvider] = useState(false); + const currentVersion = + (reducer?.currentReducerState && + "recovery_document" in reducer.currentReducerState && + reducer.currentReducerState.recovery_document?.version) || + 0; if (!reducer) { - return
no reducer in context
+ return
no reducer in context
; } - if (!reducer.currentReducerState || reducer.currentReducerState.recovery_state === undefined) { - return
invalid state
+ if ( + !reducer.currentReducerState || + reducer.currentReducerState.recovery_state === undefined + ) { + return
invalid state
; } async function doSelectVersion(p: string, n: number): Promise { @@ -33,72 +38,101 @@ export function SecretSelectionScreen(): VNode { }); } - const providerList = Object.keys(reducer.currentReducerState.authentication_providers ?? {}) - const recoveryDocument = reducer.currentReducerState.recovery_document + const providerList = Object.keys( + reducer.currentReducerState.authentication_providers ?? {}, + ); + const recoveryDocument = reducer.currentReducerState.recovery_document; if (!recoveryDocument) { - return doSelectVersion(newProv, 0)} - /> + return ( + doSelectVersion(newProv, 0)} + /> + ); } if (selectingVersion) { - return setSelectingVersion(false)} - onConfirm={doSelectVersion} - /> + return ( + setSelectingVersion(false)} + onConfirm={doSelectVersion} + /> + ); } if (manageProvider) { - return setManageProvider(false)} /> + return setManageProvider(false)} />; } return (
-
+

{recoveryDocument.provider_url}

- {currentVersion === 0 ?

- Set to recover the latest version -

:

- Set to recover the version number {currentVersion} -

} + {currentVersion === 0 ? ( +

Set to recover the latest version

+ ) : ( +

Set to recover the version number {currentVersion}

+ )}
- +
-

Secret found, you can select another version or continue to the challenges solving

+

+ Secret found, you can select another version or continue to the + challenges solving +

- +

-
); } - -function ChooseAnotherProviderScreen({ providers, selected, onChange }: { selected: string; providers: string[]; onChange: (prov: string) => void }): VNode { +function ChooseAnotherProviderScreen({ + providers, + selected, + onChange, +}: { + selected: string; + providers: string[]; + onChange: (prov: string) => void; +}): VNode { return ( - +

No recovery document found, try with another provider

- onChange(e.currentTarget.value)} + value={selected} + > + + {providers.map((prov) => ( @@ -114,9 +148,23 @@ function ChooseAnotherProviderScreen({ providers, selected, onChange }: { select ); } -function SelectOtherVersionProviderScreen({ providers, provider, version, onConfirm, onCancel }: { onCancel: () => void; provider: string; version: number; providers: string[]; onConfirm: (prov: string, v: number) => Promise; }): VNode { +function SelectOtherVersionProviderScreen({ + providers, + provider, + version, + onConfirm, + onCancel, +}: { + onCancel: () => void; + provider: string; + version: number; + providers: string[]; + onConfirm: (prov: string, v: number) => Promise; +}): VNode { const [otherProvider, setOtherProvider] = useState(provider); - const [otherVersion, setOtherVersion] = useState(version > 0 ? String(version) : ""); + const [otherVersion, setOtherVersion] = useState( + version > 0 ? String(version) : "", + ); return ( @@ -125,11 +173,11 @@ function SelectOtherVersionProviderScreen({ providers, provider, version, onConf

Provider {otherProvider}

- {version === 0 ?

- Set to recover the latest version -

:

- Set to recover the version number {version} -

} + {version === 0 ? ( +

Set to recover the latest version

+ ) : ( +

Set to recover the version number {version}

+ )}

Specify other version below or use the latest

@@ -137,9 +185,15 @@ function SelectOtherVersionProviderScreen({ providers, provider, version, onConf
- setOtherProvider(e.currentTarget.value)} + value={otherProvider} + > + + {providers.map((prov) => ( @@ -156,23 +210,40 @@ function SelectOtherVersionProviderScreen({ providers, provider, version, onConf label="Version" placeholder="version number to recover" grabFocus - bind={[otherVersion, setOtherVersion]} /> + bind={[otherVersion, setOtherVersion]} + />
-
- +
+
- onConfirm(otherProvider, 0)}>Use latest - onConfirm(otherProvider, parseInt(otherVersion, 10))}>Confirm + onConfirm(otherProvider, 0)} + > + Use latest + + + onConfirm(otherProvider, parseInt(otherVersion, 10)) + } + > + Confirm +
-
- . -
+
.
-
); - } -- cgit v1.2.3