diff --git a/src/App.tsx b/src/App.tsx index 971c786..7ae2c03 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -26,6 +26,8 @@ import MemberProfilePictureTest from "@/routes/test/MemberProfilePictureTest"; // routes import AdminLogin from "./routes/admin/AdminLogin"; +import AdminHome from "./routes/admin/AdminHome"; + import CaregiverLogin from "./routes/caregiver/CaregiverLogin"; const router = createBrowserRouter([ @@ -125,11 +127,7 @@ const router = createBrowserRouter([ // Admin Routes { path: "/admin", - element: ( -
Admin Home Page
-
+
+
+ |
+ + | - ))} ++ + | - {row.storageUsed} + {row.storageUsed} MB |
{row.lastUpdated}
diff --git a/src/components/NavigationBar.tsx b/src/components/NavigationBar.tsx
index 96f0870..2238fa3 100644
--- a/src/components/NavigationBar.tsx
+++ b/src/components/NavigationBar.tsx
@@ -1,25 +1,29 @@
//#region Imports
+import { useNavigate } from "react-router-dom";
+import { ToastContainer } from "react-toastify";
+import "react-toastify/dist/ReactToastify.css";
+
import { twMerge } from "tailwind-merge";
+
+import { initializeApp } from "firebase/app";
+import { getAuth } from "firebase/auth";
+
import logoUrl from "@/assets/images/asc_logo.svg";
+
+import { displayToast } from "@/utils";
//#endregion
//#region Interface
interface NavigationBarProps {
- /**
- * The type of user.
- * - "user" for regular users.
- * - "admin" for admin users.
- */
- userType?: "user" | "admin";
- className?: string;
+ userType?: "user" | "admin";
+ className?: string;
}
//#endregion
-//#region Functions
-function signOut() {
- // TODO: Implement sign out logic
- console.log("Signed out");
-}
+//#region firebase
+const firebaseConfig = JSON.parse(import.meta.env.VITE_FIREBASE_CONFIG);
+const app = initializeApp(firebaseConfig);
+const auth = getAuth(app);
//#endregion
/**
@@ -30,41 +34,77 @@ function signOut() {
* @returns {JSX.Element} The rendered navigation bar.
*/
export function NavigationBar({
- userType = "user",
- className,
+ userType = "user",
+ className,
}: NavigationBarProps): JSX.Element {
- return (
-
- );
+ return (
+
+
+ );
}
diff --git a/src/components/SearchBar.tsx b/src/components/SearchBar.tsx
index d317464..35ee735 100644
--- a/src/components/SearchBar.tsx
+++ b/src/components/SearchBar.tsx
@@ -1,34 +1,43 @@
-import {useState, useRef} from "react";
+//#region imports
import { MagnifyingGlass } from "@phosphor-icons/react";
+import { capitalizeSearchTerm } from "@/utils";
+//#endregion
-export interface SearchBarProps {
- target: string;
- }
+//#region interfaces
+interface SearchBarProps {
+ setSearch: React.Dispatch
+
+ setSearch(capitalizeSearchTerm(e.target.value))
+ }
+ onKeyDown={(e) => handleEnterKey(e)}
+ />
+
+
+ );
+}
- return
- setQuery(e.target.value)}
- />
-
- ;
- }
-
- export default SearchBar;
-
\ No newline at end of file
+export default SearchBar;
diff --git a/src/routes/admin/AdminHome.tsx b/src/routes/admin/AdminHome.tsx
new file mode 100644
index 0000000..4247f01
--- /dev/null
+++ b/src/routes/admin/AdminHome.tsx
@@ -0,0 +1,292 @@
+//#region Imports
+import { useEffect, useState } from "react";
+import { useNavigate } from "react-router-dom";
+import { Plus, CaretDown } from "@phosphor-icons/react";
+import { ToastContainer } from "react-toastify";
+import "react-toastify/dist/ReactToastify.css";
+
+import { initializeApp } from "firebase/app";
+import {
+ getFirestore,
+ collection,
+ getDocs,
+ query,
+ orderBy,
+ limit,
+ startAfter,
+ QueryDocumentSnapshot,
+ DocumentData,
+ startAt,
+ endAt,
+ OrderByDirection,
+} from "firebase/firestore";
+import { getAuth, onAuthStateChanged } from "firebase/auth";
+
+import { memberData } from "@/components/MemberTable";
+import Button from "@/components/Button";
+import { MemberTable } from "@/components/MemberTable";
+import { NavigationBar } from "@/components/NavigationBar";
+import SearchBar from "@/components/SearchBar";
+
+import { displayToast, convertTimestamp } from "@/utils";
+//#endregion
+
+const MAX_MEMBER_PER_LOAD = 4;
+
+//#region firebase
+const firebaseConfig = JSON.parse(import.meta.env.VITE_FIREBASE_CONFIG);
+const app = initializeApp(firebaseConfig);
+const database = getFirestore(app);
+const auth = getAuth(app);
+const usersRef = collection(database, "users");
+//#endregion
+
+/**
+ * Represents the admin home page.
+ * @returns {JSX.Element} The rendered admin home page.
+ */
+export default function AdminHome() {
+ const navigate = useNavigate();
+ const [totalStorageUsed, setTotalStorageUsed] = useState
+
+ );
+}
diff --git a/src/utils.tsx b/src/utils.tsx
new file mode 100644
index 0000000..c0569d0
--- /dev/null
+++ b/src/utils.tsx
@@ -0,0 +1,52 @@
+//#region Imports
+import { toast } from "react-toastify";
+import Toast from "@/components/Toast";
+//#endregion
+
+/**
+ * Capitalizes the first letter of each word in a string.
+ */
+const capitalizeSearchTerm = (term: string) => {
+ const words = term.toLowerCase().split(" ");
+ const capitalizedWords = words.map(
+ (word) => word.charAt(0).toUpperCase() + word.slice(1),
+ );
+ return capitalizedWords.join(" ");
+};
+
+/**
+ * Displays a toast message.
+ */
+const displayToast = (
+ message: string,
+ severity: "error" | "success" | "warning" | "info" | "neutral",
+) => {
+ if (!toast.isActive(severity))
+ toast(
+
+
+ + All Members ++ + {/* Search Section */} +
+
+
+ {/* Table Section */}
+ + Total Storage Used: {totalStorageUsed} MB + +
+
+
+
+
+ |
---|