Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion project2-front/src/page/ProfilePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ import { FollowerListProvider } from "../component/Followers/Context/FollowerLis
import {usePost} from "../component/Post/Context/UsePost.jsx";
import NoPostHereComponent from "../component/UserProfile/NoPostHereComponent.jsx";
import {HorizontalRule} from "@mui/icons-material";
import {useAuth} from "../util/auth/UseAuth.jsx";

const ProfilePage = () => {
const location = useLocation();
const [userData, setUserData] = useState(null);
const { username } = useParams();
const [key, setKey] = useState(0);
const { listPostData } = usePost();
const { isAuthenticated } = useAuth();

const getUser = async (user) => {
try {
Expand All @@ -32,6 +34,14 @@ const ProfilePage = () => {
}
};

const handleButtonDisplay = () => {
if (isAuthenticated) {
return <ProfileButton update={() => setKey(key + 1)} user={userData} />
} else {
return <br/>
}
}

useEffect(() => {
if (location.state?.userObj) {
setUserData(location.state?.userObj);
Expand Down Expand Up @@ -65,7 +75,7 @@ const ProfilePage = () => {
}}
>
{userData && (
<ProfileButton update={() => setKey(key + 1)} user={userData} />
handleButtonDisplay()
)}
{userData && (
<ProfileInformationPanel key={key} user={userData} />
Expand Down
Loading