-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from Youngseo-kangg/feature/redux
[Client] #1 Feature/redux : redux ๊ธฐ๋ณธ ์ธํ ๋ฐ ๊ธฐ์ด ์์ฑ
- Loading branch information
Showing
32 changed files
with
618 additions
and
426 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
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 @@ | ||
// ์ด๋ค ํ๋์ ํ ์ง ์ ์ํด ๋ actions | ||
export const SET_LOGIN_STATE = 'SET_LOGIN_STATE'; // ๋ก๊ทธ์ธ ์ํ ๋ณ๊ฒฝ(=๋ก๊ทธ์ธ) | ||
export const SET_LOGOUT_STATE = 'SET_LOGOUT_STATE'; // ๋ก๊ทธ์์ ์ํ ๋ณ๊ฒฝ | ||
export const EDIT_USERINFO = 'EDIT_USERINFO'; // ์ ์ ์ ๋ณด(=์ด๋ฆ, ๋น๋ฐ๋ฒํธ, ์ฌ์ง) ๋ณ๊ฒฝํ๊ธฐ | ||
export const SET_MODAL_LOGINORSIGNUP = 'SET_MODAL_LOGINORSIGNUP'; // ๋ก๊ทธ์ธorํ์๊ฐ์ ๋ชจ๋ฌ ์ํ | ||
export const SET_MODAL_QUIZ = 'SET_MODAL_QUIZ'; // ํด์ฆ ๋ชจ๋ฌ ์ํ | ||
export const SET_MODAL_SIGNOUT = 'SET_MODAL_SIGNOUT'; // ํ์ํํด ๋ชจ๋ฌ ์ํ | ||
export const SET_MODAL_LOGOUT = 'SET_MODAL_LOGOUT'; // ๋ก๊ทธ์์ ๋ชจ๋ฌ ์ํ | ||
export const SET_MODAL_CHART = 'SET_MODAL_CHART'; // ์ฐจํธ ๋ชจ๋ฌ ์ํ | ||
|
||
export const SET_USER_CONTENT = 'SET_USER_CONTENT'; // ์ ์ ๊ฐ ์ด ๊ธ ๋ฐ์์ค๊ธฐ | ||
export const DELETE_CONTENT = 'DELETE_CONTENT'; // ์ ์ ๊ฐ ์ด ๊ธ ์ญ์ | ||
export const EDIT_CONTENT = 'EDIT_CONTENT'; // ์ ์ ๊ฐ ์ด ๊ธ ์์ | ||
|
||
export const setLogin = (userData, isLogin) => { | ||
return { | ||
type: SET_LOGIN_STATE, | ||
userData, | ||
isLogin, | ||
}; | ||
}; | ||
|
||
export const getContent = (userContent) => { | ||
return { | ||
type: SET_USER_CONTENT, | ||
userContent, | ||
}; | ||
}; | ||
|
||
export const deleteContent = (contentId) => { | ||
return { | ||
type: DELETE_CONTENT, | ||
contentId, | ||
}; | ||
}; | ||
|
||
export const editContent = (contentId, wordMean) => { | ||
return { | ||
type: EDIT_CONTENT, | ||
contentId, | ||
wordMean, | ||
}; | ||
}; |
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 @@ | ||
// Chart ์์ ์ค์๊ฐ ์์ ๊ทธ๋ํ ๋ณด์ฌ์ง ๋ถ๋ถ |
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 @@ | ||
// ์ค์๊ฐ ์์ ๋ณด์ฌ์ง ๋ถ๋ถ |
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 @@ | ||
// EditMyPage์์ ์ ์ ์ ๋ณด ๋ณ๊ฒฝํ๋ ๋ถ๋ถ |
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 @@ | ||
// EditMyPage์์ ์ฌ์ง ๋ณ๊ฒฝ ์ผ์ด๋๋ ๋ถ๋ถ |
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 @@ | ||
// ๋๋ฉํ์ด์ง์์ ๋ง๋ณด๊ธฐ๋ก ์ ๊ณต๋ ํด์ฆ |
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 @@ | ||
// ๋ฉ์ธํ์ด์ง์์ ์ ๋ ฅ์ฐฝ, ์ ๋ ฅ์ฐฝ ์๋์์ฑ, ๊ณผ๊ฑฐ ๊ฒ์๊ธฐ๋ก, ๊ฒ์๊ฒฐ๊ณผ ๋ณด์ฌ์ง ๋ถ๋ถ |
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 @@ | ||
// Search์์ ์๋์์ฑ ์ฐฝ |
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 @@ | ||
// ๊ณผ๊ฑฐ ๊ฒ์๊ฒฐ๊ณผ ๋ณด๊ด |
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 @@ | ||
// Search์์ ๊ฒ์์ฐฝ ๋ถ๋ถ |
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 @@ | ||
// Search์์ ๊ฒ์ ํ ์ข์์ ์์ผ๋ก 3๊ฐ๋ง ๋ณด์ฌ์ง๋ ๋ถ๋ถ |
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 @@ | ||
// Mypage์์ ์ ์ ๊ฐ ์ด ๊ธ ๋ชฉ๋ก |
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 @@ | ||
// Mypage ์์์ ์ ์ ์ ๋ณด ๋ํ๋ ๋ถ๋ถ |
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 @@ | ||
// ์ค์๊ฐ ์์ ๊ทธ๋ํ ๋ํ๋ ๋ชจ๋ฌ |
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 @@ | ||
// ์ฌ์ฉ์๊ฐ ์ด ๊ธ ์์ ํ๋ ๋ชจ๋ฌ |
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 @@ | ||
// ๋ก๊ทธ์ธ / ํ์๊ฐ์ ๋ชจ๋ฌ |
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 @@ | ||
// ๋ก๊ทธ์์ ๋ชจ๋ฌ |
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 @@ | ||
// ์ฌ์ฉ์๊ฐ ์๋ก์ด ๊ธ์ ์ฐ๋ ๋ชจ๋ฌ |
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 @@ | ||
// ์ค๋์ ํด์ฆ ๋ถ๋ถ |
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 @@ | ||
// ํ์ ํํด ๋ชจ๋ฌ |
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 @@ | ||
// ๊ฐ์ธ์ ๋ณด ๋ณ๊ฒฝ ํ์ด์ง |
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 @@ | ||
// footer ๋ถ๋ถ |
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 @@ | ||
// main ํ์ด์ง (๊ฒ์ ๋ฐ ๊ฒ์๊ฒฐ๊ณผ ๋ณด๊ธฐ ํ์ด์ง) |
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 @@ | ||
// ๊ฐ์ธ์ ๋ณด ํ์ธ ๋ฐ ์์ฑํ ๊ธ ๋ณด์ด๋ ํ์ด์ง |
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 @@ | ||
// Navbar ๋ถ๋ถ |
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 @@ | ||
// ๊ฒ์๊ฒฐ๊ณผ ์ ์ฒด ๋ณด์ฌ์ง๋ ํ์ด์ง |
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 @@ | ||
// reducer๋ค์ ํ๋ฒ์ ์ ๋ฆฌ | ||
import { combineReducers } from 'redux'; | ||
import userInfoReducer from './userInfoReducer'; | ||
import userContentReducer from './userContentReducer'; | ||
|
||
const rootReducer = combineReducers({ | ||
userInfoReducer, | ||
userContentReducer, | ||
}); | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// ์ ์ ๊ฐ ์ด ๊ธ ๊ด๋ฆฌ reducer | ||
// ๊ธฐ๋ณธ๊ฐ: ์ ์ ๊ฐ ์์ฑํ ๊ธ | ||
// ๊ธฐ๋ฅ : ์ ์ ๊ฐ ์ด ๊ธ ๋ฐ์์ค๊ธฐ, ์ ์ ๊ฐ ์ด ๊ธ ์ญ์ , ์ ์ ๊ฐ ์ด ๊ธ ์์ | ||
|
||
import { | ||
SET_USER_CONTENT, | ||
DELETE_CONTENT, | ||
EDIT_CONTENT, | ||
} from '../actions/index'; | ||
|
||
const defaultUserContentInfo = { | ||
data: [], | ||
}; | ||
|
||
const userContentReducer = (state = defaultUserContentInfo, action) => { | ||
switch (action.type) { | ||
case SET_USER_CONTENT: // ์ ์ ๊ฐ ์ด ๊ธ ๋ค ๋ฐ์์ค๊ธฐ | ||
return { ...action.payload }; | ||
|
||
case DELETE_CONTENT: // ์ ์ ๊ฐ ์ด ๊ธ ์ ๊ฑฐํ๋ reducer, payload๋ก contentId ๋ค์ด์ด | ||
let saveContents = state.data.filter( | ||
(ele) => ele.id !== action.payload.contentId | ||
); | ||
return Object.assign({}, { data: [...saveContents] }); | ||
|
||
case EDIT_CONTENT: | ||
let editData = state.data.filter( | ||
(ele) => ele.id === action.payload.contentId | ||
); | ||
editData.wordMean = action.payload.wordMean; | ||
return Object.assign({}, { data: [...state.data] }); | ||
|
||
default: | ||
// ๊ธฐ๋ณธ reducer | ||
return state; | ||
} | ||
}; | ||
|
||
export default userContentReducer; |
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,41 @@ | ||
// ์ ์ ์ ๊ฐ์ธ์ ๋ณด ๋ฐ ๋ชจ๋ฌ ๋ซ/์ด๋ฆผ ์ํ ๊ด๋ฆฌ reducer | ||
// ๊ธฐ๋ณธ๊ฐ: ๊ฐ์ธ ์ ๋ณด (username, email, userPic, exp), ๋ก๊ทธ์ธ ์ํ, ๋ชจ๋ฌ ์ํ(๋ก๊ทธ์ธ, ๋ก๊ทธ์์, โฆ) | ||
// ๊ธฐ๋ฅ : ๋ก๊ทธ์ธํ๊ธฐ, ์ ์ ์ด๋ฆ/๋น๋ฐ๋ฒํธ/์ฌ์ง ๋ณ๊ฒฝ, ๋ชจ๋ฌ ์ผ๊ธฐ/๋๊ธฐ, ๋ก๊ทธ์์ํ๊ธฐ, ํ์ ํํดํ๊ธฐ | ||
|
||
import { SET_LOGIN_STATE, SET_LOGOUT_STATE } from '../actions/index'; | ||
|
||
const defaultUserInfo = { | ||
userInfo: { | ||
id: -1, | ||
email: '', | ||
username: '', | ||
userPic: null, | ||
exp: 0, | ||
}, // ๊ธฐ๋ณธ ์ ์ ์ ๋ณด | ||
isLogin: false, //๋ก๊ทธ์ธ ์ํ | ||
isShowLoginOrSignupModal: false, // ๋ก๊ทธ์ธorํ์๊ฐ์ ๋ชจ๋ฌ ์ํ | ||
isShowQuizModal: false, // ํด์ฆ ๋ชจ๋ฌ ์ํ | ||
isShowSignoutModal: false, // ํ์ํํด ๋ชจ๋ฌ ์ํ | ||
isShowLogoutModal: false, // ๋ก๊ทธ์์ ๋ชจ๋ฌ ์ํ | ||
isShowChartModal: false, // ์ฐจํธ ๋ชจ๋ฌ ์ํ | ||
}; | ||
|
||
const userInfoReducer = (state = defaultUserInfo, action) => { | ||
switch (action.type) { | ||
case SET_LOGIN_STATE: // ๋ก๊ทธ์ธ reducer | ||
return { | ||
...state, | ||
userInfo: action.userData, | ||
isLogin: action.isLogin, | ||
}; | ||
case SET_LOGOUT_STATE: // ๋ก๊ทธ์์ reducer | ||
return { | ||
...defaultUserInfo, | ||
}; | ||
default: | ||
// ๊ธฐ๋ณธ reducer | ||
return state; | ||
} | ||
}; | ||
|
||
export default userInfoReducer; |
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,14 @@ | ||
// react-redux์์ ์ํ๋ค์ ๊ฐ๊ณ ์์ store | ||
import { compose, createStore, applyMiddleware } from 'redux'; | ||
import rootReducer from '../reducers/index'; | ||
import thunk from 'redux-thunk'; | ||
|
||
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ | ||
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({}) | ||
: compose; | ||
const store = createStore( | ||
rootReducer, | ||
composeEnhancers(applyMiddleware(thunk)) | ||
); | ||
|
||
export default store; |
Oops, something went wrong.