diff --git a/src/components/ManageListingCard/ManageListingCard.js b/src/components/ManageListingCard/ManageListingCard.js index 0a4a25c3..d3d2352b 100644 --- a/src/components/ManageListingCard/ManageListingCard.js +++ b/src/components/ManageListingCard/ManageListingCard.js @@ -73,7 +73,7 @@ export const ManageListingCardComponent = props => { const classes = classNames(rootClassName || css.root, className); const currentListing = ensureListing(listing); const id = currentListing.id.uuid; - const { title = '', price, open } = currentListing.attributes; + const { title = '', price, closed } = currentListing.attributes; const slug = createSlug(title); const firstImage = currentListing.images && currentListing.images.length > 0 ? currentListing.images[0] @@ -87,7 +87,7 @@ export const ManageListingCardComponent = props => { const { formattedPrice, priceTitle } = priceData(price, intl); /* eslint-disable jsx-a11y/no-static-element-interactions */ - const closedOverlay = open + const closedOverlay = !closed ? null :
{
: null; - const showClosedListingHelpText = currentListing.id && !currentListing.attributes.open; + const showClosedListingHelpText = currentListing.id && currentListing.attributes.closed; const bookingHeading = (

@@ -297,7 +297,7 @@ export class ListingPageComponent extends Component { ); const handleBookingSubmit = values => { - const isClosed = !currentListing.attributes.open; + const isClosed = currentListing.attributes.closed; if (isOwnListing || isClosed) { window.scrollTo(0, 0); } else { @@ -310,7 +310,7 @@ export class ListingPageComponent extends Component { const listingClasses = classNames(css.pageRoot); const handleBookButtonClick = () => { - const isClosed = !currentListing.attributes.open; + const isClosed = currentListing.attributes.closed; if (isOwnListing || isClosed) { window.scrollTo(0, 0); } else { @@ -324,7 +324,7 @@ export class ListingPageComponent extends Component { ?
e.stopPropagation()}>
@@ -430,7 +430,7 @@ export class ListingPageComponent extends Component {

{bookingHeading} - {currentListing.attributes.open + {!currentListing.attributes.closed ?
- {currentListing.attributes.open + {!currentListing.attributes.closed ? diff --git a/src/containers/OrderPage/__snapshots__/OrderPage.test.js.snap b/src/containers/OrderPage/__snapshots__/OrderPage.test.js.snap index c536d8b2..b244fd37 100644 --- a/src/containers/OrderPage/__snapshots__/OrderPage.test.js.snap +++ b/src/containers/OrderPage/__snapshots__/OrderPage.test.js.snap @@ -117,12 +117,13 @@ exports[`OrderPage matches snapshot 1`] = ` "listing": Object { "attributes": Object { "address": "listing1 address", + "closed": false, + "deleted": false, "description": "listing1 description", "geolocation": LatLng { "lat": 40, "lng": 60, }, - "open": true, "price": Money { "amount": 5500, "currency": "USD", diff --git a/src/containers/SalePage/__snapshots__/SalePage.test.js.snap b/src/containers/SalePage/__snapshots__/SalePage.test.js.snap index 78860035..981103b4 100644 --- a/src/containers/SalePage/__snapshots__/SalePage.test.js.snap +++ b/src/containers/SalePage/__snapshots__/SalePage.test.js.snap @@ -124,12 +124,13 @@ exports[`SalePage matches snapshot 1`] = ` "listing": Object { "attributes": Object { "address": "listing1 address", + "closed": false, + "deleted": false, "description": "listing1 description", "geolocation": LatLng { "lat": 40, "lng": 60, }, - "open": true, "price": Money { "amount": 5500, "currency": "USD", diff --git a/src/util/propTypes.js b/src/util/propTypes.js index dec852be..e89e6446 100644 --- a/src/util/propTypes.js +++ b/src/util/propTypes.js @@ -22,7 +22,7 @@ import Decimal from 'decimal.js'; import { types as sdkTypes } from './sdkLoader'; const { UUID, LatLng, LatLngBounds, Money } = sdkTypes; -const { arrayOf, bool, func, instanceOf, number, oneOf, oneOfType, shape, string } = PropTypes; +const { arrayOf, bool, func, instanceOf, number, oneOf, shape, string } = PropTypes; // Fixed value export const value = val => oneOf([val]); @@ -108,24 +108,19 @@ export const image = shape({ }), }); -const listingAttributes = shape({ - title: string.isRequired, - description: string.isRequired, - address: string.isRequired, - geolocation: latlng.isRequired, - open: bool.isRequired, - price: money, -}); - -const deletedListingAttributes = shape({ - deleted: value(true).isRequired, -}); - // Denormalised listing object export const listing = shape({ id: uuid.isRequired, type: value('listing').isRequired, - attributes: oneOfType([listingAttributes, deletedListingAttributes]).isRequired, + attributes: shape({ + title: string.isRequired, + description: string.isRequired, + address: string.isRequired, + geolocation: latlng.isRequired, + closed: bool.isRequired, + deleted: bool.isRequired, + price: money, + }).isRequired, author: user, images: arrayOf(image), }); diff --git a/src/util/test-data.js b/src/util/test-data.js index e91f69db..5086bd02 100644 --- a/src/util/test-data.js +++ b/src/util/test-data.js @@ -78,7 +78,8 @@ export const createListing = (id, attributes = {}, includes = {}) => ({ description: `${id} description`, address: `${id} address`, geolocation: new LatLng(40, 60), - open: true, + closed: false, + deleted: false, price: new Money(5500, 'USD'), ...attributes, },