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 + + + Send + + + + + + © 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 ( = ({href = '#', children}) => { return ( - + {children} ) diff --git a/compass/components/Input.tsx b/compass/components/Input.tsx index 0517a01..5997296 100644 --- a/compass/components/Input.tsx +++ b/compass/components/Input.tsx @@ -1,33 +1,41 @@ -import React, { FunctionComponent, InputHTMLAttributes, ReactNode, ChangeEvent } from 'react'; +import { Icons } from '@/utils/constants'; +import React, { FunctionComponent, InputHTMLAttributes, ReactElement, ReactNode } from 'react'; type InputProps = InputHTMLAttributes & { - icon?: ReactNode; - title?: ReactNode; - type?:ReactNode; - placeholder?:ReactNode - valid?:boolean; - onChange: (event: ChangeEvent) => void; + iconKey?: keyof typeof Icons; // Use keyof typeof to ensure the key exists in Icons + title?: string; // Assuming title is always a string + type?: string; + placeholder?: string; }; -const Input: FunctionComponent = ({ icon, type, title, placeholder, onChange, valid, ...rest }) => { +const Input: FunctionComponent = ({ iconKey, type, title, placeholder, ...rest }) => { + const IconComponent = iconKey ? Icons[iconKey] : null; + return ( - - - {title} - - - - + + {title && ( + + + {title} + + + )} + + {IconComponent && ( + + + + )} + + + ); }; diff --git a/compass/package-lock.json b/compass/package-lock.json index aa9dab8..de4e361 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 a748bbe..8fac3f3 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/tsconfig.json b/compass/tsconfig.json index c714696..1acc222 100644 --- a/compass/tsconfig.json +++ b/compass/tsconfig.json @@ -8,7 +8,7 @@ "noEmit": true, "esModuleInterop": true, "module": "esnext", - "moduleResolution": "bundler", + "moduleResolution": "node", "resolveJsonModule": true, "isolatedModules": true, "jsx": "preserve", diff --git a/compass/utils/constants.tsx b/compass/utils/constants.tsx index ad0169d..d715bb7 100644 --- a/compass/utils/constants.tsx +++ b/compass/utils/constants.tsx @@ -47,8 +47,8 @@ export enum DATATYPE { SELECT } -export const COLLECTION_MAP: {[key in COLLECTION]: CollectionImpl} = { - [COLLECTION.RESOURCE]: new CollectionImpl('Resources', Icons.ResourceIcon), - [COLLECTION.SERVICE]: new CollectionImpl('Services', Icons.ServiceIcon), - [COLLECTION.USER]: new CollectionImpl('Users', Icons.UserIcon) -} \ No newline at end of file +// export const COLLECTION_MAP: {[key in COLLECTION]: CollectionImpl} = { +// [COLLECTION.RESOURCE]: new CollectionImpl('Resources', Icons.ResourceIcon), +// [COLLECTION.SERVICE]: new CollectionImpl('Services', Icons.ServiceIcon), +// [COLLECTION.USER]: new CollectionImpl('Users', Icons.UserIcon) +// } \ No newline at end of file
+ {emailError} +
+ © 2024 Compass Center +