Skip to content

Commit

Permalink
Unify RequireAuthentication and AuthenticationModal
Browse files Browse the repository at this point in the history
- Delete StaticBackground
	It wasn't doing anything anyway.
- Replace LogInModal with AuthBlock
	Create a div and use the `fixed inset-0 ...` classes from
	LogInModal to replicate the same "the modal is covering the
	screen" effect.
- Delete RequireAuthentication.tsx, which exports the LogInModal.
	This is because the file is no longer used.
  • Loading branch information
chennisden committed Aug 7, 2024
1 parent 19e5672 commit 0bff873
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 51 deletions.
28 changes: 0 additions & 28 deletions frontend/src/components/auth/AuthenticationModal.tsx

This file was deleted.

29 changes: 6 additions & 23 deletions frontend/src/components/auth/RequireAuthentication.tsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,24 @@
import React from "react";
import AuthBlock from "./AuthBlock";

import { useAuthentication } from "hooks/useAuth";

import LogInModal from "components/auth/AuthenticationModal";

interface Props {
children: React.ReactNode;
}

const StaticBackground = () => {
return (
<div
style={{
position: "fixed",
top: 0,
left: 0,
zIndex: -1,
width: "100vw",
height: "100vh",
backgroundColor: "black",
opacity: 0.5,
}}
/>
);
};

const RequireAuthentication = (props: Props) => {
const { children } = props;
const { isAuthenticated } = useAuthentication();

return isAuthenticated ? (
<>{children}</>
) : (
<>
<StaticBackground />
<LogInModal />
</>
<div className="flex justify-center items-center">
<div className="fixed inset-0 bg-black bg-opacity-50 flex justify-center items-center">
<AuthBlock />
</div>
</div>
);
};

Expand Down

0 comments on commit 0bff873

Please sign in to comment.