Use ListingLink component in ManageListingCard

This commit is contained in:
Kimmo Puputti 2018-01-30 14:55:13 +02:00
parent faf31af6ed
commit 27e6686e8c
2 changed files with 25 additions and 13 deletions

View file

@ -16,7 +16,7 @@ import {
MenuLabel,
MenuContent,
MenuItem,
NamedLink,
ListingLink,
IconSpinner,
ResponsiveImage,
} from '../../components';
@ -76,7 +76,6 @@ export const ManageListingCardComponent = props => {
const { title = '', price, state } = currentListing.attributes;
const isPendingApproval = state === LISTING_STATE_PENDING_APPROVAL;
const isClosed = state === LISTING_STATE_CLOSED;
const slug = createSlug(title);
const firstImage =
currentListing.images && currentListing.images.length > 0 ? currentListing.images[0] : null;
@ -178,11 +177,8 @@ export const ManageListingCardComponent = props => {
[css.titlePending]: isPendingApproval,
});
const linkName = isPendingApproval ? 'ListingPageVariant' : 'ListingPage';
const linkParams = isPendingApproval ? { id, slug, variant: 'pending-approval' } : { id, slug };
return (
<NamedLink className={classes} name={linkName} params={linkParams}>
<ListingLink className={classes} listing={listing}>
<div className={css.threeToTwoWrapper}>
<div className={css.aspectWrapper}>
<ResponsiveImage
@ -267,7 +263,7 @@ export const ManageListingCardComponent = props => {
<FormattedMessage id="ManageListingCard.edit" />
</button>
</div>
</NamedLink>
</ListingLink>
);
};

View file

@ -1,13 +1,29 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`ManageListingCard matches snapshot 1`] = `
<NamedLink
<ListingLink
className=""
name="ListingPage"
params={
listing={
Object {
"id": "listing1",
"slug": "listing1-title",
"attributes": Object {
"deleted": false,
"description": "listing1 description",
"geolocation": LatLng {
"lat": 40,
"lng": 60,
},
"price": Money {
"amount": 5500,
"currency": "USD",
},
"publicData": Object {},
"state": "published",
"title": "listing1 title",
},
"id": UUID {
"uuid": "listing1",
},
"type": "ownListing",
}
}
>
@ -131,5 +147,5 @@ exports[`ManageListingCard matches snapshot 1`] = `
/>
</button>
</div>
</NamedLink>
</ListingLink>
`;