Skip to content

Commit aa0a642

Browse files
authored
Merge pull request #81 from SWMTheFirstTake/dev
빌드 안 되던 거 수정
2 parents 8cbedd1 + fe925dd commit aa0a642

File tree

12 files changed

+88
-89
lines changed

12 files changed

+88
-89
lines changed

app/chat/[roomId]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default function ChatRoomPage({ params }: ChatRoomPageProps) {
3434
if (tempMessage?.roomId != roomId || !tempMessage?.userMessage) return;
3535
mutate({ inputValue: tempMessage.userMessage });
3636
setTempMessage(null);
37-
}, [roomId]);
37+
}, [roomId, mutate, setTempMessage, tempMessage?.roomId, tempMessage?.userMessage]);
3838

3939
// lg 이상일 때 panel이 'chat'이면 자동으로 'closet'으로 전환
4040
useEffect(() => {

src/components/auth/AuthJotaiInitializer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default function AuthJotaiInitializer({ initialUser }: AuthJotaiInitializ
3333
};
3434

3535
initialize();
36-
}, [initialUser]);
36+
}, [initialUser, setUser]);
3737

3838
return null;
3939
}

src/components/chat/message/ChatArea.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default function ChatArea() {
5353
// 첫 마운트 시에 대화 내용 불러오기
5454
useEffect(() => {
5555
loadMessages();
56-
}, [roomId]);
56+
}, [roomId, loadMessages]);
5757

5858
// 메시지가 변경될 때마다 그룹 업데이트
5959
useEffect(() => {

src/components/chat/modal/CodinationModal.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,13 @@ export default function CodinationModal({ isOpen, onClose }: CodinationModalProp
8989
key={cloth.id}
9090
className="flex items-center space-x-2 px-2 py-1 bg-blue-100 dark:bg-blue-800/30 rounded text-sm"
9191
>
92-
<img src={cloth.url} alt={cloth.name} className="w-6 h-6 object-cover rounded" />
92+
<Image
93+
src={cloth.url}
94+
alt={cloth.name}
95+
width={300}
96+
height={300}
97+
className="w-6 h-6 object-cover rounded"
98+
/>
9399
<span className="text-blue-800 dark:text-blue-200 text-xs truncate max-w-20">{cloth.name}</span>
94100
</div>
95101
))}

src/components/chat/settings/ModelImageUpload.tsx

Lines changed: 50 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -7,62 +7,66 @@ import { Button } from '@/components/ui/button';
77
import { Camera, X, Loader2 } from 'lucide-react';
88
import { saveUserProfile } from '@/lib/indexedDB';
99
import { postChatUpload } from '@/api/chatAPI';
10+
import Image from 'next/image';
1011

1112
export default function ModelImageUpload() {
1213
const [user, setUser] = useAtom(userAtom);
1314
const [isLoading, setIsLoading] = useState(false);
1415
const [previewImage, setPreviewImage] = useState<string | null>(null);
1516
const fileInputRef = useRef<HTMLInputElement>(null);
1617

17-
const handleImageUpload = useCallback(async (event: React.ChangeEvent<HTMLInputElement>) => {
18-
const file = event.target.files?.[0];
18+
const handleImageUpload = useCallback(
19+
async (event: React.ChangeEvent<HTMLInputElement>) => {
20+
const file = event.target.files?.[0];
1921

20-
if (file && user) {
21-
setIsLoading(true);
22+
if (file && user) {
23+
setIsLoading(true);
2224

23-
// 파일 크기 검증 (5MB 제한)
24-
if (file.size > 5 * 1024 * 1024) {
25-
alert('파일 크기는 5MB 이하여야 합니다.');
26-
setIsLoading(false);
27-
return;
28-
}
29-
30-
// 파일 타입 검증
31-
if (!file.type.startsWith('image/')) {
32-
alert('이미지 파일만 업로드 가능합니다.');
33-
setIsLoading(false);
34-
return;
35-
}
36-
37-
try {
38-
const formData = new FormData();
39-
formData.append('file', file);
25+
// 파일 크기 검증 (5MB 제한)
26+
if (file.size > 5 * 1024 * 1024) {
27+
alert('파일 크기는 5MB 이하여야 합니다.');
28+
setIsLoading(false);
29+
return;
30+
}
4031

41-
const response = await postChatUpload(formData);
42-
if (response.status === 'fail') {
43-
console.error('사진 업로드 중 에러');
32+
// 파일 타입 검증
33+
if (!file.type.startsWith('image/')) {
34+
alert('이미지 파일만 업로드 가능합니다.');
4435
setIsLoading(false);
4536
return;
4637
}
4738

48-
const result = response.data;
49-
setPreviewImage(result);
50-
51-
const newProfile: User = {
52-
...user,
53-
modelImage: result,
54-
};
55-
56-
setUser(newProfile);
57-
await saveUserProfile(newProfile);
58-
} catch (error) {
59-
console.error('이미지 업로드 실패:', error);
60-
alert('이미지 업로드에 실패했습니다.');
61-
} finally {
62-
setIsLoading(false);
39+
try {
40+
const formData = new FormData();
41+
formData.append('file', file);
42+
43+
const response = await postChatUpload(formData);
44+
if (response.status === 'fail') {
45+
console.error('사진 업로드 중 에러');
46+
setIsLoading(false);
47+
return;
48+
}
49+
50+
const result = response.data;
51+
setPreviewImage(result);
52+
53+
const newProfile: User = {
54+
...user,
55+
modelImage: result,
56+
};
57+
58+
setUser(newProfile);
59+
await saveUserProfile(newProfile);
60+
} catch (error) {
61+
console.error('이미지 업로드 실패:', error);
62+
alert('이미지 업로드에 실패했습니다.');
63+
} finally {
64+
setIsLoading(false);
65+
}
6366
}
64-
}
65-
}, [user, setUser]);
67+
},
68+
[user, setUser],
69+
);
6670

6771
const handleRemoveImage = useCallback(async () => {
6872
if (user) {
@@ -107,9 +111,11 @@ export default function ModelImageUpload() {
107111
{!isLoading && (user?.modelImage || previewImage) && (
108112
<div className="space-y-3">
109113
<div className="relative group">
110-
<img
114+
<Image
111115
src={previewImage || user?.modelImage || '/model_image.jpg'}
112116
alt="현재 설정된 모델 이미지"
117+
width={300}
118+
height={300}
113119
className="w-full h-48 object-cover rounded-lg border border-gray-200 shadow-sm"
114120
/>
115121
{/* 오버레이 버튼들 */}
@@ -132,13 +138,7 @@ export default function ModelImageUpload() {
132138
</div>
133139
</div>
134140
{/* 숨겨진 파일 입력 */}
135-
<input
136-
ref={fileInputRef}
137-
type="file"
138-
accept="image/*"
139-
onChange={handleImageUpload}
140-
className="hidden"
141-
/>
141+
<input ref={fileInputRef} type="file" accept="image/*" onChange={handleImageUpload} className="hidden" />
142142
</div>
143143
<div className="text-center">
144144
<p className="text-sm text-green-600 font-medium">✅ 모델 이미지가 설정되었습니다</p>
@@ -153,13 +153,7 @@ export default function ModelImageUpload() {
153153
<Camera className="h-12 w-12 text-gray-400 mx-auto mb-4" />
154154
<p className="text-gray-500 mb-4">가상 피팅에 사용할 모델 이미지를 업로드하세요</p>
155155
<p className="text-xs text-gray-400 mb-4">JPG, PNG, GIF 파일 (최대 5MB)</p>
156-
<input
157-
ref={fileInputRef}
158-
type="file"
159-
accept="image/*"
160-
onChange={handleImageUpload}
161-
className="hidden"
162-
/>
156+
<input ref={fileInputRef} type="file" accept="image/*" onChange={handleImageUpload} className="hidden" />
163157
<Button
164158
onClick={handleFileSelect}
165159
variant="outline"

src/hooks/useChatHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function useChatHandlers(): {
4646

4747
setMessages((prev) => [...prev, userMessage]);
4848
},
49-
[roomId],
49+
[roomId, resetAtomState, setMessages, user?.userId, user?.username],
5050
);
5151

5252
const handleExampleSelect = useCallback(

src/hooks/useChatStream.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export const useChatStream = () => {
157157
const userMessage: Message = {
158158
id: Date.now().toString(),
159159
content: inputValue,
160-
user: { userId: 'asdf', username: 'mindul', modelImage: null, darkMode: false },
160+
user: { userId: 'asdf', username: 'mindul', modelImage: null },
161161
agent: null,
162162
message_type: 'USER',
163163
products: products ? [products] : [],

src/hooks/useCodinationSave.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export function useCodinationSave() {
118118
const key = makeProductsKey(products);
119119
setLocallySavedKeys((prev) => new Set(prev).add(key));
120120
},
121-
[codinations, addCodination, setActiveCodination, setPanel, closet, addClothesToCloset, makeProductsKey],
121+
[codinations, addCodination, setActiveCodination, setPanel, addClothesToCloset, makeProductsKey],
122122
);
123123

124124
const isSaved = useCallback(
@@ -134,3 +134,4 @@ export function useCodinationSave() {
134134
isSaved,
135135
};
136136
}
137+

src/hooks/useFitting.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export const useFitting = (codinationId?: string) => {
140140
};
141141

142142
initializeFittingStatus();
143-
}, [isLoading, loadFittingStatusFromStorage, setFittingStatus, shouldUseStorage]);
143+
}, [isLoading, loadFittingStatusFromStorage, setFittingStatus, shouldUseStorage, codinationId]);
144144

145145
useEffect(() => {
146146
if (fittingStatus.status !== 'idle' && shouldUseStorage) {

src/hooks/useToast.ts

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,29 @@ export interface Toast {
1212
export const useToast = () => {
1313
const [toasts, setToasts] = useState<Toast[]>([]);
1414

15-
const addToast = useCallback((toast: Omit<Toast, 'id'>) => {
16-
const id = `toast-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
17-
const newToast: Toast = {
18-
id,
19-
duration: 5000, // 기본 5초
20-
...toast,
21-
};
22-
23-
setToasts((prev) => [...prev, newToast]);
24-
25-
// 자동 제거
26-
setTimeout(() => {
27-
removeToast(id);
28-
}, newToast.duration);
29-
}, []);
30-
3115
const removeToast = useCallback((id: string) => {
3216
setToasts((prev) => prev.filter((toast) => toast.id !== id));
3317
}, []);
3418

19+
const addToast = useCallback(
20+
(toast: Omit<Toast, 'id'>) => {
21+
const id = `toast-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
22+
const newToast: Toast = {
23+
id,
24+
duration: 5000, // 기본 5초
25+
...toast,
26+
};
27+
28+
setToasts((prev) => [...prev, newToast]);
29+
30+
// 자동 제거
31+
setTimeout(() => {
32+
removeToast(id);
33+
}, newToast.duration);
34+
},
35+
[removeToast],
36+
);
37+
3538
const showSuccess = useCallback(
3639
(message: string, duration?: number) => {
3740
addToast({ type: 'success', message, duration });
@@ -70,7 +73,3 @@ export const useToast = () => {
7073
showInfo,
7174
};
7275
};
73-
74-
75-
76-

0 commit comments

Comments
 (0)