From 1f2c7590d0de78ea36b11014fb45b83a6612d151 Mon Sep 17 00:00:00 2001 From: Vishal Ekka Date: Wed, 22 May 2024 23:40:30 +0530 Subject: [PATCH] Profile responsiveness done --- src/app/profile/[profile].jsx | 384 ++++++++++++++++++---------------- 1 file changed, 202 insertions(+), 182 deletions(-) diff --git a/src/app/profile/[profile].jsx b/src/app/profile/[profile].jsx index bc5f983..378bd35 100644 --- a/src/app/profile/[profile].jsx +++ b/src/app/profile/[profile].jsx @@ -1,182 +1,202 @@ -import { useEffect, useState } from "react"; -import { - Avatar, - Chip, - CircularProgress, - Grid, - IconButton, - Stack, - Typography, -} from "@mui/material"; -import LinkedInIcon from "@mui/icons-material/LinkedIn"; -import TwitterIcon from "@mui/icons-material/Twitter"; -import { useParams } from "react-router-dom"; -import AnimatePage from "../../ui/AnimatePage"; -import baseAPIMethods from "../../lib/axios/base"; -import useUserProfile from "./store/useUserProfile"; -// import useLoading from "../../shared/store/useLoading"; - -export default function UserProfile() { - const { username } = useParams(); - - const [loading, setLoading] = useState(false); - const [user, setUser] = useUserProfile((state) => [ - state.user, - state.setUser, - ]); - - useEffect(() => { - if (username) { - setLoading(true); - const getUserProfile = async () => { - return baseAPIMethods.user.userProfile(username); - }; - getUserProfile().then((res) => { - setUser({ - username: res.data.username, - name: res.data.name, - avatar: res.data.avatar, - graduationYear: res.data.graduation_year, - linkedin_handle: res.data.linkedin_url, - twitter_handle: res.data.twitter_username, - }); - // console.log(user); - }); - } - }, [setUser, username]); - - return ( - - - - - - {user.name} - - - {user.username} - - - {user.graduationYear} - - - - Skills - - - - - - - - - - - - - - - - - - - - - - - - - - - { user?.twitter_handle && user.twitter_handle !== "" && - - - - - - } - - - - - - - {loading && ( - - )} - setLoading((loading) => !loading)} - /> - - - - - - - ); -} +import { useEffect, useState } from "react"; +import { + Avatar, + Chip, + CircularProgress, + Grid, + IconButton, + Stack, + Typography, +} from "@mui/material"; +import LinkedInIcon from "@mui/icons-material/LinkedIn"; +import TwitterIcon from "@mui/icons-material/Twitter"; +import { useParams } from "react-router-dom"; +import AnimatePage from "../../ui/AnimatePage"; +import baseAPIMethods from "../../lib/axios/base"; +import useUserProfile from "./store/useUserProfile"; +// import useLoading from "../../shared/store/useLoading"; + +export default function UserProfile() { + const { username } = useParams(); + + const [loading, setLoading] = useState(false); + const [user, setUser] = useUserProfile((state) => [ + state.user, + state.setUser, + ]); + + useEffect(() => { + if (username) { + setLoading(true); + const getUserProfile = async () => { + return baseAPIMethods.user.userProfile(username); + }; + getUserProfile().then((res) => { + setUser({ + username: res.data.username, + name: res.data.name, + avatar: res.data.avatar, + graduationYear: res.data.graduation_year, + linkedin_handle: res.data.linkedin_url, + twitter_handle: res.data.twitter_username, + }); + // console.log(user); + }); + } + }, [setUser, username]); + + return ( + + + + + + {user.name} + + + + {user.username} + + {user.graduationYear} + + + + Skills + + + + + + + + + + + + + + + + + + + + + + + + + + + {user?.twitter_handle && user.twitter_handle !== "" && ( + + + + + + )} + + + + + + + {loading && ( + + )} + setLoading((loading) => !loading)} + /> + + + + + + + ); +}