diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/compass/app/auth/newPassword/page.tsx b/compass/app/auth/newPassword/page.tsx new file mode 100644 index 0000000..6b4aaef --- /dev/null +++ b/compass/app/auth/newPassword/page.tsx @@ -0,0 +1,89 @@ +// pages/index.tsx +"use client"; +import { useState, useEffect } from 'react'; +import Button from '@/components/Button1'; +import Input from '@/components/Input1'; +import Paper from '@/components/auth/Paper'; + + +function isStrongPassword(password: string): boolean { + const strongPasswordRegex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*]).{8,}$/; + return strongPasswordRegex.test(password); +} + + +export default function Page() { + const [newPassword, setNewPassword] = useState(''); + const [confirmPassword, setConfirmPassword] = useState(''); + const [isButtonDisabled, setIsButtonDisabled] = useState(true); + + useEffect(() => { + setIsButtonDisabled(newPassword === '' || confirmPassword === '' || newPassword !== confirmPassword|| !isStrongPassword(newPassword)); + }, [newPassword, confirmPassword]); + + + return ( + <> + +
{ + e.preventDefault(); + if (newPassword === confirmPassword) { + console.log('Passwords match. Submitting form...'); + } else { + console.log('Passwords do not match. Please try again.'); + } + }} + className="mb-0 mt-6 mb-6 space-y-4 rounded-lg p-4 shadow-lg sm:p-6 lg:p-8 bg-white" + > +
+

New Password

+
+
+ { + setNewPassword(e.target.value); + }} + /> +
+ {isStrongPassword(newPassword) || newPassword === '' ? null :
+ Password is not strong enough. +

+ Tip: Use a mix of letters, numbers, and symbols for a strong password. Aim for at least 8 characters! +

+
} +
+ { + setConfirmPassword(e.target.value); + }} + /> +
+ {newPassword === confirmPassword || confirmPassword === '' ? null :
+ Passwords do not match. +

+ Please make sure both passwords are the exact same! +

+
} +
+ +
+
+

© 2024 Compass Center

+
+ + ); +} + + + diff --git a/compass/app/page.tsx b/compass/app/page.tsx index 2c959af..56bb65b 100644 --- a/compass/app/page.tsx +++ b/compass/app/page.tsx @@ -2,6 +2,7 @@ "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'; diff --git a/compass/components/Button.tsx b/compass/components/Button.tsx index 114295f..0ebfe6c 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-4 py-1 text-md font-semibold w-20 h-10 text-center`; + return ( ); }; + export default Button; diff --git a/compass/components/Button1.tsx b/compass/components/Button1.tsx new file mode 100644 index 0000000..bf6dd55 --- /dev/null +++ b/compass/components/Button1.tsx @@ -0,0 +1,24 @@ +import { FunctionComponent, ReactNode } from 'react'; + +type ButtonProps = { + children: ReactNode; + onClick?: () => void; // make the onClick handler optional + type?: "button" | "submit" | "reset"; // specify possible values for type + 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`; + return ( + + ); +}; + +export default Button; diff --git a/compass/components/Input1.tsx b/compass/components/Input1.tsx new file mode 100644 index 0000000..0517a01 --- /dev/null +++ b/compass/components/Input1.tsx @@ -0,0 +1,34 @@ +import React, { FunctionComponent, InputHTMLAttributes, ReactNode, ChangeEvent } from 'react'; + +type InputProps = InputHTMLAttributes & { + icon?: ReactNode; + title?: ReactNode; + type?:ReactNode; + placeholder?:ReactNode + valid?:boolean; + onChange: (event: ChangeEvent) => void; +}; + +const Input: FunctionComponent = ({ icon, type, title, placeholder, onChange, valid, ...rest }) => { + return ( +
+ +
+ ); +}; + +export default Input;