Skip to content

Commit 8441ec5

Browse files
committed
Fix: 프로필 이미지 경로 수정 및 채팅 페이지 리다이렉트 로직 개선. 프로필 이미지 로딩 시 사용자 프로필 이미지 인덱스 증가, 채팅 페이지에서 현재 경로에 따라 리다이렉트 처리 추가.
1 parent a3669af commit 8441ec5

4 files changed

Lines changed: 10 additions & 3 deletions

File tree

src/app/(layout)/profile/page.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export default function ProfilePage() {
9797
</div>
9898
<div className="-mt-20 z-10">
9999
<Image
100-
src={'/userProfile/' + user.profileImage + '.png' || `/userProfile/1.png`}
100+
src={'/userProfile/' + (parseInt(user.profileImage)+1) + '.png' || `/userProfile/1.png`}
101101
alt="profile"
102102
width={150}
103103
height={150}

src/components/ChatMessages.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import remarkGfm from 'remark-gfm';
44
import remarkMath from 'remark-math';
55
import rehypeKatex from 'rehype-katex';
66
import 'katex/dist/katex.min.css';
7+
import { useAuth } from '@/contexts/AuthContext';
78

89
export default function ChatMessages({ chatList }) {
10+
const { user } = useAuth();
911
const handleCopyText = (text) => {
1012
navigator.clipboard.writeText(text);
1113
alert("Copied to clipboard");
@@ -64,7 +66,7 @@ export default function ChatMessages({ chatList }) {
6466
{chatList.map((message, index) => (
6567
<div key={index} className={`flex mb-7 ${message.sender === 'USER' ? 'justify-end' : 'justify-start'}`}>
6668
<div className="flex flex-row">
67-
<Image src={message.sender === 'USER' ? '/icon/user.png' : '/icon/ai.png'} alt="user" width={24} height={24} className="w-10 h-10 rounded-lg z-10" />
69+
<Image src={message.sender === 'USER' ? '/userProfile/' + (parseInt(user.profileImage)+1) + '.png' : '/icon/ai.png'} alt="user" width={24} height={24} className="w-10 h-10 rounded-lg z-10" />
6870
<div className="flex flex-col ml-2 max-w-full">
6971
<div className="text-xs font-semibold">{message.sender}</div>
7072
<div className={`flex flex-col text-xs rounded-2xl pr-4 pl-7 py-5 -ml-5 ${message.sender === 'USER' ? 'items-end bg-[#4b4f5b]' : 'items-start bg-[#28303F]'}`}>

src/components/Chatlist.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ export default function Chatlist() {
2929
localStorage.setItem("lastChattingId", "");
3030
setLastViewedChatId("");
3131
setCurrentChatId(null);
32-
router.push('/chat');
32+
if (window.location.pathname === '/chat') {
33+
window.location.reload();
34+
} else {
35+
router.push('/chat');
36+
}
3337
};
3438

3539
if (loading) {

src/contexts/AuthContext.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export function AuthProvider({ children }) {
4343
const logout = () => {
4444
setUser(null);
4545
localStorage.removeItem('user');
46+
localStorage.removeItem('lastChattingId');
4647
console.log('✅ 사용자 정보 삭제');
4748
document.cookie = "jwtToken=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
4849
router.push('/');

0 commit comments

Comments
 (0)