kleros/kleros-v2

View on GitHub
web/src/components/EnsureAuth.tsx

Summary

Maintainability
A
0 mins
Test Coverage
import React from "react";

import { useAccount } from "wagmi";

import { Button } from "@kleros/ui-components-library";

import { useAtlasProvider } from "context/AtlasProvider";

interface IEnsureAuth {
  children: React.ReactElement;
  className?: string;
}

const EnsureAuth: React.FC<IEnsureAuth> = ({ children, className }) => {
  const { address } = useAccount();
  const { isVerified, isSigningIn, authoriseUser } = useAtlasProvider();
  return isVerified ? (
    children
  ) : (
    <Button
      text="Sign In"
      onClick={authoriseUser}
      disabled={isSigningIn || !address}
      isLoading={isSigningIn}
      {...{ className }}
    />
  );
};

export default EnsureAuth;