Skip to content

Commit

Permalink
Merge pull request #106 from codersforcauses/improve_user_modal_funct…
Browse files Browse the repository at this point in the history
…ionality

Improve signup/login modal functionality
  • Loading branch information
K-Straiton authored Aug 3, 2024
2 parents 09d3376 + d1ff199 commit e78091e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
14 changes: 6 additions & 8 deletions client/src/components/main/header/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,14 @@ function Links({ isHiddenWhenLg }: { isHiddenWhenLg: boolean }) {
</Link>
) : (
<div className="flex flex-col items-center justify-center lg:flex-row lg:gap-5">
<button className={`${onHoverStyle}`} onClick={() => setLogIn(true)}>
Log in
</button>
<button className={outlineStyle} onClick={() => setSignUp(true)}>
Sign up
</button>
<LogInModal>
<button className={`${onHoverStyle}`}>Log in</button>
</LogInModal>
<SignUpModal>
<button className={outlineStyle}>Sign up</button>
</SignUpModal>
</div>
)}
<SignUpModal isOpen={isSignUpOpen} onClose={() => setSignUp(false)} />
<LogInModal isOpen={isLogInOpen} onClose={() => setLogIn(false)} />
</div>
);
}
Expand Down
11 changes: 6 additions & 5 deletions client/src/components/ui/LogInModal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Image from "next/image";
import { useState } from "react";
import { ReactNode, useState } from "react";

import { Button } from "@/components/ui/button";
import {
Expand All @@ -8,18 +8,18 @@ import {
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { useAuth } from "@/hooks/useAuth";

const onErrorStyle = "border-2 border-red-500";
interface Props {
isOpen: boolean;
onClose: () => void;
children: ReactNode;
}

function LogInModal({ isOpen, onClose }: Props) {
function LogInModal({ children }: Props) {
const { login } = useAuth();
const [useremail, setUseremail] = useState("");
const [password, setPassword] = useState("");
Expand All @@ -39,7 +39,8 @@ function LogInModal({ isOpen, onClose }: Props) {
};

return (
<Dialog open={isOpen} onOpenChange={onClose}>
<Dialog>
<DialogTrigger asChild>{children}</DialogTrigger>
<DialogContent
className="flex h-full max-h-[460px] w-[95%] max-w-[600px] flex-col items-center rounded-[40px] border-0 bg-accent p-1 shadow-lg file:mx-auto"
style={{ borderRadius: "32px" }}
Expand Down
11 changes: 5 additions & 6 deletions client/src/components/ui/SignUpModal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { set } from "date-fns";
import Image from "next/image";
import { useState } from "react";
import { ReactNode, useState } from "react";

import { Button } from "@/components/ui/button";
import {
Expand All @@ -25,11 +25,10 @@ import { useAuth } from "@/hooks/useAuth";
import { SelectBranch } from "./select-branch";

interface Props {
isOpen: boolean;
onClose: () => void;
children: ReactNode;
}

function SignUpModal({ isOpen, onClose }: Props) {
function SignUpModal({ children }: Props) {
const { register } = useAuth();

const [email, setEmail] = useState("");
Expand Down Expand Up @@ -162,8 +161,8 @@ function SignUpModal({ isOpen, onClose }: Props) {
};

return (
<Dialog open={isOpen} onOpenChange={onClose}>
<DialogTrigger asChild></DialogTrigger>
<Dialog>
<DialogTrigger asChild>{children}</DialogTrigger>
{/* Outer green container */}
<DialogContent
className="mx-auto flex h-full max-h-[725px] w-[95%] max-w-[600px] flex-col border-0 bg-accent p-[8px] shadow-lg"
Expand Down

0 comments on commit e78091e

Please sign in to comment.