Skip to content

Commit

Permalink
(freeCodeCamp#119-4)Instead of having the EIN field hard coded there …
Browse files Browse the repository at this point in the history
…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
ronaldblanco committed Oct 9, 2017
1 parent 24ad8bc commit 81c8c3e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
11 changes: 9 additions & 2 deletions client/modules/settings/components/General.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,15 @@ const General = () =>
</Col>
<Col lg={3}>
<RFFieldGroup
name="EIN"
label="EIN"
name="receiptFields.name"
label="Receipt Fields Name"
type="text"
/>
</Col>
<Col lg={3}>
<RFFieldGroup
name="receiptFields.value"
label="Receipt Fields Value"
type="text"
/>
</Col>
Expand Down
4 changes: 3 additions & 1 deletion server/controllers/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ export default {
}

const location = await locateAddress(req.body.address)
const receiptFields = req.body.receiptFields

if (!location) return next(new ValidationError({address: 'Address not found'}))

const settings = {
...req.body,
location
location,
receiptFields
}

const count = await Settings.count()
Expand Down
14 changes: 14 additions & 0 deletions server/models/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ import locationSchema from './location-schema'

const {Schema} = mongoose

const receiptFieldSchema = new Schema({
name: {
type: String,
required: true
},
value: {
type: String,
required: true
}
}, {
_id: false
})

const SettingsSchema = new Schema({
organization: {
type: String,
Expand All @@ -27,6 +40,7 @@ const SettingsSchema = new Schema({
trim: true
},
location: locationSchema,
receiptFields: [receiptFieldSchema],
gmapsApiKey: {
type: String,
trim: true,
Expand Down

0 comments on commit 81c8c3e

Please sign in to comment.