import React, { PropTypes } from 'react';
import { FormattedDate, FormattedMessage } from 'react-intl';
import * as propTypes from '../../util/propTypes';
import { createSlug } from '../../util/urlHelpers';
import { types } from '../../util/sdkLoader';
import { Avatar, BookingInfo, NamedLink } from '../../components';
import css from './OrderDetailsPanel.css';
const OrderDetailsPanel = props => {
const {
className,
totalPrice,
orderState,
lastTransitionedAt,
booking,
listing,
provider,
} = props;
const { firstName, lastName } = provider.attributes.profile;
const providerName = firstName ? `${firstName} ${lastName}` : '';
const listingLinkParams = { id: listing.id.uuid, slug: createSlug(listing.attributes.title) };
const listingLink = (
{listing.attributes.title}
);
// TODO We can't use price from listing, since that might have changed.
// When API includes unit price and possible additional fees, we need to change this.
const unitPrice = listing.attributes.price;
const bookingInfo = unitPrice
?
:
{'priceRequiredMessage'}
;
// orderState affects to both title and message section
let stateMsgData = {};
switch (orderState) {
case propTypes.TX_STATE_PREAUTHORIZED:
stateMsgData = {
title: (
),
message: (
),
};
break;
case propTypes.TX_STATE_ACCEPTED:
stateMsgData = {
title: (
),
message: (
),
};
break;
case propTypes.TX_STATE_REJECTED:
stateMsgData = {
title: (
),
message: (
),
};
break;
case propTypes.TX_STATE_DELIVERED:
stateMsgData = {
title: (
),
message: (
),
};
break;
default:
stateMsgData = { title: null, message: null };
}
return (
{stateMsgData.title}
{bookingInfo}
);
};
OrderDetailsPanel.defaultProps = { className: null };
const { instanceOf, string } = PropTypes;
OrderDetailsPanel.propTypes = {
className: string,
totalPrice: instanceOf(types.Money).isRequired,
orderState: string.isRequired,
lastTransitionedAt: instanceOf(Date).isRequired,
booking: propTypes.booking.isRequired,
listing: propTypes.listing.isRequired,
provider: propTypes.user.isRequired,
};
export default OrderDetailsPanel;