diff --git a/src/components/PassphraseForm.tsx b/src/components/PassphraseForm.tsx new file mode 100644 index 000000000..4dc77467a --- /dev/null +++ b/src/components/PassphraseForm.tsx @@ -0,0 +1,116 @@ +import React, { useEffect, useState } from 'react'; +import Container from 'components/Container'; +import styled from 'styled-components'; +import Card from 'react-bootstrap/Card'; +import Form from 'react-bootstrap/Form'; +import Button from 'react-bootstrap/Button'; +import constants from 'utils/strings/constants'; +import { Formik, FormikHelpers } from 'formik'; +import { getData, LS_KEYS } from 'utils/storage/localStorage'; +import { useRouter } from 'next/router'; +import * as Yup from 'yup'; +import { KeyAttributes } from 'types'; +import CryptoWorker, { setSessionKeys } from 'utils/crypto'; +import { Spinner } from 'react-bootstrap'; +import { propTypes } from 'react-bootstrap/esm/Image'; + +interface formValues { + passphrase: string; +} +interface Props { + callback: (passphrase: string, setFieldError) => void; + title: string; + placeholder: string; + buttonText: string; + alternateOption: { text: string; click: () => void }; + back: () => void; +} + +export default function PassPhraseForm(props: Props) { + const [loading, SetLoading] = useState(false); + const submitForm = async ( + values: formValues, + { setFieldError }: FormikHelpers + ) => { + SetLoading(true); + await props.callback(values.passphrase, setFieldError); + SetLoading(false); + }; + return ( + + + + + {props.title} + + + initialValues={{ passphrase: '' }} + onSubmit={submitForm} + validationSchema={Yup.object().shape({ + passphrase: Yup.string().required( + constants.REQUIRED + ), + })} + > + {({ + values, + touched, + errors, + handleChange, + handleBlur, + handleSubmit, + }) => ( +
+ + + + {errors.passphrase} + + + +
+
+ + +
+
+ )} + +
+
+
+ ); +}