diff --git a/src/components/AddMember.tsx b/src/components/AddMember.tsx index 339290f..fc79803 100644 --- a/src/components/AddMember.tsx +++ b/src/components/AddMember.tsx @@ -16,15 +16,33 @@ interface AddMemberProps { function AddMember({ isOpen, onClose }: AddMemberProps) { const [nameError, setNameError] = useState(false); const [idError, setIdError] = useState(false); + const [name, setName] = useState(""); + const [id, setId] = useState(""); // Content style const content = "flex flex-col gap-6"; + // Function to add member + const addMember = () => () => { + if (!nameError && !idError) { + resetAndClose(); + } + }; + + const resetAndClose = () => () => { + setNameError(false); + setIdError(false); + setName(""); + setId(""); + onClose(); + }; + return ( {}} + setInput={setName} /> {}} + setInput={setId} /> @@ -53,7 +71,7 @@ function AddMember({ isOpen, onClose }: AddMemberProps) { ); } diff --git a/src/components/Modal.tsx b/src/components/Modal.tsx index db2fb24..fc36b0f 100644 --- a/src/components/Modal.tsx +++ b/src/components/Modal.tsx @@ -1,4 +1,5 @@ import clsx from "clsx"; +import { twMerge } from "tailwind-merge"; import { useEffect, useRef, useCallback } from "react"; import { X } from "@phosphor-icons/react"; @@ -56,8 +57,22 @@ function Modal({ xl: "w-[37.5rem]", }; + // Background style + const background = + "fixed inset-0 flex items-center justify-center bg-black bg-opacity-25"; + // Body style - const body = `flex flex-col p-8 gap-4 bg-neutrals-light-100 rounded-lg max-w-[80vw] max-h-[95vh] overflow-auto`; + const body = + "flex flex-col p-8 gap-4 bg-neutrals-light-100 rounded-lg max-w-[80vw] max-h-[95vh] overflow-auto scale-95"; + + // Transition style + const transition = "transition-all duration-200 ease-in-out"; + + // Closed style + const closed = "opacity-0 shadow-none pointer-events-none"; + + // Open style + const open = "opacity-100 shadow-lg pointer-events-auto scale-100"; // Header style const header = "flex flex-row w-full justify-between items-center"; @@ -118,31 +133,36 @@ function Modal({ return () => document.removeEventListener("keydown", handleKeyDown); }, [isOpen, closeable, disableCloseOnEscape, onClose]); - // Encapsulates the visibility of the modal in a prop - if (!isOpen) return null; - return (
-
-
- {icon} -

{title}

-
- {closeable && !hideCloseButton && ( -
- -
+
-
- {content} - {actions} + > +
+
+ {icon} +

{title}

+
+ {closeable && !hideCloseButton && ( +
+ +
+ )} +
+
+ {content} + {actions} +
); diff --git a/src/routes/admin/AdminHome.tsx b/src/routes/admin/AdminHome.tsx index d6e302e..c9f16d4 100644 --- a/src/routes/admin/AdminHome.tsx +++ b/src/routes/admin/AdminHome.tsx @@ -3,6 +3,7 @@ import { useEffect, useState } from "react"; import { useNavigate } from "react-router-dom"; import { Plus, CaretDown } from "@phosphor-icons/react"; import { ToastContainer } from "react-toastify"; +import AddMember from "@/components/AddMember"; import "react-toastify/dist/ReactToastify.css"; import { initializeApp } from "firebase/app"; @@ -67,13 +68,17 @@ export default function AdminHome() { // Search const [searchTerm, setSearchTerm] = useState(""); + // Add member modal control + const [isAddMemberModalOpen, setIsAddMemberModalOpen] = + useState(false); + //#region functions const fetchMembers = async () => { const [category, order] = Object.entries(sortBy)[0]; try { let q; if (lastDoc) { - console.log("Fetching more members"); + console.log("Fetching more members"); q = await getDocs( query( usersRef, @@ -219,27 +224,34 @@ export default function AdminHome() {
-
+
All Members
Total Storage Used: {totalStorageUsed} MB
-
-
-
+
+
+
-
+
+ setIsAddMemberModalOpen(false)} + />