@qite/tide-booking-component 0.0.2-preview.9 → 1.0.0-preview
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/README.md +1 -0
- package/build/build-cjs/booking-wizard/components/message.d.ts +1 -0
- package/build/build-cjs/booking-wizard/components/product-card.d.ts +1 -2
- package/build/build-cjs/booking-wizard/features/booking/api.d.ts +21 -0
- package/build/build-cjs/booking-wizard/features/booking/booking-slice.d.ts +95 -19
- package/build/build-cjs/booking-wizard/features/booking/booking.d.ts +1 -2
- package/build/build-cjs/booking-wizard/features/booking/selectors.d.ts +208 -0
- package/build/build-cjs/booking-wizard/features/price-details/price-details-api.d.ts +8 -6
- package/build/build-cjs/booking-wizard/features/price-details/price-details-slice.d.ts +98 -30
- package/build/build-cjs/booking-wizard/features/price-details/util.d.ts +5 -0
- package/build/build-cjs/booking-wizard/features/product-options/no-options.d.ts +2 -0
- package/build/build-cjs/booking-wizard/features/product-options/none-option.d.ts +17 -0
- package/build/build-cjs/booking-wizard/features/product-options/option-booking-group.d.ts +18 -0
- package/build/build-cjs/booking-wizard/features/product-options/option-item.d.ts +11 -0
- package/build/build-cjs/booking-wizard/features/product-options/option-pax-card.d.ts +9 -0
- package/build/build-cjs/booking-wizard/features/product-options/option-pax-group.d.ts +20 -0
- package/build/build-cjs/booking-wizard/features/product-options/option-room.d.ts +16 -0
- package/build/build-cjs/booking-wizard/features/product-options/option-unit-group.d.ts +20 -0
- package/build/build-cjs/booking-wizard/features/product-options/option-units-card.d.ts +9 -0
- package/build/build-cjs/booking-wizard/features/sidebar/index.d.ts +5 -1
- package/build/build-cjs/booking-wizard/features/sidebar/sidebar-flight.d.ts +8 -0
- package/build/build-cjs/booking-wizard/features/sidebar/sidebar-util.d.ts +22 -5
- package/build/build-cjs/booking-wizard/features/sidebar/sidebar.d.ts +16 -8
- package/build/build-cjs/booking-wizard/features/summary/summary-booking-option-pax.d.ts +7 -0
- package/build/build-cjs/booking-wizard/features/summary/summary-booking-option-unit.d.ts +7 -0
- package/build/build-cjs/booking-wizard/features/summary/summary-flight.d.ts +8 -0
- package/build/build-cjs/booking-wizard/features/summary/summary-per-booking-option-group.d.ts +10 -0
- package/build/build-cjs/booking-wizard/features/summary/summary-per-pax-option-group.d.ts +10 -0
- package/build/build-cjs/booking-wizard/features/summary/summary-per-unit-option-group.d.ts +10 -0
- package/build/build-cjs/booking-wizard/features/summary/summary-slice.d.ts +0 -28
- package/build/build-cjs/booking-wizard/features/travelers-form/travelers-form-slice.d.ts +82 -88
- package/build/build-cjs/booking-wizard/features/travelers-form/type-ahead-input.d.ts +1 -0
- package/build/build-cjs/booking-wizard/features/travelers-form/validate-form.d.ts +2 -1
- package/build/build-cjs/booking-wizard/index.d.ts +3 -2
- package/build/build-cjs/booking-wizard/store.d.ts +23 -45
- package/build/build-cjs/booking-wizard/types.d.ts +63 -11
- package/build/build-cjs/booking-wizard/utils/query-string-util.d.ts +13 -0
- package/build/build-cjs/index.js +12065 -2381
- package/build/build-esm/booking-wizard/components/message.d.ts +1 -0
- package/build/build-esm/booking-wizard/components/product-card.d.ts +1 -2
- package/build/build-esm/booking-wizard/features/booking/api.d.ts +21 -0
- package/build/build-esm/booking-wizard/features/booking/booking-slice.d.ts +95 -19
- package/build/build-esm/booking-wizard/features/booking/booking.d.ts +1 -2
- package/build/build-esm/booking-wizard/features/booking/selectors.d.ts +208 -0
- package/build/build-esm/booking-wizard/features/price-details/price-details-api.d.ts +8 -6
- package/build/build-esm/booking-wizard/features/price-details/price-details-slice.d.ts +98 -30
- package/build/build-esm/booking-wizard/features/price-details/util.d.ts +5 -0
- package/build/build-esm/booking-wizard/features/product-options/no-options.d.ts +2 -0
- package/build/build-esm/booking-wizard/features/product-options/none-option.d.ts +17 -0
- package/build/build-esm/booking-wizard/features/product-options/option-booking-group.d.ts +18 -0
- package/build/build-esm/booking-wizard/features/product-options/option-item.d.ts +11 -0
- package/build/build-esm/booking-wizard/features/product-options/option-pax-card.d.ts +9 -0
- package/build/build-esm/booking-wizard/features/product-options/option-pax-group.d.ts +20 -0
- package/build/build-esm/booking-wizard/features/product-options/option-room.d.ts +16 -0
- package/build/build-esm/booking-wizard/features/product-options/option-unit-group.d.ts +20 -0
- package/build/build-esm/booking-wizard/features/product-options/option-units-card.d.ts +9 -0
- package/build/build-esm/booking-wizard/features/sidebar/index.d.ts +5 -1
- package/build/build-esm/booking-wizard/features/sidebar/sidebar-flight.d.ts +8 -0
- package/build/build-esm/booking-wizard/features/sidebar/sidebar-util.d.ts +22 -5
- package/build/build-esm/booking-wizard/features/sidebar/sidebar.d.ts +16 -8
- package/build/build-esm/booking-wizard/features/summary/summary-booking-option-pax.d.ts +7 -0
- package/build/build-esm/booking-wizard/features/summary/summary-booking-option-unit.d.ts +7 -0
- package/build/build-esm/booking-wizard/features/summary/summary-flight.d.ts +8 -0
- package/build/build-esm/booking-wizard/features/summary/summary-per-booking-option-group.d.ts +10 -0
- package/build/build-esm/booking-wizard/features/summary/summary-per-pax-option-group.d.ts +10 -0
- package/build/build-esm/booking-wizard/features/summary/summary-per-unit-option-group.d.ts +10 -0
- package/build/build-esm/booking-wizard/features/summary/summary-slice.d.ts +0 -28
- package/build/build-esm/booking-wizard/features/travelers-form/travelers-form-slice.d.ts +82 -88
- package/build/build-esm/booking-wizard/features/travelers-form/type-ahead-input.d.ts +1 -0
- package/build/build-esm/booking-wizard/features/travelers-form/validate-form.d.ts +2 -1
- package/build/build-esm/booking-wizard/index.d.ts +3 -2
- package/build/build-esm/booking-wizard/store.d.ts +23 -45
- package/build/build-esm/booking-wizard/types.d.ts +63 -11
- package/build/build-esm/booking-wizard/utils/query-string-util.d.ts +13 -0
- package/build/build-esm/index.js +11888 -2330
- package/package.json +8 -4
- package/rollup.config.js +1 -6
- package/src/booking-wizard/components/message.tsx +14 -8
- package/src/booking-wizard/components/product-card.tsx +10 -39
- package/src/booking-wizard/components/step-indicator.tsx +1 -1
- package/src/booking-wizard/components/step-route.tsx +1 -1
- package/src/booking-wizard/features/booking/api.ts +44 -0
- package/src/booking-wizard/features/booking/booking-slice.ts +274 -40
- package/src/booking-wizard/features/booking/booking.tsx +193 -57
- package/src/booking-wizard/features/booking/selectors.ts +328 -0
- package/src/booking-wizard/features/confirmation/confirmation.tsx +22 -11
- package/src/booking-wizard/features/error/error.tsx +15 -2
- package/src/booking-wizard/features/price-details/price-details-api.ts +12 -6
- package/src/booking-wizard/features/price-details/price-details-slice.ts +80 -50
- package/src/booking-wizard/features/price-details/util.ts +135 -0
- package/src/booking-wizard/features/product-options/no-options.tsx +18 -0
- package/src/booking-wizard/features/product-options/none-option.tsx +118 -0
- package/src/booking-wizard/features/product-options/option-booking-group.tsx +210 -0
- package/src/booking-wizard/features/product-options/option-item.tsx +321 -0
- package/src/booking-wizard/features/product-options/option-pax-card.tsx +102 -0
- package/src/booking-wizard/features/product-options/option-pax-group.tsx +169 -0
- package/src/booking-wizard/features/product-options/option-room.tsx +300 -0
- package/src/booking-wizard/features/product-options/option-unit-group.tsx +192 -0
- package/src/booking-wizard/features/product-options/option-units-card.tsx +100 -0
- package/src/booking-wizard/features/product-options/options-form.tsx +226 -48
- package/src/booking-wizard/features/sidebar/index.tsx +43 -20
- package/src/booking-wizard/features/sidebar/sidebar-flight.tsx +66 -0
- package/src/booking-wizard/features/sidebar/sidebar-util.ts +81 -39
- package/src/booking-wizard/features/sidebar/sidebar.tsx +150 -100
- package/src/booking-wizard/features/summary/summary-booking-option-pax.tsx +25 -0
- package/src/booking-wizard/features/summary/summary-booking-option-unit.tsx +25 -0
- package/src/booking-wizard/features/summary/summary-flight.tsx +35 -0
- package/src/booking-wizard/features/summary/summary-per-booking-option-group.tsx +57 -0
- package/src/booking-wizard/features/summary/summary-per-pax-option-group.tsx +51 -0
- package/src/booking-wizard/features/summary/summary-per-unit-option-group.tsx +54 -0
- package/src/booking-wizard/features/summary/summary-slice.ts +1 -134
- package/src/booking-wizard/features/summary/summary.tsx +521 -134
- package/src/booking-wizard/features/travelers-form/travelers-form-slice.ts +54 -55
- package/src/booking-wizard/features/travelers-form/travelers-form.tsx +202 -94
- package/src/booking-wizard/features/travelers-form/type-ahead-input.tsx +23 -3
- package/src/booking-wizard/features/travelers-form/validate-form.ts +40 -3
- package/src/booking-wizard/index.tsx +5 -6
- package/src/booking-wizard/settings-context.ts +33 -5
- package/src/booking-wizard/store.ts +5 -4
- package/src/booking-wizard/translations/translations.json +95 -61
- package/src/booking-wizard/types.ts +67 -10
- package/src/booking-wizard/utils/query-string-util.ts +42 -0
- package/build/build-cjs/booking-wizard/features/product-options/checkbox.d.ts +0 -11
- package/build/build-cjs/booking-wizard/features/product-options/option-details.d.ts +0 -11
- package/build/build-cjs/booking-wizard/features/product-options/product-options-api.d.ts +0 -29
- package/build/build-cjs/booking-wizard/features/product-options/product-options-slice.d.ts +0 -75
- package/build/build-cjs/booking-wizard/features/product-options/radio-button.d.ts +0 -10
- package/build/build-cjs/booking-wizard/features/product-options/rooms-slice.d.ts +0 -23
- package/build/build-cjs/booking-wizard/features/product-options/tree-level.d.ts +0 -7
- package/build/build-esm/booking-wizard/features/product-options/checkbox.d.ts +0 -11
- package/build/build-esm/booking-wizard/features/product-options/option-details.d.ts +0 -11
- package/build/build-esm/booking-wizard/features/product-options/product-options-api.d.ts +0 -29
- package/build/build-esm/booking-wizard/features/product-options/product-options-slice.d.ts +0 -75
- package/build/build-esm/booking-wizard/features/product-options/radio-button.d.ts +0 -10
- package/build/build-esm/booking-wizard/features/product-options/rooms-slice.d.ts +0 -23
- package/build/build-esm/booking-wizard/features/product-options/tree-level.d.ts +0 -7
- package/src/booking-wizard/features/product-options/checkbox.tsx +0 -38
- package/src/booking-wizard/features/product-options/option-details.tsx +0 -65
- package/src/booking-wizard/features/product-options/product-options-api.ts +0 -148
- package/src/booking-wizard/features/product-options/product-options-slice.ts +0 -149
- package/src/booking-wizard/features/product-options/radio-button.tsx +0 -35
- package/src/booking-wizard/features/product-options/rooms-slice.ts +0 -28
- package/src/booking-wizard/features/product-options/tree-level.tsx +0 -118
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qite/tide-booking-component",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "1.0.0-preview",
|
|
4
4
|
"description": "React BookingWizard component for Tide",
|
|
5
5
|
"main": "build/build-cjs/index.js",
|
|
6
6
|
"module": "build/build-esm/index.js",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"license": "OBSD",
|
|
25
25
|
"homepage": "https://bitbucket.org/qitegeneral/tide-booking-component#readme",
|
|
26
26
|
"devDependencies": {
|
|
27
|
+
"@jsonurl/jsonurl": "^1.1.4",
|
|
27
28
|
"@reach/router": "^1.3.4",
|
|
28
29
|
"@reduxjs/toolkit": "^1.6.0",
|
|
29
30
|
"@rollup/plugin-commonjs": "^19.0.1",
|
|
@@ -32,6 +33,7 @@
|
|
|
32
33
|
"@types/flat": "^5.0.2",
|
|
33
34
|
"@types/lodash": "^4.14.171",
|
|
34
35
|
"@types/reach__router": "^1.3.9",
|
|
36
|
+
"@types/react-dom": "^17.0.11",
|
|
35
37
|
"@types/uuid": "^8.3.1",
|
|
36
38
|
"date-fns": "^2.22.1",
|
|
37
39
|
"flat": "^5.0.2",
|
|
@@ -45,10 +47,12 @@
|
|
|
45
47
|
"rollup-plugin-delete": "^2.0.0",
|
|
46
48
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
47
49
|
"rollup-plugin-typescript2": "^0.30.0",
|
|
50
|
+
"tslib": "^2.3.1",
|
|
48
51
|
"typescript": "^4.3.5",
|
|
49
52
|
"uuid": "^8.3.2"
|
|
50
53
|
},
|
|
51
54
|
"peerDependencies": {
|
|
55
|
+
"@jsonurl/jsonurl": "^1.1.4",
|
|
52
56
|
"@reach/router": "^1.3.4",
|
|
53
57
|
"@reduxjs/toolkit": "^1.6.0",
|
|
54
58
|
"date-fns": "^2.22.1",
|
|
@@ -56,12 +60,12 @@
|
|
|
56
60
|
"formik": "^2.2.9",
|
|
57
61
|
"immer": "^9.0.5",
|
|
58
62
|
"lodash": "^4.17.21",
|
|
59
|
-
"react": "^
|
|
60
|
-
"react-dom": "^
|
|
63
|
+
"react": "^16.12.0",
|
|
64
|
+
"react-dom": "^16.12.0",
|
|
61
65
|
"react-redux": "^7.2.4",
|
|
62
66
|
"uuid": "^8.3.2"
|
|
63
67
|
},
|
|
64
68
|
"dependencies": {
|
|
65
|
-
"@qite/tide-client": "
|
|
69
|
+
"@qite/tide-client": "1.1.1"
|
|
66
70
|
}
|
|
67
71
|
}
|
package/rollup.config.js
CHANGED
|
@@ -11,11 +11,6 @@ export default {
|
|
|
11
11
|
output: [
|
|
12
12
|
{ file: packageJson.main, format: "cjs", banner: "/* eslint-disable */" },
|
|
13
13
|
{ file: packageJson.module, format: "esm", banner: "/* eslint-disable */" },
|
|
14
|
-
{
|
|
15
|
-
file: "playground/src/app/booking-wizard/index.js",
|
|
16
|
-
format: "esm",
|
|
17
|
-
banner: "/* eslint-disable */",
|
|
18
|
-
},
|
|
19
14
|
],
|
|
20
15
|
plugins: [
|
|
21
16
|
peerDepsExternal(),
|
|
@@ -23,6 +18,6 @@ export default {
|
|
|
23
18
|
nodeResolve(),
|
|
24
19
|
commonjs(),
|
|
25
20
|
typescript(),
|
|
26
|
-
del({ targets: ["build/*"
|
|
21
|
+
del({ targets: ["build/*"] }),
|
|
27
22
|
],
|
|
28
23
|
};
|
|
@@ -6,21 +6,27 @@ interface MessageProps {
|
|
|
6
6
|
type: "error" | "success";
|
|
7
7
|
title: string;
|
|
8
8
|
actionComponent?: JSX.Element;
|
|
9
|
+
children?: JSX.Element | JSX.Element[];
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
const Message: React.FC<MessageProps> = (
|
|
12
|
+
const Message: React.FC<MessageProps> = ({
|
|
13
|
+
type,
|
|
14
|
+
title,
|
|
15
|
+
actionComponent,
|
|
16
|
+
children,
|
|
17
|
+
}) => (
|
|
12
18
|
<div
|
|
13
19
|
className={buildClassName([
|
|
14
20
|
"booking-message",
|
|
15
|
-
|
|
16
|
-
|
|
21
|
+
type === "error" && "booking-message--error",
|
|
22
|
+
type === "success" && "booking-message--success",
|
|
17
23
|
])}
|
|
18
24
|
>
|
|
19
|
-
{
|
|
20
|
-
<h4 className="booking-message__heading">{
|
|
21
|
-
<div className="booking-message__text">{
|
|
22
|
-
{
|
|
23
|
-
<div className="booking-message__actions">{
|
|
25
|
+
{type === "error" && <Icon name="ui-error" />}
|
|
26
|
+
<h4 className="booking-message__heading">{title}</h4>
|
|
27
|
+
<div className="booking-message__text">{children}</div>
|
|
28
|
+
{actionComponent && (
|
|
29
|
+
<div className="booking-message__actions">{actionComponent}</div>
|
|
24
30
|
)}
|
|
25
31
|
</div>
|
|
26
32
|
);
|
|
@@ -1,64 +1,35 @@
|
|
|
1
|
-
import { format, parseISO } from "date-fns";
|
|
2
|
-
|
|
3
|
-
import Rating from "../components/rating";
|
|
4
1
|
import React from "react";
|
|
5
|
-
import SettingsContext from "../settings-context";
|
|
6
|
-
import { compact } from "lodash";
|
|
7
|
-
import { selectBookingAttributes } from "../features/booking/booking-slice";
|
|
8
|
-
import { useContext } from "react";
|
|
9
|
-
import { useSelector } from "react-redux";
|
|
10
2
|
|
|
11
3
|
interface ProductCardProps {
|
|
12
4
|
productName: string;
|
|
13
|
-
productDescription?: string;
|
|
14
5
|
thumbnailUrl?: string;
|
|
15
|
-
|
|
6
|
+
handleToggleClick: () => void;
|
|
16
7
|
}
|
|
17
8
|
|
|
18
9
|
const ProductCard: React.FC<ProductCardProps> = ({
|
|
19
10
|
productName,
|
|
20
|
-
productDescription,
|
|
21
11
|
thumbnailUrl,
|
|
22
|
-
|
|
12
|
+
handleToggleClick,
|
|
23
13
|
}) => {
|
|
24
|
-
const { showProductCardRating } = useContext(SettingsContext);
|
|
25
|
-
const bookingAttributes = useSelector(selectBookingAttributes);
|
|
26
|
-
|
|
27
|
-
const startDate =
|
|
28
|
-
typeof bookingAttributes?.startDate !== "undefined"
|
|
29
|
-
? parseISO(bookingAttributes.startDate)
|
|
30
|
-
: undefined;
|
|
31
|
-
|
|
32
|
-
const endDate =
|
|
33
|
-
typeof bookingAttributes?.endDate !== "undefined"
|
|
34
|
-
? parseISO(bookingAttributes.endDate)
|
|
35
|
-
: undefined;
|
|
36
|
-
|
|
37
|
-
const dateFormat = "dd/MM/yyyy";
|
|
38
|
-
|
|
39
|
-
const description = compact([
|
|
40
|
-
startDate && format(startDate, dateFormat),
|
|
41
|
-
startDate && endDate && " > ",
|
|
42
|
-
endDate && format(endDate, dateFormat),
|
|
43
|
-
productDescription && `, ${productDescription}`,
|
|
44
|
-
]).join("");
|
|
45
|
-
|
|
46
14
|
return (
|
|
47
15
|
<div className="booking__product">
|
|
48
16
|
<div className="booking__product-image">
|
|
49
17
|
{thumbnailUrl && (
|
|
50
18
|
<img
|
|
51
|
-
src={`${thumbnailUrl}?height=
|
|
19
|
+
src={`${thumbnailUrl}?height=400&width=400`}
|
|
52
20
|
alt={productName}
|
|
53
21
|
className="mediacontent"
|
|
54
22
|
/>
|
|
55
23
|
)}
|
|
56
24
|
</div>
|
|
57
|
-
<div className="booking__product-
|
|
58
|
-
|
|
59
|
-
<h1>{productName}</h1>
|
|
60
|
-
<p className="productcard__description">{description}</p>
|
|
25
|
+
<div className="booking__product-text">
|
|
26
|
+
<h3 className="booking__product-heading">{productName}</h3>
|
|
61
27
|
</div>
|
|
28
|
+
<button
|
|
29
|
+
type="button"
|
|
30
|
+
className="booking__product-toggle"
|
|
31
|
+
onClick={handleToggleClick}
|
|
32
|
+
></button>
|
|
62
33
|
</div>
|
|
63
34
|
);
|
|
64
35
|
};
|
|
@@ -12,7 +12,7 @@ const StepRoute: React.FC<StepRoute> = ({ number, title, component }) => {
|
|
|
12
12
|
return (
|
|
13
13
|
<>
|
|
14
14
|
<StepIndicators currentStep={number} />
|
|
15
|
-
<div className="booking__panel-frame">
|
|
15
|
+
<div className="booking__panel-frame booking__panel-frame--transparent">
|
|
16
16
|
<div className="booking__panel-heading">
|
|
17
17
|
<h4 className="booking__panel-title">
|
|
18
18
|
{number}. {title}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { agents, details, priceDetails } from "@qite/tide-client";
|
|
2
|
+
import {
|
|
3
|
+
BookingPackageRequest,
|
|
4
|
+
BookingPackageDetailsRequest,
|
|
5
|
+
BookingPackage,
|
|
6
|
+
BookingPackageBookRequest,
|
|
7
|
+
BookingPriceDetails,
|
|
8
|
+
BookingTravelAgent,
|
|
9
|
+
TideResponse,
|
|
10
|
+
} from "@qite/tide-client/build/types";
|
|
11
|
+
import { buildTideClientConfig } from "../../utils/tide-api-utils";
|
|
12
|
+
|
|
13
|
+
const fetchDetails = async (
|
|
14
|
+
request: BookingPackageRequest<BookingPackageDetailsRequest>,
|
|
15
|
+
signal: AbortSignal
|
|
16
|
+
): Promise<TideResponse<BookingPackage>> => {
|
|
17
|
+
const tideClientConfig = buildTideClientConfig();
|
|
18
|
+
|
|
19
|
+
return await details(tideClientConfig, request, signal);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const fetchPriceDetails = async (
|
|
23
|
+
request: BookingPackageRequest<BookingPackageBookRequest>,
|
|
24
|
+
signal: AbortSignal
|
|
25
|
+
): Promise<BookingPriceDetails> => {
|
|
26
|
+
const tideClientConfig = buildTideClientConfig();
|
|
27
|
+
|
|
28
|
+
return await priceDetails(tideClientConfig, request, signal);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const fetchAgents = async (
|
|
32
|
+
signal: AbortSignal
|
|
33
|
+
): Promise<BookingTravelAgent[]> => {
|
|
34
|
+
const tideClientConfig = buildTideClientConfig();
|
|
35
|
+
|
|
36
|
+
return await agents(tideClientConfig, signal);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const packageApi = {
|
|
40
|
+
fetchDetails,
|
|
41
|
+
fetchPriceDetails,
|
|
42
|
+
fetchAgents,
|
|
43
|
+
};
|
|
44
|
+
export default packageApi;
|
|
@@ -1,24 +1,172 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
BookingAttributes,
|
|
3
|
+
BookingOptions,
|
|
4
|
+
ProductAttributes,
|
|
5
|
+
} from "../../types";
|
|
6
|
+
import { PayloadAction, createSlice, createAsyncThunk } from "@reduxjs/toolkit";
|
|
3
7
|
|
|
4
8
|
import { RootState } from "../../store";
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
9
|
+
import { isNil, range } from "lodash";
|
|
10
|
+
import {
|
|
11
|
+
selectBookingAttributes,
|
|
12
|
+
selectBookingRooms,
|
|
13
|
+
selectOfficeId,
|
|
14
|
+
selectProductAttributes,
|
|
15
|
+
} from "./selectors";
|
|
16
|
+
import {
|
|
17
|
+
BookingOptionGroup,
|
|
18
|
+
BookingOptionPax,
|
|
19
|
+
BookingOptionUnit,
|
|
20
|
+
BookingPackage,
|
|
21
|
+
BookingPackageDetailsRequest,
|
|
22
|
+
BookingPackagePax,
|
|
23
|
+
BookingPackageRequest,
|
|
24
|
+
BookingPackageRequestRoom,
|
|
25
|
+
BookingPackageRoom,
|
|
26
|
+
BookingTravelAgent,
|
|
27
|
+
PerBookingPackageOption,
|
|
28
|
+
} from "@qite/tide-client/build/types";
|
|
29
|
+
import packageApi from "./api";
|
|
30
|
+
import { selectAgentId } from "../travelers-form/travelers-form-slice";
|
|
7
31
|
|
|
8
32
|
export interface BookingState {
|
|
9
33
|
officeId: number;
|
|
10
34
|
productAttributes?: ProductAttributes;
|
|
11
35
|
bookingAttributes?: BookingAttributes;
|
|
12
|
-
|
|
36
|
+
calculateDeposit: boolean;
|
|
13
37
|
bookingNumber?: string;
|
|
38
|
+
isRetry: boolean;
|
|
39
|
+
package?: BookingPackage;
|
|
40
|
+
agents?: BookingTravelAgent[];
|
|
41
|
+
isBusy: boolean;
|
|
42
|
+
skipPaymentWithAgent: boolean;
|
|
43
|
+
generatePaymentUrl: boolean;
|
|
44
|
+
isUnavailable?: boolean;
|
|
45
|
+
tagIds?: number[];
|
|
46
|
+
agentAdressId?: number;
|
|
47
|
+
remarks?: string;
|
|
48
|
+
voucherCodes?: string[];
|
|
49
|
+
bookingOptions: BookingOptions;
|
|
50
|
+
bookingType: string;
|
|
14
51
|
}
|
|
15
52
|
|
|
16
53
|
const initialState: BookingState = {
|
|
17
54
|
officeId: 1,
|
|
55
|
+
bookingOptions: {
|
|
56
|
+
b2b: {
|
|
57
|
+
tagIds: [],
|
|
58
|
+
entryStatus: 2,
|
|
59
|
+
customEntryStatusId: undefined,
|
|
60
|
+
},
|
|
61
|
+
b2b2c: {
|
|
62
|
+
tagIds: [],
|
|
63
|
+
entryStatus: 2,
|
|
64
|
+
customEntryStatusId: undefined,
|
|
65
|
+
},
|
|
66
|
+
b2c: {
|
|
67
|
+
tagIds: [],
|
|
68
|
+
entryStatus: 0,
|
|
69
|
+
customEntryStatusId: undefined,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
bookingType: "b2c",
|
|
18
73
|
productAttributes: undefined,
|
|
19
74
|
bookingAttributes: undefined,
|
|
20
|
-
|
|
75
|
+
calculateDeposit: false,
|
|
21
76
|
bookingNumber: undefined,
|
|
77
|
+
isRetry: false,
|
|
78
|
+
package: undefined,
|
|
79
|
+
isBusy: false,
|
|
80
|
+
skipPaymentWithAgent: false,
|
|
81
|
+
generatePaymentUrl: false,
|
|
82
|
+
tagIds: [],
|
|
83
|
+
agentAdressId: undefined,
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const fetchPackage = createAsyncThunk(
|
|
87
|
+
"booking/fetchPackage",
|
|
88
|
+
async (_, { dispatch }) => {
|
|
89
|
+
dispatch(setFetchingPackage(true));
|
|
90
|
+
await dispatch(fetchAgents());
|
|
91
|
+
await dispatch(fetchPackageDetails());
|
|
92
|
+
dispatch(setFetchingPackage(false));
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
const fetchAgents = createAsyncThunk(
|
|
97
|
+
"booking/agents",
|
|
98
|
+
async (_, { dispatch, getState, signal }) => {
|
|
99
|
+
return await packageApi.fetchAgents(signal);
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
const fetchPackageDetails = createAsyncThunk(
|
|
104
|
+
"booking/details",
|
|
105
|
+
async (_, { dispatch, getState, signal }) => {
|
|
106
|
+
const state = getState() as RootState;
|
|
107
|
+
|
|
108
|
+
const officeId = selectOfficeId(state);
|
|
109
|
+
const productAttributes = selectProductAttributes(state);
|
|
110
|
+
const bookingAttributes = selectBookingAttributes(state);
|
|
111
|
+
const agentId = selectAgentId(state);
|
|
112
|
+
const rooms = selectBookingRooms(state);
|
|
113
|
+
|
|
114
|
+
if (isNil(productAttributes)) {
|
|
115
|
+
throw Error("productAttributes could not be found");
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (isNil(bookingAttributes)) {
|
|
119
|
+
throw Error("bookingAttributes could not be found");
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (!rooms?.length) {
|
|
123
|
+
throw Error("rooms could not be found");
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
var requestRooms = rooms?.map((x, i) => {
|
|
127
|
+
var room = { index: i, pax: [] } as BookingPackageRequestRoom;
|
|
128
|
+
range(0, x.adults).forEach(() => {
|
|
129
|
+
room.pax.push({
|
|
130
|
+
age: 30,
|
|
131
|
+
} as BookingPackagePax);
|
|
132
|
+
});
|
|
133
|
+
x.childAges.forEach((x) => {
|
|
134
|
+
room.pax.push({
|
|
135
|
+
age: x,
|
|
136
|
+
} as BookingPackagePax);
|
|
137
|
+
});
|
|
138
|
+
return room;
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
const isAllotment =
|
|
142
|
+
bookingAttributes.tourCode ||
|
|
143
|
+
bookingAttributes.allotmentName ||
|
|
144
|
+
(bookingAttributes.allotmentIds && bookingAttributes.allotmentIds.length);
|
|
145
|
+
|
|
146
|
+
const request = {
|
|
147
|
+
officeId: officeId,
|
|
148
|
+
agentId: agentId,
|
|
149
|
+
payload: {
|
|
150
|
+
searchType: isAllotment ? 1 : 0,
|
|
151
|
+
catalogueId: bookingAttributes.catalog,
|
|
152
|
+
productCode: productAttributes.productCode,
|
|
153
|
+
fromDate: bookingAttributes.startDate,
|
|
154
|
+
toDate: bookingAttributes.endDate,
|
|
155
|
+
includeFlights: bookingAttributes.includeFlights,
|
|
156
|
+
allotmentName: bookingAttributes.allotmentName,
|
|
157
|
+
allotmentIds: bookingAttributes.allotmentIds ?? [],
|
|
158
|
+
tourCode: bookingAttributes.tourCode,
|
|
159
|
+
rooms: requestRooms,
|
|
160
|
+
} as BookingPackageDetailsRequest,
|
|
161
|
+
} as BookingPackageRequest<BookingPackageDetailsRequest>;
|
|
162
|
+
|
|
163
|
+
return await packageApi.fetchDetails(request, signal);
|
|
164
|
+
}
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
const getActiveOption = (state: BookingState) => {
|
|
168
|
+
if (state.package) return state.package.options.find((x) => x.isSelected);
|
|
169
|
+
return null;
|
|
22
170
|
};
|
|
23
171
|
|
|
24
172
|
const bookingSlice = createSlice({
|
|
@@ -28,58 +176,144 @@ const bookingSlice = createSlice({
|
|
|
28
176
|
setOfficeId(state, action: PayloadAction<number>) {
|
|
29
177
|
state.officeId = action.payload;
|
|
30
178
|
},
|
|
179
|
+
setBookingOptions(state, action: PayloadAction<BookingOptions>) {
|
|
180
|
+
state.bookingOptions = action.payload;
|
|
181
|
+
},
|
|
182
|
+
setBookingType(state, action: PayloadAction<string>) {
|
|
183
|
+
state.bookingType = action.payload;
|
|
184
|
+
},
|
|
31
185
|
setProductAttributes(state, action: PayloadAction<ProductAttributes>) {
|
|
32
186
|
state.productAttributes = action.payload;
|
|
33
187
|
},
|
|
34
188
|
setBookingAttributes(state, action: PayloadAction<BookingAttributes>) {
|
|
35
189
|
state.bookingAttributes = action.payload;
|
|
36
190
|
},
|
|
37
|
-
|
|
38
|
-
state.
|
|
191
|
+
setCalculateDeposit(state, action: PayloadAction<boolean>) {
|
|
192
|
+
state.calculateDeposit = action.payload;
|
|
39
193
|
},
|
|
40
194
|
setBookingNumber(state, action: PayloadAction<string>) {
|
|
41
195
|
state.bookingNumber = action.payload;
|
|
42
196
|
},
|
|
197
|
+
setIsRetry(state, action: PayloadAction<boolean>) {
|
|
198
|
+
state.isRetry = action.payload;
|
|
199
|
+
},
|
|
200
|
+
setFetchingPackage(state, action: PayloadAction<boolean>) {
|
|
201
|
+
state.isBusy = action.payload;
|
|
202
|
+
},
|
|
203
|
+
setPackage(state, action: PayloadAction<BookingPackage>) {
|
|
204
|
+
state.package = action.payload;
|
|
205
|
+
},
|
|
206
|
+
setPackageRooms(state, action: PayloadAction<BookingPackageRoom[]>) {
|
|
207
|
+
const option = getActiveOption(state);
|
|
208
|
+
if (option) option.rooms = action.payload;
|
|
209
|
+
},
|
|
210
|
+
setPackageOptionPax(state, action: PayloadAction<BookingOptionPax[]>) {
|
|
211
|
+
const option = getActiveOption(state);
|
|
212
|
+
if (option) option.optionPax = action.payload;
|
|
213
|
+
},
|
|
214
|
+
setPackageOptionUnits(state, action: PayloadAction<BookingOptionUnit[]>) {
|
|
215
|
+
const option = getActiveOption(state);
|
|
216
|
+
if (option) option.optionUnits = action.payload;
|
|
217
|
+
},
|
|
218
|
+
setSkipPayment(state, action: PayloadAction<boolean>) {
|
|
219
|
+
state.skipPaymentWithAgent = action.payload;
|
|
220
|
+
},
|
|
221
|
+
setGeneratePaymentUrl(state, action: PayloadAction<boolean>) {
|
|
222
|
+
state.generatePaymentUrl = action.payload;
|
|
223
|
+
},
|
|
224
|
+
setPackageGroups(
|
|
225
|
+
state,
|
|
226
|
+
action: PayloadAction<BookingOptionGroup<PerBookingPackageOption>[]>
|
|
227
|
+
) {
|
|
228
|
+
const option = getActiveOption(state);
|
|
229
|
+
if (option) option.groups = action.payload;
|
|
230
|
+
},
|
|
231
|
+
setTagIds(state, action: PayloadAction<number[] | undefined>) {
|
|
232
|
+
state.tagIds = action.payload;
|
|
233
|
+
},
|
|
234
|
+
setAgentAdressId(state, action: PayloadAction<number | undefined>) {
|
|
235
|
+
state.agentAdressId = action.payload;
|
|
236
|
+
},
|
|
237
|
+
setBookingRemarks(state, action: PayloadAction<string>) {
|
|
238
|
+
state.remarks = action.payload;
|
|
239
|
+
},
|
|
240
|
+
setVoucherCodes(state, action: PayloadAction<string[]>) {
|
|
241
|
+
state.voucherCodes = action.payload;
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
extraReducers: (builder) => {
|
|
245
|
+
builder.addCase(fetchPackageDetails.fulfilled, (state, action) => {
|
|
246
|
+
if (action.payload) {
|
|
247
|
+
if (action.payload.errorCode) {
|
|
248
|
+
console.error(
|
|
249
|
+
action.payload.errorCode,
|
|
250
|
+
action.payload.errorMessage,
|
|
251
|
+
action.payload.errorDetails
|
|
252
|
+
);
|
|
253
|
+
|
|
254
|
+
state.isUnavailable = true;
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (!action.payload.payload) {
|
|
259
|
+
state.isUnavailable = true;
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const bookingRooms = state.bookingAttributes?.rooms;
|
|
264
|
+
const packageDetails = action.payload.payload;
|
|
265
|
+
const activeOption = packageDetails.options.find((x) => x.isSelected);
|
|
266
|
+
|
|
267
|
+
if (
|
|
268
|
+
activeOption &&
|
|
269
|
+
bookingRooms?.some((x) => x.accommodationCode || x.regimeCode)
|
|
270
|
+
) {
|
|
271
|
+
bookingRooms.forEach((room, i) => {
|
|
272
|
+
if (room.accommodationCode || room.regimeCode) {
|
|
273
|
+
activeOption.rooms[i].options = activeOption.rooms[i].options.map(
|
|
274
|
+
(ro) => ({
|
|
275
|
+
...ro,
|
|
276
|
+
isSelected:
|
|
277
|
+
ro.accommodationCode == room.accommodationCode &&
|
|
278
|
+
ro.regimeCode == room.regimeCode,
|
|
279
|
+
})
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
state.package = packageDetails;
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
builder.addCase(fetchAgents.fulfilled, (state, action) => {
|
|
289
|
+
if (action.payload) {
|
|
290
|
+
state.agents = action.payload;
|
|
291
|
+
}
|
|
292
|
+
});
|
|
43
293
|
},
|
|
44
294
|
});
|
|
45
295
|
|
|
46
296
|
export const {
|
|
47
297
|
setOfficeId,
|
|
298
|
+
setBookingOptions,
|
|
299
|
+
setBookingType,
|
|
48
300
|
setProductAttributes,
|
|
49
301
|
setBookingAttributes,
|
|
50
|
-
|
|
302
|
+
setCalculateDeposit,
|
|
51
303
|
setBookingNumber,
|
|
304
|
+
setIsRetry,
|
|
305
|
+
setFetchingPackage,
|
|
306
|
+
setPackage,
|
|
307
|
+
setPackageRooms,
|
|
308
|
+
setPackageOptionPax,
|
|
309
|
+
setPackageOptionUnits,
|
|
310
|
+
setPackageGroups,
|
|
311
|
+
setSkipPayment,
|
|
312
|
+
setGeneratePaymentUrl,
|
|
313
|
+
setTagIds,
|
|
314
|
+
setAgentAdressId,
|
|
315
|
+
setBookingRemarks,
|
|
316
|
+
setVoucherCodes,
|
|
52
317
|
} = bookingSlice.actions;
|
|
53
318
|
|
|
54
|
-
export const selectOfficeId = (state: RootState) => state.booking.officeId;
|
|
55
|
-
|
|
56
|
-
export const selectCacheKey = (state: RootState) => state.booking.cacheKey;
|
|
57
|
-
|
|
58
|
-
export const selectProductAttributes = (state: RootState) =>
|
|
59
|
-
state.booking.productAttributes;
|
|
60
|
-
|
|
61
|
-
export const selectBookingAttributes = (state: RootState) =>
|
|
62
|
-
state.booking.bookingAttributes;
|
|
63
|
-
|
|
64
|
-
export const selectBookingNumber = (state: RootState) =>
|
|
65
|
-
state.booking.bookingNumber;
|
|
66
|
-
|
|
67
|
-
export const selectBookingQueryString = (state: RootState) => {
|
|
68
|
-
const bookingAttributes = state.booking.bookingAttributes;
|
|
69
|
-
|
|
70
|
-
if (!bookingAttributes) {
|
|
71
|
-
return undefined;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const params = new URLSearchParams();
|
|
75
|
-
Object.entries(bookingAttributes).forEach(([key, value]) => {
|
|
76
|
-
if (key === "startDate" || key === "endDate") {
|
|
77
|
-
value = format(parseISO(value), "yyyy-MM-dd");
|
|
78
|
-
}
|
|
79
|
-
params.append(key, value);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
return params.toString();
|
|
83
|
-
};
|
|
84
|
-
|
|
85
319
|
export default bookingSlice.reducer;
|