bukazu-portal-react 3.3.3 → 3.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/build/index.css +1 -1
  2. package/build/portal.es.js +19931 -20259
  3. package/build/portal.umd.js +80 -82
  4. package/package.json +9 -7
  5. package/.env.development +0 -1
  6. package/.eslintrc +0 -25
  7. package/.github/dependabot.yml +0 -11
  8. package/.github/workflows/node.js.yml +0 -31
  9. package/.github/workflows/npm-publish.yml +0 -33
  10. package/.nvmrc +0 -1
  11. package/.prettierrc +0 -6
  12. package/.vscode/settings.json +0 -24
  13. package/CHANGELOG.MD +0 -93
  14. package/babel.config.json +0 -6
  15. package/calendar.html +0 -16
  16. package/coverage/clover.xml +0 -28
  17. package/coverage/coverage-final.json +0 -2
  18. package/coverage/lcov-report/base.css +0 -224
  19. package/coverage/lcov-report/block-navigation.js +0 -87
  20. package/coverage/lcov-report/favicon.png +0 -0
  21. package/coverage/lcov-report/helper.ts.html +0 -142
  22. package/coverage/lcov-report/index.html +0 -116
  23. package/coverage/lcov-report/prettify.css +0 -1
  24. package/coverage/lcov-report/prettify.js +0 -2
  25. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  26. package/coverage/lcov-report/sorter.js +0 -196
  27. package/coverage/lcov.info +0 -36
  28. package/cypress/e2e/.examples/actions.spec.js +0 -299
  29. package/cypress/e2e/.examples/aliasing.spec.js +0 -39
  30. package/cypress/e2e/.examples/assertions.spec.js +0 -177
  31. package/cypress/e2e/.examples/connectors.spec.js +0 -97
  32. package/cypress/e2e/.examples/cookies.spec.js +0 -77
  33. package/cypress/e2e/.examples/cypress_api.spec.js +0 -202
  34. package/cypress/e2e/.examples/files.spec.js +0 -89
  35. package/cypress/e2e/.examples/local_storage.spec.js +0 -52
  36. package/cypress/e2e/.examples/location.spec.js +0 -32
  37. package/cypress/e2e/.examples/misc.spec.js +0 -104
  38. package/cypress/e2e/.examples/navigation.spec.js +0 -56
  39. package/cypress/e2e/.examples/network_requests.spec.js +0 -163
  40. package/cypress/e2e/.examples/querying.spec.js +0 -114
  41. package/cypress/e2e/.examples/spies_stubs_clocks.spec.js +0 -205
  42. package/cypress/e2e/.examples/traversal.spec.js +0 -121
  43. package/cypress/e2e/.examples/utilities.spec.js +0 -110
  44. package/cypress/e2e/.examples/viewport.spec.js +0 -59
  45. package/cypress/e2e/.examples/waiting.spec.js +0 -31
  46. package/cypress/e2e/.examples/window.spec.js +0 -22
  47. package/cypress/e2e/booking.spec.js +0 -81
  48. package/cypress/e2e/calendar.spec.js +0 -21
  49. package/cypress/e2e/search.spec.js +0 -25
  50. package/cypress/fixtures/example.json +0 -5
  51. package/cypress/plugins/index.js +0 -16
  52. package/cypress/support/commands.js +0 -25
  53. package/cypress/support/commands.ts +0 -37
  54. package/cypress/support/component-index.html +0 -12
  55. package/cypress/support/component.ts +0 -39
  56. package/cypress/support/e2e.js +0 -20
  57. package/cypress.config.ts +0 -15
  58. package/dev.tsx +0 -44
  59. package/index.html +0 -15
  60. package/invalid-calendar.html +0 -16
  61. package/jest.config.js +0 -195
  62. package/postcss.config.js +0 -17
  63. package/reviews.html +0 -16
  64. package/src/_lib/SearchQueries.ts +0 -145
  65. package/src/_lib/Tracking.ts +0 -51
  66. package/src/_lib/countries/de.json +0 -998
  67. package/src/_lib/countries/en.json +0 -998
  68. package/src/_lib/countries/es.json +0 -998
  69. package/src/_lib/countries/fr.json +0 -998
  70. package/src/_lib/countries/it.json +0 -998
  71. package/src/_lib/countries/nl.json +0 -998
  72. package/src/_lib/countries.ts +0 -15
  73. package/src/_lib/date_helper.ts +0 -27
  74. package/src/_lib/queries.ts +0 -244
  75. package/src/components/App.tsx +0 -108
  76. package/src/components/AppContext.ts +0 -14
  77. package/src/components/CalendarPage/BookingForm.tsx +0 -49
  78. package/src/components/CalendarPage/Calendar.tsx +0 -49
  79. package/src/components/CalendarPage/CalendarPage.tsx +0 -43
  80. package/src/components/CalendarPage/CalendarParts/CalendarContext.tsx +0 -89
  81. package/src/components/CalendarPage/CalendarParts/CalendarHeader.tsx +0 -72
  82. package/src/components/CalendarPage/CalendarParts/DayClasses.ts +0 -113
  83. package/src/components/CalendarPage/CalendarParts/GenerateCalendar.tsx +0 -72
  84. package/src/components/CalendarPage/CalendarParts/Legend.tsx +0 -33
  85. package/src/components/CalendarPage/CalendarParts/MonthHeader.tsx +0 -15
  86. package/src/components/CalendarPage/CalendarParts/Months.tsx +0 -37
  87. package/src/components/CalendarPage/CalendarParts/RenderCells.tsx +0 -97
  88. package/src/components/CalendarPage/CalendarParts/SingleMonth.tsx +0 -72
  89. package/src/components/CalendarPage/CalendarParts/StartBooking.tsx +0 -17
  90. package/src/components/CalendarPage/CalendarParts/WeekDays.tsx +0 -27
  91. package/src/components/CalendarPage/FormCreator.tsx +0 -230
  92. package/src/components/CalendarPage/FormItems/Date.tsx +0 -61
  93. package/src/components/CalendarPage/FormItems/NumberSelect.tsx +0 -39
  94. package/src/components/CalendarPage/FormItems/Select.tsx +0 -38
  95. package/src/components/CalendarPage/FormItems/index.ts +0 -4
  96. package/src/components/CalendarPage/PriceField/Price.tsx +0 -58
  97. package/src/components/CalendarPage/PriceField/Queries.ts +0 -23
  98. package/src/components/CalendarPage/PriceField/index.tsx +0 -129
  99. package/src/components/CalendarPage/Summary/CostRow.tsx +0 -58
  100. package/src/components/CalendarPage/Summary/CostSection.tsx +0 -15
  101. package/src/components/CalendarPage/Summary/CostSummary.tsx +0 -61
  102. package/src/components/CalendarPage/Summary/Description.tsx +0 -27
  103. package/src/components/CalendarPage/Summary/InsurancesAndRequired.tsx +0 -68
  104. package/src/components/CalendarPage/Summary/Object.tsx +0 -59
  105. package/src/components/CalendarPage/Summary/OnSite.tsx +0 -36
  106. package/src/components/CalendarPage/Summary/OptionalNotOnSite.tsx +0 -43
  107. package/src/components/CalendarPage/Summary/OptionalOnSite.tsx +0 -39
  108. package/src/components/CalendarPage/Summary/Queries.ts +0 -31
  109. package/src/components/CalendarPage/Summary/RentAndDiscount.tsx +0 -30
  110. package/src/components/CalendarPage/Summary/Totals.tsx +0 -89
  111. package/src/components/CalendarPage/Summary/cost_types.d.ts +0 -31
  112. package/src/components/CalendarPage/Summary/index.tsx +0 -24
  113. package/src/components/CalendarPage/calender_types.d.ts +0 -16
  114. package/src/components/CalendarPage/formParts/AssistanceMessage.tsx +0 -60
  115. package/src/components/CalendarPage/formParts/BookingHelpers.tsx +0 -47
  116. package/src/components/CalendarPage/formParts/BookingOrOption.tsx +0 -35
  117. package/src/components/CalendarPage/formParts/CancelInsuranceText.tsx +0 -69
  118. package/src/components/CalendarPage/formParts/DefaultBookingFields.ts +0 -105
  119. package/src/components/CalendarPage/formParts/DiscountCode.tsx +0 -62
  120. package/src/components/CalendarPage/formParts/Guests.tsx +0 -77
  121. package/src/components/CalendarPage/formParts/OptionalBookingFields.tsx +0 -148
  122. package/src/components/CalendarPage/formParts/OptionalCosts.tsx +0 -103
  123. package/src/components/CalendarPage/formParts/SuccessMessage.tsx +0 -31
  124. package/src/components/CalendarPage/formParts/Validations.tsx +0 -64
  125. package/src/components/CalendarPage/formParts/discount.tsx +0 -69
  126. package/src/components/CalendarPage/formParts/form_types.d.ts +0 -38
  127. package/src/components/CalendarPage/formParts/insurances.tsx +0 -62
  128. package/src/components/CalendarPage/formParts/radioButtons.tsx +0 -66
  129. package/src/components/Error/ApiError.tsx +0 -33
  130. package/src/components/Error/IntegrationError.tsx +0 -62
  131. package/src/components/Error/index.ts +0 -4
  132. package/src/components/ErrorBoundary.tsx +0 -34
  133. package/src/components/Modal/index.tsx +0 -46
  134. package/src/components/ReviewsPage/Queries.ts +0 -26
  135. package/src/components/ReviewsPage/ReviewsPage.tsx +0 -45
  136. package/src/components/ReviewsPage/Score.tsx +0 -29
  137. package/src/components/ReviewsPage/SingleReview.tsx +0 -38
  138. package/src/components/ReviewsPage/note.tsx +0 -17
  139. package/src/components/SafeBooking.tsx +0 -96
  140. package/src/components/SearchPage/Field.tsx +0 -75
  141. package/src/components/SearchPage/Filters.tsx +0 -91
  142. package/src/components/SearchPage/Paginator.tsx +0 -63
  143. package/src/components/SearchPage/Results.tsx +0 -129
  144. package/src/components/SearchPage/SearchPage.tsx +0 -115
  145. package/src/components/SearchPage/SingleResult.tsx +0 -93
  146. package/src/components/SearchPage/filters/Categories.tsx +0 -57
  147. package/src/components/SearchPage/filters/DateFilter.tsx +0 -34
  148. package/src/components/SearchPage/filters/List.tsx +0 -80
  149. package/src/components/SearchPage/filters/NumberFilter.tsx +0 -37
  150. package/src/components/SearchPage/filters/Radio.tsx +0 -46
  151. package/src/components/SearchPage/filters/Select.tsx +0 -85
  152. package/src/components/SearchPage/filters/__tests__/helper.spec.js +0 -13
  153. package/src/components/SearchPage/filters/filter_types.d.ts +0 -25
  154. package/src/components/SearchPage/filters/helper.ts +0 -19
  155. package/src/components/icons/ArrowLeft.svg.tsx +0 -20
  156. package/src/components/icons/ArrowRight.svg.tsx +0 -16
  157. package/src/components/icons/Reload.svg.tsx +0 -23
  158. package/src/components/icons/info.svg.tsx +0 -24
  159. package/src/components/icons/loading.svg.tsx +0 -98
  160. package/src/custom.d.ts +0 -10
  161. package/src/index.tsx +0 -104
  162. package/src/locales/de.json +0 -137
  163. package/src/locales/en.json +0 -137
  164. package/src/locales/es.json +0 -132
  165. package/src/locales/fr.json +0 -132
  166. package/src/locales/it.json +0 -128
  167. package/src/locales/nl.json +0 -138
  168. package/src/styles/calendar.css +0 -317
  169. package/src/styles/datepicker.css +0 -6
  170. package/src/styles/field.css +0 -105
  171. package/src/styles/filters.css +0 -92
  172. package/src/styles/form.css +0 -219
  173. package/src/styles/main.css +0 -80
  174. package/src/styles/modal.css +0 -79
  175. package/src/styles/pagination.css +0 -92
  176. package/src/styles/price-overview.css +0 -111
  177. package/src/styles/result.css +0 -142
  178. package/src/styles/results.css +0 -50
  179. package/src/styles/reviews.css +0 -90
  180. package/src/styles/success.css +0 -9
  181. package/src/types.d.ts +0 -91
  182. package/tmp/cache/vite/last-build-production.json +0 -7
  183. package/tsconfig.json +0 -17
  184. package/vite.config.ts +0 -31
@@ -1,72 +0,0 @@
1
- import React, { useContext } from 'react';
2
- import ArrowRight from '../../icons/ArrowRight.svg';
3
- import ArrowLeft from '../../icons/ArrowLeft.svg';
4
- import Reload from '../../icons/Reload.svg';
5
- import { CalendarContextDispatch } from './CalendarContext';
6
- import { addMonths, subMonths } from 'date-fns';
7
-
8
- interface Props {
9
- changeMonth: Function;
10
- currentMonth: Date;
11
- numberOfMonths: number;
12
- }
13
-
14
- function CalendarHeader({
15
- changeMonth,
16
- currentMonth,
17
- numberOfMonths
18
- }: Props): JSX.Element {
19
- const dispatch = useContext(CalendarContextDispatch);
20
-
21
- function next() {
22
- changeMonth(addMonths(currentMonth, numberOfMonths));
23
- }
24
- function prev() {
25
- changeMonth(subMonths(currentMonth, numberOfMonths));
26
- }
27
-
28
- return (
29
- <div className="calendars-header">
30
- <div
31
- className="bu-calendar-col bu-prev"
32
- style={{ textAlign: 'center' }}
33
- onClick={prev}
34
- tabIndex={0}
35
- role="button"
36
- >
37
- <div className="icon">
38
- {' '}
39
- <ArrowLeft />
40
- </div>
41
- </div>
42
- <div
43
- className="bu-calendar-col bu-reset"
44
- onClick={() => {
45
- dispatch({
46
- type: 'reset'
47
- });
48
- }}
49
- style={{ textAlign: 'center' }}
50
- tabIndex={0}
51
- role="button"
52
- >
53
- <div className="icon">
54
- <Reload />
55
- </div>
56
- </div>
57
- <div
58
- className="bu-calendar-col bu-next"
59
- onClick={next}
60
- style={{ textAlign: 'center' }}
61
- tabIndex={0}
62
- role="button"
63
- >
64
- <div className="icon">
65
- <ArrowRight />
66
- </div>
67
- </div>
68
- </div>
69
- );
70
- }
71
-
72
- export default CalendarHeader;
@@ -1,113 +0,0 @@
1
- import {
2
- addDays,
3
- differenceInCalendarDays,
4
- isAfter,
5
- isBefore,
6
- isSameDay,
7
- isSameMonth,
8
- subDays
9
- } from 'date-fns';
10
- import { BuDate } from '../../../types';
11
- import { Parse_EN_US } from '../../../_lib/date_helper';
12
-
13
- interface Props {
14
- day: Date;
15
- monthStart: Date;
16
- prevBooked: BuDate;
17
- buDate: BuDate;
18
- dates: {
19
- selectedDate: Date;
20
- departureDate: BuDate;
21
- arrivalDate: BuDate;
22
- };
23
- house: {
24
- max_nights: Number;
25
- };
26
- discounts: [];
27
- }
28
-
29
- function DayClasses({
30
- day,
31
- monthStart,
32
- buDate,
33
- prevBooked,
34
- dates,
35
- house,
36
- discounts
37
- }: Props): string {
38
- const { selectedDate, departureDate, arrivalDate } = dates;
39
- let classes = ['bu-calendar-col', 'cell'];
40
-
41
- if (!isSameMonth(day, monthStart)) {
42
- classes.push('disabled');
43
- return classes.join(' ');
44
- }
45
- if (buDate) {
46
- if (buDate.arrival && isAfter(day, new Date()) && buDate.max_nights !== 0) {
47
- if (prevBooked.max_nights === 0) {
48
- classes.push('departure-arrival');
49
- } else {
50
- classes.push('arrival');
51
- classes.push('arrival');
52
- }
53
- } else if (buDate.max_nights === 0) {
54
- if (prevBooked.max_nights !== 0) {
55
- classes.push('booked-departure');
56
- } else {
57
- classes.push('booked');
58
- }
59
- } else if (buDate.max_nights > 0 && prevBooked.max_nights === 0 && !buDate.arrival) {
60
- classes.push('booked');
61
- }
62
- }
63
-
64
- if (selectedDate) {
65
- if (isSameDay(day, selectedDate)) {
66
- classes.push('selected');
67
- }
68
- const minimum =
69
- differenceInCalendarDays(day, selectedDate) >= arrivalDate.min_nights;
70
- const maximum =
71
- differenceInCalendarDays(day, selectedDate) <= house.max_nights &&
72
- differenceInCalendarDays(day, selectedDate) <= arrivalDate.max_nights;
73
-
74
- if (
75
- buDate.departure &&
76
- isAfter(day, selectedDate) &&
77
- minimum &&
78
- maximum &&
79
- prevBooked.max_nights !== 0
80
- ) {
81
- classes.push('departure');
82
- }
83
- }
84
-
85
- if (departureDate) {
86
- if (
87
- isAfter(day, selectedDate) &&
88
- isBefore(day, Parse_EN_US(departureDate.date))
89
- ) {
90
- classes.push('selected');
91
- }
92
- if (isSameDay(day, Parse_EN_US(departureDate.date))) {
93
- classes.push('selected');
94
- }
95
- }
96
-
97
- const daysFromToday = differenceInCalendarDays(day, new Date());
98
- const last_minute =
99
- daysFromToday <= house.last_minute_days && daysFromToday > 0;
100
-
101
- const discount = discounts.find(
102
- (x) =>
103
- isBefore(subDays(Parse_EN_US(x.discount_starts_at), 1), day) &&
104
- isAfter(addDays(Parse_EN_US(x.discount_ends_at), 1), day)
105
- );
106
- if (last_minute || discount || buDate.special_offer > 0) {
107
- classes.push('discount');
108
- }
109
-
110
- return classes.join(' ');
111
- }
112
-
113
- export default DayClasses;
@@ -1,72 +0,0 @@
1
- import { useQuery } from '@apollo/client';
2
- import React, { useContext } from 'react';
3
- import { FormattedMessage } from 'react-intl';
4
- import { HouseType, PortalSiteType } from '../../../types';
5
- import { SINGLE_HOUSE_QUERY } from '../../../_lib/queries';
6
- import { AppContext } from '../../AppContext';
7
- import { ApiError } from '../../Error';
8
- import Loading from '../../icons/loading.svg';
9
- import Calendar from '../Calendar';
10
- import { TrackEvent } from '../../../_lib/Tracking';
11
-
12
- interface Props {
13
- PortalSite: PortalSiteType;
14
- }
15
-
16
- function GenerateCalendar({ PortalSite }: Props): JSX.Element {
17
- const { portalCode, objectCode, locale } = useContext(AppContext);
18
- const { loading, error, data } = useQuery(SINGLE_HOUSE_QUERY, {
19
- variables: { portalCode, objectCode }
20
- });
21
-
22
- TrackEvent({
23
- house_code: objectCode,
24
- portal_code: portalCode,
25
- interaction_type: 'calendar_view',
26
- locale: locale
27
- });
28
-
29
- if (loading)
30
- return (
31
- <div>
32
- <Loading />
33
- </div>
34
- );
35
- if (error) {
36
- return (
37
- <div>
38
- <ApiError errors={error} />
39
- </div>
40
- );
41
- }
42
-
43
- const Results = data.PortalSite.houses;
44
- const numberOfMonths = PortalSite.options.bookingForm
45
- ? PortalSite.options.bookingForm.numberOfMonths
46
- : 4;
47
- const numberOfMonthsInARow = PortalSite.options.bookingForm
48
- ? PortalSite.options.bookingForm.numberOfMonthsInARow
49
- : 4;
50
-
51
- return (
52
- <div id="calendar-container">
53
- {Results.length === 0 && (
54
- <div>
55
- <FormattedMessage id="no_house_found" />
56
- </div>
57
- )}
58
- {Results.map((result: HouseType) => (
59
- <div key={result.id}>
60
- <div className="house-name">{result.name}</div>
61
- <Calendar
62
- numberOfMonths={numberOfMonths}
63
- numberOfMonthsInARow={numberOfMonthsInARow}
64
- house={result}
65
- />
66
- </div>
67
- ))}
68
- </div>
69
- );
70
- }
71
-
72
- export default GenerateCalendar;
@@ -1,33 +0,0 @@
1
- import React from 'react';
2
- import { FormattedMessage } from 'react-intl';
3
-
4
- interface Props {
5
- house: {
6
- house_type: string;
7
- };
8
- }
9
-
10
- function Legend({ house }: Props): JSX.Element {
11
- return (
12
- <div className="legend">
13
- <div>
14
- <span className="legend-field arrival" />
15
- <FormattedMessage id={`${house.house_type}.arrival_date`} />
16
- </div>
17
- <div>
18
- <span className="legend-field booked" />
19
- <FormattedMessage id="booked" />
20
- </div>
21
- <div>
22
- <span className="legend-field departure" />
23
- <FormattedMessage id={`${house.house_type}.departure_date`} />
24
- </div>
25
- <div>
26
- <span className="legend-field last_minute_discount" />
27
- <FormattedMessage id="discount" />
28
- </div>
29
- </div>
30
- );
31
- }
32
-
33
- export default Legend;
@@ -1,15 +0,0 @@
1
- import React from "react";
2
- import { MONTH_FORMAT, FormatIntl } from '../../../_lib/date_helper';
3
-
4
- interface Props { month: Date; }
5
-
6
- const MonthHeader = ({ month }:Props): JSX.Element => (
7
- <div className="header bu-calendar-row flex-middle">
8
- <div className="bu-calendar-col col-center" style={{ textAlign: 'center' }}>
9
- <span>{FormatIntl(month, MONTH_FORMAT)}</span>
10
- </div>
11
- </div>
12
- );
13
-
14
-
15
- export default MonthHeader
@@ -1,37 +0,0 @@
1
- import { addMonths, format } from 'date-fns';
2
- import React from 'react';
3
- import { HouseType } from '../../../types';
4
- import SingleMonth from './SingleMonth';
5
-
6
- interface Props {
7
- house: HouseType;
8
- numberOfMonths: number;
9
- numberOfMonthsInARow: number;
10
- currentMonth: Date;
11
- }
12
-
13
- function Months({
14
- numberOfMonthsInARow,
15
- currentMonth,
16
- numberOfMonths,
17
-
18
- house
19
- }: Props): JSX.Element {
20
- let template: JSX.Element[] = [];
21
-
22
- for (let i = 0; i < numberOfMonths; i++) {
23
- template.push(
24
- <SingleMonth
25
- key={format(addMonths(currentMonth, i), 'MM-yyyy')}
26
- house={house}
27
- numberOfMonthsInARow={numberOfMonthsInARow}
28
- currentMonth={currentMonth}
29
- count={i}
30
- />
31
- );
32
- }
33
-
34
- return <div className="calendars-row">{template}</div>;
35
- }
36
-
37
- export default Months;
@@ -1,97 +0,0 @@
1
- import React, { useContext } from 'react';
2
- import {
3
- addDays,
4
- endOfMonth,
5
- endOfWeek,
6
- startOfMonth,
7
- startOfWeek,
8
- subDays,
9
- isBefore,
10
- parse
11
- } from 'date-fns';
12
- import { FormatIntl } from '../../../_lib/date_helper';
13
- import DayClasses from './DayClasses';
14
- import { HouseType } from '../../../types';
15
- import { CalendarContext, CalendarContextDispatch } from './CalendarContext';
16
-
17
- interface CellProps {
18
- availabilities: [];
19
- month: Date;
20
- discounts: [];
21
- house: HouseType;
22
- }
23
-
24
- function RenderCells({
25
- availabilities,
26
- month,
27
- discounts,
28
- house
29
- }: CellProps): JSX.Element {
30
- const dispatch = useContext(CalendarContextDispatch);
31
- const dates = useContext(CalendarContext);
32
-
33
- const monthStart = startOfMonth(month);
34
- const monthEnd = endOfMonth(monthStart);
35
- const startDate = startOfWeek(monthStart);
36
- const endDate = endOfWeek(monthEnd);
37
- const rows: JSX.Element[] = [];
38
-
39
- let days: JSX.Element[] = [];
40
- let day: Date = startDate;
41
-
42
- while (day <= endDate) {
43
- // for (let daz of dayz) {
44
- for (let i = 0; i < 7; i++) {
45
- let date = FormatIntl(day, 'yyyy-MM-dd');
46
- let yesterday = FormatIntl(subDays(day, 1), 'yyyy-MM-dd');
47
- let daz = availabilities.find((x) => x.date === date);
48
-
49
- const prevBooked = availabilities.find((x) => x.date === yesterday);
50
- const cloneDay = daz;
51
-
52
- days.push(
53
- <div
54
- className={DayClasses({
55
- day,
56
- monthStart,
57
- discounts,
58
- buDate: daz,
59
- prevBooked,
60
- house,
61
- dates
62
- })}
63
- key={daz.date}
64
- role="button"
65
- tabIndex={0}
66
- onClick={() => {
67
- if (
68
- isBefore(
69
- parse(cloneDay.date, 'yyyy-MM-dd', new Date()),
70
- new Date()
71
- )
72
- ) {
73
- return;
74
- }
75
- dispatch({
76
- type: 'clicked',
77
- day: cloneDay,
78
- house
79
- });
80
- }}
81
- >
82
- <span>{FormatIntl(day, 'd')}</span>
83
- </div>
84
- );
85
- day = addDays(day, 1);
86
- }
87
- rows.push(
88
- <div className="bu-calendar-row" key={day}>
89
- {days}
90
- </div>
91
- );
92
- days = [];
93
- }
94
- return <div className="body">{rows}</div>;
95
- }
96
-
97
- export default RenderCells;
@@ -1,72 +0,0 @@
1
- import { useQuery } from '@apollo/client';
2
- import {
3
- addMonths,
4
- endOfMonth,
5
- endOfWeek,
6
- startOfMonth,
7
- startOfWeek
8
- } from 'date-fns';
9
- import React, { useContext } from 'react';
10
- import { HouseType } from '../../../types';
11
- import { CALENDAR_QUERY } from '../../../_lib/queries';
12
- import { AppContext } from '../../AppContext';
13
- import Loading from '../../icons/loading.svg';
14
- import MonthHeader from './MonthHeader';
15
- import RenderCells from './RenderCells';
16
- import WeekDays from './WeekDays';
17
-
18
- interface Props {
19
- count: number;
20
- currentMonth: Date;
21
- house: HouseType;
22
- numberOfMonthsInARow: Number;
23
- }
24
-
25
- function SingleMonth({
26
- count,
27
- currentMonth,
28
- house,
29
- numberOfMonthsInARow
30
- }: Props): JSX.Element {
31
- const { portalCode, objectCode } = useContext(AppContext);
32
-
33
- let month = addMonths(currentMonth, count);
34
- let monthStart = startOfMonth(month);
35
- let monthEnd = endOfMonth(month);
36
- const variables = {
37
- id: portalCode,
38
- house_id: objectCode,
39
- starts_at: startOfWeek(monthStart),
40
- ends_at: endOfWeek(monthEnd)
41
- };
42
-
43
- const { loading, error, data } = useQuery(CALENDAR_QUERY, { variables });
44
-
45
- if (loading)
46
- return (
47
- <div>
48
- <Loading />
49
- </div>
50
- );
51
- if (error) {
52
- return <div>Error</div>;
53
- }
54
-
55
- const results = data.PortalSite.houses[0].availabilities;
56
- const discounts = data.Discounts;
57
-
58
- return (
59
- <div className={`bu-calendar calendar calendar-${numberOfMonthsInARow}`} key={month}>
60
- <MonthHeader month={month} />
61
- <WeekDays month={month} />
62
- <RenderCells
63
- availabilities={results}
64
- discounts={discounts}
65
- month={month}
66
- house={house}
67
- />
68
- </div>
69
- );
70
- }
71
-
72
- export default SingleMonth;
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
- import { HouseType } from '../../../types';
3
- import PriceField from '../PriceField';
4
-
5
- interface Props {
6
- house: HouseType;
7
- }
8
-
9
- function StartBooking({ house }: Props): JSX.Element {
10
- return (
11
- <div className="price-overview">
12
- <PriceField house={house} />
13
- </div>
14
- );
15
- }
16
-
17
- export default StartBooking;
@@ -1,27 +0,0 @@
1
- import { startOfWeek, addDays } from "date-fns";
2
- import React from "react";
3
- import { FormatIntl } from "../../../_lib/date_helper";
4
-
5
- interface Props {
6
- month: Date
7
- }
8
-
9
- function WeekDays({ month }: Props):JSX.Element {
10
- const dateFormat = 'E';
11
- let days: JSX.Element[] = [];
12
-
13
- let startDate: Date = startOfWeek(month);
14
-
15
- for (let i = 0; i < 7; i++) {
16
- days.push(
17
- <div className="bu-calendar-col col-center" key={i}>
18
- {FormatIntl(addDays(startDate, i), dateFormat)}
19
- </div>
20
- );
21
- }
22
-
23
- return <div className="days bu-calendar-row">{days}</div>;
24
-
25
- }
26
-
27
- export default WeekDays