Skip to content

Commit

Permalink
Merge branch 'master' into connected-react-router
Browse files Browse the repository at this point in the history
  • Loading branch information
y123ob authored Jun 19, 2019
2 parents 6b12edf + c69903d commit 155ade8
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 40 deletions.
5 changes: 4 additions & 1 deletion backend/src/dutch_broomstick/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ def update(self, instance, validated_data):

instance.save()

Profile.objects.update_or_create(user=instance, **profile_data)
profile = Profile.objects.get(user=instance)
profile.default_account = profile_data.get('default_account', profile.default_account)
profile.default_nickname = profile_data.get('default_nickname', profile.default_nickname)
profile.save()
return instance


Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/atoms/Graph/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const Wrapper = styled.div`
padding-top: 100%;
width: 100%;
position: relative;
z-index: -1;
`

const Content = styled.div`
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/organisms/PaymentList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const PaymentList = ({ paymentlist, roomurl }) => (
{
paymentlist && paymentlist.map(
({ forWhat, fromWho, total }, idx) => (
<ListItem key={idx} title={`${forWhat}${fromWho}`} description={total} linkTo={`/room/:${roomurl}/payment_list/${forWhat}`} />
<ListItem key={idx} title={`${forWhat}${fromWho}`} description={total} linkTo={`/room/${roomurl}/payment_list/${forWhat}`} />
)
)
}
Expand Down
56 changes: 33 additions & 23 deletions frontend/src/components/pages/AccountPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,41 @@ import { Link } from 'react-router-dom'
import { Button, Header, List, Block } from 'components'
import { CopyToClipboard } from 'react-copy-to-clipboard';

const AccountPage = ({ toname, money, account }) => (
//toname = '정유석',
//money = '10000',
//account = '국민 353901-01-142611',

<div>
<Header />
<Block>
<h3>To.{toname}</h3>
<h3>{money}</h3>
<h4>{account}</h4>
</Block>
const AccountPage = ({ match, roomname, sendlist, members }) => {
const to = match.params.to
const toname = to
const edge = sendlist.find(m=> m.to == toname)
const member = members.find(m=> m.membername == toname)
console.log(members)
const money = edge.label
const account = member.account
console.log(account)
return (
//toname = '정유석',
//money = '10000',
//account = '국민 353901-01-142611',

<div>
<Header />
<Block>
<h3>To.{toname}</h3>
<h3>{money}</h3>
<h4>{account}</h4>
</Block>

<CopyToClipboard
text={`${account} ${toname}`}
onCopy={() => { }}>
<span>
<Button>
Copy Account!
</Button>
</span>
</CopyToClipboard>
<CopyToClipboard
text={`${account} ${toname} ${money}`}
onCopy={() => { }}>
<span>
<Button>
Copy Account!
</Button>
</span>
</CopyToClipboard>

</div>
)
</div>
)
}


export default AccountPage
5 changes: 1 addition & 4 deletions frontend/src/components/pages/RoomPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const SettingButton = styled(LinkButton)`
height: 32px;
width: 32px;
cursor: pointer;
z-index: 1;
`

const RoomPage = props => {
Expand Down Expand Up @@ -64,9 +63,7 @@ const RoomPage = props => {
(<PaymentList />) :
(members && <MemberList />)
}
<Block transparent>
<a>로그아웃</a>
</Block>

</div>
)
}
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/pages/SignUpPage/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React from 'react'
import { Link } from 'react-router-dom'

import { Block } from 'components'
import { Block, Header } from 'components'
import { SignUpForm } from 'containers'

const SignUpPage = (props) => {
return (
<div>
<Header />
<Block>
<h1>Dutch Broomstick</h1>
<SignUpForm />
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/pages/UserInfoPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

import React from 'react'
import { UserInfoForm } from 'containers'
import { Block } from 'components'
import { Block, Header } from 'components'

const UserInfoPage = (props) => {
return (
<div>
<Header />
<Block>
<h1>개인정보 변경</h1>
<UserInfoForm />
Expand Down
21 changes: 13 additions & 8 deletions frontend/src/containers/AccountPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import { connect } from 'react-redux'
import { AccountPage } from 'components'
import { Redirect } from 'react-router-dom'


class AccountPageContainer extends React.Component {

/*
componentDidMount(){
const { roomname, toname, member, money, account, onAccoutPage } = this.props
onAccoutPage(toname)
onAccoutPage(toname,member)
}

*/
render(){

/*
Expand All @@ -31,7 +33,7 @@ class AccountPageContainer extends React.Component {
}
*/
return (
<AccountPage {...props} />
<AccountPage {...this.props} />
)

}
Expand All @@ -41,16 +43,19 @@ class AccountPageContainer extends React.Component {
const mapStateToProps = (state) => ({

roomname : state.room.room.roomname,
sendlist: state.payment.sendlist,
members : state.member.members

toname : state.payment.senddata.to,
member: state.member.members,
money : state.payment.senddata.label,
account : state.payment.account,
//toname : state.payment.senddata.to,
//member: state.member.members,

//money : state.payment.senddata.label,
//account : state.payment.account,

})

const mapDispatchToProps = dispatch => ({
onAccoutPage: (toname,member) => dispatch(accountinRequest(toname,member)),
//onAccoutPage: (toname,member) => dispatch(accountinRequest(toname,member)),
})

export default connect(mapStateToProps,mapDispatchToProps)(AccountPageContainer)
3 changes: 2 additions & 1 deletion frontend/src/containers/UserInfoForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export default connect(mapStateToProps)(
reduxForm({
form: 'UserInfoChange',
onSubmit(values, dispatch, props) {
dispatch(userInfoChangeRequest(values.password, values.name, values.account, props.username, props.token))
dispatch(userInfoChangeRequest(values.password, values.default_nickname, values.default_account, props.username, props.token))
console.log(values)
}
})(UserInfoFormContainer)
)
Expand Down
1 change: 1 addition & 0 deletions frontend/src/services/simplifier/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const getSimplifiedGraph = debts => {
const indice = members.slice() // 배열 복사
while (indice.length) {
const first = indice[0], last = indice[indice.length - 1]
if(debts[first] === 0) break;
const amount = Math.min(
debts[first], -debts[last]
)
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/store/payment/sagas.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { fork, takeEvery, put } from 'redux-saga/effects'
import { push, replace } from 'connected-react-router'
import api from 'services/api'

import * as actions from './actions'
Expand All @@ -7,6 +8,7 @@ function* createRequest({ room, payment }) {
try {
const newPayment = yield api.post(`/rooms/${room.url}/layers/0/payments/`, { ...payment })
yield put(actions.paymentCreateSuccess(room, newPayment))
yield put(replace(`/room/${room.url}/`))
} catch(e) {
yield put(actions.paymentCreateFailed(yield e.response.json()))
}
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/store/user/sagas.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { push, replace } from 'connected-react-router'
import { fork, takeEvery, put } from 'redux-saga/effects'
import api from 'services/api'

Expand Down Expand Up @@ -51,8 +52,10 @@ function* watchUserSignUpRequest() {
function* userInfoChangeRequest({ username, password, default_nickname, default_account, token }) {
console.log(token)
try{
console.log(username , password, default_nickname, default_account)
const response = yield api.put(`/users/${username}/`, { username, password, default_nickname, default_account }, { token })
yield put(userInfoChangeSuccess(password, default_nickname, default_account))
yield put(replace(`/`))
} catch (e){
yield put(userInfoChangeFailed(yield e.response.json()))
}
Expand Down

0 comments on commit 155ade8

Please sign in to comment.