Skip to content

Commit 2ebcbfe

Browse files
authored
Merge pull request #104 from CoPlay-FE/feature/refactoring
♻️refactor: 반응형 및 마무리 수정 작업
2 parents 9169f13 + fd743f4 commit 2ebcbfe

13 files changed

Lines changed: 116 additions & 94 deletions

File tree

src/app/dashboard/[id]/edit/page.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@ export default function DashBoardEditPage() {
2323
<Image src="/images/back.png" alt="돌아가기" width={6} height={4} />
2424
<p className="text-14">돌아가기</p>
2525
</button>
26-
<div className="flex w-500 flex-col gap-16 p-16">
26+
27+
{/* 컨텐츠 박스: 기본 너비 500px, 화면 작으면 100% 최대 500px */}
28+
<div className="mx-auto ml-16 flex flex-col gap-16 p-16 sm:max-w-full sm:px-4">
2729
<EditInfo />
2830
<EditMember />
2931
<EditInvitation />
3032
</div>
3133

32-
{/* 삭제 버튼 영역 */}
33-
<div className="BG-white align-center Text-btn i8 ml-16 flex w-292 justify-center rounded-md px-64 py-6">
34+
{/* 삭제 버튼 영역: 기본 너비 292px, 화면 작으면 100% 최대 292px, 좌측 margin 제거 */}
35+
<div className="BG-white align-center Text-btn i8 ml-16 mt-8 flex max-w-292 justify-center rounded-md px-16 py-6">
3436
<DeleteDashboardButton dashboardId={String(id)} />
3537
</div>
3638
</div>

src/app/features/auth/hooks/useAuth.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ export function useAuth() {
2424
return {
2525
updateAuthState,
2626
logout,
27+
setUser,
2728
}
2829
}

src/app/features/dashboard/components/edit/DeleteDashboardButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export default function DeleteDashboardButton({
5858
onClick={handleDelete}
5959
// isLoading -> isPending으로 수정됨
6060
disabled={mutation.isPending}
61-
className={`Text-black my-8 rounded-8 font-semibold transition-opacity ${
61+
className={`Text-black my-8 whitespace-nowrap rounded-8 font-semibold transition-opacity ${
6262
mutation.isPending
6363
? 'cursor-not-allowed opacity-50'
6464
: 'hover:opacity-90'

src/app/features/dashboard/components/edit/EditInfo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default function EditInfo() {
1616

1717
return (
1818
<div>
19-
<div className="BG-white h-300 w-584 rounded-16 px-32 py-24">
19+
<div className="BG-white max-w-584 rounded-16 px-32 py-24">
2020
<h2 className="Text-black mb-24 text-18 font-bold">
2121
{selectedDashboard?.title || '대시보드 편집'}
2222
</h2>

src/app/features/dashboard/components/edit/EditInvitation.tsx

Lines changed: 67 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -97,85 +97,77 @@ export default function EditInvitation() {
9797
: null
9898

9999
return (
100-
<div>
101-
<div className="BG-white max-h-[360px] w-584 overflow-y-auto rounded-16 px-32 py-24">
102-
<PaginationHeader
103-
currentPage={currentPage}
104-
totalPages={totalPages}
105-
title="초대 내역"
106-
onPrev={handlePrev}
107-
onNext={handleNext}
100+
<div className="BG-white w-full max-w-584 overflow-x-auto whitespace-nowrap rounded-16 px-32 py-24">
101+
<PaginationHeader
102+
currentPage={currentPage}
103+
totalPages={totalPages}
104+
title="초대 내역"
105+
onPrev={handlePrev}
106+
onNext={handleNext}
107+
>
108+
<button
109+
onClick={() => openModal('invite')}
110+
className="BG-violet flex w-fit shrink-0 items-center gap-8 rounded-5 px-12 py-6"
108111
>
109-
<button
110-
onClick={() => openModal('invite')}
111-
className="BG-violet flex items-center gap-8 rounded-5 px-12 py-6"
112-
>
113-
<div className="relative flex size-12">
114-
<Image src="/images/invitation-white.png" fill alt="초대 버튼" />
115-
</div>
116-
<p className="text-14 text-white">초대하기</p>
117-
</button>
118-
</PaginationHeader>
119-
120-
<form>
121-
<label htmlFor="title" className="Text-black mb-8 block text-16">
122-
이메일
123-
</label>
124-
<div className="flex flex-col gap-4">
125-
{isLoading && (
126-
<p className="Text-gray py-12 text-center">로딩 중...</p>
127-
)}
128-
129-
{errorMessage && (
130-
<p className="Text-blue py-12 text-center">{errorMessage}</p>
131-
)}
132-
133-
{!isLoading && !errorMessage && currentItems.length === 0 && (
134-
<p className="Text-gray py-12 text-center">
135-
초대된 사용자가 없습니다.
136-
</p>
137-
)}
138-
139-
{!isLoading &&
140-
!errorMessage &&
141-
currentItems.map((member, index) => {
142-
const isLast = index === currentItems.length - 1
143-
return (
144-
<div
145-
key={member.id}
112+
<div className="relative flex size-12 shrink-0">
113+
<Image src="/images/invitation-white.png" fill alt="초대 버튼" />
114+
</div>
115+
<p className="text-14 text-white">초대하기</p>
116+
</button>
117+
</PaginationHeader>
118+
119+
<form className="overflow-x-auto">
120+
<label htmlFor="title" className="Text-black mb-8 block text-16">
121+
이메일
122+
</label>
123+
<div className="flex flex-col gap-4">
124+
{isLoading && (
125+
<p className="Text-gray py-12 text-center">로딩 중...</p>
126+
)}
127+
128+
{errorMessage && (
129+
<p className="Text-blue py-12 text-center">{errorMessage}</p>
130+
)}
131+
132+
{!isLoading &&
133+
!errorMessage &&
134+
currentItems.map((member, index) => {
135+
const isLast = index === currentItems.length - 1
136+
return (
137+
<div
138+
key={member.id}
139+
className={cn(
140+
'flex items-center justify-between gap-12 py-4',
141+
!isLast && 'Border-bottom',
142+
)}
143+
>
144+
<div className="flex min-w-0 items-center gap-12">
145+
<div className="flex min-w-0 flex-col">
146+
<Tooltip content={member.invitee.nickname}>
147+
<p className="Text-black max-w-[200px] cursor-help truncate text-13">
148+
{member.invitee.email}
149+
</p>
150+
</Tooltip>
151+
</div>
152+
</div>
153+
154+
<button
155+
type="button"
156+
disabled={cancelMutation.isPending}
146157
className={cn(
147-
'flex items-center justify-between py-4',
148-
!isLast && 'Border-bottom',
158+
'Text-btn Border-btn w-fit shrink-0 rounded-md px-16 py-2',
159+
cancelMutation.isPending &&
160+
'cursor-not-allowed opacity-50',
149161
)}
162+
onClick={() => cancelMutation.mutate(member.id)}
150163
>
151-
<div className="flex items-center gap-12">
152-
<div className="flex flex-col">
153-
<Tooltip content={member.invitee.nickname}>
154-
<p className="Text-black cursor-help text-13">
155-
{member.invitee.email}
156-
</p>
157-
</Tooltip>
158-
</div>
159-
</div>
160-
161-
<button
162-
type="button"
163-
disabled={cancelMutation.isPending}
164-
className={cn(
165-
'Text-btn Border-btn rounded-md px-16 py-2',
166-
cancelMutation.isPending &&
167-
'cursor-not-allowed opacity-50',
168-
)}
169-
onClick={() => cancelMutation.mutate(member.id)}
170-
>
171-
{cancelMutation.isPending ? '취소 중...' : '취소'}
172-
</button>
173-
</div>
174-
)
175-
})}
176-
</div>
177-
</form>
178-
</div>
164+
{cancelMutation.isPending ? '취소 중...' : '취소'}
165+
</button>
166+
</div>
167+
)
168+
})}
169+
</div>
170+
</form>
179171
</div>
180172
)
181173
}

src/app/features/dashboard/components/edit/EditMember.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export default function EditMember() {
6464

6565
return (
6666
<div>
67-
<div className="BG-white h-360 w-584 rounded-16 px-32 py-24">
67+
<div className="BG-white max-w-584 rounded-16 px-32 py-24">
6868
<PaginationHeader
6969
currentPage={currentPage}
7070
totalPages={totalPages}

src/app/features/dashboard/components/edit/PaginationHeader.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ export function PaginationHeader({
2121
children,
2222
}: PaginationHeaderProps) {
2323
return (
24-
<div className="mb-24 flex items-center justify-between">
24+
<div className="mb-24 flex items-center justify-between whitespace-nowrap">
2525
<h2 className="Text-black text-18 font-bold">{title}</h2>
2626

27-
<div className="flex items-center">
28-
<p className="Text-gray mr-16 text-12">
27+
<div className="flex shrink-0 items-center">
28+
<p className="Text-gray mr-16 shrink-0 text-12">
2929
{totalPages} 페이지 중 {currentPage}
3030
</p>
3131
<button onClick={onPrev} disabled={currentPage === 1}>

src/app/features/mypage/components/ProfileEditForm.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { useRouter } from 'next/navigation'
77
import { useEffect, useState } from 'react'
88
import { Controller, useForm } from 'react-hook-form'
99

10+
import { useAuthStore } from '@/app/features/auth/store/useAuthStore'
11+
1012
import { useUpdateMyProfileMutation } from '../hook/useUpdateMyProfileMutation'
1113
import { useUploadProfileImageMutation } from '../hook/useUploadProfileImageMutation'
1214
import { useUserQuery } from '../hook/useUserQurey'
@@ -41,6 +43,9 @@ export default function ProfileEditForm() {
4143
const { mutateAsync: uploadImage } = useUploadProfileImageMutation()
4244
const { mutateAsync: updateProfile } = useUpdateMyProfileMutation()
4345

46+
// Zustand 상태 갱신 함수 가져오기
47+
const setUser = useAuthStore((state) => state.setUser)
48+
4449
// 유저 정보가 비동기적으로 넘어오기 때문에 유저가 로딩된 시점에서 RHF을 초기화 하기 위함 (SSR 도입 시 변경 예정)
4550
useEffect(() => {
4651
if (user) {
@@ -69,8 +74,18 @@ export default function ProfileEditForm() {
6974
profileImageUrl: imageUrl,
7075
}
7176

72-
// 서버에 프로필 정보 수정 요청 (PUT)
73-
await updateProfile(submitData)
77+
// 서버에 프로필 수정 요청
78+
const updatedUser = await updateProfile(submitData)
79+
80+
if (!user) return // user가 없으면 갱신하지 않음
81+
82+
// zustand 상태 갱신 (전역 사용자 정보 업데이트)
83+
setUser({
84+
...user,
85+
nickname: updatedUser.nickname ?? data.nickname,
86+
profileImageUrl: updatedUser.profileImageUrl ?? imageUrl,
87+
// 필요 시 추가 필드도 넣기
88+
})
7489

7590
// 사용자에게 성공 알림 + 컴포넌트 최신화
7691
showSuccess('프로필 변경이 완료되었습니다.')

src/app/mypage/page.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ export default function Mypage() {
1111
const router = useRouter()
1212
return (
1313
<>
14-
<Header />
14+
<div className="pl-300">
15+
<Header />
16+
</div>
17+
1518
<div className="BG-gray h-full">
1619
{/* 사이드바 */}
1720
<Sidebar />

src/app/shared/components/common/UserInfo.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ export function UserInfo({ nickname, imageUrl, size = 36 }: UserInfoProps) {
2222
<div className="flex items-center gap-4">
2323
{/* Avatar에 nickname, profileImageUrl 모두 넘겨줌 */}
2424
<Avatar size={size} name={displayNickname} imageUrl={displayImage} />
25-
<span className="ml-4 text-sm font-semibold">{displayNickname}</span>
25+
<span className="ml-4 text-sm font-semibold tablet:hidden">
26+
{displayNickname}
27+
</span>
2628
</div>
2729
)
2830
}

0 commit comments

Comments
 (0)