Skip to content

Commit a0d5781

Browse files
committed
fix: 차단 모달 닉네임 추가
1 parent 138510a commit a0d5781

File tree

4 files changed

+26
-5
lines changed

4 files changed

+26
-5
lines changed

dev-dist/sw.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ define(['./workbox-54d0af47'], (function (workbox) { 'use strict';
7979
*/
8080
workbox.precacheAndRoute([{
8181
"url": "index.html",
82-
"revision": "0.1kau0siulq"
82+
"revision": "0.koc340e0a3g"
8383
}], {});
8484
workbox.cleanupOutdatedCaches();
8585
workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), {

src/layouts/header/HeaderWithBack.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { addBlockList } from '@/apis/blockList';
22
import MoreOptionsSelect from '@/components/MoreOptionsSelect';
33
import HedaerLayout from '@/layouts/header/HedaerLayout';
44
import { useModalStore } from '@/store/modalStore';
5-
import { useSheetStore } from '@/store/sheetStore';
5+
import { useUserStore } from '@/store/userStore';
66
import backIcon from '@assets/icons/back-icon.svg';
77
import { useNavigate, useParams } from 'react-router';
88

@@ -17,16 +17,17 @@ function HeaderWithBack({ showMoreOptions = false, text }: HeaderWithBackProps)
1717
const param = useParams();
1818

1919
const { openModal, closeModal } = useModalStore();
20-
const { currentRecord } = useSheetStore();
20+
const { userData } = useUserStore(); // 차단할 유저 정보
21+
2122
// 임시함수
2223
const handleBlockUser = async () => {
23-
if (!param.userId || !currentRecord) {
24+
if (!param.userId) {
2425
console.log('차단 실패');
2526
return;
2627
}
2728

2829
openModal({
29-
title: `${currentRecord?.nickName}님을 차단할까요?`,
30+
title: `${userData?.nickname} 차단할까요?`,
3031
message: '차단된 사용자는 더이상 피드에 나타나지 않습니다',
3132
onConfirm: async () => {
3233
if (param.userId) {

src/pages/userprofile/UserProfile.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { useEffect, useState } from 'react';
99
import { useNavigate, useParams } from 'react-router';
1010
import { useInView } from 'react-intersection-observer';
1111
import EmotionRecordCardList from '@/pages/userprofile/components/EmotionRecordCardList';
12+
import { useUserStore } from '@/store/userStore';
1213

1314
// 마이페이지 / 유저페이지 동시에 사용
1415
function UserProfile({ isMyPage }: { isMyPage: boolean }) {
@@ -18,6 +19,7 @@ function UserProfile({ isMyPage }: { isMyPage: boolean }) {
1819
const { openSheet, closeSheet } = useSheetStore(); // 시트
1920
const { openModal, closeModal } = useModalStore(); // 모달
2021
const queryClient = useQueryClient(); // useMutation 사용
22+
const { setUserData } = useUserStore(); // 유저 정보 전역 저장
2123

2224
const { ref, inView } = useInView();
2325

@@ -27,6 +29,13 @@ function UserProfile({ isMyPage }: { isMyPage: boolean }) {
2729
queryFn: () => (isMyPage ? getMyProfile() : getUserProfile(userId as string)),
2830
});
2931

32+
// 유저 정보 전역 저장
33+
useEffect(() => {
34+
if (userData?.data) {
35+
setUserData(userData.data);
36+
}
37+
}, [userData, setUserData]);
38+
3039
const {
3140
data: emotionRecords,
3241
fetchNextPage,

src/store/userStore.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { create } from 'zustand';
2+
3+
interface UserState {
4+
userData: UserInfo | null;
5+
setUserData: (userData: UserInfo | null) => void;
6+
}
7+
8+
export const useUserStore = create<UserState>((set) => ({
9+
userData: null,
10+
setUserData: (userData) => set({ userData }),
11+
}));

0 commit comments

Comments
 (0)