mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-27 09:13:14 +10:00
EditListingWizard panels: pass all errors as fetchErrors to Final Form
This commit is contained in:
parent
f7efde7baf
commit
2a31ccc458
6 changed files with 29 additions and 23 deletions
|
|
@ -1,9 +1,10 @@
|
|||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { bool, func, object, string } from 'prop-types';
|
||||
import classNames from 'classnames';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import { ensureOwnListing } from '../../util/data';
|
||||
import { ListingLink } from '../../components';
|
||||
import { LISTING_STATE_DRAFT } from '../../util/types';
|
||||
import { EditListingDescriptionForm } from '../../forms';
|
||||
import config from '../../config';
|
||||
|
||||
|
|
@ -26,7 +27,8 @@ const EditListingDescriptionPanel = props => {
|
|||
const currentListing = ensureOwnListing(listing);
|
||||
const { description, title, publicData } = currentListing.attributes;
|
||||
|
||||
const panelTitle = currentListing.id ? (
|
||||
const isPublished = currentListing.id && currentListing.attributes.state !== LISTING_STATE_DRAFT;
|
||||
const panelTitle = isPublished ? (
|
||||
<FormattedMessage
|
||||
id="EditListingDescriptionPanel.title"
|
||||
values={{ listingTitle: <ListingLink listing={listing} /> }}
|
||||
|
|
@ -54,19 +56,18 @@ const EditListingDescriptionPanel = props => {
|
|||
}}
|
||||
onChange={onChange}
|
||||
updated={panelUpdated}
|
||||
updateError={errors.updateListingError}
|
||||
updateInProgress={updateInProgress}
|
||||
fetchErrors={errors}
|
||||
categories={config.custom.categories}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const { func, object, string, bool } = PropTypes;
|
||||
|
||||
EditListingDescriptionPanel.defaultProps = {
|
||||
className: null,
|
||||
rootClassName: null,
|
||||
errors: null,
|
||||
listing: null,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
|
|||
import classNames from 'classnames';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
|
||||
import { LISTING_STATE_DRAFT } from '../../util/types';
|
||||
import { ensureListing } from '../../util/data';
|
||||
import { EditListingFeaturesForm } from '../../forms';
|
||||
import { ListingLink } from '../../components';
|
||||
|
|
@ -28,7 +29,8 @@ const EditListingFeaturesPanel = props => {
|
|||
const currentListing = ensureListing(listing);
|
||||
const { publicData } = currentListing.attributes;
|
||||
|
||||
const panelTitle = currentListing.id ? (
|
||||
const isPublished = currentListing.id && currentListing.attributes.state !== LISTING_STATE_DRAFT;
|
||||
const panelTitle = isPublished ? (
|
||||
<FormattedMessage
|
||||
id="EditListingFeaturesPanel.title"
|
||||
values={{ listingTitle: <ListingLink listing={listing} /> }}
|
||||
|
|
@ -58,8 +60,8 @@ const EditListingFeaturesPanel = props => {
|
|||
onChange={onChange}
|
||||
saveActionMsg={submitButtonText}
|
||||
updated={panelUpdated}
|
||||
updateError={errors.updateListingError}
|
||||
updateInProgress={updateInProgress}
|
||||
fetchErrors={errors}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import React, { Component } from 'react';
|
|||
import PropTypes from 'prop-types';
|
||||
import classNames from 'classnames';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import { LISTING_STATE_DRAFT } from '../../util/types';
|
||||
import { ensureOwnListing } from '../../util/data';
|
||||
import { ListingLink } from '../../components';
|
||||
import { EditListingLocationForm } from '../../forms';
|
||||
|
|
@ -58,7 +59,9 @@ class EditListingLocationPanel extends Component {
|
|||
const classes = classNames(rootClassName || css.root, className);
|
||||
const currentListing = ensureOwnListing(listing);
|
||||
|
||||
const panelTitle = currentListing.id ? (
|
||||
const isPublished =
|
||||
currentListing.id && currentListing.attributes.state !== LISTING_STATE_DRAFT;
|
||||
const panelTitle = isPublished ? (
|
||||
<FormattedMessage
|
||||
id="EditListingLocationPanel.title"
|
||||
values={{ listingTitle: <ListingLink listing={listing} /> }}
|
||||
|
|
@ -95,8 +98,8 @@ class EditListingLocationPanel extends Component {
|
|||
onChange={onChange}
|
||||
saveActionMsg={submitButtonText}
|
||||
updated={panelUpdated}
|
||||
updateError={errors.updateListingError}
|
||||
updateInProgress={updateInProgress}
|
||||
fetchErrors={errors}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import React, { Component } from 'react';
|
|||
import PropTypes from 'prop-types';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import classNames from 'classnames';
|
||||
import { LISTING_STATE_DRAFT } from '../../util/types';
|
||||
import { EditListingPhotosForm } from '../../forms';
|
||||
import { ensureOwnListing } from '../../util/data';
|
||||
import { ListingLink } from '../../components';
|
||||
|
|
@ -32,7 +33,9 @@ class EditListingPhotosPanel extends Component {
|
|||
const classes = classNames(rootClass, className);
|
||||
const currentListing = ensureOwnListing(listing);
|
||||
|
||||
const panelTitle = currentListing.id ? (
|
||||
const isPublished =
|
||||
currentListing.id && currentListing.attributes.state !== LISTING_STATE_DRAFT;
|
||||
const panelTitle = isPublished ? (
|
||||
<FormattedMessage
|
||||
id="EditListingPhotosPanel.title"
|
||||
values={{ listingTitle: <ListingLink listing={listing} /> }}
|
||||
|
|
@ -48,7 +51,7 @@ class EditListingPhotosPanel extends Component {
|
|||
className={css.form}
|
||||
disabled={fetchInProgress}
|
||||
ready={newListingCreated}
|
||||
errors={errors}
|
||||
fetchErrors={errors}
|
||||
initialValues={{ images }}
|
||||
images={images}
|
||||
onImageUpload={onImageUpload}
|
||||
|
|
@ -61,7 +64,6 @@ class EditListingPhotosPanel extends Component {
|
|||
onRemoveImage={onRemoveImage}
|
||||
saveActionMsg={submitButtonText}
|
||||
updated={panelUpdated}
|
||||
updateError={errors.updateListingError}
|
||||
updateInProgress={updateInProgress}
|
||||
/>
|
||||
</div>
|
||||
|
|
@ -82,13 +84,7 @@ EditListingPhotosPanel.defaultProps = {
|
|||
EditListingPhotosPanel.propTypes = {
|
||||
className: string,
|
||||
rootClassName: string,
|
||||
errors: shape({
|
||||
createListingsError: object,
|
||||
updateListingError: object,
|
||||
showListingsError: object,
|
||||
uploadImageError: object,
|
||||
createStripeAccountError: object,
|
||||
}),
|
||||
errors: object,
|
||||
fetchInProgress: bool.isRequired,
|
||||
newListingCreated: bool.isRequired,
|
||||
images: array,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import React from 'react';
|
|||
import PropTypes from 'prop-types';
|
||||
import classNames from 'classnames';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import { LISTING_STATE_DRAFT } from '../../util/types';
|
||||
import { ensureOwnListing } from '../../util/data';
|
||||
import { ListingLink } from '../../components';
|
||||
import { EditListingPoliciesForm } from '../../forms';
|
||||
|
|
@ -25,7 +26,8 @@ const EditListingPoliciesPanel = props => {
|
|||
const currentListing = ensureOwnListing(listing);
|
||||
const { publicData } = currentListing.attributes;
|
||||
|
||||
const panelTitle = currentListing.id ? (
|
||||
const isPublished = currentListing.id && currentListing.attributes.state !== LISTING_STATE_DRAFT;
|
||||
const panelTitle = isPublished ? (
|
||||
<FormattedMessage
|
||||
id="EditListingPoliciesPanel.title"
|
||||
values={{ listingTitle: <ListingLink listing={listing} /> }}
|
||||
|
|
@ -53,8 +55,8 @@ const EditListingPoliciesPanel = props => {
|
|||
onChange={onChange}
|
||||
saveActionMsg={submitButtonText}
|
||||
updated={panelUpdated}
|
||||
updateError={errors.updateListingError}
|
||||
updateInProgress={updateInProgress}
|
||||
fetchErrors={errors}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import React from 'react';
|
|||
import PropTypes from 'prop-types';
|
||||
import classNames from 'classnames';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import { LISTING_STATE_DRAFT } from '../../util/types';
|
||||
import { ListingLink } from '../../components';
|
||||
import { EditListingPricingForm } from '../../forms';
|
||||
import { ensureOwnListing } from '../../util/data';
|
||||
|
|
@ -29,7 +30,8 @@ const EditListingPricingPanel = props => {
|
|||
const currentListing = ensureOwnListing(listing);
|
||||
const { price } = currentListing.attributes;
|
||||
|
||||
const panelTitle = currentListing.id ? (
|
||||
const isPublished = currentListing.id && currentListing.attributes.state !== LISTING_STATE_DRAFT;
|
||||
const panelTitle = isPublished ? (
|
||||
<FormattedMessage
|
||||
id="EditListingPricingPanel.title"
|
||||
values={{ listingTitle: <ListingLink listing={listing} /> }}
|
||||
|
|
@ -47,8 +49,8 @@ const EditListingPricingPanel = props => {
|
|||
onChange={onChange}
|
||||
saveActionMsg={submitButtonText}
|
||||
updated={panelUpdated}
|
||||
updateError={errors.updateListingError}
|
||||
updateInProgress={updateInProgress}
|
||||
fetchErrors={errors}
|
||||
/>
|
||||
) : (
|
||||
<div className={css.priceCurrencyInvalid}>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue