mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-31 02:26:50 +10:00
ManageListingCard: import routeConfiguration and remove context.flattenedRoutes
This commit is contained in:
parent
2fcd9a6e0f
commit
f22d9102af
4 changed files with 8 additions and 14 deletions
|
|
@ -22,7 +22,6 @@ export const ManageListingCardWrapped = {
|
||||||
onCloseListing: noop,
|
onCloseListing: noop,
|
||||||
onOpenListing: noop,
|
onOpenListing: noop,
|
||||||
onToggleMenu: noop,
|
onToggleMenu: noop,
|
||||||
flattenedRoutes: [],
|
|
||||||
history: { push: noop },
|
history: { push: noop },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,11 @@ import { compose } from 'redux';
|
||||||
import { withRouter } from 'react-router-dom';
|
import { withRouter } from 'react-router-dom';
|
||||||
import { FormattedMessage, intlShape, injectIntl } from 'react-intl';
|
import { FormattedMessage, intlShape, injectIntl } from 'react-intl';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
import routeConfiguration from '../../routeConfiguration';
|
||||||
import * as propTypes from '../../util/propTypes';
|
import * as propTypes from '../../util/propTypes';
|
||||||
import { formatMoney } from '../../util/currency';
|
import { formatMoney } from '../../util/currency';
|
||||||
import { ensureListing } from '../../util/data';
|
import { ensureListing } from '../../util/data';
|
||||||
import { createSlug } from '../../util/urlHelpers';
|
import { createSlug } from '../../util/urlHelpers';
|
||||||
import { withFlattenedRoutes } from '../../util/contextHelpers';
|
|
||||||
import { createResourceLocatorString } from '../../util/routes';
|
import { createResourceLocatorString } from '../../util/routes';
|
||||||
import {
|
import {
|
||||||
InlineTextButton,
|
InlineTextButton,
|
||||||
|
|
@ -46,19 +46,18 @@ const priceData = (price, intl) => {
|
||||||
return {};
|
return {};
|
||||||
};
|
};
|
||||||
|
|
||||||
const createURL = (flattenedRoutes, listing) => {
|
const createURL = (routes, listing) => {
|
||||||
const id = listing.id.uuid;
|
const id = listing.id.uuid;
|
||||||
const slug = createSlug(listing.attributes.title);
|
const slug = createSlug(listing.attributes.title);
|
||||||
const pathParams = { id, slug, type: 'edit', tab: 'description' };
|
const pathParams = { id, slug, type: 'edit', tab: 'description' };
|
||||||
|
|
||||||
return createResourceLocatorString('EditListingPage', flattenedRoutes, pathParams, {});
|
return createResourceLocatorString('EditListingPage', routes, pathParams, {});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ManageListingCardComponent = props => {
|
export const ManageListingCardComponent = props => {
|
||||||
const {
|
const {
|
||||||
className,
|
className,
|
||||||
rootClassName,
|
rootClassName,
|
||||||
flattenedRoutes,
|
|
||||||
hasClosingError,
|
hasClosingError,
|
||||||
hasOpeningError,
|
hasOpeningError,
|
||||||
history,
|
history,
|
||||||
|
|
@ -232,7 +231,7 @@ export const ManageListingCardComponent = props => {
|
||||||
onClick={event => {
|
onClick={event => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
history.push(createURL(flattenedRoutes, listing));
|
history.push(createURL(routeConfiguration(), listing));
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<FormattedMessage id="ManageListingCard.edit" />
|
<FormattedMessage id="ManageListingCard.edit" />
|
||||||
|
|
@ -248,7 +247,7 @@ ManageListingCardComponent.defaultProps = {
|
||||||
actionsInProgressListingId: null,
|
actionsInProgressListingId: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
const { arrayOf, bool, func, shape, string } = PropTypes;
|
const { bool, func, shape, string } = PropTypes;
|
||||||
|
|
||||||
ManageListingCardComponent.propTypes = {
|
ManageListingCardComponent.propTypes = {
|
||||||
className: string,
|
className: string,
|
||||||
|
|
@ -263,13 +262,10 @@ ManageListingCardComponent.propTypes = {
|
||||||
onOpenListing: func.isRequired,
|
onOpenListing: func.isRequired,
|
||||||
onToggleMenu: func.isRequired,
|
onToggleMenu: func.isRequired,
|
||||||
|
|
||||||
// from withFlattenedRoutes
|
|
||||||
flattenedRoutes: arrayOf(propTypes.route).isRequired,
|
|
||||||
|
|
||||||
// from withRouter
|
// from withRouter
|
||||||
history: shape({
|
history: shape({
|
||||||
push: func.isRequired,
|
push: func.isRequired,
|
||||||
}).isRequired,
|
}).isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default compose(withRouter, withFlattenedRoutes, injectIntl)(ManageListingCardComponent);
|
export default compose(withRouter, injectIntl)(ManageListingCardComponent);
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ describe('ManageListingCard', () => {
|
||||||
it('matches snapshot', () => {
|
it('matches snapshot', () => {
|
||||||
const tree = renderShallow(
|
const tree = renderShallow(
|
||||||
<ManageListingCardComponent
|
<ManageListingCardComponent
|
||||||
flattenedRoutes={[]}
|
|
||||||
history={{ push: noop }}
|
history={{ push: noop }}
|
||||||
listing={createListing('listing1')}
|
listing={createListing('listing1')}
|
||||||
intl={fakeIntl}
|
intl={fakeIntl}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
exports[`ManageListingCard matches snapshot 1`] = `
|
exports[`ManageListingCard matches snapshot 1`] = `
|
||||||
<withFlattenedRoutes(withRouter(NamedLink))
|
<withRouter(NamedLink)
|
||||||
className=""
|
className=""
|
||||||
name="ListingPage"
|
name="ListingPage"
|
||||||
params={
|
params={
|
||||||
|
|
@ -111,5 +111,5 @@ exports[`ManageListingCard matches snapshot 1`] = `
|
||||||
values={Object {}} />
|
values={Object {}} />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</withFlattenedRoutes(withRouter(NamedLink))>
|
</withRouter(NamedLink)>
|
||||||
`;
|
`;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue