Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jtjun committed Jun 17, 2019
2 parents 00198ae + a70c03c commit 9d91c34
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 18 deletions.
13 changes: 9 additions & 4 deletions frontend/package-lock.json

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

3 changes: 1 addition & 2 deletions frontend/src/components/organisms/RoomSettingForm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ const RoomSettingForm = props => {
const { handleSubmit } = props;
return (
<form onSubmit={handleSubmit}>
<Button type="button">Add Layer</Button>
<Button type="button">Delete Room</Button>
<Button type="submit">Delete Room</Button>
</form>
);
};
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/components/pages/RoomPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import PropTypes from 'prop-types'
import { Block, Button, Graph, List, ListItem, Header } from 'components'
import { MemberList, PaymentList } from 'containers'
import { getMemberDebtList, getSimplifiedGraph } from 'services/simplifier'

import { Link } from 'react-router-dom'

const RoomPage = props => {
const { room, members, showPayment, onClickMember, onToggle } = props
if (!room) return <Block transparent>Loading...</Block>
Expand Down Expand Up @@ -38,6 +39,9 @@ const RoomPage = props => {
<Block transparent>
<a>로그아웃</a>
</Block>
<Block>
<Link to={`/room/${room.url}/setting/`}>button</Link>
</Block>
</div>
)
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/pages/RoomSettingPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const RoomSettingPage = (props) => {
console.log(props)
return (
<div>
<h1>{props.roomname}</h1>
<Block>
<RoomSettingForm />
<h1>{props.roomname}</h1>
<RoomSettingForm initialValues={{url: props.url}} />
</Block>
</div>
)
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/containers/RoomPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ class RoomPageContainer extends React.Component {
return <RoomPage {...this.props} />
}

componentWillUnmount() {
// this.props.onLeave()
}
}

const mapStateToProps = state => ({
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/containers/RoomSettingForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ const RoomSettingFormContainer = props => {
export default reduxForm({
form: 'RoomSetting',
onSubmit(values, dispatch) {
dispatch(roomSettingRequest())
dispatch(roomSettingRequest({url: values.url}))
}
})(RoomSettingFormContainer)
7 changes: 3 additions & 4 deletions frontend/src/containers/RoomSettingPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { RoomSettingPage } from 'components'
import { Redirect } from 'react-router-dom'

const RoomSettingPageContainer = (props) => {



if( !props.roomname ){
return(
<Redirect to="/user/"/>
Expand All @@ -17,11 +16,11 @@ const RoomSettingPageContainer = (props) => {
)
}


}

const mapStateToProps = (state) => ({
roomname : state.room.room.roomname,
roomname: state.room.room.roomname,
url: state.room.room.url,
})

export default connect(mapStateToProps)(RoomSettingPageContainer)
12 changes: 11 additions & 1 deletion frontend/src/store/room/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,19 @@ export const entranceRequest = () => ({
})

export const ROOM_SETTING_REQUEST = "ROOM_SETTING_REQUEST"
export const ROOM_DELETE_SUCCESS = "ROOM_DELETE_SUCCESS"
export const ROOM_DELETE_FAILED = "ROOM_DELETE_FAILED"

export const roomSettingRequest = () => ({

export const roomSettingRequest = ( {url} ) => ({
type: ROOM_SETTING_REQUEST,
url,
})
export const roomDeleteSuccess = () => ({
type: ROOM_DELETE_SUCCESS,
})
export const roomDeleteFailed = () => ({
type: ROOM_DELETE_FAILED,
})


Expand Down
15 changes: 15 additions & 0 deletions frontend/src/store/room/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,21 @@ const roomReducer = (state = initialState, action) => {
action.room,
],
}

/*
case actions.ROOM_SETTING_REQUEST:
return{
...initialState,
}
case action.ROOM_DELETE_SUCCESS:
return{
...initialState,
}
case action.ROOM_DELETE_FAILED:
return{
...initialState,
}
*/
case actions.ROOM_LIST_SUCCESS:
return {
...state,
Expand Down
17 changes: 17 additions & 0 deletions frontend/src/store/room/sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,26 @@ function* watchRoomGetRequest() {
}


/* Room Delete Request */
function* deleteRequest( { url } ) {

try {
const room = yield api.delete(`/rooms/${url}/`)
yield put(actions.roomDeleteSuccess())
} catch(e) {
yield put(actions.roomDeleteFailed(e))
}

}

function* watchRoomSettingRequest() {
yield takeEvery(actions.ROOM_SETTING_REQUEST, deleteRequest)
}

export default function* () {
yield fork(watchCreatePageRequest)
yield fork(watchRoomListRequest)
yield fork(watchRoomGetRequest)
yield fork(watchRoomSettingRequest)
}

0 comments on commit 9d91c34

Please sign in to comment.