All files / app/features/auth/verification StartStrongVerificationButton.tsx

0% Statements 0/20
0% Branches 0/1
0% Functions 0/5
0% Lines 0/20

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92                                                                                                                                                                                       
import Alert from "components/Alert";
import Button from "components/Button";
import {
  Dialog,
  DialogActions,
  DialogContent,
  DialogContentText,
  DialogTitle,
} from "components/Dialog";
import StyledLink from "components/StyledLink";
import { RpcError } from "grpc-web";
import { Trans, useTranslation } from "i18n";
import { AUTH, GLOBAL } from "i18n/namespaces";
import { useRouter } from "next/router";
import { InitiateStrongVerificationRes } from "proto/account_pb";
import { useState } from "react";
import { useMutation } from "react-query";
import { tosRoute } from "routes";
import { service } from "service";
 
export default function StartStrongVerificationButton() {
  const { t } = useTranslation([GLOBAL, AUTH]);
 
  const [open, setOpen] = useState(false);
 
  const router = useRouter();
 
  const {
    error,
    isLoading,
    mutate: startStrongVerification,
  } = useMutation<InitiateStrongVerificationRes.AsObject, RpcError>(
    service.account.initiateStrongVerification,
    {
      onSuccess: async (data) => {
        router.push(data.redirectUrl);
      },
    }
  );
 
  return (
    <>
      <Dialog aria-labelledby="strong-verification-start-dialog" open={open}>
        <DialogTitle id="strong-verification-start-dialog">
          {t("auth:strong_verification.title")}
        </DialogTitle>
        <DialogContent>
          {error && (
            <DialogContentText>
              <Alert severity="error">{error.message}</Alert>
            </DialogContentText>
          )}
          <DialogContentText>
            {t("auth:strong_verification.information_text1")}
          </DialogContentText>
          <DialogContentText>
            {t("auth:strong_verification.information_text2")}
          </DialogContentText>
          <DialogContentText variant="body2">
            <Trans i18nKey="auth:strong_verification.information_text3">
              You can read more about how we and Iris ID process and store your
              data in our{" "}
              <StyledLink href={tosRoute} target="_blank">
                Terms of Service
              </StyledLink>
              . As per the{" "}
              <StyledLink
                href="https://passportreader.app/privacy"
                target="_blank"
              >
                Privacy policy
              </StyledLink>
              , they will delete your personal information within 24 hours.
            </Trans>
          </DialogContentText>
        </DialogContent>
        <DialogActions>
          <Button onClick={() => startStrongVerification()} loading={isLoading}>
            {t("auth:strong_verification.begin_button")}
          </Button>
          <Button variant="outlined" onClick={() => setOpen(false)}>
            {t("global:cancel")}
          </Button>
        </DialogActions>
      </Dialog>
      <Button loading={isLoading} onClick={() => setOpen(true)}>
        {t("auth:strong_verification.start_button")}
      </Button>
    </>
  );
}