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,15 +0,0 @@
1
- import nl from './countries/nl.json'
2
- import en from './countries/en.json'
3
- import de from './countries/de.json'
4
- import fr from './countries/fr.json'
5
- import es from './countries/es.json'
6
- import it from './countries/it.json'
7
-
8
- export const Countries = {
9
- en,
10
- nl,
11
- de,
12
- fr,
13
- es,
14
- it
15
- };
@@ -1,27 +0,0 @@
1
-
2
- import { format, parse } from 'date-fns';
3
- import { es, nl, de, fr, it, enGB } from 'date-fns/locale';
4
-
5
- const locales: any = {
6
- en: enGB,
7
- nl,
8
- de,
9
- fr,
10
- it,
11
- es,
12
- };
13
-
14
- function FormatIntl(date: number, formatStr: string) : String {
15
- return format(date, formatStr, {
16
- locale: locales[window.__localeId__], // or global.__localeId__
17
- });
18
- };
19
-
20
- function Parse_EN_US(date_string: string) {
21
- return parse(date_string, 'yyyy-MM-dd', new Date());
22
- }
23
-
24
- const MONTH_FORMAT:string = 'MMMM yyyy';
25
- const LONG_DATE_FORMAT:string = 'EEEE dd MMMM yyyy'
26
-
27
- export { FormatIntl, Parse_EN_US, MONTH_FORMAT, LONG_DATE_FORMAT };
@@ -1,244 +0,0 @@
1
- import { gql } from '@apollo/client';
2
-
3
- export const PORTAL_QUERY = gql`
4
- query PortalSiteQuery($id: ID!) {
5
- PortalSite(id: $id) {
6
- id
7
- portal_code
8
- options
9
- countries {
10
- id
11
- name
12
- }
13
- regions {
14
- id
15
- name
16
- country_id
17
- }
18
- cities {
19
- id
20
- name
21
- region
22
- country_id
23
- }
24
- extra_search
25
- max_bathrooms
26
- max_bedrooms
27
- max_nights
28
- max_persons
29
- max_weekprice
30
- country_placeholder
31
- categories
32
- countries_label
33
- country_placeholder
34
- regions_label
35
- cities_label
36
- arrival_date_label
37
- departure_date_label
38
- max_weekprice_label
39
- persons_min_label
40
- persons_max_label
41
- bedrooms_min_label
42
- bathrooms_min_label
43
- weekprice_max_label
44
- no_nights_label
45
- extra_search_label
46
- properties_label
47
- }
48
- }
49
- `;
50
-
51
- export const CALENDAR_QUERY = gql`
52
- query PortalSiteHousesQuery(
53
- $id: ID!
54
- $house_id: String!
55
- $starts_at: Date!
56
- $ends_at: Date!
57
- ) {
58
- PortalSite(id: $id) {
59
- id
60
- houses(house_code: $house_id) {
61
- id
62
- name
63
- last_minute_days
64
- availabilities(starts_at: $starts_at, ends_at: $ends_at) {
65
- arrival
66
- arrival_time_from
67
- arrival_time_to
68
- date
69
- departure
70
- departure_time
71
- max_nights
72
- min_nights
73
- special_offer
74
- }
75
- }
76
- }
77
- Discounts(
78
- house_code: $house_id
79
- discount_starts_at: $ends_at
80
- discount_ends_at: $starts_at
81
- active_today: true
82
- ) {
83
- name
84
- discount_starts_at
85
- discount_ends_at
86
- }
87
- }
88
- `;
89
-
90
- export const BOOKING_PRICE_QUERY = gql`
91
- query BookingFormQuery(
92
- $portalCode: ID!
93
- $objectCode: String!
94
- $starts_at: Date!
95
- $ends_at: Date!
96
- ) {
97
- PortalSite(id: $portalCode) {
98
- id
99
- options
100
- first_name_label
101
- preposition_label
102
- last_name_label
103
- email_label
104
- zipcode_label
105
- city_label
106
- address_label
107
- house_number_label
108
- phone_label
109
- phone_mobile_label
110
- country_label
111
- iban_label
112
- holder_label
113
- bic_label
114
- comment_label
115
- company_name_label
116
- extra_fields_drivers_license_label
117
- extra_fields_destination_label
118
- form_submit_text
119
- form_submit_button_text
120
- booking_fields {
121
- id
122
- label
123
- field_type
124
- options
125
- placeholder
126
- }
127
- houses(house_code: $objectCode) {
128
- id
129
- name
130
- code
131
- allow_option
132
- persons
133
- image_url
134
- discounts
135
- discounts_info
136
- house_type
137
- rental_terms
138
- cancel_insurance
139
- damage_insurance
140
- damage_insurance_required
141
- travel_insurance
142
- babies_extra
143
- booking_price(starts_at: $starts_at, ends_at: $ends_at)
144
- }
145
- }
146
- }
147
- `;
148
-
149
- export const CREATE_BOOKING_MUTATION = gql`
150
- mutation CreateBooking(
151
- $first_name: String!
152
- $preposition: String
153
- $last_name: String!
154
- $company_name: String
155
- $is_option: Boolean!
156
- $address: String
157
- $house_number: String
158
- $zipcode: String
159
- $city: String
160
- $phone: String
161
- $phone_mobile: String
162
- $iban: String
163
- $bic: String
164
- $holder: String
165
- $email: String!
166
- $house_code: String!
167
- $portal_code: String
168
- $language: String
169
- $country: String!
170
- $adults: Int!
171
- $children: Int
172
- $babies: Int
173
- $discount: Int
174
- $damage_insurance: Int
175
- $cancel_insurance: Int
176
- $travel_insurance: Int
177
- $discount_reason: String
178
- $discount_code: String
179
- $comment: String
180
- $arrival_date: String!
181
- $departure_date: String!
182
- $costs: Json
183
- $extra_fields: String
184
- $sessionIdentifier: String
185
- ) {
186
- createBooking(
187
- first_name: $first_name
188
- preposition: $preposition
189
- company_name: $company_name
190
- last_name: $last_name
191
- is_option: $is_option
192
- address: $address
193
- house_number: $house_number
194
- zipcode: $zipcode
195
- city: $city
196
- phone: $phone
197
- phone_mobile: $phone_mobile
198
- iban: $iban
199
- bic: $bic
200
- holder: $holder
201
- email: $email
202
- house_code: $house_code
203
- portal_code: $portal_code
204
- language: $language
205
- country: $country
206
- adults: $adults
207
- children: $children
208
- babies: $babies
209
- discount: $discount
210
- discount_code: $discount_code
211
- damage_insurance: $damage_insurance
212
- cancel_insurance: $cancel_insurance
213
- travel_insurance: $travel_insurance
214
- discount_reason: $discount_reason
215
- arrival_date: $arrival_date
216
- departure_date: $departure_date
217
- comment: $comment
218
- costs: $costs
219
- extra_fields: $extra_fields
220
- sessionIdentifier: $sessionIdentifier
221
- ) {
222
- booking_nr
223
- }
224
- }
225
- `;
226
-
227
- export const SINGLE_HOUSE_QUERY = gql`
228
- query PortalSiteSingleHouseQuery($portalCode: ID!, $objectCode: String!) {
229
- PortalSite(id: $portalCode) {
230
- id
231
- houses(house_code: $objectCode) {
232
- id
233
- code
234
- name
235
- max_nights
236
- last_minute_days
237
- discounts
238
- discounts_info
239
- house_type
240
- persons
241
- }
242
- }
243
- }
244
- `;
@@ -1,108 +0,0 @@
1
- import React, { useContext } from 'react';
2
- import Loading from './icons/loading.svg';
3
-
4
- import 'react-date-picker/dist/DatePicker.css';
5
- import 'react-calendar/dist/Calendar.css';
6
-
7
- import { PORTAL_QUERY } from '../_lib/queries';
8
-
9
- import SearchPage from './SearchPage/SearchPage';
10
- import CalendarPage from './CalendarPage/CalendarPage';
11
- import ReviewsPage from './ReviewsPage/ReviewsPage';
12
- import SafeBooking from './SafeBooking';
13
- import { ApiError } from './Error';
14
- import ErrorBoundary from './ErrorBoundary';
15
- import { useQuery } from '@apollo/client';
16
- import { AppContext } from './AppContext';
17
- import { FiltersType } from './SearchPage/filters/filter_types';
18
-
19
- interface Props {
20
- pageType?: string;
21
- filters?: FiltersType;
22
- locale: string;
23
- }
24
-
25
- function App({ pageType, locale, filters }: Props): JSX.Element {
26
- const { portalCode, objectCode } = useContext(AppContext);
27
-
28
- const { loading, error, data } = useQuery(PORTAL_QUERY, {
29
- variables: { id: portalCode }
30
- });
31
-
32
- if (loading) {
33
- return <Loading />;
34
- }
35
-
36
- if (error) {
37
- return <ApiError errors={{ ...error }} />;
38
- }
39
-
40
- const PortalSite = data.PortalSite;
41
- let options = data.PortalSite.options;
42
-
43
- let root = document.documentElement;
44
-
45
- root.style.setProperty(
46
- '--bukazu-discount',
47
- `${options.colors ? options.colors.discount : 'orange'}`
48
- );
49
- root.style.setProperty(
50
- '--bukazu-cell',
51
- `${options.colors ? options.colors.cell : '#fff'}`
52
- );
53
- root.style.setProperty(
54
- '--bukazu-arrival',
55
- `${options.colors ? options.colors.arrival : '#6eeb83'}`
56
- );
57
- root.style.setProperty(
58
- '--bukazu-booked',
59
- `${options.colors ? options.colors.booked : '#ea2b1f'}`
60
- );
61
- root.style.setProperty(
62
- '--bukazu-departure',
63
- `${options.colors ? options.colors.departure : 'yellow'}`
64
- );
65
-
66
- root.style.setProperty(
67
- '--bukazu-button',
68
- `${options.colors ? options.colors.button : 'rgba(23, 190, 187, 0.75)'}`
69
- );
70
- root.style.setProperty(
71
- '--bukazu-button_cta',
72
- `${options.colors ? options.colors.buttonCta : '#e28413'}`
73
- );
74
- root.style.setProperty(
75
- '--bukazu-background_month',
76
- `${options.colors ? options.colors.month_background : '#e28413'}`
77
- );
78
-
79
- let page;
80
-
81
- if (objectCode && objectCode !== null && pageType !== 'reviews') {
82
- page = (
83
- <ErrorBoundary>
84
- <CalendarPage PortalSite={PortalSite} />
85
- <SafeBooking />
86
- </ErrorBoundary>
87
- );
88
- } else if (objectCode && objectCode !== null && pageType === 'reviews') {
89
- page = <ReviewsPage />;
90
- } else {
91
- page = (
92
- <SearchPage
93
- PortalSite={PortalSite}
94
- locale={locale}
95
- options={options}
96
- filters={filters}
97
- />
98
- );
99
- }
100
-
101
- return <>{page}</>;
102
- }
103
-
104
- App.defaultProps = {
105
- filters: {}
106
- };
107
-
108
- export default App;
@@ -1,14 +0,0 @@
1
- import { createContext } from 'react';
2
- import { LocaleType } from '../types';
3
-
4
- export const AppContext = createContext<AppContextType>({
5
- locale: 'nl',
6
- portalCode: '',
7
- objectCode: ''
8
- });
9
-
10
- type AppContextType = {
11
- locale: LocaleType;
12
- portalCode: string;
13
- objectCode: string;
14
- };
@@ -1,49 +0,0 @@
1
- import React, { useContext } from 'react';
2
- import Loading from '../icons/loading.svg';
3
- import FormCreator from './FormCreator';
4
- import { BOOKING_PRICE_QUERY } from '../../_lib/queries';
5
- import { useQuery } from '@apollo/client';
6
- import { AppContext } from '../AppContext';
7
- import { CalendarContext } from './CalendarParts/CalendarContext';
8
- import { TrackEvent } from '../../_lib/Tracking';
9
-
10
- function BookingForm(): JSX.Element {
11
- const { portalCode, objectCode, locale } = useContext(AppContext);
12
- const { arrivalDate, departureDate } = useContext(CalendarContext);
13
-
14
- const { data, loading, error } = useQuery(BOOKING_PRICE_QUERY, {
15
- variables: {
16
- portalCode,
17
- objectCode,
18
- starts_at: arrivalDate.date,
19
- ends_at: departureDate.date
20
- }
21
- });
22
-
23
- if (loading)
24
- return (
25
- <div>
26
- <Loading />
27
- </div>
28
- );
29
- if (error) {
30
- return <div>Error</div>;
31
- }
32
-
33
- const result = data.PortalSite.houses[0];
34
-
35
- TrackEvent({
36
- house_code: objectCode,
37
- portal_code: portalCode,
38
- locale: locale,
39
- interaction_type: 'booking_started',
40
- interaction_data: {
41
- arrival_date: arrivalDate.date,
42
- departure_date: departureDate.date
43
- }
44
- });
45
-
46
- return <FormCreator house={result} PortalSite={data.PortalSite} />;
47
- }
48
-
49
- export default BookingForm;
@@ -1,49 +0,0 @@
1
- import React, { useState } from 'react';
2
- import CalendarHeader from './CalendarParts/CalendarHeader';
3
- import AssistanceMessage from './formParts/AssistanceMessage';
4
- import Legend from './CalendarParts/Legend';
5
- import Months from './CalendarParts/Months';
6
- import StartBooking from './CalendarParts/StartBooking';
7
- import { HouseType } from '../../types';
8
-
9
- interface Props {
10
- numberOfMonths: number;
11
- numberOfMonthsInARow: number;
12
- house: HouseType;
13
- }
14
-
15
- function Calendar({
16
- numberOfMonths,
17
- house,
18
- numberOfMonthsInARow
19
- }: Props): JSX.Element {
20
- const [currentMonth, setCurrentMonth] = useState(new Date());
21
-
22
- return (
23
- <div className="calendar-container ">
24
- <StartBooking house={house} />
25
- <div className="calendar-section">
26
- <CalendarHeader
27
- changeMonth={setCurrentMonth}
28
- currentMonth={currentMonth}
29
- numberOfMonths={numberOfMonths}
30
- />
31
- <Months
32
- house={house}
33
- numberOfMonths={numberOfMonths}
34
- numberOfMonthsInARow={numberOfMonthsInARow}
35
- currentMonth={currentMonth}
36
- />
37
- <Legend house={house} />
38
- <AssistanceMessage house={house} />
39
- </div>
40
- </div>
41
- );
42
- }
43
-
44
- Calendar.defaultProps = {
45
- numberOfMonths: 4,
46
- numberOfMonthsInARow: 2
47
- };
48
-
49
- export default Calendar;
@@ -1,43 +0,0 @@
1
- import React, { useContext } from 'react';
2
- import BookingForm from './BookingForm';
3
- import GenerateCalendar from './CalendarParts/GenerateCalendar';
4
- import { PortalSiteType } from '../../types';
5
- import {
6
- CalendarContext,
7
- CalendarProvider
8
- } from './CalendarParts/CalendarContext';
9
-
10
- interface Props {
11
- PortalSite: PortalSiteType;
12
- }
13
-
14
- function CalendarPage({ PortalSite }: Props): JSX.Element {
15
- const { bookingStarted } = useContext(CalendarContext);
16
-
17
- if (bookingStarted) {
18
- return <BookingForm />;
19
- } else {
20
- return <GenerateCalendar PortalSite={PortalSite} />;
21
- }
22
- }
23
-
24
- CalendarPage.DefaultProps = {
25
- PortalSite: {
26
- options: {
27
- bookingForm: {
28
- numberOfMonths: 4,
29
- numberOfMonthsInARow: 2
30
- }
31
- }
32
- }
33
- };
34
-
35
- function CalendarWrapper({ PortalSite }: Props): JSX.Element {
36
- return (
37
- <CalendarProvider>
38
- <CalendarPage PortalSite={PortalSite} />
39
- </CalendarProvider>
40
- );
41
- }
42
-
43
- export default CalendarWrapper;
@@ -1,89 +0,0 @@
1
- import { differenceInCalendarDays, isAfter } from 'date-fns';
2
- import React, { createContext, useReducer } from 'react';
3
- import { BuDate, HouseType } from '../../../types';
4
- import { Parse_EN_US } from '../../../_lib/date_helper';
5
- import { BookingType } from '../calender_types';
6
-
7
- const initialBooking: BookingType = {
8
- selectedDate: null,
9
- arrivalDate: null,
10
- departureDate: null,
11
- bookingStarted: false,
12
- persons: 0
13
- };
14
-
15
- export const CalendarContext = createContext<BookingType>(initialBooking);
16
- export const CalendarContextDispatch = createContext<Function>(calendarReducer);
17
-
18
- export function CalendarProvider({
19
- children
20
- }: {
21
- children: React.ReactNode;
22
- }): React.ReactNode {
23
- const [booking_state, dispatch] = useReducer(calendarReducer, initialBooking);
24
- return (
25
- <CalendarContext.Provider value={booking_state}>
26
- <CalendarContextDispatch.Provider value={dispatch}>
27
- {children}
28
- </CalendarContextDispatch.Provider>
29
- </CalendarContext.Provider>
30
- );
31
- }
32
-
33
- function calendarReducer(
34
- bookingState: BookingType,
35
- action: { type: string; house: HouseType; day: BuDate; persons: number }
36
- ): BookingType {
37
- switch (action.type) {
38
- case 'clicked': {
39
- const { day, house } = action;
40
- const { selectedDate, arrivalDate } = bookingState;
41
- const date = Parse_EN_US(day.date);
42
- const defaultMaxPersons = house.persons > 2 ? 2 : house.persons;
43
-
44
- if (
45
- day.departure &&
46
- selectedDate &&
47
- arrivalDate &&
48
- isAfter(date, selectedDate) &&
49
- differenceInCalendarDays(date, selectedDate) <= house.max_nights &&
50
- differenceInCalendarDays(date, selectedDate) >=
51
- arrivalDate.min_nights &&
52
- differenceInCalendarDays(date, selectedDate) <= arrivalDate.max_nights
53
- ) {
54
- return {
55
- ...bookingState,
56
- departureDate: day
57
- };
58
- } else if (day.arrival) {
59
- return {
60
- bookingStarted: false,
61
- selectedDate: date,
62
- arrivalDate: day,
63
- departureDate: null,
64
- persons: defaultMaxPersons
65
- };
66
- }
67
- return bookingState;
68
- }
69
- case 'reset': {
70
- return initialBooking;
71
- }
72
- case 'start': {
73
- return {
74
- ...bookingState,
75
- bookingStarted: true,
76
- persons: action.persons
77
- };
78
- }
79
- case 'return': {
80
- return {
81
- ...bookingState,
82
- bookingStarted: false
83
- };
84
- }
85
- default: {
86
- throw Error('Unknown action: ' + action.type);
87
- }
88
- }
89
- }