forked from freeCodeCamp/pantry-for-good
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(freeCodeCamp#119-4)Instead of having the EIN field hard coded there …
…could be a settings section for extra receipt related fields, similar to the create donation items fields and household section on the customer application
- Loading branch information
1 parent
24ad8bc
commit 85914a5
Showing
7 changed files
with
120 additions
and
12 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,96 @@ | ||
import React from 'react' | ||
import {Clearfix, Col, Row, Button} from 'react-bootstrap' | ||
|
||
import {Box, BoxBody, BoxHeader} from '../../../components/box' | ||
import {RFFieldGroup} from '../../../components/form' | ||
|
||
import { FieldArray } from 'redux-form' | ||
|
||
/*const renderField = ({ input, label, type, meta: { touched, error } }) => ( | ||
<div> | ||
<label>{label}</label> | ||
<div> | ||
<input {...input} type={type} placeholder={label} className="form-control" /> | ||
{touched && error && <span>{error}</span>} | ||
</div> | ||
</div> | ||
)*/ | ||
|
||
const renderRow = ({ fields, meta: { error, submitFailed } }) => ( | ||
<BoxBody> | ||
<h4>Receipt Fields:</h4> | ||
{fields.map((receiptField, index) => ( | ||
<Row key={index}> | ||
<Col lg={3}> | ||
<RFFieldGroup | ||
name={`${receiptField}.name`} | ||
type="text" | ||
//component={renderField} | ||
placeholder="Name" | ||
style={{ | ||
flexGrow: 1, | ||
margin: '10px 0 0 0' | ||
}} | ||
/> | ||
</Col> | ||
<Col lg={3}> | ||
<RFFieldGroup | ||
name={`${receiptField}.value`} | ||
type="text" | ||
//component={renderField} | ||
placeholder="Value" | ||
style={{ | ||
flexGrow: 1, | ||
margin: '10px 0 0 0' | ||
}} | ||
/> | ||
</Col> | ||
<Col lg={3}> | ||
<Button | ||
type="button" | ||
title="Remove ReceiptField" | ||
onClick={() => fields.remove(index)} | ||
className="btn" | ||
style={{ | ||
margin: '18px 0 0px 18px', | ||
height: '34px' | ||
}} | ||
> | ||
<i className="fa fa-trash" /> | ||
</Button> | ||
</Col> | ||
<Clearfix visibleSmBlock visibleMdBlock /> | ||
</Row> | ||
))} | ||
<Row> | ||
<Button | ||
type="button" | ||
onClick={() => fields.push({})} | ||
className="btn" | ||
style={{ | ||
margin: '15px 0px 0px 15px', | ||
height: '34px' | ||
}} | ||
> | ||
Add Field | ||
</Button> | ||
{submitFailed && error && <span>{error}</span>} | ||
</Row> | ||
</BoxBody> | ||
) | ||
|
||
const ReceiptFields = props => { | ||
const { handleSubmit /*, pristine, reset, submitting */ } = props | ||
return ( | ||
<Box> | ||
<BoxHeader heading="General Receipt Fields" /> | ||
<form onSubmit={handleSubmit} > | ||
<div className="form-group"> | ||
<FieldArray name="receiptFields" component={renderRow} /> | ||
</div> | ||
</form> | ||
</Box> | ||
) | ||
} | ||
|
||
export default ReceiptFields |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,5 @@ export default async function sendEmail( | |
path: '/v3/mail/send', | ||
body: mail.toJSON() | ||
}) | ||
|
||
return sg.API(request) | ||
} |
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