summaryrefslogtreecommitdiff
path: root/packages/anastasis-webui/src/pages/home/AuthMethodSmsSetup.tsx
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2021-10-19 10:56:52 -0300
committerSebastian <sebasjm@gmail.com>2021-10-19 11:05:32 -0300
commit5883d42d800c7b444c59d626bcaa5abca7dc83d0 (patch)
treeac42ad7b9e26c4dd2145a31101305884906a543e /packages/anastasis-webui/src/pages/home/AuthMethodSmsSetup.tsx
parent269022a526b670d602ca146f4df02850983bb72e (diff)
downloadwallet-core-5883d42d800c7b444c59d626bcaa5abca7dc83d0.tar.gz
wallet-core-5883d42d800c7b444c59d626bcaa5abca7dc83d0.tar.bz2
wallet-core-5883d42d800c7b444c59d626bcaa5abca7dc83d0.zip
add template from merchant backoffice
Diffstat (limited to 'packages/anastasis-webui/src/pages/home/AuthMethodSmsSetup.tsx')
-rw-r--r--packages/anastasis-webui/src/pages/home/AuthMethodSmsSetup.tsx50
1 files changed, 50 insertions, 0 deletions
diff --git a/packages/anastasis-webui/src/pages/home/AuthMethodSmsSetup.tsx b/packages/anastasis-webui/src/pages/home/AuthMethodSmsSetup.tsx
new file mode 100644
index 000000000..d193f6eb7
--- /dev/null
+++ b/packages/anastasis-webui/src/pages/home/AuthMethodSmsSetup.tsx
@@ -0,0 +1,50 @@
+/* eslint-disable @typescript-eslint/camelcase */
+import {
+ encodeCrock,
+ stringToBytes
+} from "@gnu-taler/taler-util";
+import { h, VNode } from "preact";
+import { useState, useRef, useLayoutEffect } from "preact/hooks";
+import { AuthMethodSetupProps, AnastasisClientFrame } from "./index";
+
+export function AuthMethodSmsSetup(props: AuthMethodSetupProps): VNode {
+ const [mobileNumber, setMobileNumber] = useState("");
+ const addSmsAuth = (): void => {
+ props.addAuthMethod({
+ authentication_method: {
+ type: "sms",
+ instructions: `SMS to ${mobileNumber}`,
+ challenge: encodeCrock(stringToBytes(mobileNumber)),
+ },
+ });
+ };
+ const inputRef = useRef<HTMLInputElement>(null);
+ useLayoutEffect(() => {
+ inputRef.current?.focus();
+ }, []);
+ return (
+ <AnastasisClientFrame hideNav title="Add SMS authentication">
+ <div>
+ <p>
+ For SMS authentication, you need to provide a mobile number. When
+ recovering your secret, you will be asked to enter the code you
+ receive via SMS.
+ </p>
+ <label>
+ Mobile number:{" "}
+ <input
+ value={mobileNumber}
+ ref={inputRef}
+ style={{ display: "block" }}
+ autoFocus
+ onChange={(e) => setMobileNumber((e.target as any).value)}
+ type="text" />
+ </label>
+ <div>
+ <button onClick={() => props.cancel()}>Cancel</button>
+ <button onClick={() => addSmsAuth()}>Add</button>
+ </div>
+ </div>
+ </AnastasisClientFrame>
+ );
+}