Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Gnito committed Nov 14, 2024
1 parent 26441b5 commit e6a3d5a
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 33 deletions.
8 changes: 7 additions & 1 deletion src/config/configListing.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,13 @@ export const listingFields = [
* - stockType This is relevant only to listings using default-purchase process.
* If set to 'oneItem', stock management is not showed and the listing is
* considered unique (stock = 1).
* Possible values: 'oneItem' and 'multipleItems'.
* Possible values: 'oneItem', 'multipleItems', 'infiniteOneItem', and 'infiniteMultipleItems'.
* Default: 'multipleItems'.
* - availabilityType This is relevant only to listings using default-booking process.
* If set to 'oneSeat', seat management is not showed and the listing is
* considered per person (seat = 1).
* Possible values: 'oneSeat' and 'multipleSeats'.
* Default: 'oneSeat'.
* - defaultListingFields These are tied to transaction processes. Different processes have different flags.
* E.g. default-inquiry can toggle price and location to true/false value to indicate,
* whether price (or location) tab should be shown. If defaultListingFields.price is not
Expand All @@ -270,6 +275,7 @@ export const listingTypes = [
alias: 'default-booking/release-1',
unitType: 'day',
},
availabilityType: 'oneSeat',
defaultListingFields: {
location: true,
payoutDetails: true,
Expand Down
13 changes: 8 additions & 5 deletions src/containers/EditListingPage/EditListingPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const listingTypesBookingDay = [
alias: 'default-booking/release-1',
},
unitType: 'day',
availabilityType: 'oneSeat',
},
];
const listingTypesBookingNightly = [
Expand All @@ -49,6 +50,7 @@ const listingTypesBookingNightly = [
alias: 'default-booking/release-1',
},
unitType: 'night',
availabilityType: 'oneSeat',
},
];
const listingTypesBookingHourly = [
Expand All @@ -59,6 +61,7 @@ const listingTypesBookingHourly = [
alias: 'default-booking/release-1',
},
unitType: 'hour',
availabilityType: 'oneSeat',
},
];
const listingTypesPurchase = [
Expand Down Expand Up @@ -1631,10 +1634,10 @@ describe('EditListingPage', () => {
getByRole('heading', { name: /EditListingAvailabilityPanel.WeeklyCalendar.scheduleTitle/i })
).toBeInTheDocument();

// Expect mon - sat to be available (6 days) and sunday to be blocked.
expect(queryAllByText('EditListingAvailabilityPanel.WeeklyCalendar.available')).toHaveLength(
6
);
// // Expect mon - sat to be available (6 days) and sunday to be blocked.
// expect(queryAllByText('EditListingAvailabilityPanel.WeeklyCalendar.available')).toHaveLength(
// 6
// );
const sunday = getByText('Sunday');
const cell = sunday.parentNode.parentNode;
const siblingContent = within(cell.nextElementSibling); // next cell in the grid
Expand Down Expand Up @@ -1785,7 +1788,7 @@ describe('EditListingPage', () => {
);
const sunday = getByText('Sunday');
const cellSun = sunday.parentNode.parentNode;
expect(cellSun.nextElementSibling.getElementsByClassName('availabilityDot')).toHaveLength(0);
expect(cellSun.nextElementSibling.getElementsByClassName('availabilityDot')).toHaveLength(1);

// button to add an exception
expect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const EditListingAvailabilityExceptionForm = props => {
seats,
} = values;
const hasMultipleSeatsInUSe =
listingTypeConfig.availabilityType === AVAILABILITY_MULTIPLE_SEATS;
listingTypeConfig?.availabilityType === AVAILABILITY_MULTIPLE_SEATS;
const hasSeats = hasMultipleSeatsInUSe ? seats != null : availability;

const { updateListingError } = fetchErrors || {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ const EditListingAvailabilityPanel = props => {
const listingTypeConfig = listingTypes.find(conf => conf.listingType === listingType);

const useFullDays = isFullDay(unitType);
const useMultipleSeats = listingTypeConfig.availabilityType === AVAILABILITY_MULTIPLE_SEATS;
const useMultipleSeats = listingTypeConfig?.availabilityType === AVAILABILITY_MULTIPLE_SEATS;

const hasAvailabilityPlan = !!listingAttributes?.availabilityPlan;
const isPublished = listing?.id && listingAttributes?.state !== LISTING_STATE_DRAFT;
Expand Down Expand Up @@ -216,7 +216,7 @@ const EditListingAvailabilityPanel = props => {

return (
<main className={classes}>
<H3 as="h1">
<H3 as="h1" className={css.heading}>
{isPublished ? (
<FormattedMessage
id="EditListingAvailabilityPanel.title"
Expand Down Expand Up @@ -319,7 +319,6 @@ const EditListingAvailabilityPanel = props => {
fetchErrors={errors}
useFullDays={useFullDays}
useMultipleSeats={useMultipleSeats}
listingTypeConfig={listingTypeConfig}
unitType={unitType}
/>
</Modal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
flex-direction: column;
}

.heading {
padding: 0;
margin-bottom: 24px;
@media (--viewportMedium) {
margin-bottom: 16px;
}
}

.sectionHeader {
display: flex;
flex-direction: row;
Expand All @@ -18,25 +26,34 @@

@media (--viewportMedium) {
align-items: baseline;
padding: 5px 0 3px 0;
padding: 3px 0 5px 0;
gap: 8px;
margin-top: 0;
}
}

.planInfo {
margin-bottom: 24px;

@media (--viewportMedium) {
padding: 1px 0 7px 0;
padding: 5px 0 3px 0;
margin-bottom: 8px;
}
}

.section {
margin: 24px 0 0 0;
margin: 0 0 24px 0;

@media (--viewportMedium) {
margin: 0 0 32px 0;
}
}

.editPlanButton {
display: block;
padding: 4px 0 2px 0;
margin: 0;
padding: 1px 0 5px 0;

@media (--viewportMedium) {
padding: 5px 0 3px 0;
}
Expand All @@ -48,7 +65,8 @@
margin: 0 0 24px 0;

@media (--viewportMedium) {
padding: 3px 0 5px 0;
display: block;
padding: 1px 0 7px 0;
margin: 0 0 72px 0;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,6 @@ EditListingAvailabilityPlanFormComponent.propTypes = {
fetchErrors: object.isRequired,

listingTitle: string.isRequired,

listingTypeConfig: shape({
availabilityType: oneOf(['oneSeat', 'multipleSeats']).isRequired,
}).isRequired,
};

const EditListingAvailabilityPlanForm = EditListingAvailabilityPlanFormComponent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,18 @@ const DayScheduleEntry = ({
const seats = range.seats;
const isAvailable = range.seats > 0;
const setBy = range.exception ? 'exception' : 'plan';
const startOfDay = getStartOf(range.start, 'day', timeZone);
const startOfNextDay = getStartOf(range.start, 'day', timeZone, 1, 'days');
const startsAtTheStartOfDay = isSameDate(range.start, startOfDay);
const endsAtTheEndOfDay = isSameDate(range.end, startOfNextDay);
const isFullDay = startsAtTheStartOfDay && endsAtTheEndOfDay;

if (!isAvailable && setBy === 'plan') {
if (!isAvailable && !isFullDay && setBy === 'plan') {
// Don't show blocked time-ranges, when it comes from the default schedule.
// This is mainly done to make date schedules shorter
return null;
}

const isFullDay =
isSameDate(range.start, getStartOf(range.start, 'day', timeZone)) &&
isSameDate(range.end, getStartOf(range.start, 'day', timeZone, 1, 'days'));

const ex = range.exception;
const exception = ex ? (
<ExceptionEntry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
display: flex;
align-items: center;
justify-content: center;
padding: 6px 8px;
padding: 6.5px 8.5px;
border: solid 1px var(--colorGrey100);
cursor: pointer;

Expand All @@ -77,7 +77,7 @@
}

@media (--viewportMedium) {
padding: 11px 13px;
padding: 11.5px 13px;
}
}
.prev {
Expand All @@ -99,12 +99,11 @@
border-right: solid 1px var(--colorGrey100);
border-left: solid 1px var(--colorGrey100);
border-radius: var(--borderRadiusMedium);
margin-top: 17px;
margin-top: 24px;

@media (--viewportMedium) {
grid-template-columns: auto 1fr;
/* this takes border-top into account */
margin-top: 15px;
margin-top: 16px;
}
}

Expand Down Expand Up @@ -149,7 +148,7 @@
padding: 4px 0 2px 0;

@media (--viewportMedium) {
padding: 8px 0 0 0;
padding: 0;
}
}

Expand Down Expand Up @@ -177,7 +176,7 @@
margin: 0;

@media (--viewportMedium) {
padding: 3px 0 5px 0;
padding: 0;
}
}

Expand All @@ -198,7 +197,13 @@

.dayEntry {
display: inline-flex;
margin-bottom: 8px;
padding: 3px 0 3px 0;
margin-bottom: 6px;

@media (--viewportMedium) {
padding: 6px 0 2px 0;
margin-bottom: 8px;
}
}

.deleteIconWrapper {
Expand All @@ -215,10 +220,12 @@
border: 0;
padding: 0px 8px;
cursor: pointer;
display: inline-block;
}

.exception {
display: inline-flex;
align-items: baseline;

&:hover > .timeRange {
color: var(--colorBlack);
Expand Down
2 changes: 1 addition & 1 deletion src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
"EditListingAvailabilityExceptionForm.notAvailable": "Not available",
"EditListingAvailabilityExceptionForm.title": "Add an availability exception",
"EditListingAvailabilityPanel.WeeklyCalendar.available": "Available",
"EditListingAvailabilityPanel.WeeklyCalendar.exception": "Exception {seats, plural, =0 {(not available):} other {(available):}} {exception}",
"EditListingAvailabilityPanel.WeeklyCalendar.exception": "Exception: {exception}",
"EditListingAvailabilityPanel.WeeklyCalendar.fetchExceptionsError": "Fetching availability exception data failed",
"EditListingAvailabilityPanel.WeeklyCalendar.notAvailable": "Not available",
"EditListingAvailabilityPanel.WeeklyCalendar.scheduleTitle": "Schedule for",
Expand Down
1 change: 1 addition & 0 deletions src/util/configHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,7 @@ const validListingTypes = listingTypes => {
...restOfTransactionType,
},
// e.g. stockType
availabilityType: 'multipleSeats', // 'oneSeat', //'multipleSeats',
...restOfListingType,
},
];
Expand Down

0 comments on commit e6a3d5a

Please sign in to comment.