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.
- package/build/index.css +1 -1
- package/build/portal.es.js +19931 -20259
- package/build/portal.umd.js +80 -82
- package/package.json +9 -7
- package/.env.development +0 -1
- package/.eslintrc +0 -25
- package/.github/dependabot.yml +0 -11
- package/.github/workflows/node.js.yml +0 -31
- package/.github/workflows/npm-publish.yml +0 -33
- package/.nvmrc +0 -1
- package/.prettierrc +0 -6
- package/.vscode/settings.json +0 -24
- package/CHANGELOG.MD +0 -93
- package/babel.config.json +0 -6
- package/calendar.html +0 -16
- package/coverage/clover.xml +0 -28
- package/coverage/coverage-final.json +0 -2
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/helper.ts.html +0 -142
- package/coverage/lcov-report/index.html +0 -116
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov.info +0 -36
- package/cypress/e2e/.examples/actions.spec.js +0 -299
- package/cypress/e2e/.examples/aliasing.spec.js +0 -39
- package/cypress/e2e/.examples/assertions.spec.js +0 -177
- package/cypress/e2e/.examples/connectors.spec.js +0 -97
- package/cypress/e2e/.examples/cookies.spec.js +0 -77
- package/cypress/e2e/.examples/cypress_api.spec.js +0 -202
- package/cypress/e2e/.examples/files.spec.js +0 -89
- package/cypress/e2e/.examples/local_storage.spec.js +0 -52
- package/cypress/e2e/.examples/location.spec.js +0 -32
- package/cypress/e2e/.examples/misc.spec.js +0 -104
- package/cypress/e2e/.examples/navigation.spec.js +0 -56
- package/cypress/e2e/.examples/network_requests.spec.js +0 -163
- package/cypress/e2e/.examples/querying.spec.js +0 -114
- package/cypress/e2e/.examples/spies_stubs_clocks.spec.js +0 -205
- package/cypress/e2e/.examples/traversal.spec.js +0 -121
- package/cypress/e2e/.examples/utilities.spec.js +0 -110
- package/cypress/e2e/.examples/viewport.spec.js +0 -59
- package/cypress/e2e/.examples/waiting.spec.js +0 -31
- package/cypress/e2e/.examples/window.spec.js +0 -22
- package/cypress/e2e/booking.spec.js +0 -81
- package/cypress/e2e/calendar.spec.js +0 -21
- package/cypress/e2e/search.spec.js +0 -25
- package/cypress/fixtures/example.json +0 -5
- package/cypress/plugins/index.js +0 -16
- package/cypress/support/commands.js +0 -25
- package/cypress/support/commands.ts +0 -37
- package/cypress/support/component-index.html +0 -12
- package/cypress/support/component.ts +0 -39
- package/cypress/support/e2e.js +0 -20
- package/cypress.config.ts +0 -15
- package/dev.tsx +0 -44
- package/index.html +0 -15
- package/invalid-calendar.html +0 -16
- package/jest.config.js +0 -195
- package/postcss.config.js +0 -17
- package/reviews.html +0 -16
- package/src/_lib/SearchQueries.ts +0 -145
- package/src/_lib/Tracking.ts +0 -51
- package/src/_lib/countries/de.json +0 -998
- package/src/_lib/countries/en.json +0 -998
- package/src/_lib/countries/es.json +0 -998
- package/src/_lib/countries/fr.json +0 -998
- package/src/_lib/countries/it.json +0 -998
- package/src/_lib/countries/nl.json +0 -998
- package/src/_lib/countries.ts +0 -15
- package/src/_lib/date_helper.ts +0 -27
- package/src/_lib/queries.ts +0 -244
- package/src/components/App.tsx +0 -108
- package/src/components/AppContext.ts +0 -14
- package/src/components/CalendarPage/BookingForm.tsx +0 -49
- package/src/components/CalendarPage/Calendar.tsx +0 -49
- package/src/components/CalendarPage/CalendarPage.tsx +0 -43
- package/src/components/CalendarPage/CalendarParts/CalendarContext.tsx +0 -89
- package/src/components/CalendarPage/CalendarParts/CalendarHeader.tsx +0 -72
- package/src/components/CalendarPage/CalendarParts/DayClasses.ts +0 -113
- package/src/components/CalendarPage/CalendarParts/GenerateCalendar.tsx +0 -72
- package/src/components/CalendarPage/CalendarParts/Legend.tsx +0 -33
- package/src/components/CalendarPage/CalendarParts/MonthHeader.tsx +0 -15
- package/src/components/CalendarPage/CalendarParts/Months.tsx +0 -37
- package/src/components/CalendarPage/CalendarParts/RenderCells.tsx +0 -97
- package/src/components/CalendarPage/CalendarParts/SingleMonth.tsx +0 -72
- package/src/components/CalendarPage/CalendarParts/StartBooking.tsx +0 -17
- package/src/components/CalendarPage/CalendarParts/WeekDays.tsx +0 -27
- package/src/components/CalendarPage/FormCreator.tsx +0 -230
- package/src/components/CalendarPage/FormItems/Date.tsx +0 -61
- package/src/components/CalendarPage/FormItems/NumberSelect.tsx +0 -39
- package/src/components/CalendarPage/FormItems/Select.tsx +0 -38
- package/src/components/CalendarPage/FormItems/index.ts +0 -4
- package/src/components/CalendarPage/PriceField/Price.tsx +0 -58
- package/src/components/CalendarPage/PriceField/Queries.ts +0 -23
- package/src/components/CalendarPage/PriceField/index.tsx +0 -129
- package/src/components/CalendarPage/Summary/CostRow.tsx +0 -58
- package/src/components/CalendarPage/Summary/CostSection.tsx +0 -15
- package/src/components/CalendarPage/Summary/CostSummary.tsx +0 -61
- package/src/components/CalendarPage/Summary/Description.tsx +0 -27
- package/src/components/CalendarPage/Summary/InsurancesAndRequired.tsx +0 -68
- package/src/components/CalendarPage/Summary/Object.tsx +0 -59
- package/src/components/CalendarPage/Summary/OnSite.tsx +0 -36
- package/src/components/CalendarPage/Summary/OptionalNotOnSite.tsx +0 -43
- package/src/components/CalendarPage/Summary/OptionalOnSite.tsx +0 -39
- package/src/components/CalendarPage/Summary/Queries.ts +0 -31
- package/src/components/CalendarPage/Summary/RentAndDiscount.tsx +0 -30
- package/src/components/CalendarPage/Summary/Totals.tsx +0 -89
- package/src/components/CalendarPage/Summary/cost_types.d.ts +0 -31
- package/src/components/CalendarPage/Summary/index.tsx +0 -24
- package/src/components/CalendarPage/calender_types.d.ts +0 -16
- package/src/components/CalendarPage/formParts/AssistanceMessage.tsx +0 -60
- package/src/components/CalendarPage/formParts/BookingHelpers.tsx +0 -47
- package/src/components/CalendarPage/formParts/BookingOrOption.tsx +0 -35
- package/src/components/CalendarPage/formParts/CancelInsuranceText.tsx +0 -69
- package/src/components/CalendarPage/formParts/DefaultBookingFields.ts +0 -105
- package/src/components/CalendarPage/formParts/DiscountCode.tsx +0 -62
- package/src/components/CalendarPage/formParts/Guests.tsx +0 -77
- package/src/components/CalendarPage/formParts/OptionalBookingFields.tsx +0 -148
- package/src/components/CalendarPage/formParts/OptionalCosts.tsx +0 -103
- package/src/components/CalendarPage/formParts/SuccessMessage.tsx +0 -31
- package/src/components/CalendarPage/formParts/Validations.tsx +0 -64
- package/src/components/CalendarPage/formParts/discount.tsx +0 -69
- package/src/components/CalendarPage/formParts/form_types.d.ts +0 -38
- package/src/components/CalendarPage/formParts/insurances.tsx +0 -62
- package/src/components/CalendarPage/formParts/radioButtons.tsx +0 -66
- package/src/components/Error/ApiError.tsx +0 -33
- package/src/components/Error/IntegrationError.tsx +0 -62
- package/src/components/Error/index.ts +0 -4
- package/src/components/ErrorBoundary.tsx +0 -34
- package/src/components/Modal/index.tsx +0 -46
- package/src/components/ReviewsPage/Queries.ts +0 -26
- package/src/components/ReviewsPage/ReviewsPage.tsx +0 -45
- package/src/components/ReviewsPage/Score.tsx +0 -29
- package/src/components/ReviewsPage/SingleReview.tsx +0 -38
- package/src/components/ReviewsPage/note.tsx +0 -17
- package/src/components/SafeBooking.tsx +0 -96
- package/src/components/SearchPage/Field.tsx +0 -75
- package/src/components/SearchPage/Filters.tsx +0 -91
- package/src/components/SearchPage/Paginator.tsx +0 -63
- package/src/components/SearchPage/Results.tsx +0 -129
- package/src/components/SearchPage/SearchPage.tsx +0 -115
- package/src/components/SearchPage/SingleResult.tsx +0 -93
- package/src/components/SearchPage/filters/Categories.tsx +0 -57
- package/src/components/SearchPage/filters/DateFilter.tsx +0 -34
- package/src/components/SearchPage/filters/List.tsx +0 -80
- package/src/components/SearchPage/filters/NumberFilter.tsx +0 -37
- package/src/components/SearchPage/filters/Radio.tsx +0 -46
- package/src/components/SearchPage/filters/Select.tsx +0 -85
- package/src/components/SearchPage/filters/__tests__/helper.spec.js +0 -13
- package/src/components/SearchPage/filters/filter_types.d.ts +0 -25
- package/src/components/SearchPage/filters/helper.ts +0 -19
- package/src/components/icons/ArrowLeft.svg.tsx +0 -20
- package/src/components/icons/ArrowRight.svg.tsx +0 -16
- package/src/components/icons/Reload.svg.tsx +0 -23
- package/src/components/icons/info.svg.tsx +0 -24
- package/src/components/icons/loading.svg.tsx +0 -98
- package/src/custom.d.ts +0 -10
- package/src/index.tsx +0 -104
- package/src/locales/de.json +0 -137
- package/src/locales/en.json +0 -137
- package/src/locales/es.json +0 -132
- package/src/locales/fr.json +0 -132
- package/src/locales/it.json +0 -128
- package/src/locales/nl.json +0 -138
- package/src/styles/calendar.css +0 -317
- package/src/styles/datepicker.css +0 -6
- package/src/styles/field.css +0 -105
- package/src/styles/filters.css +0 -92
- package/src/styles/form.css +0 -219
- package/src/styles/main.css +0 -80
- package/src/styles/modal.css +0 -79
- package/src/styles/pagination.css +0 -92
- package/src/styles/price-overview.css +0 -111
- package/src/styles/result.css +0 -142
- package/src/styles/results.css +0 -50
- package/src/styles/reviews.css +0 -90
- package/src/styles/success.css +0 -9
- package/src/types.d.ts +0 -91
- package/tmp/cache/vite/last-build-production.json +0 -7
- package/tsconfig.json +0 -17
- package/vite.config.ts +0 -31
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
import React, { useContext } from 'react';
|
|
2
|
-
import { Formik, Form } from 'formik';
|
|
3
|
-
import { FormattedMessage } from 'react-intl';
|
|
4
|
-
import { CREATE_BOOKING_MUTATION } from '../../_lib/queries';
|
|
5
|
-
import { Insurances } from './formParts/insurances';
|
|
6
|
-
import Discount from './formParts/discount';
|
|
7
|
-
import Summary from './Summary';
|
|
8
|
-
import Modal from '../Modal';
|
|
9
|
-
import DefaultBookingFields from './formParts/DefaultBookingFields';
|
|
10
|
-
import SuccessMessage from './formParts/SuccessMessage';
|
|
11
|
-
import OptionalBookingFields from './formParts/OptionalBookingFields';
|
|
12
|
-
import { ApiError } from '../Error';
|
|
13
|
-
import { initializeBookingFields } from './formParts/BookingHelpers';
|
|
14
|
-
import OptionalCosts from './formParts/OptionalCosts';
|
|
15
|
-
import Guests from './formParts/Guests';
|
|
16
|
-
import { validateForm } from './formParts/Validations';
|
|
17
|
-
import { AppContext } from '../AppContext';
|
|
18
|
-
import { HouseType, PortalSiteType } from '../../types';
|
|
19
|
-
import { BookingType } from './calender_types';
|
|
20
|
-
import { useMutation } from '@apollo/client';
|
|
21
|
-
import {
|
|
22
|
-
CalendarContext,
|
|
23
|
-
CalendarContextDispatch
|
|
24
|
-
} from './CalendarParts/CalendarContext';
|
|
25
|
-
import { getSessionIdentifier } from '../../_lib/Tracking';
|
|
26
|
-
|
|
27
|
-
interface Props {
|
|
28
|
-
house: HouseType;
|
|
29
|
-
PortalSite: PortalSiteType;
|
|
30
|
-
booking: BookingType;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function FormCreator({ house, PortalSite }: Props): JSX.Element {
|
|
34
|
-
const { persons, arrivalDate, departureDate } = useContext(CalendarContext);
|
|
35
|
-
const { locale, portalCode, objectCode } = useContext(AppContext);
|
|
36
|
-
const dispatch = useContext(CalendarContextDispatch);
|
|
37
|
-
|
|
38
|
-
const { options } = PortalSite;
|
|
39
|
-
|
|
40
|
-
const bookingFields = options.bookingFields || DefaultBookingFields;
|
|
41
|
-
|
|
42
|
-
const bookingPrice = house.booking_price;
|
|
43
|
-
|
|
44
|
-
let costs: any = {};
|
|
45
|
-
|
|
46
|
-
for (const val of bookingPrice.optional_house_costs) {
|
|
47
|
-
costs[val.id] = '0';
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const [createBooking, { loading, error, data, reset }] = useMutation(
|
|
51
|
-
CREATE_BOOKING_MUTATION
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
const optBookingFieldsInitialized = initializeBookingFields(bookingFields);
|
|
55
|
-
|
|
56
|
-
const sessionIdentifier = getSessionIdentifier();
|
|
57
|
-
|
|
58
|
-
console.log({ sessionIdentifier });
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<Formik
|
|
62
|
-
validate={(values) => validateForm(values, house, bookingFields)}
|
|
63
|
-
initialValues={{
|
|
64
|
-
...optBookingFieldsInitialized,
|
|
65
|
-
arrivalDate,
|
|
66
|
-
departureDate,
|
|
67
|
-
is_option: 'false',
|
|
68
|
-
costs,
|
|
69
|
-
adults: persons,
|
|
70
|
-
children: 0,
|
|
71
|
-
babies: 0,
|
|
72
|
-
persons,
|
|
73
|
-
discount: 0,
|
|
74
|
-
country: 'nl'
|
|
75
|
-
}}
|
|
76
|
-
onSubmit={(values, { setSubmitting }) => {
|
|
77
|
-
let variables = {
|
|
78
|
-
...values,
|
|
79
|
-
is_option: JSON.parse(values.is_option),
|
|
80
|
-
house_code: objectCode,
|
|
81
|
-
portal_code: portalCode,
|
|
82
|
-
comment: values.comment || '',
|
|
83
|
-
language: locale,
|
|
84
|
-
country: values.country.toUpperCase(),
|
|
85
|
-
adults: Number(values.adults),
|
|
86
|
-
children: Number(values.children) || 0,
|
|
87
|
-
babies: Number(values.babies) || 0,
|
|
88
|
-
discount: Number(values.discount) || 0,
|
|
89
|
-
cancel_insurance: Number(values.cancel_insurance) || 0,
|
|
90
|
-
arrival_date: values.arrivalDate.date,
|
|
91
|
-
departure_date: values.departureDate.date,
|
|
92
|
-
costs: JSON.stringify(values.costs),
|
|
93
|
-
extra_fields: JSON.stringify(values.extra_fields),
|
|
94
|
-
sessionIdentifier: sessionIdentifier
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
createBooking({ variables }).then(() => {
|
|
98
|
-
if (
|
|
99
|
-
options.bookingForm &&
|
|
100
|
-
options.bookingForm[`redirectUrl_${locale}`] &&
|
|
101
|
-
options.bookingForm[`redirectUrl_${locale}`] !== ''
|
|
102
|
-
) {
|
|
103
|
-
window.location = options.bookingForm[`redirectUrl_${locale}`];
|
|
104
|
-
} else if (
|
|
105
|
-
options.bookingForm &&
|
|
106
|
-
options.bookingForm.redirectUrl &&
|
|
107
|
-
options.bookingForm.redirectUrl !== ''
|
|
108
|
-
) {
|
|
109
|
-
window.location = options.bookingForm.redirectUrl;
|
|
110
|
-
} else {
|
|
111
|
-
setTimeout(() => {
|
|
112
|
-
dispatch({
|
|
113
|
-
type: 'return'
|
|
114
|
-
});
|
|
115
|
-
}, 15000);
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
}}
|
|
119
|
-
>
|
|
120
|
-
{({ errors, touched, values, status, isSubmitting }) => (
|
|
121
|
-
<Form className="form">
|
|
122
|
-
{loading && <div className="return-message">Creating booking...</div>}
|
|
123
|
-
{error && (
|
|
124
|
-
<Modal show={true} onClose={reset}>
|
|
125
|
-
<ApiError errors={error} modal={true} />
|
|
126
|
-
</Modal>
|
|
127
|
-
)}
|
|
128
|
-
{data && (
|
|
129
|
-
<Modal show={true}>
|
|
130
|
-
<SuccessMessage />
|
|
131
|
-
</Modal>
|
|
132
|
-
)}
|
|
133
|
-
|
|
134
|
-
<div className="form-content">
|
|
135
|
-
<div className="form-section">
|
|
136
|
-
<a
|
|
137
|
-
className="return-link"
|
|
138
|
-
role="link"
|
|
139
|
-
tabIndex={0}
|
|
140
|
-
onClick={() => {
|
|
141
|
-
dispatch({
|
|
142
|
-
type: 'return'
|
|
143
|
-
});
|
|
144
|
-
}}
|
|
145
|
-
>
|
|
146
|
-
<FormattedMessage id="return_to_calendar" />
|
|
147
|
-
</a>
|
|
148
|
-
<h2>
|
|
149
|
-
<FormattedMessage id="stay_details" />
|
|
150
|
-
</h2>
|
|
151
|
-
<Guests options={options} house={house} />
|
|
152
|
-
|
|
153
|
-
{errors.max_persons && (
|
|
154
|
-
<div className="error-message bu-error-message persons">
|
|
155
|
-
{errors.max_persons}
|
|
156
|
-
</div>
|
|
157
|
-
)}
|
|
158
|
-
</div>
|
|
159
|
-
<Discount
|
|
160
|
-
errors={errors}
|
|
161
|
-
house={house}
|
|
162
|
-
options={options}
|
|
163
|
-
values={values}
|
|
164
|
-
render={bookingPrice.optional_house_costs}
|
|
165
|
-
/>
|
|
166
|
-
|
|
167
|
-
<Insurances house={house} values={values} />
|
|
168
|
-
|
|
169
|
-
<OptionalCosts costs={bookingPrice.optional_house_costs} />
|
|
170
|
-
|
|
171
|
-
<OptionalBookingFields
|
|
172
|
-
bookingFields={bookingFields}
|
|
173
|
-
errors={errors}
|
|
174
|
-
touched={touched}
|
|
175
|
-
PortalSite={PortalSite}
|
|
176
|
-
values={values}
|
|
177
|
-
/>
|
|
178
|
-
</div>
|
|
179
|
-
|
|
180
|
-
<div className="form-sum">
|
|
181
|
-
<Summary house={house} values={values} />
|
|
182
|
-
{status && status.msg && <div>{status.msg}</div>}
|
|
183
|
-
<div className="terms">
|
|
184
|
-
{PortalSite.form_submit_text}{' '}
|
|
185
|
-
<FormattedMessage id="terms">
|
|
186
|
-
{(fm) => (
|
|
187
|
-
<Modal buttonText={fm}>
|
|
188
|
-
<div
|
|
189
|
-
style={{
|
|
190
|
-
width: '90vh',
|
|
191
|
-
height: '90vh'
|
|
192
|
-
}}
|
|
193
|
-
>
|
|
194
|
-
<iframe
|
|
195
|
-
src={house.rental_terms}
|
|
196
|
-
width="100%"
|
|
197
|
-
height="100%"
|
|
198
|
-
title="Terms"
|
|
199
|
-
/>
|
|
200
|
-
</div>
|
|
201
|
-
</Modal>
|
|
202
|
-
)}
|
|
203
|
-
</FormattedMessage>
|
|
204
|
-
{house.allow_option && (
|
|
205
|
-
<span>
|
|
206
|
-
{', '}
|
|
207
|
-
<FormattedMessage id="option_is_free" />
|
|
208
|
-
</span>
|
|
209
|
-
)}
|
|
210
|
-
</div>
|
|
211
|
-
{[1, 2].includes(Number(values.cancel_insurance)) ? (
|
|
212
|
-
<div className="terms">
|
|
213
|
-
<FormattedMessage id="comply_insurance_card" />
|
|
214
|
-
</div>
|
|
215
|
-
) : null}
|
|
216
|
-
<button
|
|
217
|
-
className="bu-calendar-button"
|
|
218
|
-
type="submit"
|
|
219
|
-
disabled={isSubmitting}
|
|
220
|
-
>
|
|
221
|
-
{PortalSite.form_submit_button_text}
|
|
222
|
-
</button>
|
|
223
|
-
</div>
|
|
224
|
-
</Form>
|
|
225
|
-
)}
|
|
226
|
-
</Formik>
|
|
227
|
-
);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
export default FormCreator;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Field } from 'formik';
|
|
3
|
-
import { FormattedMessage } from 'react-intl';
|
|
4
|
-
import DatePicker from 'react-date-picker';
|
|
5
|
-
import { format } from 'date-fns';
|
|
6
|
-
|
|
7
|
-
interface Props {
|
|
8
|
-
label: string;
|
|
9
|
-
description: string | React.ReactNode;
|
|
10
|
-
name: string;
|
|
11
|
-
inline: boolean;
|
|
12
|
-
required: boolean;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function DateField({ label, description, name, inline }: Props) {
|
|
16
|
-
return (
|
|
17
|
-
<Field name={name}>
|
|
18
|
-
{({ field, meta, form }) => {
|
|
19
|
-
const { value, name } = field;
|
|
20
|
-
|
|
21
|
-
let tempval;
|
|
22
|
-
if (value === '' || !value) {
|
|
23
|
-
tempval = null;
|
|
24
|
-
} else {
|
|
25
|
-
tempval = new Date(value);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<div
|
|
30
|
-
className={`form-row ${inline && 'inline'}`}
|
|
31
|
-
id={`bukazu_form_${name}`}
|
|
32
|
-
>
|
|
33
|
-
<label htmlFor={name}>
|
|
34
|
-
<FormattedMessage id={label} />
|
|
35
|
-
</label>
|
|
36
|
-
<DatePicker
|
|
37
|
-
className="bukazu-date-picker"
|
|
38
|
-
name={name}
|
|
39
|
-
format="dd-MM-y"
|
|
40
|
-
value={tempval}
|
|
41
|
-
onChange={(e) => {
|
|
42
|
-
field.onChange(format(e, 'yyyy-MM-dd'));
|
|
43
|
-
form.setFieldValue(name, format(e, 'yyyy-MM-dd'));
|
|
44
|
-
}}
|
|
45
|
-
/>
|
|
46
|
-
<span className="bu-input-description">{description}</span>
|
|
47
|
-
{meta.touched && meta.error && (
|
|
48
|
-
<div className="error-message bu-error-message">{meta.error}</div>
|
|
49
|
-
)}
|
|
50
|
-
</div>
|
|
51
|
-
);
|
|
52
|
-
}}
|
|
53
|
-
</Field>
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
DateField.defaultValues = {
|
|
58
|
-
inline: true
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export default DateField;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Field } from 'formik';
|
|
3
|
-
import { createPeronsArray } from '../formParts/BookingHelpers';
|
|
4
|
-
import { FormattedMessage } from 'react-intl';
|
|
5
|
-
|
|
6
|
-
export default function NumberSelect({ label, description, count, ...props }) {
|
|
7
|
-
const numbers = createPeronsArray(count);
|
|
8
|
-
|
|
9
|
-
return (
|
|
10
|
-
<Field name={props.name}>
|
|
11
|
-
{({ field, meta }) => {
|
|
12
|
-
return (
|
|
13
|
-
<div className="form-row inline" id={`bukazu_form_${props.name}`}>
|
|
14
|
-
<label htmlFor={props.name}>
|
|
15
|
-
<FormattedMessage id={label} />
|
|
16
|
-
</label>
|
|
17
|
-
<select {...field} {...props}>
|
|
18
|
-
{numbers.map((opt) => {
|
|
19
|
-
return (
|
|
20
|
-
<option key={opt} value={opt}>
|
|
21
|
-
{opt}
|
|
22
|
-
</option>
|
|
23
|
-
);
|
|
24
|
-
})}
|
|
25
|
-
</select>
|
|
26
|
-
{description}
|
|
27
|
-
{meta.touched && meta.error && (
|
|
28
|
-
<div className="error-message bu-error-message">{meta.error}</div>
|
|
29
|
-
)}
|
|
30
|
-
</div>
|
|
31
|
-
);
|
|
32
|
-
}}
|
|
33
|
-
</Field>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
NumberSelect.defaultProps = {
|
|
38
|
-
count: 0
|
|
39
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Field } from 'formik';
|
|
3
|
-
import { FormattedMessage } from 'react-intl';
|
|
4
|
-
|
|
5
|
-
export default function Select({
|
|
6
|
-
label,
|
|
7
|
-
description,
|
|
8
|
-
options,
|
|
9
|
-
name,
|
|
10
|
-
...props
|
|
11
|
-
}) {
|
|
12
|
-
return (
|
|
13
|
-
<Field name={name}>
|
|
14
|
-
{({ field, meta }) => {
|
|
15
|
-
return (
|
|
16
|
-
<div className="form-row inline" id={`bukazu_form_${props.name}`}>
|
|
17
|
-
<label htmlFor={props.name}>
|
|
18
|
-
<FormattedMessage id={label} />
|
|
19
|
-
</label>
|
|
20
|
-
<select {...field} {...props}>
|
|
21
|
-
{options.map((opt) => {
|
|
22
|
-
return (
|
|
23
|
-
<option key={opt} value={opt}>
|
|
24
|
-
{opt}
|
|
25
|
-
</option>
|
|
26
|
-
);
|
|
27
|
-
})}
|
|
28
|
-
</select>
|
|
29
|
-
{description}
|
|
30
|
-
{meta.touched && meta.error && (
|
|
31
|
-
<div className="error-message bu-error-message">{meta.error}</div>
|
|
32
|
-
)}
|
|
33
|
-
</div>
|
|
34
|
-
);
|
|
35
|
-
}}
|
|
36
|
-
</Field>
|
|
37
|
-
);
|
|
38
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { useQuery } from '@apollo/client';
|
|
2
|
-
import React, { useContext } from 'react';
|
|
3
|
-
import { FormattedMessage, FormattedNumber } from 'react-intl';
|
|
4
|
-
import { AppContext } from '../../AppContext';
|
|
5
|
-
import { ApiError } from '../../Error';
|
|
6
|
-
import Loading from '../../icons/loading.svg';
|
|
7
|
-
import { BOOKING_PRICE_QUERY } from './Queries';
|
|
8
|
-
|
|
9
|
-
interface Props {
|
|
10
|
-
persons: number;
|
|
11
|
-
variables: {
|
|
12
|
-
starts_at: string;
|
|
13
|
-
ends_at: string;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function Price({ persons, variables }: Props) {
|
|
18
|
-
const { portalCode, objectCode } = useContext(AppContext);
|
|
19
|
-
const { loading, error, data } = useQuery(BOOKING_PRICE_QUERY, {
|
|
20
|
-
variables: { ...variables, persons, portalCode, objectCode }
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
if (loading)
|
|
24
|
-
return (
|
|
25
|
-
<div className="price-overview--build">
|
|
26
|
-
<Loading />
|
|
27
|
-
</div>
|
|
28
|
-
);
|
|
29
|
-
if (error) {
|
|
30
|
-
return (
|
|
31
|
-
<div className="price-overview--build">
|
|
32
|
-
<ApiError errors={error}></ApiError>
|
|
33
|
-
</div>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
const result = data.PortalSite.houses[0].booking_price;
|
|
37
|
-
return (
|
|
38
|
-
<>
|
|
39
|
-
<div className="price-overview--book">
|
|
40
|
-
<div className="price">
|
|
41
|
-
€{' '}
|
|
42
|
-
<FormattedNumber
|
|
43
|
-
value={Math.round(result.total_price)}
|
|
44
|
-
minimumFractionDigits={2}
|
|
45
|
-
maximumFractionDigits={2}
|
|
46
|
-
/>
|
|
47
|
-
</div>
|
|
48
|
-
<div>
|
|
49
|
-
<i>
|
|
50
|
-
<FormattedMessage id="based_on_one_person" values={{ persons }} />
|
|
51
|
-
</i>
|
|
52
|
-
</div>
|
|
53
|
-
</div>
|
|
54
|
-
</>
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export default Price;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { gql } from "@apollo/client";
|
|
2
|
-
|
|
3
|
-
export const BOOKING_PRICE_QUERY = gql`
|
|
4
|
-
query BookingPriceQuery(
|
|
5
|
-
$portalCode: ID!
|
|
6
|
-
$objectCode: String!
|
|
7
|
-
$starts_at: Date!
|
|
8
|
-
$ends_at: Date!
|
|
9
|
-
$persons: Int
|
|
10
|
-
) {
|
|
11
|
-
PortalSite(id: $portalCode) {
|
|
12
|
-
houses(house_code: $objectCode) {
|
|
13
|
-
id
|
|
14
|
-
name
|
|
15
|
-
booking_price(
|
|
16
|
-
starts_at: $starts_at
|
|
17
|
-
ends_at: $ends_at
|
|
18
|
-
persons: $persons
|
|
19
|
-
)
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
`;
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import React, { useContext, useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
FormatIntl,
|
|
4
|
-
LONG_DATE_FORMAT,
|
|
5
|
-
Parse_EN_US
|
|
6
|
-
} from '../../../_lib/date_helper';
|
|
7
|
-
import { FormattedMessage } from 'react-intl';
|
|
8
|
-
import { createPeronsArray } from '../formParts/BookingHelpers';
|
|
9
|
-
import Price from './Price';
|
|
10
|
-
import { HouseType } from '../../../types';
|
|
11
|
-
import {
|
|
12
|
-
CalendarContext,
|
|
13
|
-
CalendarContextDispatch
|
|
14
|
-
} from '../CalendarParts/CalendarContext';
|
|
15
|
-
|
|
16
|
-
const dateFormat = LONG_DATE_FORMAT;
|
|
17
|
-
|
|
18
|
-
interface Props {
|
|
19
|
-
house: HouseType;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function PriceField({ house }: Props) {
|
|
23
|
-
const defaultMaxPersons = house.persons > 2 ? 2 : house.persons;
|
|
24
|
-
const [persons, setPersons] = useState(defaultMaxPersons);
|
|
25
|
-
|
|
26
|
-
const { arrivalDate, departureDate } = useContext(CalendarContext);
|
|
27
|
-
const dispatch = useContext(CalendarContextDispatch);
|
|
28
|
-
|
|
29
|
-
let adults = createPeronsArray(house.persons);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<div className="calendar--picker">
|
|
34
|
-
<div className="calendar--picker--date">
|
|
35
|
-
<span className="name">
|
|
36
|
-
<FormattedMessage id={`${house.house_type}.arrival`} />
|
|
37
|
-
</span>
|
|
38
|
-
<span className="detail">
|
|
39
|
-
{arrivalDate?.date ? (
|
|
40
|
-
<span>
|
|
41
|
-
{FormatIntl(Parse_EN_US(arrivalDate?.date), dateFormat)}
|
|
42
|
-
</span>
|
|
43
|
-
) : (
|
|
44
|
-
<FormattedMessage
|
|
45
|
-
id={`${house.house_type}.pick_your_arrivaldate_in_the_calendar`}
|
|
46
|
-
/>
|
|
47
|
-
)}
|
|
48
|
-
</span>
|
|
49
|
-
</div>
|
|
50
|
-
<div className="calendar--picker--date">
|
|
51
|
-
<span className="name">
|
|
52
|
-
<FormattedMessage id={`${house.house_type}.departure`} />
|
|
53
|
-
</span>
|
|
54
|
-
<span className="detail">
|
|
55
|
-
{departureDate?.date ? (
|
|
56
|
-
<span>
|
|
57
|
-
{FormatIntl(Parse_EN_US(departureDate?.date), dateFormat)}
|
|
58
|
-
</span>
|
|
59
|
-
) : (
|
|
60
|
-
<div>
|
|
61
|
-
<div>
|
|
62
|
-
<FormattedMessage
|
|
63
|
-
id={`${house.house_type}.pick_your_departure_in_the_calendar`}
|
|
64
|
-
/>
|
|
65
|
-
</div>
|
|
66
|
-
{arrivalDate && (
|
|
67
|
-
<FormattedMessage
|
|
68
|
-
id="minimum_nights"
|
|
69
|
-
defaultMessage="Minimum {minimum} nights"
|
|
70
|
-
values={{ minimum: arrivalDate?.min_nights }}
|
|
71
|
-
/>
|
|
72
|
-
)}
|
|
73
|
-
</div>
|
|
74
|
-
)}
|
|
75
|
-
</span>
|
|
76
|
-
</div>
|
|
77
|
-
<div className="calendar--picker--date">
|
|
78
|
-
<span className="detail">
|
|
79
|
-
<select
|
|
80
|
-
className="calendar--picker--persons"
|
|
81
|
-
value={persons}
|
|
82
|
-
onChange={(e) => {
|
|
83
|
-
setPersons(e.target.value);
|
|
84
|
-
}}
|
|
85
|
-
>
|
|
86
|
-
{adults.map((person) => (
|
|
87
|
-
<FormattedMessage
|
|
88
|
-
id="persons"
|
|
89
|
-
key={person}
|
|
90
|
-
children={(text) => (
|
|
91
|
-
<option value={person} key={person}>
|
|
92
|
-
{person} {text}
|
|
93
|
-
</option>
|
|
94
|
-
)}
|
|
95
|
-
/>
|
|
96
|
-
))}
|
|
97
|
-
</select>
|
|
98
|
-
</span>
|
|
99
|
-
</div>
|
|
100
|
-
<div className="calendar--picker--date">
|
|
101
|
-
{arrivalDate && departureDate && (
|
|
102
|
-
<Price
|
|
103
|
-
persons={parseInt(persons)}
|
|
104
|
-
variables={{
|
|
105
|
-
starts_at: arrivalDate?.date,
|
|
106
|
-
ends_at: departureDate?.date
|
|
107
|
-
}}
|
|
108
|
-
/>
|
|
109
|
-
)}
|
|
110
|
-
</div>
|
|
111
|
-
<button
|
|
112
|
-
className="button"
|
|
113
|
-
disabled={!arrivalDate || !departureDate}
|
|
114
|
-
onClick={() => {
|
|
115
|
-
if (arrivalDate && departureDate) {
|
|
116
|
-
dispatch({
|
|
117
|
-
type: 'start',
|
|
118
|
-
persons
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
}}
|
|
122
|
-
>
|
|
123
|
-
<FormattedMessage id="calculate" />
|
|
124
|
-
</button>
|
|
125
|
-
</div>
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export default PriceField;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { FormattedMessage, FormattedNumber } from 'react-intl';
|
|
3
|
-
import Description from './Description';
|
|
4
|
-
|
|
5
|
-
interface Props {
|
|
6
|
-
name: string;
|
|
7
|
-
amount: number;
|
|
8
|
-
description?: string | React.ReactNode;
|
|
9
|
-
method_name?: string;
|
|
10
|
-
formatName?: boolean;
|
|
11
|
-
forceMethod?: boolean;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function CostRow({
|
|
15
|
-
name,
|
|
16
|
-
amount,
|
|
17
|
-
description,
|
|
18
|
-
method_name,
|
|
19
|
-
formatName,
|
|
20
|
-
forceMethod
|
|
21
|
-
}: Props): JSX.Element {
|
|
22
|
-
return (
|
|
23
|
-
<tr>
|
|
24
|
-
<td>
|
|
25
|
-
{formatName ? <FormattedMessage id={name} /> : name}
|
|
26
|
-
{description && (
|
|
27
|
-
<>
|
|
28
|
-
{' '}
|
|
29
|
-
<Description description={description} />
|
|
30
|
-
</>
|
|
31
|
-
)}
|
|
32
|
-
</td>
|
|
33
|
-
|
|
34
|
-
<td className="price">
|
|
35
|
-
{amount && amount > 0 ? (
|
|
36
|
-
<>
|
|
37
|
-
€{' '}
|
|
38
|
-
<FormattedNumber
|
|
39
|
-
value={amount}
|
|
40
|
-
minimumFractionDigits={2}
|
|
41
|
-
maximumFractionDigits={2}
|
|
42
|
-
/>
|
|
43
|
-
{forceMethod && <> {method_name}</>}
|
|
44
|
-
</>
|
|
45
|
-
) : (
|
|
46
|
-
<>{method_name}</>
|
|
47
|
-
)}
|
|
48
|
-
</td>
|
|
49
|
-
</tr>
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
CostRow.defaultValues = {
|
|
54
|
-
formatName: false,
|
|
55
|
-
forceMethod: false
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export default CostRow;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
interface Props {
|
|
4
|
-
children: React.ReactNode;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export default function CostSection({ children }: Props): JSX.Element {
|
|
8
|
-
return (
|
|
9
|
-
<div className="costs-section">
|
|
10
|
-
<table>
|
|
11
|
-
<tbody>{children}</tbody>
|
|
12
|
-
</table>
|
|
13
|
-
</div>
|
|
14
|
-
);
|
|
15
|
-
}
|