diff --git a/compass/app/auth/forgot_password/page.tsx b/compass/app/auth/forgot_password/page.tsx index 554e98a..e12f6b2 100644 --- a/compass/app/auth/forgot_password/page.tsx +++ b/compass/app/auth/forgot_password/page.tsx @@ -1,9 +1,9 @@ "use client" -import Button from '@/components/Button'; +import Button from '@/components/Button49'; import Input from '@/components/Input' import InlineLink from '@/components/InlineLink'; import Paper from '@/components/auth/Paper'; -import { useState, useEffect } from 'react'; +import { useState, useEffect } from 'react'; function isValidEmail(email: string) { const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; @@ -29,7 +29,7 @@ export default function Page() { setEmailError(error); setIsButtonDisabled(error !== null && !error.includes('exists in the database')); }, [confirmEmail]); - + return ( <> @@ -37,11 +37,11 @@ export default function Page() { className="mb-0 mt-6 mb-6 space-y-4 rounded-lg p-4 shadow-lg sm:p-6 lg:p-8 bg-white">

Forgot password

- { setconfirmEmail(e.target.value); setEmailError(''); // Reset the error when the user types diff --git a/compass/app/page.tsx b/compass/app/page.tsx index 6ee34d7..56bb65b 100644 --- a/compass/app/page.tsx +++ b/compass/app/page.tsx @@ -1,33 +1,74 @@ // pages/index.tsx +"use client"; +import Button from '@/components/Button49'; import Button from '@/components/Button1'; import Input from '@/components/Input' import InlineLink from '@/components/InlineLink'; import Paper from '@/components/auth/Paper'; -import { Metadata } from 'next' - -export const metadata: Metadata = { - title: 'Login', -} +import Image from 'next/image'; +import {ChangeEvent, useState} from "react"; +import PasswordInput from '@/components/auth/PasswordInput'; export default function Page() { + const [email, setEmail] = useState(""); + const [password, setPassword] = useState(""); + const [error, setError] = useState(""); + + const handleEmailChange = (event: React.ChangeEvent) => { + setEmail(event.currentTarget.value); + } + + const handlePasswordChange = (event: React.ChangeEvent) => { + setPassword(event.currentTarget.value); + } + + const handleClick = (event: React.MouseEvent) => { + // Priority: Incorrect combo > Missing email > Missing password + + if (password.trim().length === 0) { + setError("Please enter your password.") + event.preventDefault(); + } + // This shouldn't happen, already provides validation, but just in case. + if (email.trim().length === 0) { + setError("Please enter your email.") + event.preventDefault(); + } + // Placeholder for incorrect email + password combo. + if (email === "incorrect@gmail.com" && password) { + setError("Incorrect password.") + event.preventDefault(); + } + } + return ( <> -
+ + Compass Center logo. +

Login

- +
- +
- + Forgot password? - +
diff --git a/compass/components/Button.tsx b/compass/components/Button.tsx index f8670e7..0ebfe6c 100644 --- a/compass/components/Button.tsx +++ b/compass/components/Button.tsx @@ -2,7 +2,7 @@ import { FunctionComponent, ReactNode } from 'react'; type ButtonProps = { children: ReactNode; - onClick?: () => void; // make the onClick handler optional + onClick?: (event: React.MouseEvent) => void; type?: "button" | "submit" | "reset"; // specify possible values for type disabled?: boolean; }; diff --git a/compass/components/auth/PasswordInput.tsx b/compass/components/auth/PasswordInput.tsx new file mode 100644 index 0000000..f196ec4 --- /dev/null +++ b/compass/components/auth/PasswordInput.tsx @@ -0,0 +1,48 @@ +'use client' +import { Icons } from '@/utils/constants'; +import React, { FunctionComponent, InputHTMLAttributes, ReactElement, ReactNode, useState} from 'react'; + + +type InputProps = InputHTMLAttributes & { + title?: string; // Assuming title is always a string + type?: string; + placeholder?: string; +}; + +const PasswordInput: FunctionComponent = ({ type, title, placeholder, ...rest }) => { + + const [visible, setVisible] = useState (false); + const PasswordIcon = visible ? Icons['HidePasswordIcon'] : Icons['UnhidePasswordIcon']; + + return ( +
+ {title && ( +
+ +
+ )} +
+ + + + {PasswordIcon && ( + + setVisible(!visible)}/> + + )} + +
+
+ ); +}; + +export default PasswordInput; diff --git a/compass/package-lock.json b/compass/package-lock.json index de4e361..aa9dab8 100644 --- a/compass/package-lock.json +++ b/compass/package-lock.json @@ -9,7 +9,7 @@ "version": "0.1.0", "dependencies": { "@heroicons/react": "^2.1.1", - "next": "^13.5.6", + "next": "13.5.6", "react": "^18", "react-dom": "^18" }, diff --git a/compass/package.json b/compass/package.json index 8fac3f3..a748bbe 100644 --- a/compass/package.json +++ b/compass/package.json @@ -10,7 +10,7 @@ }, "dependencies": { "@heroicons/react": "^2.1.1", - "next": "^13.5.6", + "next": "13.5.6", "react": "^18", "react-dom": "^18" }, diff --git a/compass/public/logo.png b/compass/public/logo.png new file mode 100644 index 0000000..6ab7af4 Binary files /dev/null and b/compass/public/logo.png differ diff --git a/compass/tsconfig.json b/compass/tsconfig.json index 1acc222..c714696 100644 --- a/compass/tsconfig.json +++ b/compass/tsconfig.json @@ -8,7 +8,7 @@ "noEmit": true, "esModuleInterop": true, "module": "esnext", - "moduleResolution": "node", + "moduleResolution": "bundler", "resolveJsonModule": true, "isolatedModules": true, "jsx": "preserve",