+
-
+
@@ -105,21 +101,15 @@ const Upcoming = ({
{restOfSentence}
-
{description}
+
{description}
diff --git a/src/app/(main)/activities/page.tsx b/src/app/(main)/activities/page.tsx
index 9a83ec9..d5b4a2e 100644
--- a/src/app/(main)/activities/page.tsx
+++ b/src/app/(main)/activities/page.tsx
@@ -60,18 +60,21 @@ const Activities = async ({
UPCOMING
EVENT
-
-
+
+ {upcoming.map((d, ind) => {
+ return (
+
+ );
+ })}
>
) : null}
diff --git a/src/app/(main)/styles/markdown.css b/src/app/(main)/styles/markdown.css
index ebca6c7..2b9819a 100644
--- a/src/app/(main)/styles/markdown.css
+++ b/src/app/(main)/styles/markdown.css
@@ -10,18 +10,25 @@
.markdown p {
padding-bottom: 0.5rem;
}
+
+.markdown p::first-line {
+ padding-left: 1rem;
+}
.markdown a {
color: #3b82f6;
}
.markdown h1 {
font-size: 2.25rem;
- padding-top: 1.25rem;
- padding-bottom: 0.5rem;
+ padding-top: 2.5rem;
+ padding-bottom: 1rem;
font-weight: 400;
}
+/* .markdown h1::first-letter {
+ color: #2f4770;
+} */
.markdown h2 {
font-size: 1.875rem;
- padding-top: 1.15rem;
+ padding-top: 2.5rem;
padding-bottom: 0.5rem;
font-weight: 400;
}
@@ -30,11 +37,17 @@
.markdown h5,
.markdown h6 {
font-size: 1.5rem;
- padding-top: 0.65rem;
- padding-bottom: 0.5rem;
+ padding-top: 0.25rem;
+ padding-bottom: 0.25rem;
font-family: Nunito;
font-weight: 700;
}
+
+.markdown h4,
+.markdown h5,
+.markdown h6 {
+ font-size: 1.25rem !important;
+}
.markdown table {
border: 1px solid #e4e4e7;
border-radius: 2px;
@@ -53,3 +66,18 @@
padding: 0.5rem 2rem;
border: 1px solid #d1d5db;
}
+
+.markdown ul {
+ list-style-type: circle;
+ list-style-position: inside;
+}
+
+.markdown ol {
+ list-style-type: decimal;
+ list-style-position: inside;
+}
+
+.markdown li::marker {
+ color: #3b82f6;
+ font-weight: bold;
+}
diff --git a/src/app/api/getevents/route.ts b/src/app/api/getevents/route.ts
index 768cc0d..9269095 100644
--- a/src/app/api/getevents/route.ts
+++ b/src/app/api/getevents/route.ts
@@ -87,6 +87,10 @@ export async function POST(req: NextRequest) {
imageURL: e.data().imageURL,
description: e.data().description,
category: e.data().category,
+ participated:
+ userParticipated && Array.isArray(userParticipated)
+ ? userParticipated.includes(e.id)
+ : false,
}));
return NextResponse.json({
diff --git a/src/app/api/getquestion/route.ts b/src/app/api/getquestion/route.ts
index 311c7ac..b50f90c 100644
--- a/src/app/api/getquestion/route.ts
+++ b/src/app/api/getquestion/route.ts
@@ -52,10 +52,7 @@ export async function POST(req: NextRequest) {
{ status: 404 },
);
} else if (now > endTime) {
- return NextResponse.json(
- { error: "The exam was over decades ago" },
- { status: 404 },
- );
+ return NextResponse.json({ error: "The exam is over" }, { status: 404 });
}
if ((data.ndc_id == "" || data.ndc_id == "none") && intra) {
diff --git a/src/app/api/memberdata/route.ts b/src/app/api/memberdata/route.ts
index 6109ca0..ba5e42a 100644
--- a/src/app/api/memberdata/route.ts
+++ b/src/app/api/memberdata/route.ts
@@ -16,8 +16,6 @@ export async function POST(req: NextRequest) {
const member = await memberDOC.json();
- console.log(member);
-
if (!memberDOC.ok) {
return NextResponse.json(
{ error: "No such Club Member exists" },
diff --git a/src/app/club/(user-handle)/delete-account/page.tsx b/src/app/club/(user-handle)/delete-account/page.tsx
deleted file mode 100644
index aeca790..0000000
--- a/src/app/club/(user-handle)/delete-account/page.tsx
+++ /dev/null
@@ -1,133 +0,0 @@
-"use client";
-
-import Field from "@/app/club/Components/Field";
-import React, { useEffect, useState } from "react";
-import Link from "next/link";
-import { auth, db, pfp } from "@/config/firebase";
-
-import { deleteUser, signInWithEmailAndPassword } from "firebase/auth";
-
-import { toast } from "react-toastify";
-import { CgArrowLeft, CgSpinner } from "react-icons/cg";
-import { useRouter } from "next/navigation";
-import Image from "next/image";
-import { doc, DocumentReference, deleteDoc } from "firebase/firestore";
-import { useAuthState } from "react-firebase-hooks/auth";
-import { deleteObject, ref } from "firebase/storage";
-import ActualUser from "@/util/ActualUser";
-
-const deleteEventParticipantDoc = async (uid: string) => {
- const res = await fetch("/api/submit", {
- method: "POST",
- body: JSON.stringify({ uid: uid }),
- });
-
- if (!res.ok) {
- toast.error("Error Occurred");
- return [];
- }
-
- return res.json();
-};
-
-const Page = () => {
- const [password, setPassword] = useState("");
- const [loading, setLoading] = useState(false);
- const [user] = useAuthState(auth);
- const Router = useRouter();
- const handleSubmit = async (event: any) => {
- event.preventDefault();
- setLoading(true);
- if (user && user.email) {
- signInWithEmailAndPassword(auth, user.email, password)
- .then(async (UserCred) => {
- const UserInfo = UserCred.user;
- await deleteUser(UserInfo);
- await deleteDoc(doc(db, "participants", UserInfo.uid));
- await deleteObject(ref(pfp, "pfp/" + UserInfo.uid));
- await deleteEventParticipantDoc(UserInfo.uid);
- toast.success(`User Deleted!`);
- setLoading(false);
- Router.push("/club");
- })
- .catch((error) => {
- console.dir(error);
- switch (error.code) {
- case "auth/invalid-credential":
- toast.error(`Invalid password.`);
- break;
- case "storage/object-not-found":
- break;
- default:
- console.error(error.message);
- toast.error(error.message.replaceAll("Firebase: ", ""));
- break;
- }
- setLoading(false);
- });
- } else {
- toast.error(`User not logged in.`);
- setLoading(false);
- }
- };
-
- return (
-
-
-
-
-
-
- );
-};
-
-export default Page;
diff --git a/src/app/club/(user-handle)/login/page.tsx b/src/app/club/(user-handle)/login/page.tsx
deleted file mode 100644
index 0811953..0000000
--- a/src/app/club/(user-handle)/login/page.tsx
+++ /dev/null
@@ -1,144 +0,0 @@
-"use client";
-
-import Field from "@/app/club/Components/Field";
-import React, { useEffect, useState } from "react";
-import Link from "next/link";
-import { auth, db } from "@/config/firebase";
-
-import { signInWithEmailAndPassword } from "firebase/auth";
-
-import { toast } from "react-toastify";
-import { CgLogIn, CgSpinner } from "react-icons/cg";
-import { useRouter } from "next/navigation";
-import Image from "next/image";
-import { FirebaseError } from "firebase/app";
-import { useAuthContext } from "@/app/club/Components/Layout/AuthContextProvider";
-
-const Page = () => {
- const [password, setPassword] = useState("");
- const [email, setEmail] = useState("");
- const [loading, setLoading] = useState(false);
- const [authLoading, setAuthLoading] = useState(false);
-
- const userAuth = useAuthContext().userAuth;
- const uloading = useAuthContext().loading;
-
- const Router = useRouter();
- const handleSubmit = async (event: any) => {
- event.preventDefault();
- setLoading(true);
- signInWithEmailAndPassword(auth, email, password)
- .then(async (UserCred) => {
- toast.success("User logged in!");
- setLoading(false);
- Router.push("/club/profile");
- })
- .catch((error: FirebaseError) => {
- console.dir(error);
- switch (error.code) {
- case "auth/invalid-credential":
- toast.error(`Invalid email or password.`);
- break;
- case "auth/too-many-requests":
- toast.error(
- `Too many login attempts. Please reset your password to login again.`,
- );
- break;
- default:
- console.error(error.message);
- toast.error(error.message.replaceAll("Firebase: ", ""));
- break;
- }
- setLoading(false);
- });
- };
- useEffect(() => {
- console.log(auth);
- setAuthLoading(true);
- if (userAuth) {
- Router.push("/club/profile");
- }
- setAuthLoading(false);
- }, [Router, userAuth]);
- return (
-
-
-
-
-
-
- );
-};
-
-export default Page;
diff --git a/src/app/club/(user-handle)/profile/announcements/page.tsx b/src/app/club/(user-handle)/profile/announcements/page.tsx
deleted file mode 100644
index b060e2e..0000000
--- a/src/app/club/(user-handle)/profile/announcements/page.tsx
+++ /dev/null
@@ -1,17 +0,0 @@
-"use client";
-
-import { useUserDataContext } from "@/app/club/Components/Layout/UserDataProvider";
-import Announcements from "@/app/club/Components/Profile/Announcements";
-import React from "react";
-
-const Page = () => {
- const { userData } = useUserDataContext();
- return (
-
- {userData?.ndc_id ?
: null}
-
-
- );
-};
-
-export default Page;
diff --git a/src/app/club/(user-handle)/profile/club/page.tsx b/src/app/club/(user-handle)/profile/club/page.tsx
deleted file mode 100644
index dbc8945..0000000
--- a/src/app/club/(user-handle)/profile/club/page.tsx
+++ /dev/null
@@ -1,25 +0,0 @@
-"use client";
-import { useUserDataContext } from "@/app/club/Components/Layout/UserDataProvider";
-import ClubInfo from "@/app/club/Components/Profile/ClubInfo";
-import { auth } from "@/config/firebase";
-
-const Page = () => {
- const { userData, userDataLoading, dataError, updateUserData } =
- useUserDataContext();
-
- return (
-
- {userData && !userDataLoading ? (
-
- ) : null}
-
- );
-};
-
-export default Page;
diff --git a/src/app/club/(user-handle)/profile/events/page.tsx b/src/app/club/(user-handle)/profile/events/page.tsx
deleted file mode 100644
index 6a9b51a..0000000
--- a/src/app/club/(user-handle)/profile/events/page.tsx
+++ /dev/null
@@ -1,7 +0,0 @@
-import React from "react";
-
-const page = () => {
- return S
;
-};
-
-export default page;
diff --git a/src/app/club/(user-handle)/profile/layout.tsx b/src/app/club/(user-handle)/profile/layout.tsx
deleted file mode 100644
index 6f42b76..0000000
--- a/src/app/club/(user-handle)/profile/layout.tsx
+++ /dev/null
@@ -1,99 +0,0 @@
-/* eslint-disable @next/next/no-img-element */
-"use client";
-
-import { auth } from "@/config/firebase";
-import { usePathname, useRouter } from "next/navigation";
-import React, { useEffect, useState } from "react";
-import { toast } from "react-toastify";
-import { useAuthState } from "react-firebase-hooks/auth";
-import { CgSpinner } from "react-icons/cg";
-import {
- UserDataContextProvider,
- useUserDataContext,
-} from "@/app/club/Components/Layout/UserDataProvider";
-import ProfileHero from "../../Components/Profile/ProfileHero";
-import { SubNav, SubNavItem } from "../../Components/SubNav";
-import { CgProfile } from "react-icons/cg";
-import { MdAnnouncement, MdEvent } from "react-icons/md";
-import { IoPeopleOutline } from "react-icons/io5";
-import ContestCard from "../../Components/Profile/ContestCard";
-import Loading from "../../Components/Loading";
-
-const Page = ({ children }: { children: React.ReactNode }) => {
- const [userAuth, loading, error] = useAuthState(auth);
- const [dLoading, setDLoading] = useState(true);
- const Route = useRouter();
-
- useEffect(() => {
- auth.currentUser?.reload();
-
- if (userAuth) {
- fetch("/api/admin", {
- method: "POST",
- body: JSON.stringify({ id: userAuth.email }),
- })
- .then((r) => r.json())
- .then((resp) => {
- setDLoading(false);
- if (resp.auth) {
- Route.push("/club/admin");
- }
- })
- .catch((err) => {
- setDLoading(false);
- toast.error("Something went wrong");
- });
- }
-
- if (userAuth && !userAuth?.emailVerified) {
- setDLoading(false);
- Route.push("/club/verify");
- } else if (!loading && !userAuth) {
- setDLoading(false);
- Route.push("/club/login");
- }
- }, [Route, userAuth, loading]);
-
- return (
- <>
- {userAuth ? (
-
-
-
-
-
-
-
- Profile
-
-
- Club{" "}
-
-
- Notice
-
- {/*
- Events
- */}
-
-
- {children}
-
-
-
- ) : loading || dLoading ? (
-
- ) : (
-
- )}
- >
- );
-};
-
-export default Page;
diff --git a/src/app/club/(user-handle)/profile/page.tsx b/src/app/club/(user-handle)/profile/page.tsx
deleted file mode 100644
index 5dc74c1..0000000
--- a/src/app/club/(user-handle)/profile/page.tsx
+++ /dev/null
@@ -1,59 +0,0 @@
-/* eslint-disable @next/next/no-img-element */
-"use client";
-
-import { auth } from "@/config/firebase";
-import { useRouter } from "next/navigation";
-import React, { useEffect, useState } from "react";
-import { FaRegTrashAlt } from "react-icons/fa";
-import Link from "next/link";
-import { useAuthState } from "react-firebase-hooks/auth";
-import EditData from "@/app/club/Components/Profile/EditData";
-import Announcements from "@/app/club/Components/Profile/Announcements";
-import ClubInfo from "@/app/club/Components/Profile/ClubInfo";
-import { useUserDataContext } from "@/app/club/Components/Layout/UserDataProvider";
-import { MdLockReset } from "react-icons/md";
-
-const Page = () => {
- const [userAuth, loading, error] = useAuthState(auth);
-
- const [uData, setUserData] = useState();
-
- const { userData, userDataLoading, dataError } = useUserDataContext();
-
- // const [dLoading, setDLoading] = useState(true);
-
- const Route = useRouter();
-
- useEffect(() => {
- if (userData) {
- setUserData({ ...userData });
- }
- }, [userData]);
-
- return (
- <>
-
-
-
- SPECIAL ACTIONS
-
-
-
-
- Reset Password
-
-
- Delete Account
-
-
- >
- );
-};
-
-export default Page;
diff --git a/src/app/club/(user-handle)/register/page.tsx b/src/app/club/(user-handle)/register/page.tsx
deleted file mode 100644
index 89f8407..0000000
--- a/src/app/club/(user-handle)/register/page.tsx
+++ /dev/null
@@ -1,398 +0,0 @@
-"use client";
-
-import Field from "@/app/club/Components/Field";
-import React, { useEffect, useReducer, useState } from "react";
-import { regDataInit, regDataType, classes } from "@/config/registerData";
-import Select from "@/app/club/Components/Select";
-import { auth, db } from "@/config/firebase";
-import { doc, serverTimestamp, setDoc } from "firebase/firestore";
-
-import {
- createUserWithEmailAndPassword,
- sendEmailVerification,
-} from "firebase/auth";
-
-import verifyData from "@/util/verification";
-import { AiOutlineUserAdd } from "react-icons/ai";
-import { toast } from "react-toastify";
-import { CgSpinner } from "react-icons/cg";
-import { useRouter } from "next/navigation";
-import Link from "next/link";
-import { getConfig } from "@/config/config_db";
-import { Checkbox } from "@nextui-org/checkbox";
-import { useAuthContext } from "@/app/club/Components/Layout/AuthContextProvider";
-import PassingYear from "../../Components/PassingYear";
-import { CiWarning } from "react-icons/ci";
-
-type actionType = {
- type: "SET_FIELD";
- name: string;
- data: string | number;
-};
-
-const getRegisteredNDC = async (regData: regDataType) => {
- const res = await fetch("/api/createaccountndc", {
- method: "POST",
- body: JSON.stringify({ ...regData }),
- });
-
- return res;
-};
-
-const Page = () => {
- const { userAuth, loading, error } = useAuthContext();
-
- const [regData, dispatch] = useReducer<
- (prevState: regDataType, action: actionType) => regDataType
- >((prevState: regDataType, action: actionType) => {
- switch (action.type) {
- case "SET_FIELD":
- return { ...prevState, [action.name]: action.data };
- default:
- return { ...prevState };
- }
- }, regDataInit);
- const [password, setPassword] = useState("");
- const [confirmPassword, setConfirmPassword] = useState("");
- const [isNDCStudent, setIsNDCStudent] = useState(false);
- const [configLoading, setConfigLoading] = useState(true);
- const [rloading, setLoading] = useState(false);
- const Router = useRouter();
- const handleSubmit = async (event: any) => {
- event.preventDefault();
- setLoading(true);
- const [verified, massage] = verifyData(regData, password, confirmPassword);
-
- if (isNDCStudent && regData.ndc_id != "") {
- if (verified) {
- const ndc_register_res = await getRegisteredNDC(regData);
- const ndc_register_json = await ndc_register_res.json();
-
- if (!ndc_register_res.ok) {
- toast.error(ndc_register_json.error);
- setLoading(false);
- return;
- } else {
- if (ndc_register_json.success) {
- regData.ndc_id = ndc_register_json.memberID;
- createUserWithEmailAndPassword(auth, regData.email, password)
- .then(async (userInfo) => {
- //add userInfo in Collections
- const uid = userInfo.user.uid;
- await setDoc(doc(db, "participants", uid), {
- ...regData,
- institution: "Notre Dame College",
- mobile: ndc_register_json.mobile,
- name: ndc_register_json.name,
- address: ndc_register_json.address,
- class: ndc_register_json.year,
- ndc_roll: ndc_register_json.roll,
- timestamp: serverTimestamp(),
- imageUrl:
- "https://firebasestorage.googleapis.com/v0/b/ftmpc-63d81.appspot.com/o/pfp%2Fno_user.webp?alt=media&token=fd930687-e7b9-4fa6-9603-f20b73bd0a86",
- });
- await sendEmailVerification(userInfo.user);
- toast.success(
- "Email verification link sent! Please verify your email please.",
- );
- setLoading(false);
- Router.push("/club/verify");
- })
- .catch((error) => {
- switch (error.code) {
- case "auth/email-already-in-use":
- toast.error(`Email address already in use.`);
- break;
- case "auth/invalid-email":
- toast.error(`Email address is invalid.`);
- break;
- case "auth/operation-not-allowed":
- toast.error(`Error during sign up.`);
- break;
- case "auth/weak-password":
- toast.error(
- "Password is not strong enough. Add additional characters including special characters and numbers.",
- );
- break;
- default:
- toast.error(error.message.replaceAll("Firebase: ", ""));
-
- break;
- }
- setLoading(false);
- });
- }
- }
- } else {
- toast.error(massage);
- setLoading(false);
- }
- } else {
- if (verified) {
- //
-
- regData.ndc_id = "";
- createUserWithEmailAndPassword(auth, regData.email, password)
- .then(async (userInfo) => {
- //add userInfo in Collections
- const uid = userInfo.user.uid;
- await setDoc(doc(db, "participants", uid), {
- ...regData,
- timestamp: serverTimestamp(),
- imageUrl:
- "https://firebasestorage.googleapis.com/v0/b/ftmpc-63d81.appspot.com/o/pfp%2Fno_user.webp?alt=media&token=fd930687-e7b9-4fa6-9603-f20b73bd0a86",
- });
- await sendEmailVerification(userInfo.user);
- toast.success(
- "Email verification link sent! Please verify your email please.",
- );
- setLoading(false);
- Router.push("/club/verify");
- })
- .catch((error) => {
- switch (error.code) {
- case "auth/email-already-in-use":
- toast.error(`Email address already in use.`);
- break;
- case "auth/invalid-email":
- toast.error(`Email address is invalid.`);
- break;
- case "auth/operation-not-allowed":
- toast.error(`Error during sign up.`);
- break;
- case "auth/weak-password":
- toast.error(
- "Password is not strong enough. Add additional characters including special characters and numbers.",
- );
- break;
- default:
- toast.error(error.message.replaceAll("Firebase: ", ""));
-
- break;
- }
- setLoading(false);
- });
- } else {
- toast.error(massage);
- setLoading(false);
- }
- }
- };
- const setValue = (name: string, data: string | number) => {
- dispatch({ type: "SET_FIELD", name, data });
- };
-
- useEffect(() => {
- if (!loading && userAuth) {
- Router.push("/club/verify");
- }
- }, [userAuth, loading]);
-
- useEffect(() => {
- getConfig()
- .then((config: any) => {
- if (!config.registration_status) {
- Router.push("/club/registration-closed");
- } else {
- setConfigLoading(false);
- }
- })
- .catch((err) => {
- console.error(err);
-
- toast.error("Aww Snap!");
- });
- }, [Router]);
-
- return (
-
-
- {configLoading ? (
-
-
-
- ) : (
- <>
-
-
- >
- )}
-
-
- );
-};
-
-export default Page;
diff --git a/src/app/club/(user-handle)/registration-closed/page.tsx b/src/app/club/(user-handle)/registration-closed/page.tsx
deleted file mode 100644
index 4788b0c..0000000
--- a/src/app/club/(user-handle)/registration-closed/page.tsx
+++ /dev/null
@@ -1,23 +0,0 @@
-import React from "react";
-import { TbUserOff } from "react-icons/tb";
-
-const Page = () => {
- return (
-
-
-
-
- REGISTRATION CLOSED
-
-
- We regret to inform you that registration has now closed. We
- appreciate your interest and would like to thank everyone who signed
- up. Please stay tuned for future updates and opportunities to
- participate.{" "}
-
-
-
- );
-};
-
-export default Page;
diff --git a/src/app/club/(user-handle)/reset-password/page.tsx b/src/app/club/(user-handle)/reset-password/page.tsx
deleted file mode 100644
index 823fc51..0000000
--- a/src/app/club/(user-handle)/reset-password/page.tsx
+++ /dev/null
@@ -1,122 +0,0 @@
-"use client";
-
-import Field from "@/app/club/Components/Field";
-import React, { useEffect, useState } from "react";
-import Link from "next/link";
-import { auth, db } from "@/config/firebase";
-
-import {
- deleteUser,
- sendEmailVerification,
- sendPasswordResetEmail,
- signInWithEmailAndPassword,
-} from "firebase/auth";
-
-import { toast } from "react-toastify";
-import { CgArrowLeft, CgSpinner } from "react-icons/cg";
-import { useRouter } from "next/navigation";
-import Image from "next/image";
-import { doc, DocumentReference, deleteDoc } from "firebase/firestore";
-import { useAuthState } from "react-firebase-hooks/auth";
-
-const Page = () => {
- const [email, setEmail] = useState("");
- const [loading, setLoading] = useState(false);
- const [user] = useAuthState(auth);
- const Router = useRouter();
- const handleSubmit = async (event: any) => {
- event.preventDefault();
- setLoading(true);
- sendPasswordResetEmail(auth, email)
- .then(() => {
- setLoading(false);
- auth.signOut();
- toast.success(
- "Reset password link sent to you email. Reset Password then login again.",
- );
- Router.push("/club/login");
- })
- .catch((error) => {
- switch (error.code) {
- case "auth/email-already-in-use":
- toast.error(`Email address already in use.`);
- break;
- case "auth/invalid-email":
- toast.error(`Email address is invalid.`);
- break;
- case "auth/operation-not-allowed":
- toast.error(`Error during sign up.`);
- break;
- default:
- toast.error(error.message.replaceAll("Firebase: ", ""));
-
- break;
- }
- setLoading(false);
- });
- };
- useEffect(() => {
- if (user && user.email) {
- setEmail(user.email);
- }
- }, [user]);
- return (
-
-
-
-
-
-
- );
-};
-
-export default Page;
diff --git a/src/app/club/(user-handle)/verify/page.tsx b/src/app/club/(user-handle)/verify/page.tsx
deleted file mode 100644
index 17916c8..0000000
--- a/src/app/club/(user-handle)/verify/page.tsx
+++ /dev/null
@@ -1,150 +0,0 @@
-"use client";
-
-import Field from "@/app/club/Components/Field";
-import React, { useEffect, useState } from "react";
-import Link from "next/link";
-import { auth, db } from "@/config/firebase";
-
-import {
- deleteUser,
- reauthenticateWithPopup,
- sendEmailVerification,
- signInWithEmailAndPassword,
-} from "firebase/auth";
-
-import { toast } from "react-toastify";
-import { CgArrowLeft, CgArrowRight, CgSpinner } from "react-icons/cg";
-import { useRouter } from "next/navigation";
-import Image from "next/image";
-import { doc, DocumentReference, deleteDoc } from "firebase/firestore";
-import { useAuthState } from "react-firebase-hooks/auth";
-
-const Page = () => {
- const [loading, setLoading] = useState(false);
- const [loading2, setLoading2] = useState(false);
- const [user] = useAuthState(auth);
-
- const Router = useRouter();
- const handleSubmit = async (event: any) => {
- event.preventDefault();
- setLoading(true);
- if (user) {
- try {
- await sendEmailVerification(user);
- toast.success("Verfication Email Sent! Verify and Login.");
- } catch (err) {
- console.error(err);
- toast.error("Aww! Snap!");
- }
- } else {
- toast.error("User not signed in!");
- }
- setLoading(false);
- };
- const deleteAccount = async (event: any) => {
- event.preventDefault();
- setLoading2(true);
- try {
- if (user) {
- await deleteUser(user);
- toast.info(`Please register again.`);
- Router.push("/club/register");
- }
- } catch (err: any) {
- console.error(err);
- if (err?.code === "auth/requires-recent-login") {
- toast.error(`Login expired. Please register/login again.`);
- auth.signOut();
- Router.push("/club/register");
- } else {
- setLoading2(false);
- toast.error("Aww! Snap!");
- }
- }
- };
- useEffect(() => {
- if (user && user.emailVerified) {
- Router.push("/club/profile");
- } else if (!user && !loading2) {
- Router.push("/club/login");
- }
- const x = setInterval(() => {
- auth.currentUser?.reload();
- }, 3000);
-
- return () => {
- clearInterval(x);
- };
- }, [user, Router, loading2]);
- return (
-
-
-
-
- ACCOUNT VERIFICATION
-
-
- Please verify your account. An email has been sent to {user?.email}.
- Don't forget to check you spam.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- );
-};
-
-export default Page;
diff --git a/src/app/club/Components/Admin/AddQuestions.tsx b/src/app/club/Components/Admin/AddQuestions.tsx
deleted file mode 100644
index de9b6b3..0000000
--- a/src/app/club/Components/Admin/AddQuestions.tsx
+++ /dev/null
@@ -1,522 +0,0 @@
-import { useEffect, useState } from "react";
-import { FaPlus } from "react-icons/fa6";
-import { RiDeleteBin6Line } from "react-icons/ri";
-import { RxGear } from "react-icons/rx";
-import { toast } from "react-toastify";
-
-interface questionInterface {
- mcq: boolean;
- question: string;
- option0: string;
- option1: string;
- option2: string;
- option3: string;
- point: number;
- index: number;
- correctOption: number;
- correctAnswers: string;
- onValueChange?: (
- i: number,
- question: string,
- point: number,
- option0: string,
- option1: string,
- option2: string,
- option3: string,
- correctOption: number,
- correctAnswers: string,
- ) => void;
- deleteQuestion?: (index: number) => void;
-}
-
-interface answerInterface {
- mcq: boolean;
- point: number;
- correctOption: number;
- correctAnswers: string;
-}
-
-const AddQuestions = ({
- questionsData,
- answersData,
- setData,
-}: {
- questionsData: any[];
- answersData: any[];
- setData: (questionData: any, answerData: any) => void;
-}) => {
- const [questions, setQuestions] =
- useState(questionsData);
- const [answers, setAnswers] = useState(answersData);
-
- useEffect(() => {
- setAnswers(answersData);
- setQuestions(questionsData);
- }, [questionsData, answersData]);
-
- const [isMCQ, setMCQ] = useState(true);
-
- const optionsArr = ["A", "B", "C", "D"];
-
- const [question, setQuestion] = useState("");
- const [option0, setOption0] = useState("");
- const [option1, setOption1] = useState("");
- const [option2, setOption2] = useState("");
- const [option3, setOption3] = useState("");
- const [correctOption, setCorrectOption] = useState(0);
- const [correctAnswers, setCorrectAnswers] = useState("");
-
- const [point, setPoint] = useState(1);
-
- const setOption = (i: number, value: string) => {
- switch (i) {
- case 0:
- setOption0(value);
- break;
-
- case 1:
- setOption1(value);
- break;
-
- case 2:
- setOption2(value);
- break;
-
- case 3:
- setOption3(value);
- break;
-
- default:
- break;
- }
- };
-
- const addQuestion = () => {
- setQuestions((oldValue: any) => {
- return [
- ...oldValue,
- {
- question: question,
- mcq: isMCQ,
- point: point,
- option0: option0,
- option1: option1,
- option2: option2,
- option3: option3,
- },
- ];
- });
-
- setAnswers((oldValue: any) => {
- return [
- ...oldValue,
- {
- mcq: isMCQ,
- point: point,
- correctOption: correctOption,
- correctAnswers: correctAnswers,
- },
- ];
- });
-
- setQuestion("");
- setOption0("");
- setOption1("");
- setOption2("");
- setOption3("");
- setCorrectOption(0);
- setCorrectAnswers("");
- setPoint(1);
-
- toast.success("Question Added");
- };
-
- const onValueChange = (
- i: number,
- question: string,
- point: number,
- option0: string,
- option1: string,
- option2: string,
- option3: string,
- correctOption: number,
- correctAnswers: string,
- ) => {
- let arr = [...questions];
- arr[i].question = question;
- arr[i].point = point;
- arr[i].option0 = option0;
- arr[i].option1 = option1;
- arr[i].option2 = option2;
- arr[i].option3 = option3;
-
- setQuestions(arr);
-
- let ansArr = [...answers];
-
- ansArr[i].point = point;
- ansArr[i].correctOption = correctOption;
- ansArr[i].correctAnswers = correctAnswers;
-
- setAnswers(ansArr);
- };
-
- const deleteQuestion = (i: number) => {
- setQuestions((arr) => {
- return [...arr.slice(0, i), ...arr.slice(i + 1, arr.length)];
- });
-
- setAnswers((arr) => {
- return [...arr.slice(0, i), ...arr.slice(i + 1, arr.length)];
- });
- };
-
- useEffect(() => {
- setData(questions, answers);
- }, [questions, answers]);
-
- return (
-
-
- --- Questions ---
-
-
-
- {questions.length != 0 &&
- answers.length != 0 &&
- questions.map((e, i) => {
- return (
-
- );
- })}
-
-
-
- --- New Question ---
-
-
-
-
- {isMCQ ? (
-
- Click on the correct answer option (Required)
- {optionsArr.map((e, i) => {
- return (
-
-
- {
- setOption(i, e.currentTarget.value);
- }}
- value={
- i == 0
- ? option0
- : i == 1
- ? option1
- : i == 2
- ? option2
- : i == 3
- ? option3
- : ""
- }
- placeholder="Option ..."
- />
-
- );
- })}
-
- ) : (
-
-
-
- setCorrectAnswers(e.currentTarget.value)}
- value={correctAnswers}
- name="answer"
- placeholder="Answers ..."
- disabled={false}
- />
-
-
- )}
-
-
-
- );
-};
-
-export default AddQuestions;
-
-const Question = ({
- mcq,
- point,
- question,
- correctAnswers,
- correctOption,
- index,
- option0,
- option1,
- option2,
- option3,
- onValueChange,
- deleteQuestion,
-}: questionInterface) => {
- const optionsArr = ["A", "B", "C", "D"];
-
- const [editing, setEditing] = useState(false);
-
- const [questionVal, setQuestionVal] = useState(question);
- const [option0Val, setOption0Val] = useState(option0);
- const [option1Val, setOption1Val] = useState(option1);
- const [option2Val, setOption2Val] = useState(option2);
- const [option3Val, setOption3Val] = useState(option3);
- const [correctOptionVal, setCorrectOptionVal] = useState(correctOption);
- const [correctAnswersVal, setCorrectAnswersVal] = useState(correctAnswers);
-
- const [pointVal, setPointVal] = useState(point);
-
- const setOptionVal = (i: number, value: string) => {
- switch (i) {
- case 0:
- setOption0Val(value);
- break;
-
- case 1:
- setOption1Val(value);
- break;
-
- case 2:
- setOption2Val(value);
- break;
-
- case 3:
- setOption3Val(value);
- break;
-
- default:
- break;
- }
- };
-
- return (
-
-
- {mcq ? (
-
- Click on the correct answer option (Required)
- {optionsArr.map((e, i) => {
- return (
-
-
- {
- setOptionVal(i, e.currentTarget.value);
- }}
- value={
- i == 0
- ? option0Val
- : i == 1
- ? option1Val
- : i == 2
- ? option2Val
- : i == 3
- ? option3Val
- : ""
- }
- placeholder="Option ..."
- disabled={!editing}
- />
-
- );
- })}
-
- ) : (
-
-
-
- {
- setCorrectAnswersVal(e.currentTarget.value);
- }}
- value={correctAnswersVal}
- name="answer"
- placeholder="Answers ..."
- disabled={!editing}
- />
-
- Answers:
- {correctAnswersVal
- .toString()
- .split(";")
- .map((e, i) => {
- return
{e}
;
- })}
-
- )}
-
-
-
-
- );
-};
diff --git a/src/app/club/Components/Admin/AdminAnnouncements.tsx b/src/app/club/Components/Admin/AdminAnnouncements.tsx
deleted file mode 100644
index 04b56d7..0000000
--- a/src/app/club/Components/Admin/AdminAnnouncements.tsx
+++ /dev/null
@@ -1,275 +0,0 @@
-"use client";
-
-import { db } from "@/config/firebase";
-import {
- addDoc,
- collection,
- deleteDoc,
- doc,
- getDocs,
- orderBy,
- query,
- serverTimestamp,
- updateDoc,
-} from "firebase/firestore";
-import React, { FormEvent, useEffect, useState } from "react";
-import { BsClock } from "react-icons/bs";
-import { CgLock, CgSpinner } from "react-icons/cg";
-
-import { GrAnnounce } from "react-icons/gr";
-import Modal from "../Modal";
-import { LiaTimesSolid } from "react-icons/lia";
-import { toast } from "react-toastify";
-import { FaRegEdit } from "react-icons/fa";
-import { FaPlus } from "react-icons/fa6";
-import Field from "../Field";
-import Textarea from "../Textarea";
-import { TbTrash } from "react-icons/tb";
-import { Checkbox } from "@nextui-org/checkbox";
-const Announcements = () => {
- const [announcements, setAnnouncements] = useState([]);
- const [modalState, setModalState] = useState(false);
- const [modalLoading, setModalLoading] = useState(false);
- const [editState, setEditState] = useState(false);
- const [title, setTitle] = useState("");
- const [desc, setDesc] = useState("");
- const [club, setClub] = useState(false);
- const [order, setOrder] = useState(0);
- const closeModal = () => {
- setModalState(false);
- setEditState(false);
- setTitle("");
- setDesc("");
- setOrder(announcements[announcements.length - 1].order + 1 || 1580);
- };
- const loadAnnc = () => {
- getDocs(query(collection(db, "announcements"), orderBy("order")))
- .then((docs) => {
- const annc: any[] = [];
- docs.forEach((data) => {
- annc.push({ id: data.id, ...data.data() });
- });
- annc.reverse();
- setAnnouncements(annc);
- })
- .catch((err) => {
- toast.error("Announcements can't be loaded");
- console.error(err);
- });
- };
- const addAnnc = (e: FormEvent) => {
- e.preventDefault();
- setModalLoading(true);
- addDoc(collection(db, "announcements"), {
- title,
- description: desc,
- order,
- timestamp: serverTimestamp(),
- club,
- })
- .then(() => {
- toast.success("Success");
- loadAnnc();
- closeModal();
- setModalLoading(false);
- })
- .catch((err) => {
- toast.error("Announcements can't be added");
- console.error(err);
- setModalLoading(false);
- });
- };
- const deleteAnnc = (id: string) => {
- setModalLoading(true);
- deleteDoc(doc(db, "announcements", id))
- .then(() => {
- toast.success("Success");
- loadAnnc();
- closeModal();
- setModalLoading(false);
- })
- .catch((err) => {
- toast.error("Announcements can't be edited");
- console.error(err);
- setModalLoading(false);
- });
- };
- const editAnnc = (e: FormEvent, id: string) => {
- e.preventDefault();
-
- setModalLoading(true);
- updateDoc(doc(db, "announcements", id), { title, description: desc, order })
- .then(() => {
- toast.success("Success");
- loadAnnc();
- closeModal();
- setModalLoading(false);
- })
- .catch((err) => {
- toast.error("Announcements can't be edited");
- console.error(err);
- setModalLoading(false);
- });
- };
- useEffect(() => {
- loadAnnc();
- }, []);
- useEffect(() => {
- if (announcements.length > 0) {
- setOrder(announcements[announcements.length - 1].order + 1 || 1580);
- }
- }, [announcements]);
- useEffect(() => {
- if (editState !== false) {
- setTitle(announcements[editState].title);
- setDesc(announcements[editState].description);
- setOrder(announcements[editState].order || 1580);
- setModalState(true);
- }
- }, [editState, announcements]);
- return (
-
-
-
-
-
- ANNOUNCEMENTS
-
-
-
-
-
-
-
-
- {announcements.map((data: any, index: number) => {
- return (
-
-
{data.title}
-
{data.description}
-
- {data?.club ? "Club" : null}
- Order:{data.order}
-
- {new Date(data.timestamp.seconds * 1000).toDateString()}
-
-
-
-
-
-
-
- );
- })}
-
-
- {modalState ? (
-
-
-
-
-
- {editState !== false ? "EDIT" : "ADD"}{" "}
- ANNOUNCEMENT
-
-
-
- ) : null}
-
-
- );
-};
-
-export default Announcements;
diff --git a/src/app/club/Components/Admin/AdminEventCard.tsx b/src/app/club/Components/Admin/AdminEventCard.tsx
deleted file mode 100644
index c83383e..0000000
--- a/src/app/club/Components/Admin/AdminEventCard.tsx
+++ /dev/null
@@ -1,72 +0,0 @@
-import Link from "next/link";
-import { IoCalendarOutline, IoSettingsOutline } from "react-icons/io5";
-import { BsStopwatch } from "react-icons/bs";
-import { timeValue } from "../Time";
-import { Timestamp } from "firebase/firestore";
-
-const AdminEventCard = ({
- title,
- date,
- endDate,
- image,
- desc,
- id,
- ongoing,
- category,
-}: {
- title: string;
- date: Timestamp;
- endDate: Timestamp;
- image: string;
- desc: string;
- id: string;
- ongoing: boolean;
- category: string;
-}) => {
- const dateData = timeValue(date);
-
- return (
-
- {ongoing && (
-
- Ongoing
-
- )}
-
-
-
-
-
- {title}
-
-
- {timeValue(endDate).minute - dateData.minute} Minutes
-
-
-
{category}
-
-
- {`${dateData.date} ${dateData.monthText} ${dateData.year}`} |{" "}
- {`${dateData.hour}:${dateData.minute}`}
-
-
-
- {desc}
-
-
-
- EDIT
-
-
-
- );
-};
-
-export default AdminEventCard;
diff --git a/src/app/club/Components/Admin/AdminEvents.tsx b/src/app/club/Components/Admin/AdminEvents.tsx
deleted file mode 100644
index 55abfcf..0000000
--- a/src/app/club/Components/Admin/AdminEvents.tsx
+++ /dev/null
@@ -1,70 +0,0 @@
-import Link from "next/link";
-import { FaPlus } from "react-icons/fa";
-import { MdOutlineEventNote } from "react-icons/md";
-import AdminEventCard from "./AdminEventCard";
-import { db } from "@/config/firebase";
-import { getDocs, query, collection, orderBy, limit } from "firebase/firestore";
-import { toast } from "react-toastify";
-import { useEffect, useState } from "react";
-
-const AdminEvents = ({ adminAuth }: { adminAuth: boolean }) => {
- const [events, setEvents] = useState([]);
-
- useEffect(() => {
- if (!adminAuth) return;
- const docs = getDocs(
- query(collection(db, "events"), limit(10), orderBy("addTime", "desc")),
- ).then(async (data) => {
- const eventData: any = [];
- await data.forEach((e) => {
- eventData.push({ id: e.id, data: e.data() });
- });
-
- setEvents(eventData);
- });
- }, [adminAuth]);
-
- return (
-
-
-
-
-
-
- EVENTS
-
-
-
-
-
- Add Event
-
-
-
-
-
- {events.map((e: any, i: number) => {
- return (
-
- );
- })}
-
-
- );
-};
-
-export default AdminEvents;
diff --git a/src/app/club/Components/Admin/EditConfig.tsx b/src/app/club/Components/Admin/EditConfig.tsx
deleted file mode 100644
index 214697c..0000000
--- a/src/app/club/Components/Admin/EditConfig.tsx
+++ /dev/null
@@ -1,110 +0,0 @@
-import { FormEvent, useEffect, useState } from "react";
-import { CgSpinner } from "react-icons/cg";
-import { auth } from "@/config/firebase";
-import { useAuthState } from "react-firebase-hooks/auth";
-import { toast } from "react-toastify";
-import { PiGearBold } from "react-icons/pi";
-import { setConfig, getConfig, setConfigAll } from "@/config/config_db";
-
-const EditConfig = () => {
- const [configs, setConfigs] = useState();
- const [loading, setLoading] = useState(false);
- const [userAuth] = useAuthState(auth);
- useEffect(() => {
- getConfig()
- .then((config: any) => {
- setConfigs(config);
- })
- .catch((err) => {
- console.error(err);
-
- toast.error("Aww Snap!");
- });
- }, []);
- const submitHandler = async (e: FormEvent) => {
- e.preventDefault();
- setLoading(true);
- if (userAuth) {
- try {
- await setConfigAll(configs);
- toast.success("Config Updated");
- } catch (err) {
- console.error(err);
-
- toast.error("Aww Snap!");
- }
- }
- setLoading(false);
- };
- console.log(configs);
- return (
-
-
-
- );
-};
-
-export default EditConfig;
diff --git a/src/app/club/Components/Admin/EventPicture.tsx b/src/app/club/Components/Admin/EventPicture.tsx
deleted file mode 100644
index a0461f2..0000000
--- a/src/app/club/Components/Admin/EventPicture.tsx
+++ /dev/null
@@ -1,143 +0,0 @@
-/* eslint-disable @next/next/no-img-element */
-import Image from "next/image";
-import { useRef, useState } from "react";
-import Modal from "@/app/club/Components/Modal";
-import { CgSpinner } from "react-icons/cg";
-import { getDownloadURL, ref, uploadBytes } from "firebase/storage";
-import { auth, db, pfp } from "@/config/firebase";
-import { LiaTimesSolid } from "react-icons/lia";
-import { toast } from "react-toastify";
-import fileValidator from "@/util/fileValidator";
-import { doc, updateDoc } from "firebase/firestore";
-
-const EventPicture = ({
- imageUrl,
- setImage,
- eventID,
-}: {
- imageUrl: any;
- setImage: (url: string) => void;
- eventID: string;
-}) => {
- const [changeImage, setChangeImage] = useState();
- const [newImage, setNewImage] = useState();
- const [loading, setLoading] = useState(false);
-
- const FileRef = useRef(null);
- const changeEp = () => {
- if (newImage) {
- setLoading(true);
- const storeRef = ref(pfp, "ep/" + eventID);
- uploadBytes(storeRef, newImage[0])
- .then(async (snapshot) => {
- const url = await getDownloadURL(storeRef);
- await updateDoc(doc(db, "events", eventID), { imageURL: url });
- setImage(url);
- setLoading(false);
- setNewImage(null);
- setChangeImage(false);
- toast.success("Photo Updated!");
- })
- .catch((error) => {
- console.dir(error);
-
- toast.error(error.message.replaceAll("Firebase: ", ""));
-
- setLoading(false);
- });
- } else {
- toast.error("Something Happenned");
- }
- };
- return (
- <>
- {
- setChangeImage(true);
- }}
- >
-
- Click to Change
-
-
-
-
- {changeImage ? (
-
-
-
-
-
- UPDATE EVENT PICTURE
-
- {newImage && newImage[0] ? (
-
- ) : null}
-
{
- try {
- await fileValidator(
- e.target.files || [],
- ["image/png", "image/jpeg", "image/webp"],
- 512,
- 1,
- "File must have to be a .jpg, .png or .webp file",
- );
- setNewImage(e.target.files ? e.target.files : null);
- } catch (err) {
- e.target.value = "";
-
- toast.error(String(err));
- }
- }}
- className="my-5 file:mr-3 file:cursor-pointer file:rounded-lg file:border-none file:bg-primary file:px-4 file:py-2 file:text-white file:hover:bg-secondary_light file:hover:text-primary"
- ref={FileRef}
- name="pfp"
- type={"file"}
- accept=".png, .jpg, .jpeg, .webp"
- />
-
-
-
-
- ) : null}
-
- >
- );
-};
-
-export default EventPicture;
diff --git a/src/app/club/Components/CommonPage.tsx b/src/app/club/Components/CommonPage.tsx
deleted file mode 100644
index a9bd49e..0000000
--- a/src/app/club/Components/CommonPage.tsx
+++ /dev/null
@@ -1,150 +0,0 @@
-'use client';
-import React, { useEffect, useRef, useState } from 'react';
-
-interface Section {
- heading: string;
- content: React.ReactNode;
- subSections?: Section[];
-}
-
-interface CommonPageProps {
- heading: string;
- sections: Section[];
- icon: React.ReactNode;
- hasTableOfContent?: boolean;
-}
-
-const Sections = ({ sections, subNumber }: { sections: Section[]; subNumber?: string }) => {
- const subNum = subNumber ? subNumber : '';
- return (
- <>
- {sections.map(({ heading, content, subSections }, index) => {
- return (
- <>
-
-
- {heading}
-
-
{content}
-
- {subSections?.length ? (
-
- ) : null}
- >
- );
- })}
- >
- );
-};
-
-const TOCList = ({
- sections,
- subNumber,
- scrollPos,
-}: {
- sections: Section[];
- subNumber?: string;
- scrollPos?: number;
-}) => {
- const subNum = subNumber ? subNumber : '';
- const ref = useRef(null);
- useEffect(() => {
- // ref.current?.scrollTo({
- // top: (ref.current?.scrollHeight - ref?.current.clientHeight || 0) * (scrollPos || 0),
- // });
- }, [scrollPos]);
- return (
-
- {sections.map(({ heading, content, subSections }, index) => {
- return (
- -
-
-
- {heading}
-
-
- {subSections?.length ? (
-
- ) : null}
-
- );
- })}
-
- );
-};
-const CommonPage = ({ heading, icon, sections, hasTableOfContent }: CommonPageProps) => {
- const headingArray = heading.split(' ');
- const firstWord = headingArray.splice(0, 1) + ' ';
- const restWord = headingArray.join(' ');
- const [scrollPos, setScrollPos] = useState(0);
- useEffect(() => {
- const handler = () => {
- setScrollPos(
- document.documentElement.scrollTop /
- (document.documentElement.scrollHeight - window.innerHeight)
- );
- };
- document.addEventListener('scroll', handler);
-
- return () => {
- document.removeEventListener('scroll', handler);
- };
- }, []);
- return (
-
-
-
-
- {icon}
-
- {firstWord}
- {restWord}
-
-
-
- {hasTableOfContent ? (
-
-
- Table of contents
-
-
-
-
-
- ) : null}
-
- {' '}
-
-
-
-
- );
-};
-
-export default CommonPage;
diff --git a/src/app/club/Components/Contact.tsx b/src/app/club/Components/Contact.tsx
deleted file mode 100644
index c2bb4ea..0000000
--- a/src/app/club/Components/Contact.tsx
+++ /dev/null
@@ -1,191 +0,0 @@
-'use client';
-
-import { useEffect, useRef, useState } from 'react';
-import { IoIosCloseCircleOutline } from 'react-icons/io';
-
-const Contact = () => {
- const [sending, setSending] = useState(false);
-
- const formRef = useRef(null);
- const dialogRef = useRef(null);
- const [showingModal, setShowingModal] = useState(false);
-
- useEffect(() => {
- dialogRef.current?.close();
- setShowingModal(false);
- }, []);
-
- async function handleSubmit(event: any) {
- event.preventDefault();
- setSending(true);
- const formData = new FormData(event.target);
-
- try {
- const response = await fetch('/api/contact', {
- method: 'post',
- body: formData,
- });
-
- formRef.current?.reset();
-
- if (!response.ok) {
- throw new Error(`response status: ${response.status}`);
- }
-
- setSending(false);
-
- dialogRef.current?.showModal();
- setShowingModal(true);
- } catch (err) {
- console.error(err);
- alert('Error, please try resubmitting the form');
- }
- }
-
- return (
- <>
-
-
-
-
-
-
-
-
-
-
-
-
-
- >
- );
-};
-
-export default Contact;
diff --git a/src/app/club/Components/CurrentYear.tsx b/src/app/club/Components/CurrentYear.tsx
deleted file mode 100644
index 3806c79..0000000
--- a/src/app/club/Components/CurrentYear.tsx
+++ /dev/null
@@ -1,18 +0,0 @@
-'use client';
-
-const CurrentYear = () => {
- let currentDate = new Date();
- let currentYear = currentDate.getFullYear();
-
- return (
-
- © {currentYear}{' '}
-
- NDITC™
-
- . All Rights Reserved.
-
- );
-};
-
-export default CurrentYear;
diff --git a/src/app/club/Components/Dashboard/Ranking.tsx b/src/app/club/Components/Dashboard/Ranking.tsx
deleted file mode 100644
index 8aee48f..0000000
--- a/src/app/club/Components/Dashboard/Ranking.tsx
+++ /dev/null
@@ -1,108 +0,0 @@
-import { getConfig } from "@/config/config_db";
-import { initAdmin } from "@/config/firebaseAdmin";
-import { getFirestore } from "firebase-admin/firestore";
-import { FaCrown, FaRankingStar } from "react-icons/fa6";
-
-const Ranking = async () => {
- await initAdmin();
-
- const firestore = getFirestore();
-
- const rank_visible = (
- await firestore.collection("config").doc("config").get()
- ).data()?.rank_visible;
-
- if (!rank_visible) {
- return ;
- }
-
- const rankSnapshot = await firestore
- .collection("eventparticipant")
- .orderBy("points", "desc")
- .limit(3)
- .get();
-
- const rankList: any[] = rankSnapshot.docs.map((e) => ({
- id: e.id,
- ...e.data(),
- }));
-
- return (
- <>
- {rankList.length != 0 && (
-
-
-
-
-
- TOP
-
-
-
- RANKERS
-
-
-
-
- {rankList.map((e, i) => {
- return (
-
- );
- })}
-
-
-
- )}
- >
- );
-};
-
-export default Ranking;
-
-const RankHolder = async ({
- firestore,
- id,
- points,
- i,
-}: {
- firestore: FirebaseFirestore.Firestore;
- id: string;
- points: number;
- i: number;
-}) => {
- const infoSnapshot = await firestore.collection("participants").doc(id).get();
-
- const data = infoSnapshot.data();
-
- if (infoSnapshot.exists)
- return (
-
-
-
-
-
-
-
-
- {data?.name}
-
-
- {data?.institution}
-
-
Points: {points}
-
-
- );
-};
diff --git a/src/app/club/Components/DeveloperLink.tsx b/src/app/club/Components/DeveloperLink.tsx
deleted file mode 100644
index 4d0e308..0000000
--- a/src/app/club/Components/DeveloperLink.tsx
+++ /dev/null
@@ -1,19 +0,0 @@
-"use client";
-
-import Link from "next/link";
-import { usePathname } from "next/navigation";
-import { IoCodeSlash } from "react-icons/io5";
-
-const DeveloperLink = () => {
- const Route = usePathname();
- return (
-
-
-
- );
-};
-
-export default DeveloperLink;
diff --git a/src/app/club/Components/Error.tsx b/src/app/club/Components/Error.tsx
deleted file mode 100644
index 29b5acc..0000000
--- a/src/app/club/Components/Error.tsx
+++ /dev/null
@@ -1,44 +0,0 @@
-"use client";
-import React from "react";
-import Image from "next/image";
-import Link from "next/link";
-
-type ErrorProp = {
- statusCode: number;
- msg: string;
- action?: () => void;
- dest?: string;
-};
-
-const Error = ({ statusCode, msg, action, dest }: ErrorProp) => {
- return (
-
-
-
-
-
-
-
-
- {statusCode}
-
-
{msg}
-
action && action()}
- >
- Try Again
-
-
-
-
- );
-};
-
-export default Error;
diff --git a/src/app/club/Components/Events/EventCard.tsx b/src/app/club/Components/Events/EventCard.tsx
deleted file mode 100644
index 4881a44..0000000
--- a/src/app/club/Components/Events/EventCard.tsx
+++ /dev/null
@@ -1,101 +0,0 @@
-import Link from "next/link";
-import { IoCalendarOutline } from "react-icons/io5";
-import { BsStopwatch } from "react-icons/bs";
-import { timeValue } from "../Time";
-import { PiStudent } from "react-icons/pi";
-import { TbListDetails } from "react-icons/tb";
-import { Timestamp } from "firebase/firestore";
-import PartcipateButton from "./PartcipateButton";
-import { MdOutlineTimer } from "react-icons/md";
-import { createCipheriv } from "crypto";
-
-const EventCard = ({
- title,
- date,
- endDate,
- ongoingForParticipate,
- image,
- desc,
- id,
- category,
-}: {
- title: string;
- date: any;
- endDate: any;
- ongoingForParticipate: boolean;
- image: string;
- desc: string;
- id: string;
- category: string;
-}) => {
- const now = Timestamp.now();
-
- const ongoing = now > date && now < endDate;
-
- const upcoming = now < date;
-
- const dateData = timeValue(date);
-
- return (
-
- {ongoing && (
-
- Ongoing
-
- )}
-
- {upcoming && (
-
- Upcoming
-
- )}
-
-
-
-
-
-
{category}
-
- {title}
-
-
-
- {`${dateData.date} ${dateData.monthText} ${dateData.year}`}{" "}
- |{" "}
- {`${dateData.hour}:${dateData.minute}`}
-
-
-
- {timeValue(endDate).hour - dateData.hour > 0 &&
- `${timeValue(endDate).hour - dateData.hour}H : `}
- {timeValue(endDate).minute - dateData.minute}M
-
-
- {desc}
-
-
-
- {ongoingForParticipate &&
}
- {!ongoingForParticipate && (
-
-
- Details
-
- )}
-
-
-
- );
-};
-
-export default EventCard;
diff --git a/src/app/club/Components/Events/EventList.tsx b/src/app/club/Components/Events/EventList.tsx
deleted file mode 100644
index a4b34f3..0000000
--- a/src/app/club/Components/Events/EventList.tsx
+++ /dev/null
@@ -1,32 +0,0 @@
-import { Timestamp } from "firebase/firestore";
-import EventCard from "./EventCard";
-
-const EventList = ({
- eventList,
- participate,
-}: {
- eventList: any[];
- participate?: boolean;
-}) => {
- return (
-
- {eventList.map((e, i) => {
- return (
-
- );
- })}
-
- );
-};
-
-export default EventList;
diff --git a/src/app/club/Components/Events/PartcipateButton.tsx b/src/app/club/Components/Events/PartcipateButton.tsx
deleted file mode 100644
index a6d968a..0000000
--- a/src/app/club/Components/Events/PartcipateButton.tsx
+++ /dev/null
@@ -1,18 +0,0 @@
-"use client";
-
-import Link from "next/link";
-import { PiStudent } from "react-icons/pi";
-
-const PartcipateButton = ({ id }: { id: string }) => {
- return (
-
-
- Participate
-
- );
-};
-
-export default PartcipateButton;
diff --git a/src/app/club/Components/Field.tsx b/src/app/club/Components/Field.tsx
deleted file mode 100644
index 3c806aa..0000000
--- a/src/app/club/Components/Field.tsx
+++ /dev/null
@@ -1,50 +0,0 @@
-import React, { HTMLInputTypeAttribute } from "react";
-
-type props = {
- name: string;
- label: string;
- type: HTMLInputTypeAttribute;
- state: string | number;
- setValue: (name: string, data: string | number) => void;
- notRequired?: boolean;
- editable?: boolean;
- returnNumber?: boolean;
-};
-
-const Field = ({
- name,
- label,
- type,
- state,
- setValue,
- notRequired,
- editable = true,
- returnNumber,
-}: props) => {
- return (
-
-
-
- setValue(name, returnNumber ? e.target.valueAsNumber : e.target.value)
- }
- value={state}
- type={type}
- name={name}
- required={!notRequired}
- placeholder={label}
- disabled={!editable}
- readOnly={!editable}
- />
-
- );
-};
-
-export default Field;
diff --git a/src/app/club/Components/File.tsx b/src/app/club/Components/File.tsx
deleted file mode 100644
index 6cef7e3..0000000
--- a/src/app/club/Components/File.tsx
+++ /dev/null
@@ -1,11 +0,0 @@
-import React from 'react';
-
-const File = () => {
- return (
-
-
-
- );
-};
-
-export default File;
diff --git a/src/app/club/Components/Home/About.tsx b/src/app/club/Components/Home/About.tsx
deleted file mode 100644
index 59a7232..0000000
--- a/src/app/club/Components/Home/About.tsx
+++ /dev/null
@@ -1,57 +0,0 @@
-import Image from "next/image";
-
-const About = () => {
- return (
-
-
- {" "}
-
-
-
- ABOUT Club Portal
-
-
-
- {/*
-
-
*/}
-
-
- Welcome to the Club Portal, your gateway to an engaging and
- interactive club experience! Our Club Panel offers a variety of
- features designed to enhance your participation and enjoyment
- within the club.
-
Quizzes: Test your knowledge with our diverse range of
- quizzes, including Intra College Quiz, Intra Club Quiz, and Open
- for All Quiz. Challenge yourself and compete with others!
-
- Profile System: Create and manage your personal profile, keeping
- track of your progress within the club.
-
- Leaderboard: Track your performance and see how you rank against
- your peers with our dynamic points-based leaderboard.
-
-
Open to students from diverse educational backgrounds,
- including schools, colleges, and polytechnic institutes, this
- panel promises to be a transformative experience. Participants
- will engage in the art of Tech individually.
-
-
-
-
-
-
- );
-};
-
-export default About;
diff --git a/src/app/club/Components/Home/FAQ.tsx b/src/app/club/Components/Home/FAQ.tsx
deleted file mode 100644
index 30d584b..0000000
--- a/src/app/club/Components/Home/FAQ.tsx
+++ /dev/null
@@ -1,106 +0,0 @@
-"use client";
-import React, { useState } from "react";
-import Member from "./Member";
-import { BsQuestionCircle } from "react-icons/bs";
-
-const FAQS = [
- {
- title: "What is NDITC?",
- desc: "The Notre Dame Information Technology Club (NDITC) is a co-curricular club at Notre Dame College, Dhaka, established in 2018. Our mission is to promote technology awareness and provide students with opportunities to engage in areas like Web Development, competitive programming, robotics, graphics design, and content creation.",
- },
- {
- title: "How do we operate?",
- desc: "We organize various events, workshops, and competitions to encourage active learning. Our signature events, such as the Father Timm Memorial Programming Contest (FTMPC) and PixelCon, provide a platform for students to showcase their tech skills.",
- },
- {
- title: "How do I register for an account?",
- desc: "Click on the register button. Then enter the required information. Then set up your password and enter click. After that you will receive a verification email and after verifying you're all set!",
- },
- {
- title: "How do I register for an account as a member?",
- desc: "After you officialy become our club member, click on the register button on the website, enter your college roll number, email address you entered in the club registration form. Then set up your password and enter click. After that you will receive a verification email and after verifying you're all set!",
- },
- {
- title: "What is the purpose of this website?",
- desc: "We will host intra-college, intra-club and inter college quizzes on this websites. Based on the results, we will display a leaderboard. Also, you will get updates of any club activities through your profile.",
- },
-];
-const FAQ = () => {
- const [openIndex, setOpenIndex] = useState(1);
- //here index starts from 1. 0 means all closed
- return (
-
-
-
-
-
- FREQUENTLY ASKED{" "}
- {" "}
-
-
- QUESTIONS{" "}
- {" "}
-
- {FAQS.map((data, index) => (
-
-
-
-
-
-
- ))}
-
-
- );
-};
-
-export default FAQ;
diff --git a/src/app/club/Components/Home/Hero.tsx b/src/app/club/Components/Home/Hero.tsx
deleted file mode 100644
index 8df05bb..0000000
--- a/src/app/club/Components/Home/Hero.tsx
+++ /dev/null
@@ -1,48 +0,0 @@
-import Image from "next/image";
-import { SlCalender } from "react-icons/sl";
-import Ranking from "../Dashboard/Ranking";
-import Link from "next/link";
-import RedirectButton from "./RedirectButton";
-
-const Hero = () => {
- return (
- <>
-
-
-
- Welcome to
-
-
-
- Welcome to
-
-
- Club Portal
-
-
-
- Join the ultimate event experience at NDITC – where everyone is
- welcome to connect, create, and celebrate together!
-
-
-
-
-
- {/* */}
-
-
- >
- );
-};
-
-export default Hero;
diff --git a/src/app/club/Components/Home/Member.tsx b/src/app/club/Components/Home/Member.tsx
deleted file mode 100644
index 4552f74..0000000
--- a/src/app/club/Components/Home/Member.tsx
+++ /dev/null
@@ -1,68 +0,0 @@
-/* eslint-disable @next/next/no-img-element */
-import { useState, useEffect } from "react";
-import Image from "next/image";
-type memberProps = {
- img: string;
- imgInCenter?: boolean;
- name: string;
- designation: string;
- department?: string | null;
- hasClickHandler?: boolean;
- hoverText?: string;
-};
-
-const Member = ({
- img,
- imgInCenter,
- name,
- designation,
- department,
- hasClickHandler,
- hoverText,
-}: memberProps) => {
- const [hover, setHover] = useState(false);
- return (
- {
- setHover(true);
- }}
- onMouseOut={() => {
- setHover(false);
- }}
- className={
- "flex place-items-center gap-4 text-center transition-all hover:scale-105 md:flex-col md:gap-2 " +
- (hasClickHandler ? "cursor-pointer" : "saa")
- }
- >
-
-
- {hoverText}
-
-
-
-
-
{name}
-
{designation}
-
{department}
-
-
- );
-};
-
-export default Member;
diff --git a/src/app/club/Components/Home/RedirectButton.tsx b/src/app/club/Components/Home/RedirectButton.tsx
deleted file mode 100644
index 2f17157..0000000
--- a/src/app/club/Components/Home/RedirectButton.tsx
+++ /dev/null
@@ -1,37 +0,0 @@
-"use client";
-
-import Link from "next/link";
-import { useUserDataContext } from "../Layout/UserDataProvider";
-
-const RedirectButton = () => {
- const { userData, userDataLoading, dataError } = useUserDataContext();
- return (
-
- {userData && !userDataLoading ? (
-
- My Profile
-
- ) : (
- <>
-
- Login
-
-
- Register
-
- >
- )}
-
- );
-};
-
-export default RedirectButton;
diff --git a/src/app/club/Components/Home/Rules.tsx b/src/app/club/Components/Home/Rules.tsx
deleted file mode 100644
index 5d7e50d..0000000
--- a/src/app/club/Components/Home/Rules.tsx
+++ /dev/null
@@ -1,71 +0,0 @@
-import { FaC, FaPython } from 'react-icons/fa6';
-import { SiC, SiCplusplus, SiPython } from 'react-icons/si';
-
-const Rules = () => {
- return (
-
-
-
- RULES & {' '}
-
- ELEGIBILITY {' '}
-
-
- -
- {' '}
- All students from schools and colleges (including HSC batch-2023) and corresponding
- institutions such as polytechnic institutes (4th year and below) are eligible to
- participate. Participants have to participate individually.{' '}
-
- - The contest will follow the IOI format.
- -
- {' '}
- Participants can use{' '}
-
-
- Python
-
- ,{' '}
-
- C
- {' '}
- or{' '}
-
-
- C++
- {' '}
- programming language.{' '}
-
- - The preliminary contest will last for 3 hours.
- -
- {' '}
- Participants selected for the Offline Contest must bring their laptops with them.{' '}
-
- - Participants have to participate in the contest using the custom handle.
- - Custom handles will be given to participants via email.
- -
- Contest will be hosted on{' '}
-
- https://toph.co/
- {' '}
-
- -
- {' '}
- Before one day of the Preliminary contest, Toph.co login credentials will be sent to
- registered participants.
-
-
-
- ⚠️ Plagiarism Issues: Since Preliminary will be
- an online contest, third-party codes that were written or available online before the
- start of the contest can be used, but it may lead to confusion if more than one
- participant uses the same template. In that case, the decision of the judges will be
- considered. Apart from that, if a person is caught cheating by providing/taking code from
- others, then they will be DISQUALIFIED from the contest immediately.
-
-
-
- );
-};
-
-export default Rules;
diff --git a/src/app/club/Components/Home/Setter.tsx b/src/app/club/Components/Home/Setter.tsx
deleted file mode 100644
index 9ee31e3..0000000
--- a/src/app/club/Components/Home/Setter.tsx
+++ /dev/null
@@ -1,48 +0,0 @@
-"use client";
-
-import Member from "./Member";
-import setter from "@/data/setter_data";
-import { IoExtensionPuzzleOutline } from "react-icons/io5";
-
-const Setter = () => {
- return (
-
-
- {/*
-
*/}
-
-
-
-
- Problem
-
-
- Setters
-
-
- Hats off to all the brilliant setters who craft mind-bending problems,
- keeping us hooked and our coding skills razor-sharp!
-
-
- {setter.map(({ name, post, image_url, dept }, index) => (
-
-
-
- ))}
-
-
-
- );
-};
-
-export default Setter;
diff --git a/src/app/club/Components/InfoBox.tsx b/src/app/club/Components/InfoBox.tsx
deleted file mode 100644
index 313fc49..0000000
--- a/src/app/club/Components/InfoBox.tsx
+++ /dev/null
@@ -1,27 +0,0 @@
-import React from "react";
-
-const InfoBox = ({
- icon,
- title,
- children,
- type,
-}: {
- icon: React.ReactNode;
- title: string;
- children: React.ReactNode;
- type?: "warning" | undefined;
-}) => {
- return (
-
-
- {icon}
- {title}:
-
- {children}
-
- );
-};
-
-export default InfoBox;
diff --git a/src/app/club/Components/Layout/AuthContextProvider.tsx b/src/app/club/Components/Layout/AuthContextProvider.tsx
deleted file mode 100644
index 7ab8a14..0000000
--- a/src/app/club/Components/Layout/AuthContextProvider.tsx
+++ /dev/null
@@ -1,27 +0,0 @@
-"use client";
-
-import { auth } from "@/config/firebase";
-import { User } from "firebase/auth";
-import { createContext, useContext } from "react";
-import { useAuthState } from "react-firebase-hooks/auth";
-
-const context = createContext<{
- userAuth: User | null | undefined;
- loading: boolean;
- error: Error | undefined;
-}>({ userAuth: null, loading: false, error: undefined });
-
-export const AuthContextProvider = ({
- children,
-}: {
- children: React.ReactNode;
-}) => {
- const [userAuth, loading, error] = useAuthState(auth);
- return (
-
- {children}
-
- );
-};
-
-export const useAuthContext = () => useContext(context);
diff --git a/src/app/club/Components/Layout/ConfigProvider.tsx b/src/app/club/Components/Layout/ConfigProvider.tsx
deleted file mode 100644
index 406b599..0000000
--- a/src/app/club/Components/Layout/ConfigProvider.tsx
+++ /dev/null
@@ -1,63 +0,0 @@
-"use client";
-
-import { db } from "@/config/firebase";
-import { doc, getDoc } from "firebase/firestore";
-import { usePathname } from "next/navigation";
-import { createContext, useContext, useEffect, useState } from "react";
-
-const context = createContext<{
- rank_visible: boolean;
- regStatus: boolean;
- configError: any;
-}>({
- rank_visible: false,
- regStatus: false,
- configError: null,
-});
-
-export const ConfigContextProvider = ({
- children,
-}: {
- children: React.ReactNode;
-}) => {
- const Route = usePathname();
-
- const [rankVisible, setRankVisible] = useState(false);
- const [regStatus, setRegStatus] = useState(false);
-
- const [canLoadData, setCanLoadData] = useState(false);
- const [gotData, setGotData] = useState(false);
-
- const [configError, setConfigError] = useState(null);
-
- useEffect(() => {
- if (Route.includes("club")) {
- setCanLoadData(true);
- }
- }, [Route]);
-
- useEffect(() => {
- if (canLoadData && !gotData) {
- getDoc(doc(db, "config", "config"))
- .then((data) => {
- setRankVisible(data.data()?.rank_visible);
- setRegStatus(data.data()?.registration_status);
- })
- .catch((err) => setConfigError(err));
- }
- }, [canLoadData, gotData]);
-
- return (
-
- {children}
-
- );
-};
-
-export const useConfigContext = () => useContext(context);
diff --git a/src/app/club/Components/Layout/Footer.tsx b/src/app/club/Components/Layout/Footer.tsx
deleted file mode 100644
index 40fbaa6..0000000
--- a/src/app/club/Components/Layout/Footer.tsx
+++ /dev/null
@@ -1,176 +0,0 @@
-import Image from "next/image";
-import Link from "next/link";
-import CurrentYear from "../CurrentYear";
-import { FaFacebook } from "react-icons/fa";
-
-const Footer = () => {
- return (
-
- );
-};
-
-export default Footer;
diff --git a/src/app/club/Components/Layout/Hover.tsx b/src/app/club/Components/Layout/Hover.tsx
deleted file mode 100644
index 52854a8..0000000
--- a/src/app/club/Components/Layout/Hover.tsx
+++ /dev/null
@@ -1,144 +0,0 @@
-'use client';
-
-import { useState, useEffect } from 'react';
-import Link from 'next/link';
-import { usePathname } from 'next/navigation';
-import { FaAngleLeft } from 'react-icons/fa6';
-interface Props {
- windowWidth: number;
- text: string;
- showOptions: boolean;
- setShowOption: () => void;
-}
-
-const Hover = ({ text, showOptions, windowWidth, setShowOption }: Props) => {
- const [hover, setHover] = useState(false);
- const [open, setOpen] = useState(false);
- const Route = usePathname();
- useEffect(() => {
- const listener = () => {
- if (window.innerHeight >= 768) {
- setOpen(false);
- }
- };
- listener();
- window.addEventListener('resize', listener);
-
- return () => {
- window.removeEventListener('resize', listener);
- };
- }, []);
- useEffect(() => {
- setOpen(false);
- }, [showOptions]);
- return (
-
- {windowWidth >= 768 ? (
-
setHover(true)}
- onMouseLeave={() => setHover(false)}
- id="dropdownHoverButton"
- data-dropdown-toggle="dropdownHover"
- data-dropdown-trigger="hover"
- onClick={setShowOption}
- className={
- 'block py-2 px-3 rounded hover:bg-gray-100 md:hover:bg-transparent md:p-0' +
- ' ' +
- (Route === '/activities' ? 'md:text-primary' : '') +
- ' ' +
- (hover ? 'text-primary' : 'text-gray-900 ')
- }
- type="button"
- >
- {text}
-
- ) : (
-
- )}
-
-
setHover(true)}
- onMouseLeave={() => setHover(false)}
- id="dropdownHover"
- className={`md:bg-transparent top-7 right-0 flex transition-all duration-300 items-center md:w-[150px] justify-evenly md:absolute divide-y divide-gray-100 rounded-lg ${
- hover
- ? 'md:blur-0 md:-translate-y-1 md:left-0 md:-translate-x-3 md:opacity-100 md:z-50'
- : 'md:blur-0 md:-translate-y-36 md:left-0 md:-translate-x-3 md:opacity-0 md:z-[-1] md:pointer-events-none'
- } ${
- open
- ? 'z-50 bg-gray-100 h-[180px] md:h-auto overflow-hidden my-1 md:my-0'
- : 'h-0 md:h-auto overflow-hidden md:overflow-visible'
- }`}
- >
-
- -
-
- Events
-
-
- -
-
- Workshop
-
-
-
- -
-
- Projects
-
-
- -
-
- Publication
-
-
-
-
-
- );
-};
-
-export default Hover;
diff --git a/src/app/club/Components/Layout/Navbar.tsx b/src/app/club/Components/Layout/Navbar.tsx
deleted file mode 100644
index 204de39..0000000
--- a/src/app/club/Components/Layout/Navbar.tsx
+++ /dev/null
@@ -1,320 +0,0 @@
-"use client";
-
-import { createCipheriv, createDecipheriv } from "crypto";
-import { useEffect, useRef, useState } from "react";
-import Link from "next/link";
-import { usePathname, useSearchParams } from "next/navigation";
-import { RxCross2 } from "react-icons/rx";
-import { Suspense } from "react";
-import { LuLogIn } from "react-icons/lu";
-import { auth } from "@/config/firebase";
-import { FiUser } from "react-icons/fi";
-import { useConfig } from "@/config/config_db";
-import { useAuthContext } from "./AuthContextProvider";
-import { useUserDataContext } from "./UserDataProvider";
-import { ImDownload } from "react-icons/im";
-import { Avatar } from "@nextui-org/react";
-
-const ClubNavbar = () => {
- const [showOptions, setShowOptions] = useState(false);
- const Route = usePathname();
- const Params = useSearchParams();
- const navRef = useRef(null);
- const [config] = useConfig([]);
- const [windowWidth, setWindowWidth] = useState(800);
- const userAuth = useAuthContext().userAuth;
-
- const encryption_key = "kjfofvdhjHjgrmgherTtyLJfVbshJbvQ"; // Must be 32 characters
- const initialization_vector = "X05IGQ5qdBnIqAWD"; // Must be 16 characters
-
- const { userData, userDataLoading, dataError } = useUserDataContext();
-
- function encrypt(text: any) {
- const cipher = createCipheriv(
- "aes-256-cbc",
- Buffer.from(encryption_key),
- Buffer.from(initialization_vector),
- );
- var crypted = cipher.update(text, "utf8", "hex");
- crypted += cipher.final("hex");
- return crypted;
- }
-
- const [hydrated, setHydrated] = useState(false);
-
- const [deferredPrompt, setDeferredPrompt] = useState(null);
-
- useEffect(() => {
- setHydrated(true);
-
- const stateHandler = () => {
- setShowOptions(false);
- };
- const handleClickOutside: EventListener = (e) => {
- if (
- navRef.current &&
- e.target instanceof Node &&
- !navRef.current.contains(e.target)
- ) {
- setShowOptions(false);
- }
- };
-
- const install = (e: any) => {
- setDeferredPrompt(e);
- };
-
- window.addEventListener("beforeinstallprompt", install);
-
- const listener = () => {
- setWindowWidth(window.innerWidth);
- if (window.innerWidth >= 1024) {
- setShowOptions(false);
- }
- };
- setShowOptions(false);
-
- listener();
-
- window.addEventListener("hashchange", stateHandler);
- window.addEventListener("resize", listener);
- document.addEventListener("mousedown", handleClickOutside);
- return () => {
- window.removeEventListener("hashchange", stateHandler);
- window.removeEventListener("resize", listener);
- window.removeEventListener("beforeinstallprompt", install);
- };
- }, [Route, Params]);
-
- if (!hydrated) {
- return null;
- }
-
- return (
-
- );
-};
-
-export default ClubNavbar;
diff --git a/src/app/club/Components/Layout/UserDataProvider.tsx b/src/app/club/Components/Layout/UserDataProvider.tsx
deleted file mode 100644
index 3b47865..0000000
--- a/src/app/club/Components/Layout/UserDataProvider.tsx
+++ /dev/null
@@ -1,92 +0,0 @@
-"use client";
-
-import { auth, db } from "@/config/firebase";
-import { doc, updateDoc, getDoc } from "firebase/firestore";
-import { usePathname } from "next/navigation";
-import { createContext, useContext, useEffect, useState } from "react";
-import { useAuthState } from "react-firebase-hooks/auth";
-
-const context = createContext<{
- userData: any | null | undefined;
- userDataLoading: boolean;
- dataError: boolean;
- updateUserData: Function;
-}>({
- userData: null,
- userDataLoading: false,
- dataError: false,
- updateUserData: () => {},
-});
-
-export const UserDataContextProvider = ({
- children,
-}: {
- children: React.ReactNode;
-}) => {
- const [userAuth, loading] = useAuthState(auth);
-
- const [userData, setUserData] = useState(null);
- const [userDataLoading, setUserDataLoading] = useState(true);
- const [dataError, setDataError] = useState(false);
-
- const Route = usePathname();
-
- const [canLoadData, setCanLoadData] = useState(false);
-
- const [forceReload, setForceReload] = useState(0);
-
- const updateUserData = () => {
- setForceReload(Math.random());
- };
-
- useEffect(() => {
- if (Route.includes("club")) {
- setCanLoadData(true);
- }
- }, [Route]);
-
- useEffect(() => {
- if (canLoadData) {
- auth.currentUser?.reload();
-
- if (userAuth && userAuth.emailVerified) {
- const docRef = doc(db, "participants", userAuth.uid);
-
- getDoc(doc(db, "participants", userAuth.uid))
- .then((docs) => {
- if (!docs.data()?.verified) {
- updateDoc(docRef, { verified: true })
- .then(() => {
- location.reload();
- })
- .catch(() => {
- setDataError(true);
- setUserDataLoading(false);
- });
- } else {
- setUserData(docs.data());
- setUserDataLoading(false);
- }
- })
- .catch((err) => {
- setDataError(true);
- setUserDataLoading(false);
- });
- } else if (userAuth && !userAuth?.emailVerified) {
- setUserData(null);
- } else if (!loading) {
- setUserData(null);
- }
- }
- }, [userAuth, loading, canLoadData, forceReload]);
-
- return (
-
- {children}
-
- );
-};
-
-export const useUserDataContext = () => useContext(context);
diff --git a/src/app/club/Components/Loading.tsx b/src/app/club/Components/Loading.tsx
deleted file mode 100644
index 380d14f..0000000
--- a/src/app/club/Components/Loading.tsx
+++ /dev/null
@@ -1,12 +0,0 @@
-import React from "react";
-import { CgSpinner } from "react-icons/cg";
-
-const Loading = ({ height }: { height?: string }) => {
- return (
-
-
-
- );
-};
-
-export default Loading;
diff --git a/src/app/club/Components/Modal.tsx b/src/app/club/Components/Modal.tsx
deleted file mode 100644
index c32637c..0000000
--- a/src/app/club/Components/Modal.tsx
+++ /dev/null
@@ -1,27 +0,0 @@
-import React from 'react';
-
-interface props {
- state: any;
- children: React.ReactNode;
-}
-
-const Modal = ({ state, children }: props) => {
- return (
-
- );
-};
-
-export default Modal;
diff --git a/src/app/club/Components/Participate/AnswerSheet.tsx b/src/app/club/Components/Participate/AnswerSheet.tsx
deleted file mode 100644
index 73d3fa0..0000000
--- a/src/app/club/Components/Participate/AnswerSheet.tsx
+++ /dev/null
@@ -1,274 +0,0 @@
-"use client";
-
-import { doc, setDoc } from "firebase/firestore";
-import { useAuthContext } from "../Layout/AuthContextProvider";
-import Timer from "./Timer";
-import Question from "./Question";
-import { useState } from "react";
-import { RiContactsBookUploadLine } from "react-icons/ri";
-import ActualUser from "@/util/ActualUser";
-import { CgSpinner } from "react-icons/cg";
-import { toast } from "react-toastify";
-import { Modal, ModalContent, Button, useDisclosure } from "@nextui-org/react";
-import {
- CircularProgress,
- Card,
- CardBody,
- CardFooter,
- Chip,
-} from "@nextui-org/react";
-
-import { useRouter } from "next/navigation";
-import { CiCircleInfo, CiWarning } from "react-icons/ci";
-import InfoBox from "../InfoBox";
-
-interface Questions {
- mcq: boolean;
- question: string;
- option0: string;
- option1: string;
- option2: string;
- option3: string;
- point: number;
-}
-
-interface answerInterface {
- option: number;
- answer: string;
-}
-
-const getResult = async (answers: any, uid: string, id: string) => {
- const res = await fetch("/api/submit", {
- method: "POST",
- body: JSON.stringify({ answers: answers, uid: uid, id: id }),
- });
-
- if (!res.ok) {
- toast.error("Error Occurred");
- return [];
- }
-
- return res.json();
-};
-
-const AnswerSheet = ({
- endTime,
- id,
- questions,
- publicQuiz,
- name,
- img,
- category,
- description,
- showResult,
-}: {
- endTime: number;
- id: string;
- questions: Questions[];
- publicQuiz: boolean;
- name: string;
- img: string;
- category: string;
- description: string;
- showResult: boolean;
-}) => {
- const [answers, setAnswers] = useState(
- Array(questions.length).fill({ option: 5, answer: "" }),
- );
-
- const { isOpen, onOpen, onOpenChange } = useDisclosure();
-
- const setAnswerData = (
- chosenOption: number,
- givenAnswer: string,
- i: number,
- ) => {
- const ansArr: answerInterface[] = answers.map((e, index) => {
- if (index === i) {
- return { option: chosenOption, answer: givenAnswer };
- } else {
- return e;
- }
- });
-
- setAnswers(ansArr);
- };
-
- const currentUID = useAuthContext().userAuth?.uid;
-
- //------------Submission-----------
-
- const [submitClicked, setSubmitClicked] = useState(false);
-
- const [examMarks, setExamMarks] = useState(1);
- const [resultMarks, setResultMarks] = useState(0);
- const [totalMarks, setTotalMarks] = useState(0);
-
- const SubmitFunc = async () => {
- if (submitClicked) return;
- setSubmitClicked(true);
-
- getResult(answers, currentUID || "", id)
- .then((res) => {
- setExamMarks(res.examMarks);
- setResultMarks(res.result);
- setTotalMarks(res.totalMarks);
- onOpen();
- //setSubmitClicked(false);
- })
- .catch(() => toast.error("Submission Error"));
- };
-
- const router = useRouter();
-
- return (
-
-
-
-
-
-
-
- {category || "Contest"}
-
-
{name}
-
-
-
-
-
-
-
-
-
- {(onClose) => (
- <>
-
-
- {showResult ? (
-
- ) : (
-
- )}
-
-
-
- {showResult ? (
-
- Result:{" "}
- {resultMarks} /{" "}
- {examMarks}
-
- ) : (
- The Result will be Published Later
- )}
-
-
- {publicQuiz && (
-
- Season's Total Marks:{" "}
- {totalMarks}
-
- )}
-
-
-
-
- >
- )}
-
-
-
-
- Questions
-
-
-
- {questions.map((e, i) => {
- return (
-
- );
- })}
-
-
- } type="warning">
- Recheck before submitting your answers. Submission after time will not
- be allowed
-
-
-
- );
-};
-
-export default AnswerSheet;
diff --git a/src/app/club/Components/Participate/Question.tsx b/src/app/club/Components/Participate/Question.tsx
deleted file mode 100644
index 4719c79..0000000
--- a/src/app/club/Components/Participate/Question.tsx
+++ /dev/null
@@ -1,121 +0,0 @@
-import { useEffect, useState } from "react";
-
-interface questionInterface {
- mcq: boolean;
- question: string;
- option0: string;
- option1: string;
- option2: string;
- option3: string;
- point: number;
- index: number;
- setAnswerData: (option: number, answer: string, index: number) => void;
- selectedOption: number;
- givenAnswer: string;
-}
-
-const Question = ({
- mcq,
- point,
- question,
- index,
- option0,
- option1,
- option2,
- option3,
- setAnswerData,
- selectedOption,
- givenAnswer,
-}: questionInterface) => {
- const [selectedVal, setSelectedVal] = useState(selectedOption);
-
- const options = [option0, option1, option2, option3];
- const optionsArr = ["A", "B", "C", "D"];
-
- const [answer, setAnswer] = useState(givenAnswer);
-
- useEffect(() => {
- setAnswerData(selectedVal, answer, index);
- }, [selectedVal, answer]);
-
- return (
-
-
-
-
- {index + 1}
-
-
{question}
-
-
- {mcq ? (
-
- {optionsArr.map((e, i) => {
- return (
-
- );
- })}
-
- ) : (
-
-
-
- {
- setAnswer(e.currentTarget.value);
- }}
- value={answer}
- name="answer"
- placeholder="Your Answer ..."
- />
-
-
- )}
-
- Mark: {point}
-
-
- );
-};
-
-export default Question;
-
-const Option = ({
- optionI,
- option,
- selected,
- index,
- setSelected,
-}: {
- optionI: string;
- option: string;
- selected: number;
- index: number;
- setSelected: (i: number) => void;
-}) => {
- return (
-
- );
-};
diff --git a/src/app/club/Components/Participate/Timer.tsx b/src/app/club/Components/Participate/Timer.tsx
deleted file mode 100644
index 5d0ae75..0000000
--- a/src/app/club/Components/Participate/Timer.tsx
+++ /dev/null
@@ -1,60 +0,0 @@
-"use client";
-
-import { useEffect, useState } from "react";
-import { timeValue } from "../Time";
-import { Timestamp } from "firebase/firestore";
-import Countdown from "react-countdown";
-
-const Timer = ({
- currentTime,
- endTime,
- onEnd,
- submitClicked,
- setSubmitClicked,
-}: {
- currentTime: number;
- endTime: number;
- onEnd: () => void;
- submitClicked: boolean;
- setSubmitClicked: (value: boolean) => void;
-}) => {
- return (
-
-
{
- if (!submitClicked) {
- onEnd();
- }
- setSubmitClicked(true);
- }}
- renderer={(props) => (
-
- {props.hours > 0 && (
- <>
-
-
{props.hours}
-
Hours
-
-
:
- >
- )}
-
-
{props.minutes}
-
Minutes
-
-
:
-
-
{props.seconds}
-
Seconds
-
-
- )}
- />
-
- );
-};
-
-export default Timer;
diff --git a/src/app/club/Components/PassingYear.tsx b/src/app/club/Components/PassingYear.tsx
deleted file mode 100644
index 17a64f6..0000000
--- a/src/app/club/Components/PassingYear.tsx
+++ /dev/null
@@ -1,50 +0,0 @@
-import { HTMLInputTypeAttribute } from "react";
-
-type props = {
- name: string;
- label: string;
- type: HTMLInputTypeAttribute;
- state: number;
- setValue: (name: string, data: number) => void;
- notRequired?: boolean;
- editable?: boolean;
-};
-
-const PassingYear = ({
- name,
- label,
- type,
- state,
- setValue,
- notRequired,
- editable = true,
-}: props) => {
- return (
-
-
-
- setValue(name, e.target.valueAsNumber)}
- value={state}
- type={type}
- name={name}
- required={!notRequired}
- placeholder={label}
- disabled={!editable}
- readOnly={!editable}
- />
-
- );
-};
-
-export default PassingYear;
diff --git a/src/app/club/Components/Profile/Announcements.tsx b/src/app/club/Components/Profile/Announcements.tsx
deleted file mode 100644
index 71c15d3..0000000
--- a/src/app/club/Components/Profile/Announcements.tsx
+++ /dev/null
@@ -1,74 +0,0 @@
-"use client";
-import { db } from "@/config/firebase";
-import {
- collection,
- getDocs,
- limit,
- orderBy,
- query,
- where,
-} from "firebase/firestore";
-import React, { useEffect, useState } from "react";
-import { BsClock } from "react-icons/bs";
-import { CgLock } from "react-icons/cg";
-import { GrAnnounce } from "react-icons/gr";
-import { MdAnnouncement } from "react-icons/md";
-import { toast } from "react-toastify";
-const Announcements = ({ club }: { club?: boolean }) => {
- const [announcements, setAnnouncements] = useState([]);
- useEffect(() => {
- getDocs(
- query(
- collection(db, "announcements"),
- where("club", "==", club ? true : false),
- orderBy("order"),
- limit(3),
- ),
- )
- .then((docs) => {
- const annc: any[] = [];
- docs.forEach((data) => {
- annc.push(data.data());
- });
- annc.reverse();
- setAnnouncements(annc);
- })
- .catch((err) => {
- toast.error("Announcements can't be loaded");
- console.error(err);
- });
- }, []);
- return (
-
-
-
-
- {club ? "NDITC" : ""} NOTICE
-
-
-
- {announcements?.length ? (
- announcements.map((data: any, index: number) => {
- return (
-
-
{data.title}
-
{data.description}
-
-
-
- {new Date(data.timestamp.seconds * 1000).toDateString()}
-
-
- );
- })
- ) : (
-
- No Notices Yet
-
- )}
-
-
- );
-};
-
-export default Announcements;
diff --git a/src/app/club/Components/Profile/ClubInfo.tsx b/src/app/club/Components/Profile/ClubInfo.tsx
deleted file mode 100644
index 0c69fd4..0000000
--- a/src/app/club/Components/Profile/ClubInfo.tsx
+++ /dev/null
@@ -1,315 +0,0 @@
-import { useEffect, useState } from "react";
-import { PiStudentFill } from "react-icons/pi";
-import { toast } from "react-toastify";
-import { CgSpinner } from "react-icons/cg";
-import { doc, updateDoc } from "firebase/firestore";
-import { db } from "@/config/firebase";
-import { CiCircleInfo, CiWarning } from "react-icons/ci";
-import Loading from "../Loading";
-import { Checkbox } from "@nextui-org/checkbox";
-import { useAuthContext } from "../Layout/AuthContextProvider";
-
-const getRegisteredNDC = async (ndc_id: string) => {
- const res = await fetch("/api/memberdata", {
- method: "POST",
- body: JSON.stringify({ ndc_id: ndc_id }),
- });
-
- return res;
-};
-
-const getConnectToNDITC = async (ndc_id: string, email: string) => {
- const res = await fetch("/api/createaccountndc", {
- method: "POST",
- body: JSON.stringify({ ndc_id: ndc_id, email: email }),
- });
-
- return res;
-};
-
-const ClubInfo = ({
- ndc_id,
- ndc_roll,
- email,
- uid,
- updateUserData,
-}: {
- ndc_id: any;
- ndc_roll: any;
- email: string;
- uid: string;
- updateUserData: Function;
-}) => {
- const [memberData, setMemberData] = useState();
-
- const [roll, setRoll] = useState(ndc_roll || "");
- const [loading, setLoading] = useState(false);
-
- const [asMember, setAsMember] = useState(false);
-
- const userAuth = useAuthContext().userAuth;
- const userLoading = useAuthContext().loading;
-
- useEffect(() => {
- if (ndc_id != "") {
- getRegisteredNDC(ndc_id)
- .then((r) => r.json())
- .then((resp) => {
- setMemberData(resp);
- })
- .catch(() => {
- toast.error("You are not a member of NDITC!");
- updateDoc(doc(db, "participants", uid), { ndc_id: "" });
- });
- }
- }, []);
-
- const [editing, setEditing] = useState(false);
-
- const onSubmit = async (e: any) => {
- e.preventDefault();
-
- if (roll == "") {
- toast.error("Roll can't be empty");
- return;
- }
-
- setLoading(true);
-
- if (asMember) {
- const docRes = await getConnectToNDITC(roll, email);
-
- if (!docRes.ok) {
- toast.error("Invalid Roll or Email.");
- setLoading(false);
- } else {
- const memberID = await docRes.json();
-
- if (memberID.success) {
- const fields: any = {};
-
- if (memberID.year) {
- fields["class"] = memberID.year;
- }
-
- await updateDoc(doc(db, "participants", uid), {
- ndc_id: memberID.memberID,
- name: memberID.name,
- ...fields,
- }).then(() => {
- //setLoading(false);
- location.reload();
- });
- }
- }
- } else {
- if (userAuth && !userLoading) {
- try {
- await updateDoc(doc(db, "participants", userAuth.uid), {
- ndc_roll: roll,
- });
-
- toast.success("Data Updated!");
- updateUserData();
- setEditing(false);
- setLoading(false);
- } catch (err) {
- console.error(err);
-
- toast.error("Aww Snap!");
- }
- }
- }
- };
-
- return (
-
- {ndc_id == "" ? (
-
- ) : (
-
-
-
-
-
- {"NDITC"}
- {" INFORMATION"}
-
-
-
-
-
- {" "}
-
- Info:
-
- The information submitted in the membership forms is displayed here
- and cannot be edited. If you need to make changes, please contact
- the panelists.
-
- {memberData ? (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ) : (
-
- )}
-
- )}
-
- );
-};
-
-export default ClubInfo;
-
-const Info = ({ label, info }: { label: string; info: string }) => {
- return (
-
- {`${label}: `}
-
- {info === "" ? "-" : info}
-
- );
-};
diff --git a/src/app/club/Components/Profile/ContestCard.tsx b/src/app/club/Components/Profile/ContestCard.tsx
deleted file mode 100644
index 134c9e6..0000000
--- a/src/app/club/Components/Profile/ContestCard.tsx
+++ /dev/null
@@ -1,115 +0,0 @@
-import { auth, db } from "@/config/firebase";
-import { doc, getDoc } from "firebase/firestore";
-import { useEffect, useState } from "react";
-import { useAuthState } from "react-firebase-hooks/auth";
-import { FaTimes } from "react-icons/fa";
-import { IoCheckmarkDone } from "react-icons/io5";
-import { toast } from "react-toastify";
-import nthNumber from "@/util/nthNumber";
-import { GrTrophy } from "react-icons/gr";
-import { AiFillCode } from "react-icons/ai";
-import { getConfig } from "@/config/config_db";
-import { useUserDataContext } from "../Layout/UserDataProvider";
-import { BiTrophy } from "react-icons/bi";
-import { CgTrophy } from "react-icons/cg";
-import { SiHtmlacademy } from "react-icons/si";
-import { IoIosStats } from "react-icons/io";
-
-const ContestCard = () => {
- const [userAuth, loading, error] = useAuthState(auth);
- const { userData } = useUserDataContext();
-
- const [points, setPoints] = useState(0);
-
- // useEffect(() => {
- // const func = async () => {
- // if (user?.uid) {
- // try {
- // const config = await getConfig();
- // const pre = await getDoc(doc(db, "pre_result", user.uid));
- // const final = await getDoc(doc(db, "final_result", user.uid));
- // setPreResult(
- // pre.exists() && config?.pre_result_published ? pre.data() : null,
- // );
- // setFinalResult(
- // final.exists() &&
- // config?.final_result_published &&
- // config?.pre_result_published
- // ? final.data()
- // : null,
- // );
- // } catch (err) {
- // toast.error("Result Cannot be Loaded!");
- // }
- // }
- // };
- // func();
- // }, [user]);
-
- useEffect(() => {
- const func = async () => {
- if (userAuth?.uid) {
- try {
- const points = await getDoc(
- doc(db, "eventparticipant", userAuth.uid),
- );
-
- setPoints(points.data()?.points);
- } catch (err) {
- toast.error("Result Cannot be Loaded!");
- }
- }
- };
- func();
- }, []);
-
- return (
-
- {/* Contest Details Coming Soon */}
- {/*
-
- YOU IN CONTEST
-
-
-
- Preliminary
-
-
-
- <>
-
- {"Selected"}
- >
-
*/}
-
-
-
-
-
-
- {points || 0}
-
-
- Season Points
-
-
-
-
-
- {/*
- Rank:
- {nthNumber(preResult.ranking)}
-
*/}
-
- );
-};
-
-export default ContestCard;
diff --git a/src/app/club/Components/Profile/EditData.tsx b/src/app/club/Components/Profile/EditData.tsx
deleted file mode 100644
index f8df6ec..0000000
--- a/src/app/club/Components/Profile/EditData.tsx
+++ /dev/null
@@ -1,181 +0,0 @@
-import { FormEvent, useEffect, useState } from "react";
-import { FaRegEdit, FaRegTrashAlt, FaTimes } from "react-icons/fa";
-import Field from "@/app/club/Components/Field";
-import Select from "@/app/club/Components/Select";
-import { FiUser } from "react-icons/fi";
-import { classes, regDataType } from "@/config/registerData";
-import { LiaTimesSolid } from "react-icons/lia";
-import { CgSpinner } from "react-icons/cg";
-import { doc, updateDoc } from "firebase/firestore";
-import { auth, db } from "@/config/firebase";
-import { useAuthState } from "react-firebase-hooks/auth";
-import { toast } from "react-toastify";
-import PassingYear from "../PassingYear";
-import { useUserDataContext } from "../Layout/UserDataProvider";
-
-interface props {
- userData: any;
- setUserData: React.Dispatch;
-}
-
-const EditData = ({ userData, setUserData }: props) => {
- const [editUserData, setEditUserData] = useState(userData);
- const [editin, setEditing] = useState(false);
- const [loading, setLoading] = useState(false);
- const [userAuth] = useAuthState(auth);
- const { updateUserData } = useUserDataContext();
- const setValue = (fname: string, value: string | number) => {
- setEditUserData((s: regDataType) => ({ ...s, [fname]: value }));
- };
- useEffect(() => {
- setEditUserData(userData);
- }, [userData]);
- const submitHandler = async (e: FormEvent) => {
- e.preventDefault();
- setLoading(true);
- if (userAuth) {
- try {
- await updateDoc(doc(db, "participants", userAuth.uid), editUserData);
-
- setUserData(editUserData);
- toast.success("Data Updated!");
- updateUserData();
- setEditing(false);
- } catch (err) {
- console.error(err);
-
- toast.error("Aww Snap!");
- }
- }
- setLoading(false);
- };
- return (
-
- {editUserData ? (
-
- ) : null}
-
- );
-};
-
-export default EditData;
diff --git a/src/app/club/Components/Profile/ProfileHero.tsx b/src/app/club/Components/Profile/ProfileHero.tsx
deleted file mode 100644
index 4cb1c0d..0000000
--- a/src/app/club/Components/Profile/ProfileHero.tsx
+++ /dev/null
@@ -1,50 +0,0 @@
-import React from "react";
-import { useUserDataContext } from "../Layout/UserDataProvider";
-import ProfilePic from "./ProfilePic";
-import { IoIosPower } from "react-icons/io";
-import { useRouter } from "next/navigation";
-import { auth } from "@/config/firebase";
-
-const ProfileHero = () => {
- const { userData } = useUserDataContext() || { userData: null };
- const Router = useRouter();
- const logOut = () => {
- auth.signOut();
- Router.push("/club/login");
- };
-
- return (
-
-
-
-
Welcome Back!
-
- {userData?.name || (
-
- )}
-
-
- {userData?.email || (
-
- )}
-
-
-
-
-
-
- );
-};
-
-export default ProfileHero;
diff --git a/src/app/club/Components/Profile/ProfilePic.tsx b/src/app/club/Components/Profile/ProfilePic.tsx
deleted file mode 100644
index cd46280..0000000
--- a/src/app/club/Components/Profile/ProfilePic.tsx
+++ /dev/null
@@ -1,157 +0,0 @@
-/* eslint-disable @next/next/no-img-element */
-import Image from "next/image";
-import React, { useRef, useState } from "react";
-import Modal from "@/app/club/Components/Modal";
-import { CgSpinner } from "react-icons/cg";
-import { getDownloadURL, ref, uploadBytes } from "firebase/storage";
-import { auth, db, pfp } from "@/config/firebase";
-import { useAuthState } from "react-firebase-hooks/auth";
-import { doc, updateDoc } from "firebase/firestore";
-import { LiaTimesSolid } from "react-icons/lia";
-import { toast } from "react-toastify";
-import fileValidator from "@/util/fileValidator";
-import imageCompression from "browser-image-compression";
-
-const ProfilePic = ({ imageUrl }: { imageUrl: any }) => {
- const [changeImage, setChangeImage] = useState();
- const [newImage, setNewImage] = useState();
- const [loading, setLoading] = useState(false);
- const [compressing, setCompressing] = useState(false);
- const [user] = useAuthState(auth);
-
- const FileRef = useRef(null);
- const changePfp = async () => {
- if (user?.uid && newImage) {
- setLoading(true);
- const storeRef = ref(pfp, "pfp/" + user.uid);
- const options = {
- maxSizeMB: 0.25,
- maxWidthOrHeight: 420,
- useWebWorker: true,
- };
- const compressedFile = await imageCompression(newImage, options);
-
- uploadBytes(storeRef, compressedFile)
- .then(async (snapshot) => {
- const url = await getDownloadURL(storeRef);
- await updateDoc(doc(db, "participants", user.uid), { imageUrl: url });
- setLoading(false);
- setNewImage(null);
- setChangeImage(false);
- toast.success("Photo Updated!");
- })
- .catch((error) => {
- console.dir(error);
- toast.error(error.message.replaceAll("Firebase: ", ""));
- setLoading(false);
- });
- } else {
- toast.error("Something Happenned");
- }
- };
- return (
- <>
- {
- setChangeImage(true);
- }}
- >
-
- Click to Change
-
-
-
-
- {changeImage ? (
-
-
-
-
-
- UPLOAD PROFILE PICTURE
-
- {compressing ? (
-
-
- Image Compressing
-
- ) : null}
- {newImage ? (
-
- ) : null}
-
{
- if (e?.target?.files && e.target.files[0]) {
- try {
- const options = {
- maxSizeMB: 0.25,
- maxWidthOrHeight: 1920,
- useWebWorker: true,
- };
- await fileValidator(
- e.target.files || [],
- ["image/png", "image/jpeg", "image/webp"],
- 5120,
- 1,
- "File must have to be a .jpg, .png or .webp file",
- );
-
- setNewImage(e.target.files[0]);
- setCompressing(false);
- console.log("complete compressing");
- } catch (err) {
- e.target.value = "";
-
- toast.error(String(err));
- }
- }
- }}
- className="my-5 file:mr-3 file:cursor-pointer file:rounded-lg file:border-none file:bg-primary file:px-4 file:py-2 file:text-white file:hover:bg-secondary_light file:hover:text-primary"
- ref={FileRef}
- name="pfp"
- type={"file"}
- accept=".png, .jpg, .jpeg, .webp"
- />
-
-
-
-
- ) : null}
-
- >
- );
-};
-
-export default ProfilePic;
diff --git a/src/app/club/Components/Select.tsx b/src/app/club/Components/Select.tsx
deleted file mode 100644
index f72649e..0000000
--- a/src/app/club/Components/Select.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-import React from 'react';
-
-type props = {
- name: string;
- label: string;
- values: string[];
- selected: string | number;
- setValue: (name: string, data: string | number) => void;
- editable?: boolean;
-};
-const Select = ({ name, label, values, selected, setValue, editable = true }: props) => {
- return (
-
-
-
-
-
- );
-};
-
-export default Select;
diff --git a/src/app/club/Components/SubNav.tsx b/src/app/club/Components/SubNav.tsx
deleted file mode 100644
index e04650b..0000000
--- a/src/app/club/Components/SubNav.tsx
+++ /dev/null
@@ -1,45 +0,0 @@
-import Link from "next/link";
-import { usePathname } from "next/navigation";
-import React from "react";
-import { IconType } from "react-icons";
-
-const SubNavItem = ({
- href,
- icon,
- children,
-}: {
- href: string;
- icon: IconType;
- children: React.ReactNode;
-}) => {
- const path = usePathname();
-
- return (
-
- {React.createElement(icon, {
- className:
- "h-[1.5rem] w-[1.5rem] md:h-[1.125rem] md:w-[1.125rem] " +
- (path === href ? "text-secondary_lightest" : "text-primary"),
- })}
- {children}
-
- );
-};
-
-const SubNav = ({ children }: { children: React.ReactNode }) => {
- return (
-
- {children}
-
- );
-};
-
-export { SubNav, SubNavItem };
diff --git a/src/app/club/Components/Textarea.tsx b/src/app/club/Components/Textarea.tsx
deleted file mode 100644
index 5c607b6..0000000
--- a/src/app/club/Components/Textarea.tsx
+++ /dev/null
@@ -1,44 +0,0 @@
-type props = {
- name: string;
- label: string;
- state: string | number;
- setValue: (name: string, data: string | number) => void;
- notRequired?: boolean;
- editable?: boolean;
- rows?: number;
-};
-
-const Textarea = ({
- name,
- label,
- state,
- setValue,
- notRequired,
- editable = true,
- rows,
-}: props) => {
- return (
-
-
-
- );
-};
-
-export default Textarea;
diff --git a/src/app/club/Components/Time.ts b/src/app/club/Components/Time.ts
deleted file mode 100644
index b894ad1..0000000
--- a/src/app/club/Components/Time.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-import { Timestamp } from "firebase/firestore";
-
-export function timeValue(timeParam: Timestamp) {
- const months = [
- "January",
- "February",
- "March",
- "April",
- "May",
- "June",
- "July",
- "August",
- "September",
- "October",
- "November",
- "December",
- ];
-
- const time = new Date(
- timeParam?.seconds * 1000 + timeParam?.nanoseconds / 1000000
- );
-
- const hour = time?.getHours();
- const minute = time?.getMinutes();
- const seconds = time?.getSeconds();
- const date = time?.getDate();
- const month = time?.getMonth() + 1;
- const year = time?.getFullYear();
-
- return {
- hour: hour,
- minute: minute,
- seconds: seconds,
- date: date,
- month: month,
- monthText: months[month - 1],
- year: year,
- time: time,
- };
-}
diff --git a/src/app/club/Context/AdminContext.ts b/src/app/club/Context/AdminContext.ts
deleted file mode 100644
index ed151f2..0000000
--- a/src/app/club/Context/AdminContext.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import { createContext } from "react";
-
-const AdminContext = createContext(false);
-
-export default AdminContext;
diff --git a/src/app/club/actions/actions.ts b/src/app/club/actions/actions.ts
deleted file mode 100644
index 908fe79..0000000
--- a/src/app/club/actions/actions.ts
+++ /dev/null
@@ -1 +0,0 @@
-"use server";
diff --git a/src/app/club/admin/(adminpanel)/announcements/page.tsx b/src/app/club/admin/(adminpanel)/announcements/page.tsx
deleted file mode 100644
index 40a758b..0000000
--- a/src/app/club/admin/(adminpanel)/announcements/page.tsx
+++ /dev/null
@@ -1,14 +0,0 @@
-import Announcements from "@/app/club/Components/Admin/AdminAnnouncements";
-import AdminEvents from "@/app/club/Components/Admin/AdminEvents";
-import AdminContext from "@/app/club/Context/AdminContext";
-import React, { useContext } from "react";
-
-const Page = () => {
- return (
-
- );
-};
-
-export default Page;
diff --git a/src/app/club/admin/(adminpanel)/events/page.tsx b/src/app/club/admin/(adminpanel)/events/page.tsx
deleted file mode 100644
index bd40300..0000000
--- a/src/app/club/admin/(adminpanel)/events/page.tsx
+++ /dev/null
@@ -1,15 +0,0 @@
-"use client";
-import AdminEvents from "@/app/club/Components/Admin/AdminEvents";
-import AdminContext from "@/app/club/Context/AdminContext";
-import React, { useContext } from "react";
-
-const Page = () => {
- const adminAuth = useContext(AdminContext);
- return (
-
- );
-};
-
-export default Page;
diff --git a/src/app/club/admin/(adminpanel)/layout.tsx b/src/app/club/admin/(adminpanel)/layout.tsx
deleted file mode 100644
index bc121ff..0000000
--- a/src/app/club/admin/(adminpanel)/layout.tsx
+++ /dev/null
@@ -1,120 +0,0 @@
-/* eslint-disable @next/next/no-img-element */
-"use client";
-
-import { auth } from "@/config/firebase";
-import { usePathname, useRouter } from "next/navigation";
-import React, { createContext, useContext, useEffect, useState } from "react";
-import { toast } from "react-toastify";
-import { useAuthState } from "react-firebase-hooks/auth";
-import { CgSpinner } from "react-icons/cg";
-import {
- UserDataContextProvider,
- useUserDataContext,
-} from "@/app/club/Components/Layout/UserDataProvider";
-import ProfileHero from "../../Components/Profile/ProfileHero";
-import { SubNav, SubNavItem } from "../../Components/SubNav";
-import { CgProfile } from "react-icons/cg";
-import { MdAnnouncement, MdEvent } from "react-icons/md";
-import { IoPeopleOutline } from "react-icons/io5";
-import ContestCard from "../../Components/Profile/ContestCard";
-import Loading from "../../Components/Loading";
-import { IoIosPower } from "react-icons/io";
-import AdminContext from "../../Context/AdminContext";
-import { BsGear } from "react-icons/bs";
-
-const Page = ({ children }: { children: React.ReactNode }) => {
- const [userAuth, loading, error] = useAuthState(auth);
- const [dLoading, setDLoading] = useState(true);
-
- const [adminAuth, setAdminAuth] = useState(false);
- const [authLoading, setAuthLoading] = useState(true);
- const Router = useRouter();
- const logOut = () => {
- auth.signOut();
- Router.push("/club/login");
- };
-
- useEffect(() => {
- if (userAuth && userAuth.email) {
- fetch("/api/admin", {
- method: "POST",
- body: JSON.stringify({ id: userAuth.email }),
- })
- .then((r) => r.json())
- .then((resp) => {
- setAdminAuth(resp.auth || false);
- setAuthLoading(false);
- })
- .catch((err) => {
- toast.error("Something went wrong");
- setAdminAuth(false);
- setAuthLoading(false);
- });
- } else {
- setAdminAuth(false);
- setAuthLoading(false);
- }
- }, [userAuth]);
- return (
- <>
- {userAuth && adminAuth ? (
-
-
-
-
-
-
-
Welcome Back!
-
- WEB ADMIN
-
- {/*
- {userAuth.email || (
-
- )}
- */}
-
-
-
-
-
-
-
-
-
- Config
-
-
- Users
-
-
- Notice
-
-
- Events
-
-
-
- {children}
-
-
-
- ) : loading || dLoading || authLoading ? (
-
- ) : (
-
- )}
- >
- );
-};
-
-export default Page;
diff --git a/src/app/club/admin/(adminpanel)/page.tsx b/src/app/club/admin/(adminpanel)/page.tsx
deleted file mode 100644
index 2f27bd1..0000000
--- a/src/app/club/admin/(adminpanel)/page.tsx
+++ /dev/null
@@ -1,117 +0,0 @@
-"use client";
-import Announcements from "@/app/club/Components/Admin/AdminAnnouncements";
-import EditConfig from "@/app/club/Components/Admin/EditConfig";
-import { auth } from "@/config/firebase";
-import { useRouter } from "next/navigation";
-import React, { useState, useRef } from "react";
-import { FaClipboardUser, FaHouseUser } from "react-icons/fa6";
-
-const Page = () => {
- const [loading, setLoading] = useState([
- false,
- false,
- false,
- false,
- ]);
- const downloadRef = useRef(null);
- const [dataURL, setUrl] = useState("");
- const Router = useRouter();
-
- return (
- <>
-
-
- {/* Downloads */}
- {/*
-
-
-
-
- DOWNLOADS
-
-
-
-
-
-
-
-
*/}
- {/* Uploads */}
- {/*
-
-
-
-
- UPLOADS
-
-
-
-
-
-
*/}
-
-
-
-
-
-
-
-
- NDITC Members DB
-
-
-
-
-
-
-
- Down
-
-
-
- >
- );
-};
-
-export default Page;
diff --git a/src/app/club/admin/(adminpanel)/users/AddUser.tsx b/src/app/club/admin/(adminpanel)/users/AddUser.tsx
deleted file mode 100644
index 85e41cb..0000000
--- a/src/app/club/admin/(adminpanel)/users/AddUser.tsx
+++ /dev/null
@@ -1,65 +0,0 @@
-import {
- Modal,
- ModalContent,
- ModalHeader,
- ModalBody,
- ModalFooter,
- Button,
- useDisclosure,
-} from "@nextui-org/react";
-import React from "react";
-import { IoPersonAdd } from "react-icons/io5";
-
-//Currently This Component Is NOT Being Used
-
-const AddUser = () => {
- const { isOpen, onOpen, onOpenChange } = useDisclosure();
-
- const addUser = () => {};
-
- return (
-
-
-
-
-
- {(onClose) => (
- <>
-
- Add an User
-
-
-
-
-
-
- >
- )}
-
-
-
- );
-};
-
-export default AddUser;
diff --git a/src/app/club/admin/(adminpanel)/users/page.tsx b/src/app/club/admin/(adminpanel)/users/page.tsx
deleted file mode 100644
index 138d1c8..0000000
--- a/src/app/club/admin/(adminpanel)/users/page.tsx
+++ /dev/null
@@ -1,835 +0,0 @@
-"use client";
-
-import { auth, db } from "@/config/firebase";
-import { FormEvent, SetStateAction, useEffect, useState } from "react";
-import { useAuthState } from "react-firebase-hooks/auth";
-import { CgSpinner } from "react-icons/cg";
-import Error from "@/app/club/Components/Error";
-import { toast } from "react-toastify";
-import Field from "../../../Components/Field";
-import Select from "@/app/club/Components/Select";
-import { MdEventNote, MdOutlinePersonSearch } from "react-icons/md";
-import {
- collection,
- doc,
- getDoc,
- getDocs,
- limit,
- orderBy,
- Query,
- query,
- QueryDocumentSnapshot,
- startAfter,
- updateDoc,
- where,
-} from "firebase/firestore";
-import { regDataType } from "@/config/registerData";
-import {
- Button,
- Checkbox,
- Modal,
- ModalBody,
- ModalContent,
- ModalFooter,
- ModalHeader,
- useDisclosure,
-} from "@nextui-org/react";
-import { FaCaretUp, FaFilter, FaRegEdit } from "react-icons/fa";
-import { FiCheckCircle, FiUser } from "react-icons/fi";
-import { LiaTimesSolid } from "react-icons/lia";
-import PassingYear from "../../../Components/PassingYear";
-import { CiEdit } from "react-icons/ci";
-import Loading from "../../../Components/Loading";
-import { BiHeart } from "react-icons/bi";
-
-const getMemberByRoll = async (ndc_roll: string) => {
- const res = await fetch("/api/getmemberbyroll", {
- method: "POST",
- body: JSON.stringify({ ndc_id: ndc_roll }),
- });
-
- return res;
-};
-
-const Page = () => {
- const [adminAuth, setAdminAuth] = useState(false);
- const [user] = useAuthState(auth);
- const [authLoading, setAuthLoading] = useState(true);
-
- const [usersData, setUsersData] = useState([]);
- const [lastUserDoc, setLastUserDoc] = useState();
-
- const docLimit = 10;
-
- useEffect(() => {
- if (user && user.email) {
- fetch("/api/admin", {
- method: "POST",
- body: JSON.stringify({ id: user.email }),
- })
- .then((r) => r.json())
- .then((resp) => {
- setAdminAuth(resp.auth || false);
-
- getDocs(onFilterQuery(false)).then((data) => {
- console.log(data.docs[data.docs.length - 1]);
- setLastUserDoc(data.docs[data.docs.length - 1]);
- const tempArr: any[] = [];
- data.docs.forEach((e, i) => {
- tempArr.push({ id: e.id, data: { ...e.data() } });
- });
-
- //setUsersData((oldArr: any) => [oldArr, ...tempArr]);
- setUsersData(tempArr);
- setAuthLoading(false);
- });
- })
- .catch((err) => {
- toast.error("Something went wrong");
- setAdminAuth(false);
- setAuthLoading(false);
- });
- } else {
- setAdminAuth(false);
- setAuthLoading(false);
- }
- }, [user]);
-
- const { isOpen, onOpen, onOpenChange } = useDisclosure();
-
- const [selectedStudentData, setSelectedStudentData] = useState();
- const [selectedStudentIndex, setSelectedStudentIndex] = useState(0);
-
- const [searchBy, setSearchBy] = useState("name");
- const [searchText, setSearchText] = useState("");
-
- //-------Filters------
-
- const [filterOpen, setFilterOpen] = useState(false);
-
- const [isVerified, setIsVerified] = useState(false);
- const [isSelected, setIsSelected] = useState(false);
- const [isMember, setIsMember] = useState(false);
- const [isDamian, setIsDamian] = useState(false);
- const [isTimeSort, setIsTimeSort] = useState(true);
-
- const [isYearSelected, setIsYearSelected] = useState(false);
- const [selectedClass, setSelectedClass] = useState(2001);
-
- const onFilterQuery = (loadMore: boolean) => {
- let conditions = [];
-
- if (isTimeSort) {
- conditions.push(orderBy("timestamp", "desc"));
- } else {
- conditions.push(orderBy("name"));
- }
-
- if (searchText != "") conditions.push(where(searchBy, "==", searchText));
- if (isYearSelected) conditions.push(where("class", "==", selectedClass));
- if (isMember) conditions.push(where("ndc_id", "!=", ""));
- if (isDamian) conditions.push(where("ndc_roll", "!=", ""));
- if (isVerified) conditions.push(where("verified", "==", true));
- if (isSelected) conditions.push(where("selected", "==", true));
- if (loadMore) conditions.push(startAfter(lastUserDoc));
-
- const usersQuery = query(
- collection(db, "participants"),
- limit(docLimit),
- ...conditions,
- );
- return usersQuery;
- };
-
- const onFilter = () => {
- if (searchBy == "NDC Roll") {
- if (searchText != "") {
- getMemberByRoll(searchText)
- .then((r) => r.json())
- .then((resp) => {
- let c = [];
-
- if (isTimeSort) {
- c.push(orderBy("timestamp", "desc"));
- } else {
- c.push(orderBy("name"));
- }
-
- if (isYearSelected) c.push(where("class", "==", selectedClass));
- if (isVerified) c.push(where("verified", "==", true));
- if (isSelected) c.push(where("selected", "==", true));
-
- const q = query(
- collection(db, "participants"),
- limit(docLimit),
- where("ndc_id", "==", resp.memberID),
- ...c,
- );
-
- getDocs(q).then((data) => {
- setLastUserDoc(data.docs[data.docs.length - 1]);
- const tempArr: any[] = [];
- data.docs.forEach((e, i) => {
- tempArr.push({ id: e.id, data: { ...e.data() } });
- });
-
- //setUsersData((oldArr: any) => [oldArr, ...tempArr]);
- setUsersData(tempArr);
- setAuthLoading(false);
- });
- })
- .catch((e) => toast.error(e));
- }
- } else {
- getDocs(onFilterQuery(false)).then((data) => {
- setLastUserDoc(data.docs[data.docs.length - 1]);
- const tempArr: any[] = [];
- data.docs.forEach((e, i) => {
- tempArr.push({ id: e.id, data: { ...e.data() } });
- });
-
- //setUsersData((oldArr: any) => [oldArr, ...tempArr]);
- setUsersData(tempArr);
- setAuthLoading(false);
- });
- }
- };
-
- const loadMoreUsers = () => {
- getDocs(onFilterQuery(true)).then((data) => {
- setLastUserDoc(data.docs[data.docs.length - 1]);
- const tempArr: any[] = [];
- data.docs.forEach((e) => {
- tempArr.push({ id: e.id, data: { ...e.data() } });
- });
-
- setUsersData((oldArr: any) => [...oldArr, ...tempArr]);
-
- setAuthLoading(false);
- });
- };
-
- return (
- <>
- {adminAuth ? (
-
-
-
- USERS PANEL
-
-
-
-
-
-
-
FILTERS
-
-
- Sort By Time
-
-
- NDITC Member
-
-
- Notre Damian
-
-
- Verified
-
-
- Selected
-
-
-
- Filter With Year
-
-
-
-
setSelectedClass(data)}
- name="class"
- label="HSC Passing Year"
- type="number"
- editable={isYearSelected}
- />
-
-
-
-
-
- USERS INFO
-
-
-
-
- {" "}
-
-
-
- Name / Institution
-
-
Passing Year
-
- Verified
-
-
- Selected
-
-
-
- {usersData?.map(
- (e: { id: string; data: any }, i: number) => {
- return (
-
{
- setSelectedStudentData(e);
- setSelectedStudentIndex(i);
- onOpen();
- }}
- key={i}
- className="flex h-20 w-full min-w-[800px] cursor-pointer items-center gap-5 rounded-xl border-1 border-transparent bg-white p-2 pr-8 transition hover:border-secondary_lighter"
- >
-
-
-
-
-
- {e.data?.name}
-
-
- {" "}
- {e.data?.institution}
-
-
-
- {" "}
- HSC-
-
- {e.data?.class}
-
-
-
-
-
-
-
-
-
- );
- },
- )}
-
-
-
-
-
-
-
- {(onClose) => (
- <>
-
- Student Info
-
- {`UID: ${selectedStudentData.id}`}
-
-
-
-
-
-
-
-
-
- >
- )}
-
-
-
- {usersData.length >= docLimit && (
-
- )}
-
-
- ) : authLoading ? (
-
- ) : (
-
- )}
- >
- );
-};
-
-export default Page;
-
-interface props {
- allUsersData: any[];
- userData: regDataType;
- setUsersData: React.Dispatch;
- i: number;
- uid: string;
-}
-
-const EditUserData = ({
- allUsersData,
- userData,
- setUsersData,
- i,
- uid,
-}: props) => {
- const [editUserData, setEditUserData] = useState(userData);
- const [editin, setEditing] = useState(false);
- const [loading, setLoading] = useState(false);
- const [userAuth] = useAuthState(auth);
-
- const setValue = (fname: string, value: string | number | boolean) => {
- setEditUserData((s: regDataType) => ({ ...s, [fname]: value }));
- };
-
- const setValueAllUsers = () => {
- const nextUsers = allUsersData.map((e, index) => {
- if (index != i) {
- // No change
- return e;
- } else {
- return { id: uid, data: editUserData };
- }
- });
- // Re-render with the new array
- setUsersData(nextUsers);
- };
-
- const submitHandler = async (e: FormEvent) => {
- e.preventDefault();
-
- setLoading(true);
- if (userAuth) {
- try {
- await updateDoc(doc(db, "participants", uid), editUserData);
- setValueAllUsers();
- toast.success("Data Updated!");
- setEditing(false);
- } catch (err) {
- toast.error("Aww Snap!");
- }
- }
- setLoading(false);
- };
- return (
-
- {editUserData ? (
-
- ) : null}
-
- );
-};
-
-const EditEventData = ({ uid }: { uid: string }) => {
- const [eventData, setEventData] = useState(null);
-
- const [examData, setExamData] = useState(null);
-
- const [error, setError] = useState();
- const [examError, setExamError] = useState();
-
- const loadEventData = async () => {
- const eventDoc = await getDoc(doc(db, "eventparticipant", uid));
- if (!eventDoc.exists()) {
- toast.error("User hasn't participated yet");
- setEventData(null);
- return;
- }
- setEventData({ id: eventDoc.id, data: eventDoc.data() });
- };
-
- const updateData = async () => {
- updateDoc(doc(db, "eventparticipant", uid), eventData.data)
- .then(() => toast.success("Event Data Updated"))
- .catch((err) => {
- setError(err);
- toast.error(err);
- });
- };
-
- const getExamData = async (name: any) => {
- getDoc(doc(db, "eventparticipant", uid, "eventsData", name))
- .then((e) => {
- setExamData(e.data());
- })
- .catch((err) => {
- setExamError(err);
- toast.error("Error");
- });
- };
- return (
-
-
-
- {!error && eventData && eventData?.id == uid && (
-
-
{
- setEventData((oldData: any) => {
- return {
- id: oldData.id,
- data: { ...oldData.data, points: data },
- };
- });
- }}
- />
-
-
- {eventData.data?.events.map((e: any, i: number) => {
- return (
-
- {e}
- {/**/}
-
- );
- })}
-
-
- {/*!examError && examData && (
-
-
- {examData?.answers.map((answer: any, i: number) => {
- return (
- -
- {`${i + 1}.`}
-
-
{`Chosen Option: ${answer.option}`}
-
{`Given Answer: ${answer.answer}`}
-
-
- );
- })}
-
-
-
{`Marks: ${examData.marks}`}
-
- )*/}
-
-
-
- )}
-
- );
-};
diff --git a/src/app/club/admin/eventEdit/[eventID]/page.tsx b/src/app/club/admin/eventEdit/[eventID]/page.tsx
deleted file mode 100644
index 2b1e5d8..0000000
--- a/src/app/club/admin/eventEdit/[eventID]/page.tsx
+++ /dev/null
@@ -1,703 +0,0 @@
-"use client";
-
-import EventPicture from "@/app/club/Components/Admin/EventPicture";
-import NotFound from "@/app/not-found";
-import { auth, db, pfp } from "@/config/firebase";
-import {
- deleteDoc,
- doc,
- getDoc,
- serverTimestamp,
- setDoc,
-} from "firebase/firestore";
-import { useState, useEffect, useReducer, useRef } from "react";
-import { useAuthState } from "react-firebase-hooks/auth";
-import { CgSpinner } from "react-icons/cg";
-import { RiDeleteBin6Line } from "react-icons/ri";
-import { toast } from "react-toastify";
-import Image from "next/image";
-import Modal from "@/app/club/Components/Modal";
-import fileValidator from "@/util/fileValidator";
-import { LiaTimesSolid } from "react-icons/lia";
-import { getDownloadURL, ref, uploadBytes } from "firebase/storage";
-import { useRouter } from "next/navigation";
-import AddQuestions from "@/app/club/Components/Admin/AddQuestions";
-import { Checkbox, DatePicker, Radio, RadioGroup } from "@nextui-org/react";
-import {
- now,
- getLocalTimeZone,
- ZonedDateTime,
- parseAbsoluteToLocal,
-} from "@internationalized/date";
-import { timeValue } from "@/app/club/Components/Time";
-import Link from "next/link";
-
-const Page = ({ params }: { params: { eventID: string } }) => {
- const [adminAuth, setAdminAuth] = useState(false);
- const [user] = useAuthState(auth);
- const [authLoading, setAuthLoading] = useState(true);
-
- const [eventName, setEventName] = useState("");
- const [category, setCategory] = useState("");
- const [eventUID, setEventUID] = useState("");
-
- const [showResult, setShowResult] = useState(true);
-
- const [intra, setIntra] = useState(false);
- const [intraCollege, setIntraCollege] = useState(false);
- const [publicQuiz, setPublicQuiz] = useState(true);
-
- const [selectedEventType, setSelectedEventType] = useState("public");
-
- useEffect(() => {
- if (selectedEventType == "public") {
- setIntra(false);
- setIntraCollege(false);
- setPublicQuiz(true);
- }
-
- if (selectedEventType == "intra_college") {
- setIntra(false);
- setIntraCollege(true);
- setPublicQuiz(false);
- }
-
- if (selectedEventType == "intra_club") {
- setIntra(true);
- setIntraCollege(false);
- setPublicQuiz(false);
- }
- }, [selectedEventType]);
-
- useEffect(() => {
- if (intra) setSelectedEventType("intra_club");
- if (intraCollege) setSelectedEventType("intra_college");
- if (publicQuiz) setSelectedEventType("public");
- }, [intra, intraCollege, publicQuiz]);
-
- const [date, setDate] = useState(now(getLocalTimeZone()));
- const [endDate, setEndDate] = useState(now(getLocalTimeZone()));
- const [addTime, setAddTime] = useState();
- const [imageURL, setImageURL] = useState(
- "https://firebasestorage.googleapis.com/v0/b/nditc-event.appspot.com/o/ep%2F356631772_874301840754682_3334138381481657833_n.jpg?alt=media&token=042e40b4-46ff-4ff6-90f0-2fb64990bffe",
- );
- const [description, setDescription] = useState("");
-
- //---------------Questions---------------
-
- const [questions, setQuestions] = useState([]);
- const [answers, setAnswers] = useState([]);
-
- const setData = (questionData: any, answerData: any) => {
- setQuestions(questionData);
- setAnswers(answerData);
- };
-
- const [loading, setLoading] = useState(false);
-
- const router = useRouter();
-
- useEffect(() => {
- if (user && user.email) {
- fetch("/api/admin", {
- method: "POST",
- body: JSON.stringify({ id: user.email }),
- })
- .then((r) => r.json())
- .then((resp) => {
- console.log(resp);
- setAdminAuth(resp.auth || false);
- setAuthLoading(false);
- })
- .catch((err) => {
- toast.error("Something went wrong");
- setAdminAuth(false);
- setAuthLoading(false);
- });
- } else {
- setAdminAuth(false);
- setAuthLoading(false);
- }
-
- if (params.eventID != "new") {
- const event = getDoc(doc(db, "events", params.eventID)).then((event) => {
- if (event.exists()) {
- setNotfound(false);
- setEventName(event.data().eventName);
- let time = parseAbsoluteToLocal(
- timeValue(event.data().date).time.toISOString(),
- );
- let endTime = parseAbsoluteToLocal(
- timeValue(event.data().enddate).time.toISOString(),
- );
- setDate(time);
- setEndDate(endTime);
- setAddTime(event.data().addTime);
- setEventUID(event.id);
- setImageURL(event.data().imageURL);
- setDescription(event.data().description);
- setPublicQuiz(event.data().public);
- setIntraCollege(event.data().intraCollege);
- setIntra(event.data().intra);
- setShowResult(event.data().showResult);
- setQuestions(event.data().questions);
- setCategory(event.data().category);
-
- const ans = getDoc(doc(db, "answers", params.eventID)).then((ans) => {
- if (ans.exists()) {
- setAnswers(ans.data().answers);
- }
- });
- } else {
- setNotfound(true);
- }
- });
- } else {
- setNotfound(false);
- }
- }, [user]);
-
- const handleSubmit = async (event: any) => {
- event.preventDefault();
-
- if (!date) {
- toast.error("Date not specified");
- return;
- }
-
- if (questions.length == 0) {
- toast.error("At least one question must be added");
- return;
- }
-
- setLoading(true);
-
- const checkUID = await getDoc(doc(db, "events", eventUID));
-
- if (checkUID.exists()) {
- toast.error("This UID is already in use!");
- setLoading(false);
- } else {
- if (newImage) {
- const storeRef = ref(pfp, "ep/" + eventUID);
- uploadBytes(storeRef, newImage[0]).then(async (snapshot) => {
- const url = await getDownloadURL(storeRef);
- setDoc(doc(db, "events", eventUID), {
- eventName: eventName,
- addTime: serverTimestamp(),
- date: date.toDate(),
- enddate: endDate.toDate(),
- imageURL: url,
- description: description,
- public: publicQuiz,
- intraCollege: intraCollege,
- intra: intra,
- showResult: showResult,
- questions: questions,
- category,
- })
- .then(() => {
- setDoc(doc(db, "answers", eventUID), {
- public: publicQuiz,
- intraCollege: intraCollege,
- intra: intra,
- answers: answers,
- date: date.toDate(),
- enddate: endDate.toDate(),
- });
- })
- .then(() => {
- toast.success("Successfully Event Added");
- setLoading(false);
- goToAdminPanel();
- });
- });
- } else {
- setDoc(doc(db, "events", eventUID), {
- eventName: eventName,
- addTime: serverTimestamp(),
- date: date.toDate(),
- enddate: endDate.toDate(),
- imageURL: imageURL,
- description: description,
- public: publicQuiz,
- intraCollege: intraCollege,
- intra: intra,
- showResult: showResult,
- questions: questions,
- category,
- })
- .then(() => {
- setDoc(doc(db, "answers", eventUID), {
- public: publicQuiz,
- intraCollege: intraCollege,
- intra: intra,
- answers: answers,
- date: date.toDate(),
- enddate: endDate.toDate(),
- });
- })
- .then(() => {
- toast.success("Successfully Event Added");
- setLoading(false);
- goToAdminPanel();
- });
- }
- }
- };
-
- const handleUpdate = async (event: any) => {
- event.preventDefault();
- if (!date) {
- toast.error("Date not specified");
- return;
- }
- if (questions.length == 0) {
- toast.error("At least one question must be added");
- return;
- }
- setLoading(true);
-
- setDoc(doc(db, "events", eventUID), {
- eventName: eventName,
- addTime: addTime,
- date: date.toDate(),
- enddate: endDate.toDate(),
- imageURL: imageURL,
- description: description,
- public: publicQuiz,
- intraCollege: intraCollege,
- intra: intra,
- showResult: showResult,
- questions: questions,
- category,
- })
- .then(() => {
- setDoc(doc(db, "answers", eventUID), {
- public: publicQuiz,
- intraCollege: intraCollege,
- intra: intra,
- answers: answers,
- date: date.toDate(),
- enddate: endDate.toDate(),
- });
- })
- .then(() => {
- toast.success("Successfully Event Updated");
- setLoading(false);
- goToAdminPanel();
- });
- };
-
- const [notfound, setNotfound] = useState(false);
-
- const [changeImage, setChangeImage] = useState();
- const [newImage, setNewImage] = useState();
-
- const FileRef = useRef(null);
-
- //---------Navigation--------
-
- const goToAdminPanel = () => {
- router.push("/club/admin/events");
- };
-
- //-----------Delete Event------------
-
- const [deleteModalOpen, setDeleteModalOpen] = useState(false);
-
- const deleteWarning = (e: any) => {
- e.preventDefault();
- setDeleteModalOpen(true);
- };
-
- const deleteEvent = (e: any) => {
- e.preventDefault();
- setLoading(true);
- deleteDoc(doc(db, "events", eventUID))
- .then(() => {
- deleteDoc(doc(db, "answers", eventUID)).then(() => {
- toast.warning("Event Deleted");
- setLoading(false);
- goToAdminPanel();
- });
- })
- .catch((e) => {
- toast.error(e);
- });
- };
-
- return (
-
- {!notfound ? (
-
-
-
- ) : (
-
- )}
-
- );
-};
-
-export default Page;
diff --git a/src/app/club/admin/login/page.tsx b/src/app/club/admin/login/page.tsx
deleted file mode 100644
index 83b8453..0000000
--- a/src/app/club/admin/login/page.tsx
+++ /dev/null
@@ -1,142 +0,0 @@
-"use client";
-
-import Field from "@/app/club/Components/Field";
-import React, { useEffect, useState } from "react";
-import { auth, db } from "@/config/firebase";
-
-import { signInWithEmailAndPassword } from "firebase/auth";
-
-import { toast } from "react-toastify";
-import { CgLogIn, CgSpinner } from "react-icons/cg";
-import { useRouter } from "next/navigation";
-import Image from "next/image";
-import { FirebaseError } from "firebase/app";
-import { useAuthContext } from "@/app/club/Components/Layout/AuthContextProvider";
-
-const Page = () => {
- const [password, setPassword] = useState("");
- const [email, setEmail] = useState("");
- const [loading, setLoading] = useState(false);
- const [authLoading, setAuthLoading] = useState(true);
- const userAuth = useAuthContext().userAuth;
- const uloading = useAuthContext().loading;
-
- const Router = useRouter();
- const handleSubmit = async (event: any) => {
- event.preventDefault();
- setLoading(true);
- signInWithEmailAndPassword(auth, email, password)
- .then(async (UserCred) => {
- setLoading(false);
- })
- .catch((error: FirebaseError) => {
- console.dir(error);
- switch (error.code) {
- case "auth/invalid-credential":
- toast.error(`Invalid email or password.`);
- break;
- case "auth/too-many-requests":
- toast.error(
- `Too many login attempts. Please reset your password to login again.`,
- );
- break;
- default:
- console.error(error.message);
- toast.error(error.message.replaceAll("Firebase: ", ""));
- break;
- }
- setLoading(false);
- });
- };
- useEffect(() => {
- if (userAuth && userAuth.email) {
- fetch("/api/admin", {
- method: "POST",
- body: JSON.stringify({ id: userAuth.email }),
- })
- .then((r) => r.json())
- .then((resp) => {
- console.log(resp);
- if (resp.auth) {
- Router.push("/club/admin");
- } else {
- auth.signOut();
- toast.error("not an admin account");
- }
- setAuthLoading(false);
- })
- .catch((err) => {
- toast.error("Something went wrong");
- setAuthLoading(false);
- });
- } else {
- setAuthLoading(false);
- }
- }, [userAuth, Router]);
- return (
-
-
-
-
-
-
- );
-};
-
-export default Page;
diff --git a/src/app/club/admin/rankers/[id]/page.tsx b/src/app/club/admin/rankers/[id]/page.tsx
deleted file mode 100644
index c4c0f43..0000000
--- a/src/app/club/admin/rankers/[id]/page.tsx
+++ /dev/null
@@ -1,753 +0,0 @@
-"use client";
-
-import { auth, db } from "@/config/firebase";
-import React, { FormEvent, SetStateAction, useEffect, useState } from "react";
-import { useAuthState } from "react-firebase-hooks/auth";
-import { CgSpinner } from "react-icons/cg";
-import Error from "@/app/club/Components/Error";
-import { toast } from "react-toastify";
-
-import Select from "@/app/club/Components/Select";
-import { MdEventNote, MdOutlinePersonSearch } from "react-icons/md";
-import {
- collection,
- doc,
- getDoc,
- getDocs,
- limit,
- orderBy,
- Query,
- query,
- QueryDocumentSnapshot,
- startAfter,
- updateDoc,
- where,
-} from "firebase/firestore";
-import { regDataType } from "@/config/registerData";
-import {
- Button,
- Checkbox,
- Modal,
- ModalBody,
- ModalContent,
- ModalFooter,
- ModalHeader,
- useDisclosure,
-} from "@nextui-org/react";
-import { FaCaretUp, FaFilter, FaRegEdit } from "react-icons/fa";
-import { FiCheckCircle, FiUser } from "react-icons/fi";
-import { LiaTimesSolid } from "react-icons/lia";
-import { CiEdit } from "react-icons/ci";
-import { BiHeart } from "react-icons/bi";
-import Field from "../../../Components/Field";
-import PassingYear from "../../../Components/PassingYear";
-import Loading from "../../../Components/Loading";
-import { useRouter } from "next/navigation";
-
-const Page = ({ params }: { params: { id: string } }) => {
- const [adminAuth, setAdminAuth] = useState(false);
- const [user] = useAuthState(auth);
- const [authLoading, setAuthLoading] = useState(true);
-
- const [usersData, setUsersData] = useState([]);
- const [lastUserDoc, setLastUserDoc] = useState();
-
- const docLimit = 5;
-
- const router = useRouter();
-
- const firstQ =
- params.id == "public"
- ? query(collection(db, "eventparticipant"), orderBy("points"))
- : query(
- collection(db, "answers", params.id, "eventparticipant"),
- orderBy("marks", "desc"),
- );
-
- const getData = async () => {
- const docsSnap = await getDocs(firstQ);
-
- setLastUserDoc(docsSnap.docs[docsSnap.docs.length - 1]);
-
- const tempArr: any[] = [];
-
- docsSnap.docs.forEach(async (e) => {
- const userData = await getDoc(doc(db, "participants", e.id));
-
- tempArr.push({
- id: e.id,
- data: { ...userData.data() },
- quizData: { ...e.data() },
- });
-
- setUsersData(tempArr);
- });
-
- //setUsersData((oldArr: any) => [oldArr, ...tempArr]);
-
- setAuthLoading(false);
- };
-
- useEffect(() => {
- if (user && user.email) {
- fetch("/api/admin", {
- method: "POST",
- body: JSON.stringify({ id: user.email }),
- })
- .then((r) => r.json())
- .then((resp) => {
- setAdminAuth(resp.auth || false);
-
- getData();
- })
- .catch((err) => {
- toast.error("Something went wrong");
- setAdminAuth(false);
- setAuthLoading(false);
- });
- } else {
- setAdminAuth(false);
- setAuthLoading(false);
- }
- }, [user]);
-
- const { isOpen, onOpen, onOpenChange } = useDisclosure();
-
- const [selectedStudentData, setSelectedStudentData] = useState();
- const [selectedStudentIndex, setSelectedStudentIndex] = useState(0);
-
- const [searchText, setSearchText] = useState("");
-
- //-------Filters------
-
- const [filterOpen, setFilterOpen] = useState(false);
-
- const loadMoreUsers = () => {
- const loadMoreQ =
- params.id == "public"
- ? query(
- collection(db, "eventparticipant"),
- orderBy("points"),
- startAfter(lastUserDoc),
- )
- : query(
- collection(db, "answers", params.id, "eventparticipant"),
- orderBy("marks"),
- startAfter(lastUserDoc),
- );
-
- getDocs(loadMoreQ).then((data) => {
- setLastUserDoc(data.docs[data.docs.length - 1]);
- const tempArr: any[] = [];
- data.docs.forEach((e) => {
- getDoc(doc(db, "participants", e.id))
- .then((userData) => {
- tempArr.push({
- id: e.id,
- data: { ...userData.data() },
- quizData: { ...e.data() },
- });
-
- setUsersData((oldArr: any) => [...oldArr, ...tempArr]);
- })
- .catch(() => {
- toast.error("Error Occurred");
- router.push("/club/admin");
- });
- });
-
- setAuthLoading(false);
- });
- };
-
- const onFilter = () => {
- if (searchText == "") {
- toast.error("Search Text is empty");
- return;
- }
-
- const filterRef =
- params.id == "public"
- ? doc(db, "eventparticipant", searchText)
- : doc(db, "answers", params.id, "eventparticipant", searchText);
-
- getDoc(filterRef)
- .then((data) => {
- if (!data.exists) {
- toast.error("This user hasn't participated in this Quiz yet");
- return;
- }
-
- const tempArr: any[] = [];
-
- getDoc(doc(db, "participants", data.id)).then((userData) => {
- if (!data.exists || userData.data()?.name == "") {
- toast.error("This user hasn't participated in this Quiz yet");
- return;
- }
- tempArr.push({
- id: data.id,
- data: { ...userData.data() },
- quizData: { ...data.data() },
- });
-
- setUsersData(tempArr);
- });
-
- setAuthLoading(false);
- })
- .catch(() => {
- toast.error("Error Occurred");
- router.push("/club/admin");
- });
- };
-
- return (
- <>
- {adminAuth ? (
-
-
-
- RANKERS PANEL
-
-
-
-
-
- setSearchText(e.target.value)}
- value={searchText}
- type={"text"}
- name={"searchtext"}
- placeholder={"Enter ..."}
- />
-
-
-
-
-
-
-
-
- RANKERS INFO
-
-
-
-
- {" "}
-
-
-
- Name / Institution
-
-
Points
-
Passing Year
-
- Verified
-
-
- Selected
-
-
-
- {usersData?.map(
- (
- e: {
- quizData: any;
- id: string;
- data: any;
- },
- i: number,
- ) => {
- return (
-
{
- setSelectedStudentData(e);
- setSelectedStudentIndex(i);
- onOpen();
- }}
- key={i}
- className="flex h-20 w-full min-w-[800px] cursor-pointer items-center gap-5 rounded-xl border-1 border-transparent bg-white p-2 pr-8 transition hover:border-secondary_lighter"
- >
-
-
-
-
-
- {e.data?.name}
-
-
- {" "}
- {e.data?.institution}
-
-
-
- {" "}
-
- {e.quizData?.points || e.quizData.marks}
-
-
-
- {" "}
- HSC-
-
- {e.data?.class}
-
-
-
-
-
-
-
-
-
- );
- },
- )}
-
-
-
-
-
-
-
- {(onClose) => (
- <>
-
- Student Info
-
-
-
-
- {params.id != "public" && (
-
- )}
-
-
-
-
- >
- )}
-
-
-
- {usersData.length >= docLimit && (
-
- )}
-
-
- ) : authLoading ? (
-
- ) : (
-
- )}
- >
- );
-};
-
-export default Page;
-
-interface props {
- allUsersData: any[];
- userData: regDataType;
- setUsersData: React.Dispatch;
- i: number;
- uid: string;
-}
-
-const EditUserData = ({
- allUsersData,
- userData,
- setUsersData,
- i,
- uid,
-}: props) => {
- const [editUserData, setEditUserData] = useState(userData);
- const [editin, setEditing] = useState(false);
- const [loading, setLoading] = useState(false);
- const [userAuth] = useAuthState(auth);
-
- const setValue = (fname: string, value: string | number | boolean) => {
- setEditUserData((s: regDataType) => ({ ...s, [fname]: value }));
- };
-
- const setValueAllUsers = () => {
- const nextUsers = allUsersData.map((e, index) => {
- if (index != i) {
- // No change
- return e;
- } else {
- return { ...e, id: uid, data: editUserData };
- }
- });
- // Re-render with the new array
- setUsersData(nextUsers);
- };
-
- const submitHandler = async (e: FormEvent) => {
- e.preventDefault();
-
- setLoading(true);
- if (userAuth) {
- try {
- await updateDoc(doc(db, "participants", uid), editUserData);
- setValueAllUsers();
- toast.success("Data Updated!");
- setEditing(false);
- } catch (err) {
- toast.error("Aww Snap!");
- }
- }
- setLoading(false);
- };
- return (
-
- {editUserData ? (
-
- ) : null}
-
- );
-};
-
-const EditEventData = ({
- data,
- id,
- uid,
- allData,
- setAllData,
- i,
-}: {
- data: any;
- id: string;
- uid: string;
- allData: any[];
- setAllData: React.Dispatch;
- i: number;
-}) => {
- const [eventData, setEventData] = useState(data);
-
- const [error, setError] = useState("");
-
- console.log(data);
-
- const updateData = async () => {
- await updateDoc(
- doc(db, "answers", id, "eventparticipant", uid),
- eventData,
- ).catch(() => {
- setError("Error Occurred. Code 0");
- toast.error("Error Occurred 0");
- });
-
- await updateDoc(
- doc(db, "eventparticipant", uid, "eventsData", id),
- eventData,
- ).catch(() => {
- setError("Error Occurred. Code 1");
- toast.error("Error Occurred 1");
- });
-
- const nextUsers = allData.map((e, index) => {
- if (index != i) {
- // No change
- return e;
- } else {
- return { ...e, quizData: { ...eventData } };
- }
- });
- // Re-render with the new array
- setAllData(nextUsers);
-
- toast.success("Event Data Updated");
- };
-
- return (
-
- {error == "" && eventData && eventData?.uid == uid && (
-
-
{
- setEventData((oldData: any) => {
- return {
- ...oldData,
- marks: data,
- };
- });
- }}
- />
-
-
- {eventData.answers.map((e: any, i: number) => {
- return (
-
- {`${i + 1}. `}
-
-
{`Chosen Option: ${e.option == 0 ? "A" : e.option == 1 ? "B" : e.option == 2 ? "C" : e.option == 3 ? "D" : "Not Selected"}`}
-
{`Chosen Answer: ${e.answer == "" ? "Not Answered" : e.answer}`}
-
-
- );
- })}
-
-
-
-
- )}
-
- );
-};
diff --git a/src/app/club/developer/Modal.tsx b/src/app/club/developer/Modal.tsx
deleted file mode 100644
index 35756a8..0000000
--- a/src/app/club/developer/Modal.tsx
+++ /dev/null
@@ -1,141 +0,0 @@
-/* eslint-disable @next/next/no-img-element */
-import React, { Dispatch, SetStateAction, useEffect } from "react";
-import DeveloperData from "./developers";
-import ModalCont from "@/app/club/Components/Modal";
-import Link from "next/link";
-const Field = ({ title, desc }: { title: string; desc: React.ReactNode }) => {
- return (
-
- );
-};
-const Links = ({ img, href }: { img: string; href: string }) => {
- return (
-
-
-
- );
-};
-const Modal = ({
- modalState,
- setModalState,
-}: {
- modalState: [string, number] | null;
- setModalState: Dispatch>;
-}) => {
- const data = modalState ? DeveloperData[modalState[0]][modalState[1]] : null;
- const firstNameArr = data?.name.split(" ");
- const lastName = firstNameArr?.pop();
- const firstName = firstNameArr?.join(" ") + " ";
- const deptName = data?.dept?.replace("Department of ", "");
- useEffect(() => {
- if (modalState) {
- document.body.style.overflow = "hidden";
- } else {
- document.body.style.overflow = "auto";
- }
- }, [modalState]);
- return (
-
-
-
-
-
-
- {modalState && modalState[0] !== "SUPERVISION AND GUIDELINES" ? (
-
- Web Developers
-
- ) : null}
-
- Web Developers
-
-
- {modalState ? modalState[0].replace("WEB DEVELOPERS", "") : ""}
-
-
-
-
- {modalState && data ? (
-
-
-
-
-
- {firstName}
- {lastName}
-
-
- {data.post}
-
- {data.dept ? (
-
{deptName}
- ) : null}
-
-
-
-
-
- {Array.isArray(data.profile_url) &&
- data.profile_url.length > 0 ? (
-
- {data.profile_url.map((arr, index) => {
- return (
-
- );
- })}
-
- }
- />
- ) : null}
-
-
-
- ) : null}
-
-
-
- );
-};
-
-export default Modal;
diff --git a/src/app/club/developer/developers.ts b/src/app/club/developer/developers.ts
deleted file mode 100644
index 77ce1ee..0000000
--- a/src/app/club/developer/developers.ts
+++ /dev/null
@@ -1,75 +0,0 @@
-type dev = {
- name: string;
- image_url: string;
- imageInCenter?: boolean;
- roll?: number;
- group?: number;
- email?: string;
- phone?: string;
- profile_url?: string | { platform: string; url: string }[];
- modal_image_url?: string;
- post: string;
- dept?: string | null;
-};
-type devData = {
- [key: string]: dev[];
-};
-
-const x: devData = {
- "MAIN DEVELOPER": [
- {
- name: "Wasef Rahman Swapnil",
- image_url: "/image/Developers/swapnil.jpg",
- modal_image_url: "/image/Developers/tr-swapnil.png",
- imageInCenter: true,
- profile_url: [
- {
- platform: "facebook",
- url: "https://www.facebook.com/profile.php?id=100083625623282",
- },
- {
- platform: "github",
- url: "https://github.com/The-XENO-Studios/",
- },
- {
- platform: "web",
- url: "https://xenostudios.vercel.app",
- },
- ],
- post: "Member",
- dept: "Batch '25",
- group: 8,
- roll: 12508025,
- email: "wasefrahmanswapnil@gmail.com",
- },
- ],
- "KEY DEVELOPER": [
- {
- name: "HRM Rafsan Amin",
- image_url: "/image/Developers/hrm_rafsan.jpg",
- modal_image_url: "/image/Developers/tr-hrm_rafsan.png",
- imageInCenter: false,
- profile_url: [
- {
- platform: "facebook",
- url: "https://www.facebook.com/profile.php?id=100082305411559",
- },
- {
- platform: "github",
- url: "https://github.com/RafsanAmin",
- },
- {
- platform: "web",
- url: "https://rafsanamin.epizy.com",
- },
- ],
- post: "Member",
- dept: "Batch '25",
- group: 5,
- roll: 12505033,
- email: "rafsanamin2020@gmail.com",
- },
- ],
-};
-
-export default x;
diff --git a/src/app/club/developer/page.tsx b/src/app/club/developer/page.tsx
deleted file mode 100644
index ae97d4c..0000000
--- a/src/app/club/developer/page.tsx
+++ /dev/null
@@ -1,88 +0,0 @@
-"use client";
-
-import { FaCode } from "react-icons/fa";
-import Member from "@/app/club/Components/Home/Member";
-import DevData from "./developers";
-import { useState } from "react";
-import Modal from "./Modal";
-
-const Developer = () => {
- const [modalState, setModalState] = useState<[string, number] | null>(null);
- return (
-
-
-
-
-
-
-
-
-
-
MEET OUR
-
- DEVELOPERS
-
-
-
- We would like to thank our amazing developers who worked hard to
- create this website. They have shown great skill, creativity, and
- dedication in bringing our vision to life. They have overcome many
- challenges and delivered a high-quality product that we are proud
- of. We appreciate their efforts and contributions to our success.
-
-
-
-
- We would like to thank our amazing developers who worked hard to
- create this website. They have shown great skill, creativity, and
- dedication in bringing our vision to life. They have overcome many
- challenges and delivered a high-quality product that we are proud of.
- We appreciate their efforts and contributions to our success.
-
-
- {Object.entries(DevData).map(([title, members], index) => {
- const titleArr = title.split(" ");
- const first = titleArr?.splice(0, 1);
- const last = titleArr?.join(" ") + " ";
- return (
-
-
-
{first}
- {last}
-
-
- {members.map(
- ({ name, post, image_url, dept, imageInCenter }, index) => (
-
{
- setModalState([title, index]);
- }}
- >
-
-
- ),
- )}
-
-
- );
- })}
-
-
-
- );
-};
-
-export default Developer;
diff --git a/src/app/club/eventdetails/[id]/ParticipateButton.tsx b/src/app/club/eventdetails/[id]/ParticipateButton.tsx
deleted file mode 100644
index acd48ab..0000000
--- a/src/app/club/eventdetails/[id]/ParticipateButton.tsx
+++ /dev/null
@@ -1,63 +0,0 @@
-"use client";
-
-import Link from "next/link";
-import { useUserDataContext } from "../../Components/Layout/UserDataProvider";
-
-const ParticipateButton = ({
- id,
- intra_club,
- intra_college,
- publicQuiz,
-}: {
- id: string;
- intra_club: boolean;
- intra_college: boolean;
- publicQuiz: boolean;
-}) => {
- const { userData, userDataLoading, dataError } = useUserDataContext();
-
- if (userDataLoading) return
;
-
- if (intra_college && userData && userData.ndc_roll != "") {
- return (
-
-
- Participate
-
-
- );
- }
-
- if (intra_club && userData && userData.ndc_id != "") {
- return (
-
-
- Participate
-
-
- );
- }
-
- if (publicQuiz && userData) {
- return (
-
-
- Participate
-
-
- );
- }
-
- return
;
-};
-
-export default ParticipateButton;
diff --git a/src/app/club/eventdetails/[id]/loading.tsx b/src/app/club/eventdetails/[id]/loading.tsx
deleted file mode 100644
index 6260a11..0000000
--- a/src/app/club/eventdetails/[id]/loading.tsx
+++ /dev/null
@@ -1,35 +0,0 @@
-const Loading = async () => {
- return (
-
- );
-};
-
-export default Loading;
diff --git a/src/app/club/eventdetails/[id]/page.tsx b/src/app/club/eventdetails/[id]/page.tsx
deleted file mode 100644
index bf01985..0000000
--- a/src/app/club/eventdetails/[id]/page.tsx
+++ /dev/null
@@ -1,102 +0,0 @@
-import Link from "next/link";
-import { MdOutlineDateRange } from "react-icons/md";
-import { notFound } from "next/navigation";
-import ImageGrid from "@/app/(main)/Components/ImageComponents/ImageGrid";
-import Markdown from "react-markdown";
-import remarkGfm from "remark-gfm";
-import { createDecipheriv } from "crypto";
-import { initAdmin } from "@/config/firebaseAdmin";
-import { firestore } from "firebase-admin";
-import { getFirestore, Timestamp } from "firebase-admin/firestore";
-import { timeValue } from "../../Components/Time";
-import ParticipateButton from "./ParticipateButton";
-
-type ParamType = { id: string };
-
-const page = async ({ params }: { params: ParamType }) => {
- await initAdmin();
- const encryption_key = "kjfofvdhjHjgrmgherTtyLJfVbshJbvQ"; // Must be 32 characters
- const initialization_vector = "X05IGQ5qdBnIqAWD"; // Must be 16 characters
-
- function decrypt(text: any) {
- const decipher = createDecipheriv(
- "aes-256-cbc",
- Buffer.from(encryption_key),
- Buffer.from(initialization_vector),
- );
- let dec = decipher.update(text, "hex", "utf8");
- dec += decipher.final("utf8");
- return dec;
- }
-
- const firestore = getFirestore();
-
- const dataDoc = await firestore
- .collection("events")
- .doc(decrypt(params.id))
- .get();
-
- if (!dataDoc.exists) notFound();
-
- const data = dataDoc.data();
-
- const title = data?.eventName;
-
- const DateData = timeValue(data?.date);
-
- const now = Timestamp.now();
-
- const timeUp = now > data?.enddate;
- const notTime = now < data?.date;
-
- return (
-
-
-
-
-
-
- {"Category>"}
- {`${data?.category}>`}
-
-
-
{title}
-
-
-
- {`${DateData.date} ${DateData.monthText} ${DateData.year}`}{" "}
- |{" "}
- {`${DateData.hour}:${DateData.minute}`}
-
-
- {!timeUp && !notTime && (
-
- )}
-
-
-
-
-
-
-
-
- {data?.description}
-
-
-
-
- );
-};
-
-export default page;
diff --git a/src/app/club/events/[uid]/[memberid]/[type]/page.tsx b/src/app/club/events/[uid]/[memberid]/[type]/page.tsx
deleted file mode 100644
index 9cb06ef..0000000
--- a/src/app/club/events/[uid]/[memberid]/[type]/page.tsx
+++ /dev/null
@@ -1,29 +0,0 @@
-import { createDecipheriv } from "crypto";
-
-const page = ({ params }: { params: { uid: string; type: string } }) => {
- const encryption_key = "kjfofvdhjHjgrmgherTtyLJfVbshJbvQ"; // Must be 32 characters
- const initialization_vector = "X05IGQ5qdBnIqAWD"; // Must be 16 characters
-
- function decrypt(text: any) {
- const decipher = createDecipheriv(
- "aes-256-cbc",
- Buffer.from(encryption_key),
- Buffer.from(initialization_vector),
- );
- let dec = decipher.update(text, "hex", "utf8");
- dec += decipher.final("utf8");
- return dec;
- }
-
- return (
-
-
-
- ONGOING EVENTS
-
-
-
- );
-};
-
-export default page;
diff --git a/src/app/club/events/[uid]/[memberid]/page.tsx b/src/app/club/events/[uid]/[memberid]/page.tsx
deleted file mode 100644
index 8d6714c..0000000
--- a/src/app/club/events/[uid]/[memberid]/page.tsx
+++ /dev/null
@@ -1,92 +0,0 @@
-"use client";
-
-import Error from "@/app/club/Components/Error";
-import EventList from "@/app/club/Components/Events/EventList";
-import { useAuthContext } from "@/app/club/Components/Layout/AuthContextProvider";
-import { useUserDataContext } from "@/app/club/Components/Layout/UserDataProvider";
-import { useState, useEffect } from "react";
-import Loading from "@/app/club/Components/Loading";
-
-const getEvents = async (ndc_id: string, uid: string, ndc_roll: string) => {
- const res = await fetch("/api/getevents", {
- method: "POST",
- body: JSON.stringify({
- ndc_id: ndc_id,
- uid: uid,
- ndc_roll,
- }),
- cache: "no-store",
- });
-
- return res;
-};
-
-export const dynamic = "force-dynamic";
-
-const Page = ({ params }: { params: { uid: string; memberid: string } }) => {
- const { userData, userDataLoading, dataError } = useUserDataContext();
-
- const { userAuth, loading, error } = useAuthContext();
-
- const uidVal = userAuth?.uid;
- const memberidval = userData?.ndc_id;
-
- const [isLoading, setIsLoading] = useState(true);
-
- const [isError, setIsError] = useState("");
-
- const [ongoingList, setOngoingList] = useState
(null);
- const [eventsList, setEventsList] = useState(null);
-
- useEffect(() => {
- if (!loading && !userDataLoading) {
- getEvents(memberidval, uidVal || "", userData?.ndc_roll || "")
- .then((r) => r.json())
- .then((resp) => {
- setIsLoading(false);
-
- setOngoingList(resp.ongoingList);
-
- setEventsList(resp.eventList);
-
- if (resp.error) {
- setIsLoading(false);
- setIsError(resp.error || "Error Occurred");
- }
- });
- }
-
- if (error || dataError) {
- setIsLoading(false);
- setIsError("Error Occurred");
- }
- }, [userAuth, userData, loading, userDataLoading, error, dataError]);
-
- return (
-
- {isError != "" && }
- {isLoading && }
- {!isLoading && isError == "" && (
-
- {ongoingList.length != 0 && (
-
-
- ONGOING EVENTS
-
-
-
-
- )}
-
-
- ALL EVENTS
-
-
-
-
- )}
-
- );
-};
-
-export default Page;
diff --git a/src/app/club/events/page.tsx b/src/app/club/events/page.tsx
deleted file mode 100644
index a9864e4..0000000
--- a/src/app/club/events/page.tsx
+++ /dev/null
@@ -1,54 +0,0 @@
-import EventCard from "@/app/club/Components/Events/EventCard";
-import { getFirestore, Timestamp } from "firebase-admin/firestore";
-import { initAdmin } from "@/config/firebaseAdmin";
-import EventList from "../Components/Events/EventList";
-import { createCipheriv } from "crypto";
-
-const page = async () => {
- await initAdmin();
-
- const encryption_key = "kjfofvdhjHjgrmgherTtyLJfVbshJbvQ"; // Must be 32 characters
- const initialization_vector = "X05IGQ5qdBnIqAWD"; // Must be 16 characters
-
- function encrypt(text: string) {
- const cipher = createCipheriv(
- "aes-256-cbc",
- Buffer.from(encryption_key),
- Buffer.from(initialization_vector),
- );
- var crypted = cipher.update(text, "utf8", "hex");
- crypted += cipher.final("hex");
- return crypted;
- }
-
- //const now = Timestamp.now();
-
- const firestore = getFirestore();
-
- const collectionSnapshot = await firestore
- .collection("events")
- .orderBy("date", "desc")
- .limit(9)
- .get();
-
- const eventList: any[] = collectionSnapshot.docs.map((e) => ({
- id: encrypt(e.id),
- ...e.data(),
- }));
-
- console.log(eventList);
-
- return (
-
-
-
- ALL EVENTS
-
-
-
-
-
- );
-};
-
-export default page;
diff --git a/src/app/club/page.tsx b/src/app/club/page.tsx
deleted file mode 100644
index 7dda67c..0000000
--- a/src/app/club/page.tsx
+++ /dev/null
@@ -1,25 +0,0 @@
-/* eslint-disable jsx-a11y/img-redundant-alt */
-
-import Setter from "@/app/club/Components/Home/Setter";
-import Hero from "@/app/club/Components/Home/Hero";
-import About from "@/app/club/Components/Home/About";
-import Rules from "@/app/club/Components/Home/Rules";
-import Contact from "@/app/club/Components/Contact";
-import FAQ from "@/app/club/Components/Home/FAQ";
-import Ranking from "./Components/Dashboard/Ranking";
-
-const page = () => {
- return (
- <>
-
-
-
-
-
-
-
- >
- );
-};
-
-export default page;
diff --git a/src/app/club/participate/[id]/page.tsx b/src/app/club/participate/[id]/page.tsx
deleted file mode 100644
index ddcb19c..0000000
--- a/src/app/club/participate/[id]/page.tsx
+++ /dev/null
@@ -1,114 +0,0 @@
-"use client";
-
-import Error from "@/app/club/Components/Error";
-import AnswerSheet from "@/app/club/Components/Participate/AnswerSheet";
-import { createDecipheriv } from "crypto";
-import { useUserDataContext } from "../../Components/Layout/UserDataProvider";
-import { useAuthContext } from "../../Components/Layout/AuthContextProvider";
-import { CgSpinner } from "react-icons/cg";
-import { useEffect, useState } from "react";
-import Loading from "../../Components/Loading";
-
-const getQuestions = async (
- id: string,
- ndc_id: string,
- uid: string,
- email: string,
- ndc_roll: string,
-) => {
- const res = await fetch("/api/getquestion", {
- method: "POST",
- body: JSON.stringify({
- id: id,
- ndc_id: ndc_id,
- uid: uid,
- email: email,
- ndc_roll,
- }),
- cache: "no-store",
- });
-
- return res;
-};
-
-const Page = ({ params }: { params: { id: string } }) => {
- const encryption_key = "kjfofvdhjHjgrmgherTtyLJfVbshJbvQ"; // Must be 32 characters
- const initialization_vector = "X05IGQ5qdBnIqAWD"; // Must be 16 characters
-
- function decrypt(text: any) {
- const decipher = createDecipheriv(
- "aes-256-cbc",
- Buffer.from(encryption_key),
- Buffer.from(initialization_vector),
- );
- let dec = decipher.update(text, "hex", "utf8");
- dec += decipher.final("utf8");
- return dec;
- }
-
- const { userData, userDataLoading, dataError } = useUserDataContext();
-
- const { userAuth, loading, error } = useAuthContext();
-
- const id = decrypt(params.id);
-
- const uidVal = userAuth?.uid;
- const memberidval = userData?.ndc_id;
-
- const [docSnapshot, setDocSnapShot] = useState(null);
-
- const [isLoading, setIsLoading] = useState(true);
-
- const [isError, setIsError] = useState("");
-
- useEffect(() => {
- if (!loading && !userDataLoading) {
- getQuestions(
- id,
- memberidval,
- uidVal || "",
- userAuth?.email || "",
- userData?.ndc_roll || "",
- )
- .then((r) => r.json())
- .then((resp) => {
- setIsLoading(false);
- setDocSnapShot(resp);
-
- if (resp.error) {
- setIsLoading(false);
- setIsError(resp.error || "Error Occurred");
- }
- });
- }
-
- if (error || dataError) {
- setIsLoading(false);
- setIsError("Error Occurred");
- }
- }, [userAuth, userData, loading, userDataLoading, error, dataError]);
-
- return (
-
- {isError != "" && }
- {isLoading && }
- {!isLoading && isError == "" && docSnapshot.questions && (
-
- )}
-
- );
-};
-
-export default Page;
diff --git a/src/app/club/standings/[type]/page.tsx b/src/app/club/standings/[type]/page.tsx
deleted file mode 100644
index 90f978a..0000000
--- a/src/app/club/standings/[type]/page.tsx
+++ /dev/null
@@ -1,194 +0,0 @@
-"use client";
-import { useConfig } from "@/config/config_db";
-import { pfp } from "@/config/firebase";
-import nthNumber from "@/util/nthNumber";
-import { getBlob, getBytes, getDownloadURL, ref } from "firebase/storage";
-import Image from "next/image";
-import Link from "next/link";
-import React, { useEffect, useState } from "react";
-import {
- BsCalendar2CheckFill,
- BsDownload,
- BsGraphUpArrow,
-} from "react-icons/bs";
-import { CgSpinner } from "react-icons/cg";
-import { FaTimes } from "react-icons/fa";
-import { FiUserCheck } from "react-icons/fi";
-import { GrTrophy, GrWorkshop } from "react-icons/gr";
-import { IoCheckmarkDone } from "react-icons/io5";
-import { LuArchive } from "react-icons/lu";
-import { toast } from "react-toastify";
-
-const Page = ({ params }: { params: { type: string } }) => {
- const { type } = params;
- const [config, , configLoading] = useConfig([]);
- const [result, setResult] = useState("loading");
- useEffect(() => {
- setResult("loading");
- if (
- (type === "final" && config?.final_result_published) ||
- (type === "preliminary" && config?.pre_result_published)
- ) {
- getBytes(
- ref(
- pfp,
- "result/" + (type === "preliminary" ? "pre_result" : "final_result"),
- ),
- )
- .then((data) => {
- const json = JSON.parse(
- new TextDecoder("utf-8").decode(new Uint8Array(data)),
- );
- setResult(json);
- })
- .catch((err) => {
- setResult(null);
- console.error(err);
- });
- } else if (!configLoading) {
- setResult(null);
- }
- }, [type, config, configLoading]);
-
- return (
-
-
-
- STANDINGS |
- {String(type)}
-
-
- {type === "preliminary"
- ? "Only Selected Students are listed here!"
- : "Final result have been published"}
-
- {config?.pre_result_published ? (
-
-
-
- Preliminary
-
-
- {config?.final_result_published ? (
-
-
- Final
-
- ) : null}
-
- ) : null}
-
-
- {((type === "final" && config?.final_result_published) ||
- (type === "preliminary" && config?.pre_result_published)) &&
- result?.length > 0 &&
- result !== "loading" ? (
-
-
-
- Ranking |
- Participant |
- Score / Penalty |
- {/* Selected | */}
-
-
-
- {result.map((data: any, index: number) => (
-
-
-
- {nthNumber(index + 1)}
-
- |
-
-
-
-
- {data.name}
-
- {data.institution}
-
- |
-
-
- {data.score}
- {" "}
- /{" "}
-
- {data.penalty}
-
- |
- {/*
- {data.selected ? (
-
-
-
- ) : (
-
-
-
- )}
-
- | */}
-
- ))}
-
-
- ) : configLoading || result === "loading" ? (
-
-
-
- ) : (
-
- Result not published yet
-
- )}
-
-
-
- );
-};
-
-export default Page;
diff --git a/src/app/globals.css b/src/app/globals.css
index 95726e9..a8ad8af 100644
--- a/src/app/globals.css
+++ b/src/app/globals.css
@@ -329,3 +329,98 @@ p {
.container-login {
@apply mx-auto max-w-[100vw] sm:max-w-[90vw] xl:max-w-[85vw] 2xl:max-w-[75vw];
}
+
+.ques img {
+ max-width: 450px;
+ width: 100%;
+}
+.ques ul li {
+ list-style: lead;
+ list-style-position: inside;
+ margin-left: 0.35rem;
+}
+.ques ul {
+ margin-top: 0.25rem;
+ margin-bottom: 0.75rem;
+}
+.ques p {
+ padding-bottom: 0.5rem;
+}
+
+.ques p::first-line {
+ padding-left: 1rem;
+}
+.ques a {
+ color: #3b82f6;
+}
+.ques h1 {
+ font-size: 1.75rem;
+ padding-top: 0.5rem;
+ padding-bottom: 0.25rem;
+ font-weight: 600;
+ font-family: "Inter";
+}
+/* .ques h1::first-letter {
+ color: #2f4770;
+} */
+.ques h2 {
+ font-size: 1.5rem;
+ padding-top: 0.5rem;
+ padding-bottom: 0.25rem;
+ font-weight: 600;
+ font-family: "Inter";
+}
+.ques h3,
+.ques h4,
+.ques h5,
+.ques h6 {
+ font-size: 1.25rem;
+ padding-top: 0.25rem;
+ padding-bottom: 0.25rem;
+ font-family: "Inter";
+
+ font-weight: 600;
+}
+
+.ques h4,
+.ques h5,
+.ques h6 {
+ font-size: 1.15rem !important;
+}
+.ques table {
+ border: 1px solid #e4e4e7;
+ border-radius: 2px;
+}
+.ques thead tr {
+ background-color: #e4e4e7;
+}
+.ques tbody tr:nth-child(2n-1) {
+ background-color: transparent;
+}
+.ques tbody tr:nth-child(2n) {
+ background-color: #e4e4e7d0;
+}
+.ques td,
+.ques th {
+ padding: 0.5rem 2rem;
+ border: 1px solid #d1d5db;
+}
+
+.ques ul {
+ list-style-type: circle;
+ list-style-position: inside;
+}
+
+.ques ol {
+ list-style-type: inherit;
+ list-style-position: inside;
+}
+
+.ques code {
+ line-height: 0.75;
+}
+
+.ques li::marker {
+ color: #3b82f6;
+ font-weight: bold;
+}
diff --git a/src/app/layout.tsx b/src/app/layout.tsx
index 8468576..2044085 100644
--- a/src/app/layout.tsx
+++ b/src/app/layout.tsx
@@ -12,9 +12,6 @@ import NextTopLoader from "nextjs-toploader";
import { Suspense } from "react";
import { ToastContainer } from "react-toastify";
import { NextUIProvider } from "@nextui-org/react";
-import DeveloperLink from "./club/Components/DeveloperLink";
-import { AuthContextProvider } from "./club/Components/Layout/AuthContextProvider";
-import { UserDataContextProvider } from "./club/Components/Layout/UserDataProvider";
const inter = Inter({ subsets: ["latin"] });
@@ -54,20 +51,16 @@ export default function RootLayout({
-
-
-
-
-
-
-
-
- {children}
-
-
-
-
-
+
+
+
+
+
+
+ {children}
+
+
+
diff --git a/src/util/ActualUser.tsx b/src/util/ActualUser.tsx
deleted file mode 100644
index 2ce1477..0000000
--- a/src/util/ActualUser.tsx
+++ /dev/null
@@ -1,26 +0,0 @@
-"use client";
-
-import { useAuthContext } from "@/app/club/Components/Layout/AuthContextProvider";
-import Error from "@/app/club/Components/Error";
-import { CgSpinner } from "react-icons/cg";
-
-const ActualUser = ({ passedUID }: { passedUID: string }) => {
- const uid = useAuthContext().userAuth?.uid;
- const loading = useAuthContext().loading;
-
- if (passedUID != uid) {
- return (
- <>
- {loading ? (
-
-
-
- ) : (
-
- )}
- >
- );
- }
-};
-
-export default ActualUser;
diff --git a/src/util/MemberCheck.tsx b/src/util/MemberCheck.tsx
deleted file mode 100644
index 47348ed..0000000
--- a/src/util/MemberCheck.tsx
+++ /dev/null
@@ -1,57 +0,0 @@
-"use client";
-
-import { useUserDataContext } from "@/app/club/Components/Layout/UserDataProvider";
-import { auth, db } from "@/config/firebase";
-import { updateDoc, doc } from "firebase/firestore";
-import { useRouter } from "next/navigation";
-import { useEffect } from "react";
-import { useAuthState } from "react-firebase-hooks/auth";
-import { toast } from "react-toastify";
-
-const getConnectToNDITC = async (ndc_id: string, email: string) => {
- const res = await fetch("/api/createaccountndc", {
- method: "POST",
- body: JSON.stringify({ ndc_id: ndc_id, email: email }),
- });
-
- return res;
-};
-
-const MemberCheck = ({
- urlMemberID,
- noDeepMemberCheck,
-}: {
- urlMemberID: string;
- noDeepMemberCheck?: boolean;
-}) => {
- const { userData, userDataLoading, dataError } = useUserDataContext();
- const [userAuth, loading, error] = useAuthState(auth);
-
- const router = useRouter();
-
- useEffect(() => {
- if (userData?.ndc_id != "none" && !noDeepMemberCheck) {
- getConnectToNDITC(userData?.ndc_id, userAuth?.email || "").catch(() => {
- toast.error("You are not a member of NDITC!");
- updateDoc(doc(db, "participants", `${userAuth?.uid}`), {
- ndc_id: "",
- }).then(() => router.push("/club"));
- });
- }
- }, []);
-
- useEffect(() => {
- if (
- urlMemberID != "none" &&
- userAuth &&
- !loading &&
- urlMemberID != userData?.ndc_id
- ) {
- router.push("/");
- }
- }, [userAuth, loading]);
-
- return ;
-};
-
-export default MemberCheck;
diff --git a/src/util/leadingzero.ts b/src/util/leadingzero.ts
new file mode 100644
index 0000000..907a40b
--- /dev/null
+++ b/src/util/leadingzero.ts
@@ -0,0 +1,16 @@
+const _L0 = (num: number, digits: number = 2): string => {
+ let str = String(num);
+ const zeros = digits - str.length;
+
+ if (zeros <= 0) {
+ return str;
+ }
+
+ for (let i = 0; i < zeros; i++) {
+ str = '0' + str;
+ }
+
+ return str;
+};
+
+export default _L0;