-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: reducer 데이터 저장 호출 변경 * feat: chatroom reducer 정의 * feat: chatroom dispatch 정의 * feat: getChatroom axios api 정의 * feat: channel 이동 시 chatroom 정보 얻어오는 로직 추가 * feat: Chatroom Container 정의 및 Chatroom 정보 불러오기
- Loading branch information
Showing
13 changed files
with
81 additions
and
18 deletions.
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,9 @@ | ||
import { api } from '@utils/index'; | ||
import store from '@store/index'; | ||
|
||
const getChatroomInfo = async (selectedChatroomId: number) => { | ||
const chatroomInfo = await api.getChatroom(selectedChatroomId); | ||
store.dispatch({ type: 'LOAD', ...chatroomInfo }); | ||
}; | ||
|
||
export { getChatroomInfo }; |
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,4 +1,5 @@ | ||
import { getUserInfo } from './user-dispatch'; | ||
import { getUserChatroom } from './user-chatroom-dispatch'; | ||
import { getChatroomInfo } from './chatroom-dispatch'; | ||
|
||
export { getUserInfo, getUserChatroom }; | ||
export { getUserInfo, getUserChatroom, getChatroomInfo }; |
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,29 @@ | ||
const initialState = { | ||
chatType: '', | ||
description: '', | ||
isPrivate: false, | ||
title: '', | ||
topic: null, | ||
userCount: 0, | ||
users: [] | ||
}; | ||
|
||
const chatroomReducer = (state = initialState, action: any) => { | ||
switch (action.type) { | ||
case 'LOAD': | ||
return { | ||
...state, | ||
chatType: action.chatType, | ||
description: action.description, | ||
isPrivate: action.isPrivate, | ||
title: action.title, | ||
topic: action.topic, | ||
userCount: action.userCount, | ||
users: action.users | ||
}; | ||
default: | ||
return state; | ||
} | ||
}; | ||
|
||
export default chatroomReducer; |
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,10 +1,12 @@ | ||
import { combineReducers } from 'redux'; | ||
import userReducer from './user-reducer'; | ||
import sidebarReducer from './sidebar-reducer'; | ||
import chatroomReducer from './chatroom-reducer'; | ||
|
||
const rootReducer = combineReducers({ | ||
userReducer, | ||
sidebarReducer | ||
userData: userReducer, | ||
sidebarData: sidebarReducer, | ||
chatroomData: chatroomReducer | ||
}); | ||
|
||
export default rootReducer; |
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
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
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
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
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
13 changes: 6 additions & 7 deletions
13
client/src/components/organisms/Sidebar/SidebarContainer.tsx
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
9 changes: 7 additions & 2 deletions
9
client/src/pages/Chatroom.tsx → client/src/pages/Chatroom/Chatroom.tsx
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
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,11 @@ | ||
import { connect } from 'react-redux'; | ||
import { Chatroom } from './Chatroom'; | ||
|
||
function mapReduxStateToReactProps(state: any) { | ||
return { | ||
selectedChatroomId: state.sidebarData.selectedChatroomId, | ||
title: state.chatroomData.title | ||
}; | ||
} | ||
|
||
export default connect(mapReduxStateToReactProps)(Chatroom); |
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,4 +1,4 @@ | ||
import { Chatroom } from './Chatroom'; | ||
import Chatroom from './Chatroom/ChatroomContainer'; | ||
import { Login } from './Login'; | ||
|
||
export { Chatroom, Login }; |