From 64a4b24fcfb308f35cf283bebefee753d329fa48 Mon Sep 17 00:00:00 2001 From: "Hung Q. Le" Date: Sun, 4 Feb 2018 14:03:42 +0700 Subject: [PATCH 1/6] Added InvoiceID component to the form --- app/components/form/InvoiceID.jsx | 67 +++++++++++++++++++++++++++++++ app/containers/Form.jsx | 9 +++++ 2 files changed, 76 insertions(+) create mode 100644 app/components/form/InvoiceID.jsx diff --git a/app/components/form/InvoiceID.jsx b/app/components/form/InvoiceID.jsx new file mode 100644 index 00000000..03d7ca73 --- /dev/null +++ b/app/components/form/InvoiceID.jsx @@ -0,0 +1,67 @@ +// Libraries +import React, { PureComponent } from 'react'; +import PropTypes from 'prop-types'; + +// Custom Components +import { Section } from '../shared/Section'; + +// Animation +import _withFadeInAnimation from '../shared/hoc/_withFadeInAnimation'; + +// Styles +import styled from 'styled-components'; +const NoteContent = styled.textarea` + min-height: 36px; + border-radius: 4px; + padding: 10px; + display: block; + width: 100%; + border: 1px solid #f2f3f4; + color: #3a3e42; + font-size: 14px; +`; + +// Component +export class InvoiceID extends PureComponent { + constructor(props) { + super(props); + this.state = { invoiceID: this.props.invoiceID }; + this.handleInputChange = this.handleInputChange.bind(this); + } + + componentWillReceiveProps(nextProps) { + if (nextProps.invoiceID === "") { + this.setState({ invoiceID: "" }); + } + } + + handleInputChange(event) { + this.setState({ invoiceID: event.target.value }, () => { + this.props.updateFieldData('invoiceID', this.state.invoiceID); + }); + } + + render() { + const { t } = this.props; + return ( +
+ + +
+ ); + } +} + +InvoiceID.propTypes = { + invoiceID: PropTypes.string.isRequired, + t: PropTypes.func.isRequired, + updateFieldData: PropTypes.func.isRequired, +}; + +// Export +export default _withFadeInAnimation(InvoiceID); diff --git a/app/containers/Form.jsx b/app/containers/Form.jsx index 304ed3de..efc37fd8 100644 --- a/app/containers/Form.jsx +++ b/app/containers/Form.jsx @@ -19,6 +19,7 @@ import Discount from '../components/form/Discount'; import DueDate from '../components/form/DueDate'; import Tax from '../components/form/Tax'; import Note from '../components/form/Note'; +import InvoiceID from '../components/form/InvoiceID'; import Settings from '../components/form/Settings'; import Button from '../components/shared/Button'; import _withFadeInAnimation from '../components/shared/hoc/_withFadeInAnimation'; @@ -50,6 +51,7 @@ class Form extends PureComponent { discount, tax, note, + invoiceID, settings, savedSettings, } = this.props.currentInvoice; @@ -89,6 +91,13 @@ class Form extends PureComponent { savedSettings={savedSettings.required_fields} updateSavedSettings={updateSavedFormSettings} /> + {required_fields.invoiceID && ( + + )} {required_fields.dueDate && ( From 193e741ab49a990c4bb24b2c99362c1221a02bc3 Mon Sep 17 00:00:00 2001 From: "Hung Q. Le" Date: Sun, 4 Feb 2018 14:04:51 +0700 Subject: [PATCH 2/6] Added setting to toggle invoiceID field --- app.js | 1 + app/components/form/Settings.jsx | 9 +++++++++ app/components/settings/Invoice.jsx | 13 ++++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index 2543265f..fc5de341 100644 --- a/app.js +++ b/app.js @@ -200,6 +200,7 @@ function setInitialValues() { amount: 0, }, required_fields: { + invoiceID: false, dueDate: false, currency: false, discount: false, diff --git a/app/components/form/Settings.jsx b/app/components/form/Settings.jsx index 6d0bcbf8..180fb681 100644 --- a/app/components/form/Settings.jsx +++ b/app/components/form/Settings.jsx @@ -138,6 +138,15 @@ class Settings extends PureComponent { + + + + + {t('settings:fields:requiredFields')}
+ + + + -