new CustomersAdd()
React component that creates new a Customer into the database.
React component that creates new a Customer into the database
- Source:
Extends
- React.Component
Members
-
entity
Entity name which this component represents to.
-
Entity name which this component represents to
- Source:
-
foundation
access to foundation instance.
-
access to foundation instance
- Source:
-
pagination
default pagination to list data.
-
default pagination to list data
- Source:
-
state
component state.
-
component state
- Source:
Methods
-
<static> handleChangeFieldValue(event)
Event handler that change form field values and set it state
-
Parameters:
Name Type Description event
event The HTML event triggered on User interation - Source:
Example
handleChangeFieldValue(e) { const newHash = { ...this.state.customer } const name = e.target.id || e.target.name const value = e.target.value newHash[name] = value if (name === 'cards') { if (value !== '') { newHash[name] = [value] } else { newHash[name] = [] } } this.setState({ customer: newHash }) }
-
<async, static> handleFormSubmit(event)
Event handler that handles the form submission
-
Parameters:
Name Type Description event
event The HTML event triggered on User interation - Source:
Example
async handleFormSubmit(e) { const { Customer } = this.foundation.data if (!this.form.checkValidity()) { // console.log('not validated') } e.preventDefault() e.stopPropagation() this.form.classList.add('was-validated') const doc = { ...this.state.customer } const { data, error } = await Customer.add(doc) if (error) { swal('Database error', error.message, 'error') return } this.setState({ toDashboard: true }) }
-
<async, static> render()
Component render function.
-
Renders a form to create the Customer data
- Source: