diff --git a/compass/app/auth/forgot_password/page.tsx b/compass/app/auth/forgot_password/page.tsx new file mode 100644 index 0000000..554e98a --- /dev/null +++ b/compass/app/auth/forgot_password/page.tsx @@ -0,0 +1,72 @@ +"use client" +import Button from '@/components/Button'; +import Input from '@/components/Input' +import InlineLink from '@/components/InlineLink'; +import Paper from '@/components/auth/Paper'; +import { useState, useEffect } from 'react'; + +function isValidEmail(email: string) { + const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; + + if (email.trim() === '') { + return 'Email cannot be empty'; + } else if (!emailRegex.test(email)) { + return 'Invalid email format'; + } + else{ + return 'If your email exists in the database, you should receive a password reset in your inbox.' + } + +} + +export default function Page() { + const [isButtonDisabled, setIsButtonDisabled] = useState(true); + const [confirmEmail, setconfirmEmail] = useState(''); + const [emailError, setEmailError] = useState(''); + + useEffect(() => { + const error = isValidEmail(confirmEmail); + setEmailError(error); + setIsButtonDisabled(error !== null && !error.includes('exists in the database')); + }, [confirmEmail]); + + return ( + <> + +
+

Forgot password

+
+ { + setconfirmEmail(e.target.value); + setEmailError(''); // Reset the error when the user types + }}/> + {emailError && ( +

+ {emailError} +

+ )} +
+
+ + Back to Sign In + + + +
+
+

+ © 2024 Compass Center +

+
+ + ); +}; + diff --git a/compass/app/page.tsx b/compass/app/page.tsx index 0d73d47..6ee34d7 100644 --- a/compass/app/page.tsx +++ b/compass/app/page.tsx @@ -16,10 +16,10 @@ export default function Page() {
- +
- +
diff --git a/compass/components/Button.tsx b/compass/components/Button.tsx index bf6dd55..f8670e7 100644 --- a/compass/components/Button.tsx +++ b/compass/components/Button.tsx @@ -7,8 +7,10 @@ type ButtonProps = { disabled?: boolean; }; -const Button: FunctionComponent = ({ children, type, disabled, onClick }) => { - const buttonClassName = `inline-block rounded border ${disabled ? 'bg-gray-400 text-gray-600 cursor-not-allowed' : 'border-purple-600 bg-purple-600 text-white hover:bg-transparent hover:text-purple-600 focus:outline-none focus:ring active:text-purple-500'} px-12 py-3 text-sm font-semibold`; + +const Button: FunctionComponent = ({ children, type, disabled, onClick}) => { + const buttonClassName = `inline-block rounded border ${disabled ? 'bg-gray-400 text-gray-600 cursor-not-allowed' : 'border-purple-600 bg-purple-600 text-white hover:bg-transparent hover:text-purple-600 focus:outline-none focus:ring active:text-purple-500'} px-4 py-1 text-md font-semibold w-20 h-10 text-center`; + return (