-});
-
-interface CollectionTagFormDataProps {
- submitting: boolean;
- invalid: boolean;
- pristine: boolean;
-}
-
-interface CollectionTagFormActionProps {
- handleSubmit: any;
-}
-
-interface TextFieldProps {
- label: string;
- floatinglabeltext: string;
- className?: string;
- input?: string;
- meta?: any;
-}
-
-type CollectionTagFormProps = CollectionTagFormDataProps & CollectionTagFormActionProps & WithStyles<CssRules>;
-
-export const CollectionTagForm = compose(
- reduxForm({
- form: COLLECTION_TAG_FORM_NAME,
- onSubmit: (data: TagProperty, dispatch: Dispatch) => {
- dispatch<any>(createCollectionTag(data));
- dispatch(reset(COLLECTION_TAG_FORM_NAME));
- }
- }),
- withStyles(styles))(
-
- class CollectionTagForm extends React.Component<CollectionTagFormProps> {
-
- render() {
- const { classes, submitting, pristine, invalid, handleSubmit } = this.props;
- return (
- <form className={classes.form} onSubmit={handleSubmit}>
- <Field name="key"
- disabled={submitting}
- component={this.renderTextField}
- floatinglabeltext="Key"
- validate={TAG_KEY_VALIDATION}
- className={classes.textField}
- label="Key" />
- <Field name="value"
- disabled={submitting}
- component={this.renderTextField}
- floatinglabeltext="Value"
- validate={TAG_VALUE_VALIDATION}
- className={classes.textField}
- label="Value" />
- <div className={classes.buttonWrapper}>
- <Button type="submit" className={classes.saveButton}
- color="primary"
- size='small'
- disabled={invalid || submitting || pristine}
- variant="contained">
- ADD
- </Button>
- {submitting && <CircularProgress size={20} className={classes.circularProgress} />}
- </div>
- </form>
- );
- }
-
- renderTextField = ({ input, label, meta: { touched, error }, ...custom }: TextFieldProps) => (
- <TextField
- helperText={touched && error}
- label={label}
- className={this.props.classes.textField}
- error={touched && !!error}
- autoComplete='off'
- {...input}
- {...custom}
- />
- )
-
- }
-
- );