mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-29 05:00:43 +10:00
Use displayStart and dislayEnd (Booking entity)
This commit is contained in:
parent
ce9d61adc2
commit
97c7654073
4 changed files with 30 additions and 6 deletions
|
|
@ -40,9 +40,13 @@ const BookingPeriod = props => {
|
|||
const LineItemBookingPeriod = props => {
|
||||
const { transaction, booking, unitType } = props;
|
||||
|
||||
const { start: startDate, end: endDateRaw } = booking.attributes;
|
||||
const localStartDate = dateFromAPIToLocalNoon(startDate);
|
||||
const localEndDateRaw = dateFromAPIToLocalNoon(endDateRaw);
|
||||
// Attributes: displayStart and displayEnd can be used to differentiate shown time range
|
||||
// from actual start and end times used for availability reservation. It can help in situations
|
||||
// where there are preparation time needed between bookings.
|
||||
// Read more: https://www.sharetribe.com/api-reference/#bookings
|
||||
const { start, end, displayStart, displayEnd } = booking.attributes;
|
||||
const localStartDate = dateFromAPIToLocalNoon(displayStart || start);
|
||||
const localEndDateRaw = dateFromAPIToLocalNoon(displayEnd || end);
|
||||
|
||||
const isNightly = unitType === LINE_ITEM_NIGHT;
|
||||
const isDaily = unitType === LINE_ITEM_DAY;
|
||||
|
|
|
|||
|
|
@ -136,9 +136,13 @@ export const txState = (intl, tx, type) => {
|
|||
};
|
||||
|
||||
const bookingData = (unitType, tx, isOrder, intl) => {
|
||||
const { start, end } = tx.booking.attributes;
|
||||
const startDate = dateFromAPIToLocalNoon(start);
|
||||
const endDateRaw = dateFromAPIToLocalNoon(end);
|
||||
// Attributes: displayStart and displayEnd can be used to differentiate shown time range
|
||||
// from actual start and end times used for availability reservation. It can help in situations
|
||||
// where there are preparation time needed between bookings.
|
||||
// Read more: https://www.sharetribe.com/api-reference/#bookings
|
||||
const { start, end, displayStart, displayEnd } = tx.booking.attributes;
|
||||
const startDate = dateFromAPIToLocalNoon(displayStart || start);
|
||||
const endDateRaw = dateFromAPIToLocalNoon(displayEnd || end);
|
||||
const isDaily = unitType === LINE_ITEM_DAY;
|
||||
const isUnits = unitType === LINE_ITEM_UNITS;
|
||||
const isSingleDay = isDaily && daysBetween(startDate, endDateRaw) === 1;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,9 @@ export const createBooking = (id, attributes = {}) => ({
|
|||
type: 'booking',
|
||||
attributes: {
|
||||
start: new Date(Date.UTC(2017, 5, 10)),
|
||||
displayStart: new Date(Date.UTC(2017, 5, 10)),
|
||||
end: new Date(Date.UTC(2017, 5, 10)),
|
||||
displayEnd: new Date(Date.UTC(2017, 5, 10)),
|
||||
...attributes,
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -207,6 +207,17 @@ propTypes.ownListing = shape({
|
|||
images: arrayOf(propTypes.image),
|
||||
});
|
||||
|
||||
export const BOOKING_STATE_PENDING = 'pending';
|
||||
export const BOOKING_STATE_ACCEPTED = 'accepted';
|
||||
export const BOOKING_STATE_DECLINED = 'declined';
|
||||
export const BOOKING_STATE_CANCELLED = 'cancelled';
|
||||
export const BOOKING_STATES = [
|
||||
BOOKING_STATE_PENDING,
|
||||
BOOKING_STATE_ACCEPTED,
|
||||
BOOKING_STATE_DECLINED,
|
||||
BOOKING_STATE_CANCELLED,
|
||||
];
|
||||
|
||||
// Denormalised booking object
|
||||
propTypes.booking = shape({
|
||||
id: propTypes.uuid.isRequired,
|
||||
|
|
@ -214,6 +225,9 @@ propTypes.booking = shape({
|
|||
attributes: shape({
|
||||
end: instanceOf(Date).isRequired,
|
||||
start: instanceOf(Date).isRequired,
|
||||
displayStart: instanceOf(Date),
|
||||
displayEnd: instanceOf(Date),
|
||||
state: oneOf(BOOKING_STATES),
|
||||
}),
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue