Skip to content

Commit

Permalink
refactoring: 다른 사람 프로필 Global bar 사진 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
YongChanCho committed Nov 20, 2024
1 parent 598f096 commit d58ceff
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
17 changes: 16 additions & 1 deletion src/components/global/GlobalNavigationBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { ReactComponent as User } from '../../assets/user.svg';
import { ReactComponent as Login } from '../../assets/btn_login.svg';
import { ReactComponent as Logout } from '../../assets/btn_logout.svg';
import useLogOutMutation from '../../apis/auth/useLogOutMutation';
import useUserViewState from '../../stores/userViewState';

import instance from '../../apis/instance';

Expand All @@ -29,6 +30,7 @@ const GlobalNavigationBar = (props: { children?: React.ReactNode }) => {
useRegisterStore();

const logOutMutation = useLogOutMutation(prevUrl);
const { viewUserData } = useUserViewState();
const [userData, setUserData] = useState({
nickname: '',
profileId: '',
Expand Down Expand Up @@ -120,14 +122,27 @@ const GlobalNavigationBar = (props: { children?: React.ReactNode }) => {
<div
className={`${styles.iconContainer} ${isUserpageActive ? styles.iconContainer_on : styles.iconContainer_off}`}
>
{userData.imgUrl ? (
{/* {userData.imgUrl ? (
<img
src={userData.imgUrl}
alt="User Profile"
className={styles.iconContainer}
/>
) : (
<User />
)} */}
{ viewUserData.nickname != '' ? (
<img
src={viewUserData.imgUrl}
alt="User Profile"
className={styles.iconContainer}
/>
) : (
<img
src={userData.imgUrl}
alt="User Profile"
className={styles.iconContainer}
/>
)}
</div>
</Link>
Expand Down
4 changes: 3 additions & 1 deletion src/components/userProfile/OtherUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ReactComponent as CreatMap } from '../../assets/btn_map_create.svg';

import useRegisterStore from '../../stores/registerStore';
import { RegisterStatus } from '../../types/enum/RegisterStatus';
import useUserViewState from '../../stores/userViewState';

import instance from '../../apis/instance';
import NewMap from './getNewMap/NewMap';
Expand All @@ -29,6 +30,7 @@ const GetUser = (props: { children?: React.ReactNode }) => {
const [isDropdownOpen, setIsDropdownOpen] = useState<boolean>(false);
const [mapData, setMapData] = useState([]);
const [searchInput,setSearchInput] = useState<string>('');
const { viewUserData } = useUserViewState();
const [userData, setUserData] = useState({
nickname: '',
profileId: '',
Expand Down Expand Up @@ -224,7 +226,7 @@ const GetUser = (props: { children?: React.ReactNode }) => {
<div className={styles.mapLocation}>{map.region}</div>
</div>
<img
src={userData.imgUrl}
src={viewUserData.imgUrl}
alt="userProfileImage"
className={styles.profileImage}
/>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/UserProfile/UserProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ const UserProfile = () => {
<div className={styles.container}>
<GlobalNavigationBar />
{registerStatus === RegisterStatus.LOG_IN ? (
viewUserData ? <OtherUserInfobar /> : <GetUserInfobar />
viewUserData.nickname!='' ? <OtherUserInfobar /> : <GetUserInfobar />
): (
<EmtpyUserInfobar />
)}

{registerStatus === RegisterStatus.LOG_IN ? (
viewUserData ? <OtherUser /> : <GetUser />
viewUserData.nickname!='' ? <OtherUser /> : <GetUser />
): (
<EmptyUser />
)}
Expand Down

0 comments on commit d58ceff

Please sign in to comment.