Skip to content

Commit

Permalink
chore: refactoring some logicbased on review
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshLarouche committed Jun 26, 2023
1 parent 0817fa4 commit 64a61f3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 30 deletions.
24 changes: 12 additions & 12 deletions app/components/Layout/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ const Navigation: React.FC<Props> = ({
{userProfileComponent}
<LogoutForm />
</>
) : router.pathname === "/" ? (
isLoggedIn
) : (
<div
style={{
display: "flex",
flexDirection: "row",
gap: "1.25em",
}}
>
<LoginForm />
{showExternalOperatorsLogin && <LoginForm isExternal={true} />}
</div>
router.pathname !== "/" && (
<div
style={{
display: "flex",
flexDirection: "row",
gap: "1.25em",
}}
>
<LoginForm />
{showExternalOperatorsLogin && <LoginForm isExternal={true} />}
</div>
)
);

const unauthorizedIdir = title === "Access required";
Expand Down
33 changes: 15 additions & 18 deletions app/components/Session/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,30 @@ interface Props {

const LoginForm: React.FC<Props> = ({ isExternal }) => {
const router = useRouter();
let loginURI = isExternal
? `/login?redirectTo=${getExternalUserLandingPageRoute().pathname}`
: "/login";
let loginURI = "/login";

if (router.query.redirectTo)
loginURI += `?redirectTo=${encodeURIComponent(
router.query.redirectTo as string
)}`;
else if (isExternal)
loginURI += `?redirectTo=${encodeURIComponent(
getExternalUserLandingPageRoute().pathname as string
)}`;

return (
<>
<form id="login-buttons" action={loginURI} method="post">
{isExternal && router.pathname.includes("login-redirect") ? (
<Button type="submit" variant="secondary-inverse">
External User Login
</Button>
) : isExternal ? (
<Button type="submit" variant="secondary">
External User Login
</Button>
) : router.pathname.includes("login-redirect") ? (
<Button type="submit" variant="secondary-inverse">
Administrator Login
</Button>
) : (
<Button type="submit">Administrator Login</Button>
)}
<Button
type="submit"
variant={
router.pathname.includes("login-redirect")
? "secondary-inverse"
: isExternal && "secondary"
}
>
{isExternal ? "External User Login" : "Administrator Login"}
</Button>
</form>
<style jsx>{`
#login-buttons {
Expand Down

0 comments on commit 64a61f3

Please sign in to comment.