diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index d823c23..0eb26a9 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -83,7 +83,7 @@ function App() { path="/clubAdmin/*" element={} /> - } /> + {/* } /> */} } /> } /> } /> diff --git a/frontend/src/appComponents/ClubLogin.tsx b/frontend/src/appComponents/ClubLogin.tsx index 8c1f56b..7ec5a6f 100644 --- a/frontend/src/appComponents/ClubLogin.tsx +++ b/frontend/src/appComponents/ClubLogin.tsx @@ -5,6 +5,7 @@ import password_icon from "../assets/password_icon.png"; import { useAuth } from "../context/AuthContext"; import { Eye, EyeOff } from "lucide-react" import ClipLoader from "react-spinners/ClipLoader"; +import ClubRegistration from "./ClubRegistration"; const ClubLogin: React.FC = ({ onClose, handleClosePopup }) => { const [email, setEmail] = useState(""); @@ -15,6 +16,8 @@ const ClubLogin: React.FC = ({ onClose, handleClosePopup }) => { const [hidden, setHidden] = useState(true); const navigate = useNavigate(); const { login } = useAuth(); + const [showRegistrationPage, setShowRegistrationPage] = useState(false); + const handleLogin = async (e: React.FormEvent) => { e.preventDefault(); @@ -48,8 +51,16 @@ const ClubLogin: React.FC = ({ onClose, handleClosePopup }) => { } }; + const handleOpenRegistration = () => { + setShowRegistrationPage(true); + }; + + const handleCloseRegistration = () => { + setShowRegistrationPage(false); + }; + return ( -
+

= ({ onClose, handleClosePopup }) => { onClose(false); }} > - X + navigate("/")} + src="https://img.icons8.com/pastel-glyph/128/cancel--v1.png" + alt="cancel--v1" + /> +

{" "} @@ -107,13 +126,13 @@ const ClubLogin: React.FC = ({ onClose, handleClosePopup }) => { + {showRegistrationPage && ( + + )}

diff --git a/frontend/src/appComponents/ClubRegistration.tsx b/frontend/src/appComponents/ClubRegistration.tsx index 000eef3..6dce074 100644 --- a/frontend/src/appComponents/ClubRegistration.tsx +++ b/frontend/src/appComponents/ClubRegistration.tsx @@ -5,7 +5,9 @@ import type { FieldApi } from "@tanstack/react-form"; import { useNavigate } from "react-router-dom"; import confetti from "canvas-confetti"; import { autoGrow } from "@/lib/utils"; -import {Eye, EyeOff} from "lucide-react" +import { Eye, EyeOff } from "lucide-react" +import ClubLogin from "./ClubLogin"; + // Define a TypeScript interface for the club interface Club { ClubName: string; @@ -38,10 +40,11 @@ const addClub = async (newClub: Club): Promise => { return response.data; }; -const ClubRegistration: React.FC = () => { +const ClubRegistration: React.FC = ({ onClose, handleClosePopup }) => { const navigate = useNavigate(); const [displayModal, setDisplayModal] = useState(false); const [hidden, setHidden] = useState(true); + const [showLoginPage, setShowLoginPage] = useState(false); const form = useForm({ defaultValues: { @@ -60,7 +63,8 @@ const ClubRegistration: React.FC = () => { console.log(response) setDisplayModal(true); handleClick(); - } catch (e:any) { + onClose(false); + } catch (e: any) { alert("Error: " + e.message); return; } @@ -97,18 +101,26 @@ const ClubRegistration: React.FC = () => { }; const togglePasswordVisibility = () => { - setHidden( !hidden ); + setHidden(!hidden); + }; + + const handleOpenLogin = () => { + setShowLoginPage(true); + }; + + const handleCloseLogin = () => { + setShowLoginPage(false); }; return ( -
-
-
- {/* close */} -
-

- Club Registration Form -

+
+
+

{ + onClose(false); + }} + > { src="https://img.icons8.com/pastel-glyph/128/cancel--v1.png" alt="cancel--v1" /> -

+

+

+ {" "} + Club Registration Form +

{ e.preventDefault(); e.stopPropagation(); form.handleSubmit(); }} > -
- {/* A type-safe field component*/} -
- - !value ? "Club Name is required" : undefined, - onChangeAsyncDebounceMs: 500, - onChangeAsync: async ({ value }) => { - await new Promise((resolve) => setTimeout(resolve, 1000)); - return ( - value.includes("error") && - 'No "error" allowed in ClubName' - ); - }, - }} - children={(field) => { - // Avoid hasty abstractions. Render props are great! + {/* A type-safe field component*/} +
+ + !value ? "Club Name is required" : undefined, + onChangeAsyncDebounceMs: 500, + onChangeAsync: async ({ value }) => { + await new Promise((resolve) => setTimeout(resolve, 1000)); return ( - <> - {/* */} - field.handleChange(e.target.value)} - /> -
- -
- + value.includes("error") && + 'No "error" allowed in ClubName' ); - }} - /> -
+ }, + }} + children={(field) => { + // Avoid hasty abstractions. Render props are great! + return ( + <> + {/* */} + field.handleChange(e.target.value)} + /> +
+ +
+ + ); + }} + /> +
-
- - !value ? "A Description is required" : undefined, - onChangeAsyncDebounceMs: 500, - onChangeAsync: async ({ value }) => { - await new Promise((resolve) => setTimeout(resolve, 1000)); - return ( - value?.includes("error") && - 'No "error" allowed in first name' - ); - }, - }} - children={(field) => { - const descriptionRef = useRef(null); - const handleInput = () => { - if (descriptionRef && typeof descriptionRef !== "function") { - autoGrow(descriptionRef); - } - }; - // Avoid hasty abstractions. Render props are great! +
+ + !value ? "A Description is required" : undefined, + onChangeAsyncDebounceMs: 500, + onChangeAsync: async ({ value }) => { + await new Promise((resolve) => setTimeout(resolve, 1000)); return ( - <> - {/* */} -