import { React } from "react" import { useState, useEffect } from "react"; import { ProfileForm } from "./ProfileForm"; export const Profile = () => { const [Users, fetchUsers] = useState([]) const [currentuser, setcurrentuser] = useState(localStorage.getItem("graphicsbaytracker_customer")) const [currentUsertrackedcards, setcurrentUsertrackedcards] = useState([]) const [formactive, setformstate] = useState(false) useEffect( () => { fetch("http://localhost:8088/trackedCards?_expand=cardData") .then(res => res.json()) .then(setcurrentUsertrackedcards) }, []) useEffect( () => { fetch("http://localhost:8088/users") .then(res => res.json()) .then(fetchUsers) }, []) // useEffect = ( // () = { // }, [currentUsertrackedcards] // ) const showprofileinfo = () => { const founduser = Users.find((user) => user.id === parseInt(currentuser)) return (

{founduser?.name}
{founduser?.email}

) } const toggleForm = () => { setformstate(true) formactive === true ? : } useEffect(() => { Users.filter( ({ id, name, email }) => { if (Users.id === parseInt(currentuser)) return ( ) } ) } ) const removetrackedcard = (gpudataobj) => { const deletefetchfortrackedcards = { method: "DELETE", } return fetch(`http://localhost:8088/trackedCards/${gpudataobj.id}`, deletefetchfortrackedcards) .then(() => { fetch("http://localhost:8088/trackedCards?_expand=cardData") .then(res => res.json()) .then(setcurrentUsertrackedcards) }) } return( <>

My Tracked Cards

{showprofileinfo()}

< tr > { currentUsertrackedcards.map( gpudataobj => { return ( <> { gpudataobj.cardData.oem } { gpudataobj.cardData.brand } { gpudataobj.cardData.model } { gpudataobj.cardData.price.toLocaleString('en-US', { style: 'currency', currency: 'USD' }) } { } ) } ) }
Brand Model Price
) }