-
Notifications
You must be signed in to change notification settings - Fork 10
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
[5주차] 한규진 미션 제출합니다. #11
Open
9yujin
wants to merge
24
commits into
CEOS-Developers:main
Choose a base branch
from
9yujin:9yujin
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+30,162
−27,587
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
cc6896b
feat : 기초 설정 & 데이터 설정
9yujin 2f4a9d8
feat : 채팅기록 렌더링
9yujin 7eece65
feat : recoil setting
9yujin 0e06566
feat : getuser api
9yujin b5aee19
feat : api 디렉토리구조...
9yujin 952997f
feat : sendMessage api
9yujin 0fe9c05
feat : 스타일링 & 스크롤 내리기
9yujin ed4cb3c
feat : 스크롤 최하단으로 가기 버튼
9yujin 786ea32
feat : 채팅 말풍선 스타일
9yujin d4d7379
feat : 사용자 전환 기능
9yujin 841006d
rename : 깃에 파일 대소문자변경 반영되지 않던 오류
9yujin 2adbab1
design : 매우자잘한.. 시간 띄어쓰기없애기
9yujin a8a0d70
fix: 제출전.. 경고없애기
9yujin 107b6c1
refactor : react.memo 최적화
9yujin 9a7bc20
feat : 페이지 라우팅 설정, 전체 구조 디자인-설정
9yujin 6ae7a9a
feat : 친구목록, 채팅방 라우팅 구현
9yujin d258c45
rename ChatDataType to RoomType
9yujin a6e2e82
feat : 채팅목록 스타일링, 구현
9yujin c36c2c3
feat : 카카오로그인 구현
9yujin 16ad2e7
fix : 마지막 채팅이 긴 문자열일때 프로필사진 작아지는 오류 수정
9yujin 30098a7
feat : 친구목록 검색기능 구현
9yujin f2325b3
searchBox autoFocus
9yujin 7e9aaf0
아맞다 border radius...
9yujin f291fd5
끝끝
9yujin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"root": true, | ||
"parser": "@typescript-eslint/parser", | ||
"plugins": ["@typescript-eslint", "no-loops"], | ||
"extends": ["eslint:recommended", "plugin:@typescript-eslint/eslint-recommended", "plugin:@typescript-eslint/recommended"], | ||
"rules": { | ||
"no-console": 2, | ||
"no-loops/no-loops": 2 | ||
} | ||
} | ||
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,60 @@ | ||
{ | ||
"name": "react-messenger-15th", | ||
"version": "0.1.0", | ||
"private": true, | ||
"dependencies": { | ||
"@testing-library/jest-dom": "^5.16.4", | ||
"@testing-library/react": "^13.1.1", | ||
"@testing-library/user-event": "^13.5.0", | ||
"react": "^18.1.0", | ||
"react-dom": "^18.1.0", | ||
"react-scripts": "5.0.1", | ||
"web-vitals": "^2.1.4" | ||
}, | ||
"scripts": { | ||
"start": "react-scripts start", | ||
"build": "react-scripts build", | ||
"test": "react-scripts test", | ||
"eject": "react-scripts eject" | ||
}, | ||
"eslintConfig": { | ||
"extends": [ | ||
"react-app", | ||
"react-app/jest" | ||
] | ||
}, | ||
"browserslist": { | ||
"production": [ | ||
">0.2%", | ||
"not dead", | ||
"not op_mini all" | ||
], | ||
"development": [ | ||
"last 1 chrome version", | ||
"last 1 firefox version", | ||
"last 1 safari version" | ||
] | ||
} | ||
"name": "react-messenger-15th", | ||
"version": "0.1.0", | ||
"private": true, | ||
"dependencies": { | ||
"@testing-library/jest-dom": "^5.16.4", | ||
"@testing-library/react": "^13.1.1", | ||
"@testing-library/user-event": "^13.5.0", | ||
"@types/jest": "^27.4.1", | ||
"@types/lodash": "^4.14.182", | ||
"@types/node": "^17.0.31", | ||
"@types/react": "^18.0.8", | ||
"@types/react-dom": "^18.0.3", | ||
"@types/styled-components": "^5.1.25", | ||
"@types/uuid": "^8.3.4", | ||
"dayjs": "^1.11.1", | ||
"lodash": "^4.17.21", | ||
"react": "^18.1.0", | ||
"react-dom": "^18.1.0", | ||
"react-kakao-login": "^2.1.0", | ||
"react-router-dom": "^6.3.0", | ||
"react-scripts": "5.0.1", | ||
"recoil": "^0.7.2", | ||
"styled-components": "^5.3.5", | ||
"styled-normalize": "^8.0.7", | ||
"typescript": "^4.6.4", | ||
"uuid": "^8.3.2", | ||
"web-vitals": "^2.1.4" | ||
}, | ||
"scripts": { | ||
"start": "react-scripts start", | ||
"build": "react-scripts build", | ||
"test": "react-scripts test", | ||
"eject": "react-scripts eject" | ||
}, | ||
"eslintConfig": { | ||
"extends": [ | ||
"react-app", | ||
"react-app/jest" | ||
] | ||
}, | ||
"browserslist": { | ||
"production": [ | ||
">0.2%", | ||
"not dead", | ||
"not op_mini all" | ||
], | ||
"development": [ | ||
"last 1 chrome version", | ||
"last 1 firefox version", | ||
"last 1 safari version" | ||
] | ||
}, | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^5.21.0", | ||
"@typescript-eslint/parser": "^5.21.0", | ||
"eslint": "^8.14.0", | ||
"eslint-plugin-no-loops": "^0.3.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,24 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta name="theme-color" content="#000000" /> | ||
<meta | ||
name="description" | ||
content="Web site created using create-react-app" | ||
/> | ||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" /> | ||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> | ||
<title>React App</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
</body> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta name="theme-color" content="#000000" /> | ||
<meta name="description" content="Web site created using create-react-app" /> | ||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" /> | ||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> | ||
<link rel="preconnect" href="https://fonts.googleapis.com" /> | ||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /> | ||
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;700&display=swap" rel="stylesheet" /> | ||
<script src="https://developers.kakao.com/sdk/js/kakao.js"></script> | ||
<script> | ||
Kakao.init('1da4996513f2ad5ab840e4af1bcba99d'); | ||
Kakao.isInitialized(); | ||
</script> | ||
<title>9yujin</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
</body> | ||
</html> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import GlobalStyle from './styles/GlobalStyle'; | ||
import { Main } from './styles/Container'; | ||
import { RecoilRoot } from 'recoil'; | ||
import { BrowserRouter, Routes, Route } from 'react-router-dom'; | ||
import Router from './pages/Router'; | ||
import Login from './pages/Login'; | ||
import RequireAuth from './utils/RequireAuth'; | ||
import ChatRoom from './pages/ChatRoom'; | ||
|
||
function App() { | ||
return ( | ||
<> | ||
<GlobalStyle /> | ||
<RecoilRoot> | ||
<BrowserRouter> | ||
Comment on lines
+13
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
<Main> | ||
<Routes> | ||
<Route path="/login" element={<Login />} /> | ||
<Route | ||
path="/*" | ||
element={ | ||
<RequireAuth> | ||
<Router /> | ||
</RequireAuth> | ||
Comment on lines
+22
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
/> | ||
<Route | ||
path="/room/:roomId" | ||
element={ | ||
<RequireAuth> | ||
<ChatRoom /> | ||
</RequireAuth> | ||
} | ||
/> | ||
</Routes> | ||
</Main> | ||
</BrowserRouter> | ||
</RecoilRoot> | ||
</> | ||
); | ||
} | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
export interface ChatType { | ||
userId: number; | ||
content: string; | ||
date: string; | ||
like: boolean; | ||
chatId: string; | ||
} | ||
export interface RoomType { | ||
roomId: number; | ||
user: { | ||
userId: number; | ||
}[]; | ||
chat: ChatType[]; | ||
} | ||
|
||
export interface UserType { | ||
userId: number; | ||
userName: string; | ||
profileImage: string; | ||
statusMessage: string; | ||
} | ||
|
||
export interface AuthType { | ||
userName: string; | ||
profileImage: string; | ||
init: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { SetterOrUpdater } from 'recoil'; | ||
import { RoomType, ChatType, UserType } from '../Interface'; | ||
import { getUserInfoById } from './userInfo'; | ||
|
||
// 채팅 내역 가져오기 | ||
export const getChats = (roomId: number, chatData: RoomType[]) => { | ||
const [chatObj] = chatData.filter((room) => room.roomId === roomId); | ||
if (!chatObj) throw new Error('존재하지 않는 ID'); | ||
return chatObj.chat; | ||
}; | ||
|
||
// 채팅방 내 대화상대 id 가져오기 | ||
export const getUserIdListByRoom = (roomId: number, chatData: RoomType[]): number[] => { | ||
const [chatObj] = chatData.filter((room) => room.roomId === roomId); | ||
const userIdList = chatObj['user'].map((user) => user['userId']); | ||
return userIdList; | ||
}; | ||
|
||
// 채팅방 내 대화상대 정보 가져오기 | ||
export const getUserInfoListByRoomId = (roomId: number, chatData: RoomType[], userData: UserType[]): UserType[] => { | ||
const userIdList = getUserIdListByRoom(roomId, chatData); | ||
//const userInfoList = userData.filter((user, index) => user.userId === userIdList[index]); | ||
const userInfoList = userIdList.map((userId) => getUserInfoById(userId, userData)); | ||
return userInfoList; | ||
}; | ||
|
||
// 채팅보내기 | ||
export const postMessage = (roomId: number, MessageObj: ChatType, chatData: RoomType[], setChatData: SetterOrUpdater<RoomType[]>) => { | ||
const [chatObj] = chatData.filter((room) => room.roomId === roomId); | ||
|
||
const newChatObj: RoomType = { ...chatObj, chat: [...chatObj.chat, MessageObj] }; | ||
setChatData(chatData.map((room) => (room.roomId === roomId ? newChatObj : room))); | ||
return { status: 200 }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './chatRoom'; | ||
export * from './userInfo'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { AuthType, RoomType, UserType } from '../Interface'; | ||
import { SetterOrUpdater } from 'recoil'; | ||
// userId 로 유저 정보 가져오기 | ||
export const getUserInfoById = (userId: number, userData: UserType[]): UserType => { | ||
const [userObj] = userData.filter((user) => user.userId === userId); | ||
return userObj; | ||
}; | ||
|
||
// userId로 roomId 가져오기 (갠톡) | ||
export const getRoomIdByUser = (userId: number, chatData: RoomType[]): number => { | ||
const [chatObj] = chatData.filter((room) => room.user[1]['userId'] === userId); | ||
return chatObj.roomId; | ||
}; | ||
|
||
// 로그인 | ||
export const login = (name: string, image: string, setAuth: SetterOrUpdater<AuthType>, users: UserType[], setUsers: SetterOrUpdater<UserType[]>) => { | ||
setAuth({ userName: name, profileImage: image, init: true }); | ||
setUsers( | ||
users.map((user) => | ||
user.userId === 0 | ||
? { | ||
userId: 0, | ||
userName: name, | ||
profileImage: image, | ||
statusMessage: '', | ||
myAccount: true, | ||
} | ||
: user | ||
) | ||
); | ||
localStorage.setItem('name', name); | ||
localStorage.setItem('image', image); | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍👏