From 1d9030731fdd296333e1b731a726273248ccc5d8 Mon Sep 17 00:00:00 2001 From: tugn205 <140466876+tugn205@users.noreply.github.com> Date: Sat, 21 Sep 2024 12:59:05 +1200 Subject: [PATCH 1/3] Fix problems for unused/wrong code --- .../Dashboard/DashboardCommunity/CommunityGallery.tsx | 2 +- .../Dashboard/DashboardCommunity/CommunityGalleryWhole.tsx | 2 +- .../Dashboard/DashboardCommunity/DashboardCommunity.tsx | 2 +- web/src/components/TestComponent.tsx | 2 +- web/src/pages/Dashboard.tsx | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/web/src/components/Dashboard/DashboardCommunity/CommunityGallery.tsx b/web/src/components/Dashboard/DashboardCommunity/CommunityGallery.tsx index 70ac3f9..16dbda4 100644 --- a/web/src/components/Dashboard/DashboardCommunity/CommunityGallery.tsx +++ b/web/src/components/Dashboard/DashboardCommunity/CommunityGallery.tsx @@ -1,6 +1,6 @@ import axios from 'axios'; import { useState, useEffect } from 'react'; -import CommunityGalleryCard from '../dashboardCommunity/CommunityGalleryCard'; +import CommunityGalleryCard from '../DashboardCommunity/CommunityGalleryCard'; interface GalleryData { title: string; diff --git a/web/src/components/Dashboard/DashboardCommunity/CommunityGalleryWhole.tsx b/web/src/components/Dashboard/DashboardCommunity/CommunityGalleryWhole.tsx index d88ffd4..bbf87d3 100644 --- a/web/src/components/Dashboard/DashboardCommunity/CommunityGalleryWhole.tsx +++ b/web/src/components/Dashboard/DashboardCommunity/CommunityGalleryWhole.tsx @@ -4,7 +4,7 @@ import axios from "axios"; import { useState, useEffect } from "react"; -import CommunityGallery from "../dashboardCommunity/CommunityGallery"; +import CommunityGallery from "../DashboardCommunity/CommunityGallery"; interface EventData { title: string; diff --git a/web/src/components/Dashboard/DashboardCommunity/DashboardCommunity.tsx b/web/src/components/Dashboard/DashboardCommunity/DashboardCommunity.tsx index 3896876..6e19bd9 100644 --- a/web/src/components/Dashboard/DashboardCommunity/DashboardCommunity.tsx +++ b/web/src/components/Dashboard/DashboardCommunity/DashboardCommunity.tsx @@ -1,4 +1,4 @@ -import CommunityGalleryWhole from '@components/Dashboard/dashboardCommunity/CommunityGalleryWhole'; +import CommunityGalleryWhole from '@components/Dashboard/DashboardCommunity/CommunityGalleryWhole'; import Leaderboard from '../Leaderboard'; function DashboardCommunity() { diff --git a/web/src/components/TestComponent.tsx b/web/src/components/TestComponent.tsx index 0b5a7a0..bb3da4d 100644 --- a/web/src/components/TestComponent.tsx +++ b/web/src/components/TestComponent.tsx @@ -1,4 +1,4 @@ -import EventsScrollContainer from "./Dashboard/dashboardDiscover/EventsScrollContainer" +import EventsScrollContainer from "./Dashboard/DashboardDiscover/EventsScrollContainer" export default function TestingComponent() { return (
{/*try add className="dashboard" inside the div tag */} diff --git a/web/src/pages/Dashboard.tsx b/web/src/pages/Dashboard.tsx index 9034582..7623ebf 100644 --- a/web/src/pages/Dashboard.tsx +++ b/web/src/pages/Dashboard.tsx @@ -1,9 +1,9 @@ import { useState } from "react"; -import DashboardCommunity from "../components/Dashboard/dashboardCommunity/DashboardCommunity"; +import DashboardCommunity from "../components/Dashboard/DashboardCommunity/DashboardCommunity"; import DashboardProfile from "@components/Dashboard/dashboardProfile/DashboardProfile"; import DashboardDashboard from "@components/Dashboard/dashboardDashboard/DashboardDashboard"; -import DashboardDiscover from "@components/Dashboard/dashboardDiscover/DashboardDiscover"; -import SearchBar from "@components/Dashboard/dashboardCommunity/SearchBar"; +import DashboardDiscover from "@components/Dashboard/DashboardDiscover/DashboardDiscover"; +import SearchBar from "@components/Dashboard/DashboardCommunity/SearchBar"; import ProfileEditModalContextProvider from "../context/ProfileEditModalContextProvider"; import DashboardHeader from "@components/Dashboard/DashboardHeader"; import SideBar from "@components/Dashboard/SideBar"; From 706654a9d1ee7928e8926012f25e1543f8579f44 Mon Sep 17 00:00:00 2001 From: tugn205 <140466876+tugn205@users.noreply.github.com> Date: Mon, 30 Sep 2024 13:33:34 +1300 Subject: [PATCH 2/3] Update --- .../Dashboard/DashboardDiscover/DashboardDiscover.tsx | 4 ++-- .../Dashboard/DashboardDiscover/EventsScrollContainer.tsx | 2 +- web/src/components/TestComponent.tsx | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/web/src/components/Dashboard/DashboardDiscover/DashboardDiscover.tsx b/web/src/components/Dashboard/DashboardDiscover/DashboardDiscover.tsx index f3f82c9..e06c190 100644 --- a/web/src/components/Dashboard/DashboardDiscover/DashboardDiscover.tsx +++ b/web/src/components/Dashboard/DashboardDiscover/DashboardDiscover.tsx @@ -1,7 +1,7 @@ import { useEffect, useState } from "react"; -import EventsScrollContainer from "../dashboardDiscover/EventsScrollContainer"; +import EventsScrollContainer from "../DashboardDiscover/EventsScrollContainer"; import axios from "axios"; -import EventDetails from "../dashboardDiscover/EventDetails"; +import EventDetails from "../DashboardDiscover/EventDetails"; type Event = { event_title: string; diff --git a/web/src/components/Dashboard/DashboardDiscover/EventsScrollContainer.tsx b/web/src/components/Dashboard/DashboardDiscover/EventsScrollContainer.tsx index 1815d1d..4dfb958 100644 --- a/web/src/components/Dashboard/DashboardDiscover/EventsScrollContainer.tsx +++ b/web/src/components/Dashboard/DashboardDiscover/EventsScrollContainer.tsx @@ -1,5 +1,5 @@ import { Dispatch, SetStateAction } from "react"; -import Event from "../dashboardDiscover/Event.tsx" +import Event from "../DashboardDiscover/Event.tsx" type Event = { event_title: string; diff --git a/web/src/components/TestComponent.tsx b/web/src/components/TestComponent.tsx index f7c36d3..64c36e3 100644 --- a/web/src/components/TestComponent.tsx +++ b/web/src/components/TestComponent.tsx @@ -1,4 +1,4 @@ -import EventsScrollContainer from "../components/Dashboard/dashboardDiscover/EventsScrollContainer" +import EventsScrollContainer from "./Dashboard/DashboardDiscover/EventsScrollContainer" export default function TestingComponent() { return (
From ed875075fe5481b2e70d8fa414bfe233b93731c6 Mon Sep 17 00:00:00 2001 From: tugn205 <140466876+tugn205@users.noreply.github.com> Date: Thu, 3 Oct 2024 09:56:31 +1300 Subject: [PATCH 3/3] Link backend to edit profile modal --- .../dashboardProfile/ProfileEditModal.tsx | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/web/src/components/Dashboard/dashboardProfile/ProfileEditModal.tsx b/web/src/components/Dashboard/dashboardProfile/ProfileEditModal.tsx index eb41224..805ff09 100644 --- a/web/src/components/Dashboard/dashboardProfile/ProfileEditModal.tsx +++ b/web/src/components/Dashboard/dashboardProfile/ProfileEditModal.tsx @@ -1,13 +1,15 @@ -import { useContext, useState } from 'react'; +import { useContext, useState, useEffect } from 'react'; import ProfileEditModalContext from '../../../context/ProfileEditModalContext'; import ProfileEditModalSideBarTab from '../dashboardProfile/ProfileEditModalSideBarTab'; import { AiFillCamera } from "react-icons/ai"; +import AuthenticationContext from "../../../context/AuthenticationContext"; const ProfileEditModal = () => { //TEMPORARY PROFILE IMAGE const profileImgLink = '/assets/EventHighlights/Events/RelayForLife/imgB.png' // ###################### - + const authContext = useContext(AuthenticationContext); + const { isUserLoggedIn, firestoreUserDetails } = authContext as unknown as {isUserLoggedIn: boolean, firestoreUserDetails: any}; const { showModal, setShowModal } = useContext(ProfileEditModalContext); const baseBackgroundStyle = 'fixed z-[500] top-0 left-0 w-full h-full bg-black bg-opacity-50 flex justify-center items-center transition-all duration-200 '; const [page1, setPage1] = useState(true); @@ -95,6 +97,32 @@ const ProfileEditModal = () => { e.preventDefault(); } + useEffect(() => { + console.log("User is logged in: ", isUserLoggedIn); + if (!isUserLoggedIn) { + // redirect to login page + // window.location.href = "/login"; + console.log("User is not logged in"); + } + + if (firestoreUserDetails) { + setFirstName(firestoreUserDetails.firstName); + setLastName(firestoreUserDetails.lastName); + setEmail(firestoreUserDetails.email); + setMobile(firestoreUserDetails.mobile); + setBirthdate(firestoreUserDetails.birthdate); + setUpi(firestoreUserDetails.upi); + setGender(firestoreUserDetails.gender); + setYearLevel(firestoreUserDetails.yearLevel); + setDietaryRequirements(firestoreUserDetails.dietaryRequirements || []); + setDriversLicense(firestoreUserDetails.driversLicense); + setEmergencyContactFirstName(firestoreUserDetails.emergencyContactFirstName); + setEmergencyContactLastName(firestoreUserDetails.emergencyContactLastName); + setEmergencyContactRelationship(firestoreUserDetails.emergencyContactRelationship); + setEmergencyContactMobile(firestoreUserDetails.emergencyContactMobile); + } +}, []); + return (