Skip to content
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

Connected react router #72

Merged
merged 7 commits into from
Jun 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions frontend/src/components/atoms/Button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const Button = styled.button`
padding: 4px 15px;
width: 100%;
max-width: 224px;
z-index: 1;
`

const LightButton = styled(Button)`
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/atoms/Header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const Wrapper = styled.div`
position: fixed;
top: 0;
width: 100%;
z-index: 2;
`

const Header = (props) => (
Expand Down
15 changes: 10 additions & 5 deletions frontend/src/components/organisms/PaymentForm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import styled from 'styled-components'
import { Link, } from 'react-router-dom'
import { Form, Field, } from 'redux-form'

import { Block, Button, FieldWithLabel, Input, Select, TwoLineBlock, } from 'components'
import { Block, Button, FieldWithLabel, Input, LinkButton, Select, TwoLineBlock, } from 'components'

const SimpleInput = props => <Input simple {...props} />

Expand Down Expand Up @@ -37,7 +37,8 @@ const PaymentForm = ({ handleSubmit, room, members, payment, amountLeft, total,
<Form onSubmit={handleSubmit}>
<Block>
<FieldWithLabel label="결제 내용" name="forWhat" type="text" component={SimpleInput} required />
<FieldWithLabel label="결제자" name="fromWho" component={Select}>
<FieldWithLabel label="결제자" name="fromWho" component={Select} required>
<option selected value="">-- 멤버 목록 --</option>
{members.map(
({ membername }) => (
<option key={membername} value={membername}>
Expand Down Expand Up @@ -70,9 +71,13 @@ const PaymentForm = ({ handleSubmit, room, members, payment, amountLeft, total,
)}
</Block>
<Block direction="row">
<Button type="button" light horizontal>
<Link to={`/room/${room.url}/`}>취소</Link>
</Button>
<LinkButton
type="button"
to={`/room/${room.url}/`}
light horizontal
>
취소
</LinkButton>
<Button type="submit" horizontal>확인</Button>
</Block>
</Form>
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/components/pages/RoomPage/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'
import styled from 'styled-components'
import PropTypes from 'prop-types'
import { CopyToClipboard } from 'react-copy-to-clipboard'

import { Block, Button, Graph, List, LinkButton, ListItem, Header } from 'components'
import { MemberList, PaymentList } from 'containers'
Expand Down Expand Up @@ -47,8 +48,11 @@ const RoomPage = props => {

return (
<div>
<Header />
<Header />
<Block transparent>
<CopyToClipboard text={window.location.href} onCopy={() => {}}>
<Button>링크 복사</Button>
</CopyToClipboard>
<Graph graph={graph} events={events} />
<SettingButton to={`/room/${room.url}/setting/`} />
</Block>
Expand All @@ -59,6 +63,7 @@ const RoomPage = props => {
(<PaymentList />) :
(members && <MemberList />)
}

</div>
)
}
Expand Down
15 changes: 14 additions & 1 deletion frontend/src/containers/PaymentForm.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'
import { connect } from 'react-redux'
import { reduxForm, formValueSelector, change } from 'redux-form'
import { toastr } from 'react-redux-toastr'
import { reduxForm, formValueSelector, change, SubmissionError } from 'redux-form'

import { PaymentForm } from 'components'
import { paymentCreateRequest } from 'store/actions'
Expand All @@ -11,6 +12,18 @@ const PaymentReduxForm = reduxForm({
form: FORM_NAME,
onSubmit(values, dispatch) {
const { room, ...payment } = values
const validationError = message => {
toastr.light(
"결제 추가 오류", message,
{ icon: 'error', status: 'error' }
)
throw new SubmissionError({ _error: message})
}

if (payment.total !== payment.credits.map(c => c.amount).reduce((a,b)=>(a+b),0)) {
validationError("남은 돈이 0이 아닙니다!")
}

dispatch(paymentCreateRequest(room, payment))
}
})(PaymentForm)
Expand Down