import React from 'react'; import { bool, func, shape, string } from 'prop-types'; import { compose } from 'redux'; import { Form as FinalForm } from 'react-final-form'; import { intlShape, injectIntl, FormattedMessage } from 'react-intl'; import classNames from 'classnames'; import { propTypes } from '../../util/types'; import { autocompleteSearchRequired, autocompletePlaceSelected, composeValidators, } from '../../util/validators'; import { Form, LocationAutocompleteInputField, Button, FieldTextInput } from '../../components'; import css from './EditListingLocationForm.css'; export const EditListingLocationFormComponent = props => ( { const { className, disabled, handleSubmit, intl, invalid, pristine, saveActionMsg, updated, updateInProgress, fetchErrors, values, } = fieldRenderProps; const titleRequiredMessage = intl.formatMessage({ id: 'EditListingLocationForm.address' }); const addressPlaceholderMessage = intl.formatMessage({ id: 'EditListingLocationForm.addressPlaceholder', }); const addressRequiredMessage = intl.formatMessage({ id: 'EditListingLocationForm.addressRequired', }); const addressNotRecognizedMessage = intl.formatMessage({ id: 'EditListingLocationForm.addressNotRecognized', }); const buildingMessage = intl.formatMessage({ id: 'EditListingLocationForm.building' }); const buildingPlaceholderMessage = intl.formatMessage({ id: 'EditListingLocationForm.buildingPlaceholder', }); const { updateListingError, showListingsError } = fetchErrors || {}; const errorMessage = updateListingError ? (

) : null; const errorMessageShowListing = showListingsError ? (

) : null; const classes = classNames(css.root, className); const submitReady = updated && pristine; const submitInProgress = updateInProgress; const submitDisabled = invalid || disabled || submitInProgress; return (
{errorMessage} {errorMessageShowListing} ); }} /> ); EditListingLocationFormComponent.defaultProps = { selectedPlace: null, fetchErrors: null, }; EditListingLocationFormComponent.propTypes = { intl: intlShape.isRequired, onSubmit: func.isRequired, saveActionMsg: string.isRequired, selectedPlace: propTypes.place, updated: bool.isRequired, updateInProgress: bool.isRequired, fetchErrors: shape({ showListingsError: propTypes.error, updateListingError: propTypes.error, }), }; export default compose(injectIntl)(EditListingLocationFormComponent);