Skip to content

Commit

Permalink
Merge pull request #298 from UoaWDCC/VOL-253/Link-backend-to-edit-pro…
Browse files Browse the repository at this point in the history
…file-modal

Vol 253/link backend to edit profile modal
  • Loading branch information
jerry2005hn authored Oct 8, 2024
2 parents 8bf922e + c4b7fb7 commit 56f4e44
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Dispatch, SetStateAction } from "react";
import Event from "../DashboardDiscover/Event.tsx";


type Event = {
event_title: string;
description: string;
Expand Down
32 changes: 30 additions & 2 deletions web/src/components/Dashboard/dashboardProfile/ProfileEditModal.tsx
Original file line number Diff line number Diff line change
@@ -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);
Expand Down Expand Up @@ -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 (
<div
id='modalBackground'
Expand Down

0 comments on commit 56f4e44

Please sign in to comment.