diff --git a/src/App.js b/src/App.js index 1346ce2..2135a95 100644 --- a/src/App.js +++ b/src/App.js @@ -13,6 +13,7 @@ import Tasks from './pages/Tasks'; import RASummary from './pages/RASummary'; import PersonalSummary from './pages/PersonalSummary'; import ProjectDocuments from './pages/ProjectDocuments'; +import BioSummary from './pages/BioSummary'; function App() { const theme = extendTheme({ @@ -38,6 +39,7 @@ function App() { }/> }/> } /> + } /> diff --git a/src/components/MembersGrid.jsx b/src/components/MembersGrid.jsx index 0687a3a..feafdb4 100644 --- a/src/components/MembersGrid.jsx +++ b/src/components/MembersGrid.jsx @@ -1,15 +1,20 @@ -import React from "react"; +import React, {useEffect, useState} from "react"; import { Button } from "@chakra-ui/react"; +import {useNavigate} from "react-router-dom"; +import { supabase } from "../config/supabase"; +import { useSession } from "@supabase/auth-helpers-react"; + const membersGrid = [ { - name: "Marie Sharp", + name: "Test User 2", role: "Designer", imageUrl: "https://img.freepik.com/free-vector/cute-cool-boy-dabbing-pose-cartoon-vector-icon-illustration-people-fashion-icon-concept-isolated_138676-5680.jpg?t=st=1724332220~exp=1724335820~hmac=bc603da56e53ea1ab04b26d87afa62513c5d0bf94d014f37741598a1370b8564&w=1060", url: "https://www.google.com", }, { + id:"48fd95db-ba9c-4f14-8b68-a89265e0ecff", name: "Marie Sharp", role: "Developer", imageUrl: @@ -102,18 +107,75 @@ const styles = { visit: { margin: "10px", }, -}; +} + + + +const MembersGrid = (members) => { + // + // members must include {name, id, role, imageUrl} + + const {session} = useSession(); + const [username, setUsername] = useState( + localStorage.getItem("username") ? localStorage.getItem("username") : "" + ); + const [userType, setUserType] = useState( + localStorage.getItem("usertype") ? localStorage.getItem("usertype") : "" + ); + + + // create member state. (useState) + useEffect(() => { + console.log(username, userType) + // get member info from database + // save member info in member state. + }, []); + const navigate = useNavigate(); + + // async function getMemberUsername(member) { + // if (session) { + // const {data: Users, error} = await supabase + // .from("Users") + // .select("*") + // .eq("user_", member.name); + // } + // } + + const handleClick = async (member) => { + // 1. get user info + // 2. compare member + // 3.if not current member --> route new page + // 4.if yes, check user_type, + // 5.if admin, route-->personal summary + // 6.if not, route-->personal summary + // const user = session.user; + if (userType === true){ + navigate("/personal-summary") + }else{ + // @TODO: how to get member's username + // const targetMember = await getMemberUsername(member); + // if( targetMember.username === username){ + if (member.name === username){ + navigate("/personal-summary") + + }else{ + navigate(`/bio-summary?username=${member.name}&id=${member.id}`) + } + } + + console.log(session) -const MembersGrid = () => { - const handleClick = (url) => { - const newWindow = window.open(url, "_blank"); - if (newWindow) newWindow.opener = null; + // navigate("/bio-summary") + // const newWindow = window.open(url, "_blank"); + // if (newWindow) newWindow.opener = null; }; return (

Project Members

{membersGrid.map((member, index) => ( + // {members.map((member, index) => ( + // replace dom to component(org card, project card)
{member.name}
@@ -122,7 +184,7 @@ const MembersGrid = () => {