Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/issue-107 #108

Merged
merged 6 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.21.3",
"react-toastify": "^10.0.4",
"simple-peer": "^9.11.1",
"zustand": "^4.5.0"
},
Expand Down
19 changes: 19 additions & 0 deletions frontend/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/src/components/chat/ChatForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const ChatForm = ({ isLoading, isError, username }: UserDataProps) => {
return (
<ChatWrapper>
<ChattingContainer>
<ChatMessage messages={messages} />
<ChatMessage messages={messages} username={username} />
</ChattingContainer>
<InputContainer>
<ChatInput
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/components/chat/ChatMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import styled from '@emotion/styled';

type ChatMessageListProps = {
messages: Message[];
username: string | undefined;
};

const ChatMessage = ({ messages }: ChatMessageListProps) => {
const ChatMessage = ({ messages, username }: ChatMessageListProps) => {
let currentFormattedDate = '';

return (
Expand Down Expand Up @@ -40,7 +41,7 @@ const ChatMessage = ({ messages }: ChatMessageListProps) => {
{shouldDisplayYear && <DateWrapper>{formattedDate}</DateWrapper>}
<MessageWrapper>
{/* 추후 코드 본인일 경우 상태관리 추가해야됨 */}
{item.sender === '123' ? (
{item.sender === username ? (
<ChatReverseWrapper>
<ChatOwnBox>{item.content}</ChatOwnBox>
<ChatDateWrapper>
Expand Down
34 changes: 17 additions & 17 deletions frontend/src/components/user/UserProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@ const SmallText = styled.span`
color: var(--color-orient);
`;

const DUMMY_DATA: UserList[] = [
{
userName: '[email protected]',
},
{
userName: '[email protected]',
},
{
userName: '[email protected]',
},
{
userName: '[email protected]',
},
{
userName: '[email protected]',
},
];
// const DUMMY_DATA: UserList[] = [
// {
// userName: '[email protected]',
// },
// {
// userName: '[email protected]',
// },
// {
// userName: '[email protected]',
// },
// {
// userName: '[email protected]',
// },
// {
// userName: '[email protected]',
// },
// ];
5 changes: 3 additions & 2 deletions frontend/src/hooks/react-query/useUserData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ import { UserData } from '../../interface/UserListInterface';

export const getUserData = async (): Promise<UserData> => {
try {
const accessToken = localStorage.getItem('AccessToken');
const accessToken = localStorage.getItem('Accesstoken');
// console.log(accessToken);
if (!accessToken) {
throw new Error('AccessToken이 없습니다.');
}

const response = await axios.get('http://localhost:8001/user-service/user-info', {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${accessToken}`,
Accesstoken: `Bearer ${accessToken}`,
},
});

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/ChattingRoomPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const ChattingRoomPage = () => {
} = useQuery({
queryKey: ['userData'],
queryFn: getUserData,
staleTime: 2000000,
staleTime: 5000,
});
let username = userData?.username;

Expand Down
8 changes: 4 additions & 4 deletions frontend/src/stores/useChatStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import { create } from 'zustand';
import { Message } from '../interface/ChatInterface';

type ChatStore = {
id: string;
// id: string;
messages: Message[];
inputMessage: string;
setId: (id: string) => void;
// setId: (id: string) => void;
setMessages: (messages: (prev: Message[]) => Message[]) => void;
setInputMessage: (inputMessage: string) => void;
};

export const useChatStore = create<ChatStore>((set) => ({
id: '',
// id: '',
messages: [],
inputMessage: '',
setId: (id) => set({ id }),
// setId: (id) => set({ id }),
setMessages: (messages) => set((state) => ({ messages: messages(state.messages) })),
setInputMessage: (inputMessage) => set({ inputMessage }),
}));