@qite/tide-booking-component 1.3.1 → 1.3.3
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/.vs/ProjectSettings.json +3 -3
- package/.vs/VSWorkspaceState.json +5 -5
- package/README.md +8 -8
- package/build/build-cjs/booking-product/components/age-select.d.ts +8 -8
- package/build/build-cjs/booking-product/components/amount-input.d.ts +10 -10
- package/build/build-cjs/booking-product/components/date-range-picker/calendar-day.d.ts +12 -12
- package/build/build-cjs/booking-product/components/date-range-picker/calendar.d.ts +19 -19
- package/build/build-cjs/booking-product/components/date-range-picker/index.d.ts +20 -23
- package/build/build-cjs/booking-product/components/dates.d.ts +9 -9
- package/build/build-cjs/booking-product/components/footer.d.ts +10 -10
- package/build/build-cjs/booking-product/components/header.d.ts +11 -11
- package/build/build-cjs/booking-product/components/icon.d.ts +10 -10
- package/build/build-cjs/booking-product/components/product.d.ts +9 -9
- package/build/build-cjs/booking-product/components/rating.d.ts +6 -6
- package/build/build-cjs/booking-product/components/rooms.d.ts +10 -10
- package/build/build-cjs/booking-product/index.d.ts +10 -10
- package/build/build-cjs/booking-product/settings-context.d.ts +5 -6
- package/build/build-cjs/booking-product/types.d.ts +25 -25
- package/build/build-cjs/booking-product/utils/api.d.ts +16 -6
- package/build/build-cjs/booking-product/utils/price.d.ts +9 -1
- package/build/build-cjs/booking-wizard/api-settings-slice.d.ts +14 -4
- package/build/build-cjs/booking-wizard/components/icon.d.ts +10 -10
- package/build/build-cjs/booking-wizard/components/labeled-input.d.ts +18 -18
- package/build/build-cjs/booking-wizard/components/labeled-select.d.ts +21 -21
- package/build/build-cjs/booking-wizard/components/message.d.ts +9 -9
- package/build/build-cjs/booking-wizard/components/multi-range-filter.d.ts +11 -11
- package/build/build-cjs/booking-wizard/components/print-offer-button.d.ts +17 -17
- package/build/build-cjs/booking-wizard/components/product-card.d.ts +8 -8
- package/build/build-cjs/booking-wizard/components/step-indicator.d.ts +6 -6
- package/build/build-cjs/booking-wizard/components/step-route.d.ts +9 -9
- package/build/build-cjs/booking-wizard/features/booking/api.d.ts +29 -10
- package/build/build-cjs/booking-wizard/features/booking/booking-self-contained.d.ts +8 -8
- package/build/build-cjs/booking-wizard/features/booking/booking-slice.d.ts +177 -46
- package/build/build-cjs/booking-wizard/features/booking/booking.d.ts +8 -8
- package/build/build-cjs/booking-wizard/features/booking/constants.d.ts +15 -8
- package/build/build-cjs/booking-wizard/features/booking/selectors.d.ts +308 -136
- package/build/build-cjs/booking-wizard/features/confirmation/confirmation.d.ts +4 -5
- package/build/build-cjs/booking-wizard/features/error/error.d.ts +4 -5
- package/build/build-cjs/booking-wizard/features/flight-options/flight-filter.d.ts +9 -9
- package/build/build-cjs/booking-wizard/features/flight-options/flight-option-flight.d.ts +8 -8
- package/build/build-cjs/booking-wizard/features/flight-options/flight-option-modal.d.ts +3 -3
- package/build/build-cjs/booking-wizard/features/flight-options/flight-option.d.ts +10 -10
- package/build/build-cjs/booking-wizard/features/flight-options/flight-utils.d.ts +16 -6
- package/build/build-cjs/booking-wizard/features/flight-options/index.d.ts +4 -5
- package/build/build-cjs/booking-wizard/features/price-details/price-details-api.d.ts +15 -6
- package/build/build-cjs/booking-wizard/features/price-details/price-details-slice.d.ts +121 -80
- package/build/build-cjs/booking-wizard/features/price-details/util.d.ts +5 -2
- package/build/build-cjs/booking-wizard/features/product-options/no-options.d.ts +3 -3
- package/build/build-cjs/booking-wizard/features/product-options/none-option.d.ts +17 -9
- package/build/build-cjs/booking-wizard/features/product-options/option-booking-airline-group.d.ts +17 -8
- package/build/build-cjs/booking-wizard/features/product-options/option-booking-group.d.ts +18 -12
- package/build/build-cjs/booking-wizard/features/product-options/option-item.d.ts +11 -11
- package/build/build-cjs/booking-wizard/features/product-options/option-pax-card.d.ts +13 -10
- package/build/build-cjs/booking-wizard/features/product-options/option-pax-group.d.ts +20 -13
- package/build/build-cjs/booking-wizard/features/product-options/option-room.d.ts +18 -10
- package/build/build-cjs/booking-wizard/features/product-options/option-unit-group.d.ts +20 -13
- package/build/build-cjs/booking-wizard/features/product-options/option-units-card.d.ts +9 -9
- package/build/build-cjs/booking-wizard/features/product-options/options-form.d.ts +4 -5
- package/build/build-cjs/booking-wizard/features/room-options/index.d.ts +4 -5
- package/build/build-cjs/booking-wizard/features/room-options/room-utils.d.ts +29 -9
- package/build/build-cjs/booking-wizard/features/room-options/room.d.ts +15 -12
- package/build/build-cjs/booking-wizard/features/room-options/traveler-rooms.d.ts +13 -9
- package/build/build-cjs/booking-wizard/features/sidebar/index.d.ts +7 -7
- package/build/build-cjs/booking-wizard/features/sidebar/sidebar-flight.d.ts +8 -8
- package/build/build-cjs/booking-wizard/features/sidebar/sidebar-util.d.ts +31 -12
- package/build/build-cjs/booking-wizard/features/sidebar/sidebar.d.ts +29 -25
- package/build/build-cjs/booking-wizard/features/summary/summary-booking-option-pax.d.ts +7 -7
- package/build/build-cjs/booking-wizard/features/summary/summary-booking-option-unit.d.ts +7 -7
- package/build/build-cjs/booking-wizard/features/summary/summary-flight.d.ts +8 -8
- package/build/build-cjs/booking-wizard/features/summary/summary-per-booking-option-group.d.ts +10 -7
- package/build/build-cjs/booking-wizard/features/summary/summary-per-pax-option-group.d.ts +10 -7
- package/build/build-cjs/booking-wizard/features/summary/summary-per-unit-option-group.d.ts +10 -7
- package/build/build-cjs/booking-wizard/features/summary/summary-slice.d.ts +14 -8
- package/build/build-cjs/booking-wizard/features/summary/summary.d.ts +4 -5
- package/build/build-cjs/booking-wizard/features/travelers-form/travelers-form-slice.d.ts +75 -49
- package/build/build-cjs/booking-wizard/features/travelers-form/travelers-form.d.ts +4 -5
- package/build/build-cjs/booking-wizard/features/travelers-form/type-ahead-input.d.ts +16 -16
- package/build/build-cjs/booking-wizard/features/travelers-form/validate-form.d.ts +9 -4
- package/build/build-cjs/booking-wizard/index.d.ts +12 -12
- package/build/build-cjs/booking-wizard/settings-context.d.ts +5 -6
- package/build/build-cjs/booking-wizard/store.d.ts +44 -24
- package/build/build-cjs/booking-wizard/types.d.ts +253 -257
- package/build/build-cjs/booking-wizard/use-offer-printer.d.ts +19 -13
- package/build/build-cjs/index.d.ts +3 -3
- package/build/build-cjs/index.js +16348 -7394
- package/build/build-cjs/shared/components/loader.d.ts +6 -6
- package/build/build-cjs/shared/types.d.ts +4 -4
- package/build/build-cjs/shared/utils/class-util.d.ts +1 -1
- package/build/build-cjs/shared/utils/localization-util.d.ts +248 -248
- package/build/build-cjs/shared/utils/query-string-util.d.ts +29 -8
- package/build/build-cjs/shared/utils/tide-api-utils.d.ts +6 -4
- package/build/build-esm/booking-product/components/age-select.d.ts +8 -8
- package/build/build-esm/booking-product/components/amount-input.d.ts +10 -10
- package/build/build-esm/booking-product/components/date-range-picker/calendar-day.d.ts +12 -12
- package/build/build-esm/booking-product/components/date-range-picker/calendar.d.ts +19 -19
- package/build/build-esm/booking-product/components/date-range-picker/index.d.ts +20 -23
- package/build/build-esm/booking-product/components/dates.d.ts +9 -9
- package/build/build-esm/booking-product/components/footer.d.ts +10 -10
- package/build/build-esm/booking-product/components/header.d.ts +11 -11
- package/build/build-esm/booking-product/components/icon.d.ts +10 -10
- package/build/build-esm/booking-product/components/product.d.ts +9 -9
- package/build/build-esm/booking-product/components/rating.d.ts +6 -6
- package/build/build-esm/booking-product/components/rooms.d.ts +10 -10
- package/build/build-esm/booking-product/index.d.ts +10 -10
- package/build/build-esm/booking-product/settings-context.d.ts +5 -6
- package/build/build-esm/booking-product/types.d.ts +25 -25
- package/build/build-esm/booking-product/utils/api.d.ts +16 -6
- package/build/build-esm/booking-product/utils/price.d.ts +9 -1
- package/build/build-esm/booking-wizard/api-settings-slice.d.ts +14 -4
- package/build/build-esm/booking-wizard/components/icon.d.ts +10 -10
- package/build/build-esm/booking-wizard/components/labeled-input.d.ts +18 -18
- package/build/build-esm/booking-wizard/components/labeled-select.d.ts +21 -21
- package/build/build-esm/booking-wizard/components/message.d.ts +9 -9
- package/build/build-esm/booking-wizard/components/multi-range-filter.d.ts +11 -11
- package/build/build-esm/booking-wizard/components/print-offer-button.d.ts +17 -17
- package/build/build-esm/booking-wizard/components/product-card.d.ts +8 -8
- package/build/build-esm/booking-wizard/components/step-indicator.d.ts +6 -6
- package/build/build-esm/booking-wizard/components/step-route.d.ts +9 -9
- package/build/build-esm/booking-wizard/features/booking/api.d.ts +29 -10
- package/build/build-esm/booking-wizard/features/booking/booking-self-contained.d.ts +8 -8
- package/build/build-esm/booking-wizard/features/booking/booking-slice.d.ts +177 -46
- package/build/build-esm/booking-wizard/features/booking/booking.d.ts +8 -8
- package/build/build-esm/booking-wizard/features/booking/constants.d.ts +15 -8
- package/build/build-esm/booking-wizard/features/booking/selectors.d.ts +308 -136
- package/build/build-esm/booking-wizard/features/confirmation/confirmation.d.ts +4 -5
- package/build/build-esm/booking-wizard/features/error/error.d.ts +4 -5
- package/build/build-esm/booking-wizard/features/flight-options/flight-filter.d.ts +9 -9
- package/build/build-esm/booking-wizard/features/flight-options/flight-option-flight.d.ts +8 -8
- package/build/build-esm/booking-wizard/features/flight-options/flight-option-modal.d.ts +3 -3
- package/build/build-esm/booking-wizard/features/flight-options/flight-option.d.ts +10 -10
- package/build/build-esm/booking-wizard/features/flight-options/flight-utils.d.ts +16 -6
- package/build/build-esm/booking-wizard/features/flight-options/index.d.ts +4 -5
- package/build/build-esm/booking-wizard/features/price-details/price-details-api.d.ts +15 -6
- package/build/build-esm/booking-wizard/features/price-details/price-details-slice.d.ts +121 -80
- package/build/build-esm/booking-wizard/features/price-details/util.d.ts +5 -2
- package/build/build-esm/booking-wizard/features/product-options/no-options.d.ts +3 -3
- package/build/build-esm/booking-wizard/features/product-options/none-option.d.ts +17 -9
- package/build/build-esm/booking-wizard/features/product-options/option-booking-airline-group.d.ts +17 -8
- package/build/build-esm/booking-wizard/features/product-options/option-booking-group.d.ts +18 -12
- package/build/build-esm/booking-wizard/features/product-options/option-item.d.ts +11 -11
- package/build/build-esm/booking-wizard/features/product-options/option-pax-card.d.ts +13 -10
- package/build/build-esm/booking-wizard/features/product-options/option-pax-group.d.ts +20 -13
- package/build/build-esm/booking-wizard/features/product-options/option-room.d.ts +18 -10
- package/build/build-esm/booking-wizard/features/product-options/option-unit-group.d.ts +20 -13
- package/build/build-esm/booking-wizard/features/product-options/option-units-card.d.ts +9 -9
- package/build/build-esm/booking-wizard/features/product-options/options-form.d.ts +4 -5
- package/build/build-esm/booking-wizard/features/room-options/index.d.ts +4 -5
- package/build/build-esm/booking-wizard/features/room-options/room-utils.d.ts +29 -9
- package/build/build-esm/booking-wizard/features/room-options/room.d.ts +15 -12
- package/build/build-esm/booking-wizard/features/room-options/traveler-rooms.d.ts +13 -9
- package/build/build-esm/booking-wizard/features/sidebar/index.d.ts +7 -7
- package/build/build-esm/booking-wizard/features/sidebar/sidebar-flight.d.ts +8 -8
- package/build/build-esm/booking-wizard/features/sidebar/sidebar-util.d.ts +31 -12
- package/build/build-esm/booking-wizard/features/sidebar/sidebar.d.ts +29 -25
- package/build/build-esm/booking-wizard/features/summary/summary-booking-option-pax.d.ts +7 -7
- package/build/build-esm/booking-wizard/features/summary/summary-booking-option-unit.d.ts +7 -7
- package/build/build-esm/booking-wizard/features/summary/summary-flight.d.ts +8 -8
- package/build/build-esm/booking-wizard/features/summary/summary-per-booking-option-group.d.ts +10 -7
- package/build/build-esm/booking-wizard/features/summary/summary-per-pax-option-group.d.ts +10 -7
- package/build/build-esm/booking-wizard/features/summary/summary-per-unit-option-group.d.ts +10 -7
- package/build/build-esm/booking-wizard/features/summary/summary-slice.d.ts +14 -8
- package/build/build-esm/booking-wizard/features/summary/summary.d.ts +4 -5
- package/build/build-esm/booking-wizard/features/travelers-form/travelers-form-slice.d.ts +75 -49
- package/build/build-esm/booking-wizard/features/travelers-form/travelers-form.d.ts +4 -5
- package/build/build-esm/booking-wizard/features/travelers-form/type-ahead-input.d.ts +16 -16
- package/build/build-esm/booking-wizard/features/travelers-form/validate-form.d.ts +9 -4
- package/build/build-esm/booking-wizard/index.d.ts +12 -12
- package/build/build-esm/booking-wizard/settings-context.d.ts +5 -6
- package/build/build-esm/booking-wizard/store.d.ts +44 -24
- package/build/build-esm/booking-wizard/types.d.ts +253 -257
- package/build/build-esm/booking-wizard/use-offer-printer.d.ts +19 -13
- package/build/build-esm/index.d.ts +3 -3
- package/build/build-esm/index.js +15949 -7383
- package/build/build-esm/shared/components/loader.d.ts +6 -6
- package/build/build-esm/shared/types.d.ts +4 -4
- package/build/build-esm/shared/utils/class-util.d.ts +1 -1
- package/build/build-esm/shared/utils/localization-util.d.ts +248 -248
- package/build/build-esm/shared/utils/query-string-util.d.ts +29 -8
- package/build/build-esm/shared/utils/tide-api-utils.d.ts +6 -4
- package/package.json +75 -75
- package/rollup.config.js +23 -23
- package/src/booking-product/components/age-select.tsx +35 -35
- package/src/booking-product/components/amount-input.tsx +78 -78
- package/src/booking-product/components/date-range-picker/calendar-day.tsx +58 -58
- package/src/booking-product/components/date-range-picker/calendar.tsx +178 -178
- package/src/booking-product/components/date-range-picker/index.tsx +196 -196
- package/src/booking-product/components/dates.tsx +136 -136
- package/src/booking-product/components/footer.tsx +69 -69
- package/src/booking-product/components/header.tsx +79 -79
- package/src/booking-product/components/icon.tsx +251 -251
- package/src/booking-product/components/product.tsx +314 -314
- package/src/booking-product/components/rating.tsx +21 -21
- package/src/booking-product/components/rooms.tsx +195 -195
- package/src/booking-product/index.tsx +30 -30
- package/src/booking-product/settings-context.ts +14 -14
- package/src/booking-product/types.ts +28 -28
- package/src/booking-product/utils/api.ts +25 -25
- package/src/booking-product/utils/price.ts +29 -29
- package/src/booking-wizard/api-settings-slice.ts +24 -24
- package/src/booking-wizard/components/icon.tsx +508 -508
- package/src/booking-wizard/components/labeled-input.tsx +64 -64
- package/src/booking-wizard/components/labeled-select.tsx +69 -69
- package/src/booking-wizard/components/message.tsx +34 -34
- package/src/booking-wizard/components/multi-range-filter.tsx +113 -113
- package/src/booking-wizard/components/print-offer-button.tsx +63 -66
- package/src/booking-wizard/components/product-card.tsx +37 -37
- package/src/booking-wizard/components/step-indicator.tsx +51 -51
- package/src/booking-wizard/components/step-route.tsx +27 -27
- package/src/booking-wizard/declarations.d.ts +4 -4
- package/src/booking-wizard/features/booking/api.ts +49 -49
- package/src/booking-wizard/features/booking/booking-self-contained.tsx +389 -384
- package/src/booking-wizard/features/booking/booking-slice.ts +665 -662
- package/src/booking-wizard/features/booking/booking.tsx +361 -356
- package/src/booking-wizard/features/booking/constants.ts +16 -16
- package/src/booking-wizard/features/booking/selectors.ts +441 -441
- package/src/booking-wizard/features/confirmation/confirmation.tsx +97 -97
- package/src/booking-wizard/features/error/error.tsx +78 -78
- package/src/booking-wizard/features/flight-options/flight-filter.tsx +432 -432
- package/src/booking-wizard/features/flight-options/flight-option-flight.tsx +385 -385
- package/src/booking-wizard/features/flight-options/flight-option-modal.tsx +229 -229
- package/src/booking-wizard/features/flight-options/flight-option.tsx +81 -81
- package/src/booking-wizard/features/flight-options/flight-utils.ts +516 -516
- package/src/booking-wizard/features/flight-options/index.tsx +196 -196
- package/src/booking-wizard/features/price-details/price-details-api.ts +24 -24
- package/src/booking-wizard/features/price-details/price-details-slice.ts +178 -178
- package/src/booking-wizard/features/price-details/util.ts +155 -155
- package/src/booking-wizard/features/product-options/no-options.tsx +21 -21
- package/src/booking-wizard/features/product-options/none-option.tsx +120 -120
- package/src/booking-wizard/features/product-options/option-booking-airline-group.tsx +64 -64
- package/src/booking-wizard/features/product-options/option-booking-group.tsx +216 -216
- package/src/booking-wizard/features/product-options/option-item.tsx +317 -317
- package/src/booking-wizard/features/product-options/option-pax-card.tsx +201 -201
- package/src/booking-wizard/features/product-options/option-pax-group.tsx +175 -175
- package/src/booking-wizard/features/product-options/option-room.tsx +321 -321
- package/src/booking-wizard/features/product-options/option-unit-group.tsx +198 -198
- package/src/booking-wizard/features/product-options/option-units-card.tsx +185 -185
- package/src/booking-wizard/features/product-options/options-form.tsx +481 -563
- package/src/booking-wizard/features/room-options/index.tsx +187 -187
- package/src/booking-wizard/features/room-options/room-utils.ts +190 -190
- package/src/booking-wizard/features/room-options/room.tsx +160 -160
- package/src/booking-wizard/features/room-options/traveler-rooms.tsx +75 -75
- package/src/booking-wizard/features/sidebar/index.tsx +76 -76
- package/src/booking-wizard/features/sidebar/sidebar-flight.tsx +68 -68
- package/src/booking-wizard/features/sidebar/sidebar-util.ts +177 -177
- package/src/booking-wizard/features/sidebar/sidebar.tsx +364 -364
- package/src/booking-wizard/features/summary/summary-booking-option-pax.tsx +25 -25
- package/src/booking-wizard/features/summary/summary-booking-option-unit.tsx +25 -25
- package/src/booking-wizard/features/summary/summary-flight.tsx +39 -39
- package/src/booking-wizard/features/summary/summary-per-booking-option-group.tsx +69 -69
- package/src/booking-wizard/features/summary/summary-per-pax-option-group.tsx +63 -63
- package/src/booking-wizard/features/summary/summary-per-unit-option-group.tsx +66 -66
- package/src/booking-wizard/features/summary/summary-slice.ts +28 -28
- package/src/booking-wizard/features/summary/summary.tsx +674 -674
- package/src/booking-wizard/features/travelers-form/travelers-form-slice.ts +164 -164
- package/src/booking-wizard/features/travelers-form/travelers-form.tsx +754 -754
- package/src/booking-wizard/features/travelers-form/type-ahead-input.tsx +101 -101
- package/src/booking-wizard/features/travelers-form/validate-form.ts +245 -245
- package/src/booking-wizard/index.tsx +36 -36
- package/src/booking-wizard/settings-context.ts +62 -62
- package/src/booking-wizard/store.ts +31 -31
- package/src/booking-wizard/types.ts +279 -278
- package/src/booking-wizard/use-offer-printer.ts +117 -136
- package/src/index.ts +4 -4
- package/src/shared/components/loader.tsx +16 -16
- package/src/shared/translations/en-GB.json +237 -237
- package/src/shared/translations/fr-BE.json +238 -238
- package/src/shared/translations/nl-BE.json +237 -237
- package/src/shared/types.ts +4 -4
- package/src/shared/utils/class-util.ts +9 -9
- package/src/shared/utils/localization-util.ts +62 -62
- package/src/shared/utils/query-string-util.ts +119 -119
- package/src/shared/utils/tide-api-utils.ts +36 -36
- package/styles/booking-product-variables.scss +394 -394
- package/styles/booking-product.scss +446 -446
- package/styles/booking-wizard-variables.scss +873 -873
- package/styles/booking-wizard.scss +59 -59
- package/styles/components/_animations.scss +39 -39
- package/styles/components/_base.scss +107 -107
- package/styles/components/_booking.scss +879 -879
- package/styles/components/_button.scss +238 -238
- package/styles/components/_checkbox.scss +219 -219
- package/styles/components/_cta.scss +208 -208
- package/styles/components/_date-list.scss +41 -41
- package/styles/components/_date-range-picker.scss +225 -225
- package/styles/components/_decrement-increment.scss +35 -35
- package/styles/components/_dropdown.scss +72 -72
- package/styles/components/_flight-option.scss +1429 -1429
- package/styles/components/_form.scss +1583 -1583
- package/styles/components/_info-message.scss +71 -71
- package/styles/components/_input.scss +25 -25
- package/styles/components/_list.scss +187 -187
- package/styles/components/_loader.scss +72 -72
- package/styles/components/_mixins.scss +550 -550
- package/styles/components/_placeholders.scss +166 -166
- package/styles/components/_pricing-summary.scss +155 -155
- package/styles/components/_qsm.scss +17 -17
- package/styles/components/_radiobutton.scss +170 -170
- package/styles/components/_select-wrapper.scss +80 -80
- package/styles/components/_spinner.scss +29 -29
- package/styles/components/_step-indicators.scss +168 -168
- package/styles/components/_table.scss +81 -81
- package/styles/components/_tree.scss +530 -530
- package/styles/components/_typeahead.scss +281 -281
- package/styles/components/_variables.scss +89 -89
- package/tsconfig.json +24 -24
|
@@ -1,178 +1,178 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createAsyncThunk,
|
|
3
|
-
createSelector,
|
|
4
|
-
createSlice,
|
|
5
|
-
PayloadAction,
|
|
6
|
-
} from "@reduxjs/toolkit";
|
|
7
|
-
import { sum } from "lodash";
|
|
8
|
-
import { RootState } from "../../store";
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
BookingPriceDetail,
|
|
12
|
-
BookingPriceDetails,
|
|
13
|
-
BookingProductNotification,
|
|
14
|
-
} from "@qite/tide-client/build/types";
|
|
15
|
-
import { setPackage } from "../booking/booking-slice";
|
|
16
|
-
import {
|
|
17
|
-
selectBookingPackageBookRequest,
|
|
18
|
-
selectLanguageCode,
|
|
19
|
-
selectPackageDetails,
|
|
20
|
-
} from "../booking/selectors";
|
|
21
|
-
import priceDetailsApi from "./price-details-api";
|
|
22
|
-
import { updatePackageDetails } from "./util";
|
|
23
|
-
|
|
24
|
-
export interface PriceDetailsState {
|
|
25
|
-
priceDetails: BookingPriceDetail[];
|
|
26
|
-
notifications: BookingProductNotification[];
|
|
27
|
-
deposit?: number;
|
|
28
|
-
isBusy: boolean;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const fetchPriceDetails = createAsyncThunk(
|
|
32
|
-
"priceDetails/fetchPriceDetails",
|
|
33
|
-
async (_, { dispatch, getState, signal }) => {
|
|
34
|
-
dispatch(setFetchingPriceDetails(true));
|
|
35
|
-
dispatch(resetPriceDetails());
|
|
36
|
-
|
|
37
|
-
const state = getState() as RootState;
|
|
38
|
-
const languageCode = selectLanguageCode(state);
|
|
39
|
-
|
|
40
|
-
const request = selectBookingPackageBookRequest(state);
|
|
41
|
-
|
|
42
|
-
if (!request) {
|
|
43
|
-
throw Error("Product not available.");
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const priceDetails: BookingPriceDetails =
|
|
47
|
-
await priceDetailsApi.fetchPriceDetails(
|
|
48
|
-
state.apiSettings,
|
|
49
|
-
request,
|
|
50
|
-
signal,
|
|
51
|
-
languageCode
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
dispatch(setFetchingPriceDetails(false));
|
|
55
|
-
|
|
56
|
-
const packageDetails = selectPackageDetails(state);
|
|
57
|
-
if (packageDetails) {
|
|
58
|
-
const updatedPackageDetails = updatePackageDetails(
|
|
59
|
-
packageDetails,
|
|
60
|
-
priceDetails.changedLines
|
|
61
|
-
);
|
|
62
|
-
dispatch(setPackage(updatedPackageDetails));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return priceDetails;
|
|
66
|
-
}
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
const priceDetailsSlice = createSlice({
|
|
70
|
-
name: "priceDetails",
|
|
71
|
-
initialState: <PriceDetailsState>{
|
|
72
|
-
priceDetails: [],
|
|
73
|
-
notifications: [],
|
|
74
|
-
isBusy: false,
|
|
75
|
-
},
|
|
76
|
-
reducers: {
|
|
77
|
-
setFetchingPriceDetails(state, action: PayloadAction<boolean>) {
|
|
78
|
-
state.isBusy = action.payload;
|
|
79
|
-
},
|
|
80
|
-
setNotifications(
|
|
81
|
-
state,
|
|
82
|
-
action: PayloadAction<BookingProductNotification[]>
|
|
83
|
-
) {
|
|
84
|
-
state.notifications = action.payload;
|
|
85
|
-
},
|
|
86
|
-
resetPriceDetails(state, _: PayloadAction<void>) {
|
|
87
|
-
state.priceDetails = [];
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
extraReducers: (builder) => {
|
|
91
|
-
builder.addCase(fetchPriceDetails.fulfilled, (state, action) => {
|
|
92
|
-
if (action.payload) {
|
|
93
|
-
state.deposit = action.payload.deposit;
|
|
94
|
-
state.priceDetails = action.payload.details;
|
|
95
|
-
state.notifications = action.payload.notifications;
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
},
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
export const selectPriceDetails = (state: RootState) =>
|
|
102
|
-
state.priceDetails.priceDetails;
|
|
103
|
-
|
|
104
|
-
export const selectPackagePriceDetails = createSelector(
|
|
105
|
-
selectPriceDetails,
|
|
106
|
-
(priceDetails) =>
|
|
107
|
-
priceDetails.filter((priceDetail) => priceDetail.isInPackage)
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
export const selectSeparatePackagePriceDetails = createSelector(
|
|
111
|
-
selectPackagePriceDetails,
|
|
112
|
-
(pricedetails) => {
|
|
113
|
-
const result: BookingPriceDetail[] = [];
|
|
114
|
-
const filteredPriceDetails = pricedetails.filter(
|
|
115
|
-
(priceDetail) => priceDetail.isSeparate
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
filteredPriceDetails.forEach((priceDetail) => {
|
|
119
|
-
const priceDetailToMerge = result.find(
|
|
120
|
-
(x) =>
|
|
121
|
-
x.productCode === priceDetail.productCode &&
|
|
122
|
-
x.accommodationCode === priceDetail.accommodationCode &&
|
|
123
|
-
x.productType === priceDetail.productType
|
|
124
|
-
);
|
|
125
|
-
if (priceDetailToMerge) {
|
|
126
|
-
priceDetailToMerge.total += priceDetail.total;
|
|
127
|
-
priceDetailToMerge.price += priceDetail.price;
|
|
128
|
-
} else {
|
|
129
|
-
result.push(Object.assign({}, priceDetail));
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
return result;
|
|
134
|
-
}
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
export const selectBasePrice = createSelector(
|
|
138
|
-
selectPackagePriceDetails,
|
|
139
|
-
(priceDetails) =>
|
|
140
|
-
sum(
|
|
141
|
-
priceDetails.map((priceDetail) => priceDetail.price * priceDetail.amount)
|
|
142
|
-
)
|
|
143
|
-
);
|
|
144
|
-
|
|
145
|
-
export const selectSeparateExtraPriceDetails = createSelector(
|
|
146
|
-
selectPriceDetails,
|
|
147
|
-
(priceDetails) =>
|
|
148
|
-
priceDetails.filter(
|
|
149
|
-
(priceDetail) => !priceDetail.isInPackage && priceDetail.isSeparate
|
|
150
|
-
)
|
|
151
|
-
);
|
|
152
|
-
|
|
153
|
-
export const selectTotalPrice = createSelector(
|
|
154
|
-
selectBasePrice,
|
|
155
|
-
selectSeparateExtraPriceDetails,
|
|
156
|
-
(basePrice, separatePriceDetails) =>
|
|
157
|
-
sum([
|
|
158
|
-
basePrice,
|
|
159
|
-
...separatePriceDetails.map(
|
|
160
|
-
(priceDetail) => priceDetail.price * priceDetail.amount
|
|
161
|
-
),
|
|
162
|
-
])
|
|
163
|
-
);
|
|
164
|
-
|
|
165
|
-
export const selectDeposit = (state: RootState) => state.priceDetails.deposit;
|
|
166
|
-
|
|
167
|
-
export const selectIsFetchingPriceDetails = (state: RootState) =>
|
|
168
|
-
state.priceDetails.isBusy;
|
|
169
|
-
|
|
170
|
-
export const selectNotifications = (state: RootState) =>
|
|
171
|
-
state.priceDetails.notifications;
|
|
172
|
-
|
|
173
|
-
const { setFetchingPriceDetails } = priceDetailsSlice.actions;
|
|
174
|
-
|
|
175
|
-
export const { resetPriceDetails, setNotifications } =
|
|
176
|
-
priceDetailsSlice.actions;
|
|
177
|
-
|
|
178
|
-
export default priceDetailsSlice.reducer;
|
|
1
|
+
import {
|
|
2
|
+
createAsyncThunk,
|
|
3
|
+
createSelector,
|
|
4
|
+
createSlice,
|
|
5
|
+
PayloadAction,
|
|
6
|
+
} from "@reduxjs/toolkit";
|
|
7
|
+
import { sum } from "lodash";
|
|
8
|
+
import { RootState } from "../../store";
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
BookingPriceDetail,
|
|
12
|
+
BookingPriceDetails,
|
|
13
|
+
BookingProductNotification,
|
|
14
|
+
} from "@qite/tide-client/build/types";
|
|
15
|
+
import { setPackage } from "../booking/booking-slice";
|
|
16
|
+
import {
|
|
17
|
+
selectBookingPackageBookRequest,
|
|
18
|
+
selectLanguageCode,
|
|
19
|
+
selectPackageDetails,
|
|
20
|
+
} from "../booking/selectors";
|
|
21
|
+
import priceDetailsApi from "./price-details-api";
|
|
22
|
+
import { updatePackageDetails } from "./util";
|
|
23
|
+
|
|
24
|
+
export interface PriceDetailsState {
|
|
25
|
+
priceDetails: BookingPriceDetail[];
|
|
26
|
+
notifications: BookingProductNotification[];
|
|
27
|
+
deposit?: number;
|
|
28
|
+
isBusy: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const fetchPriceDetails = createAsyncThunk(
|
|
32
|
+
"priceDetails/fetchPriceDetails",
|
|
33
|
+
async (_, { dispatch, getState, signal }) => {
|
|
34
|
+
dispatch(setFetchingPriceDetails(true));
|
|
35
|
+
dispatch(resetPriceDetails());
|
|
36
|
+
|
|
37
|
+
const state = getState() as RootState;
|
|
38
|
+
const languageCode = selectLanguageCode(state);
|
|
39
|
+
|
|
40
|
+
const request = selectBookingPackageBookRequest(state);
|
|
41
|
+
|
|
42
|
+
if (!request) {
|
|
43
|
+
throw Error("Product not available.");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const priceDetails: BookingPriceDetails =
|
|
47
|
+
await priceDetailsApi.fetchPriceDetails(
|
|
48
|
+
state.apiSettings,
|
|
49
|
+
request,
|
|
50
|
+
signal,
|
|
51
|
+
languageCode
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
dispatch(setFetchingPriceDetails(false));
|
|
55
|
+
|
|
56
|
+
const packageDetails = selectPackageDetails(state);
|
|
57
|
+
if (packageDetails) {
|
|
58
|
+
const updatedPackageDetails = updatePackageDetails(
|
|
59
|
+
packageDetails,
|
|
60
|
+
priceDetails.changedLines
|
|
61
|
+
);
|
|
62
|
+
dispatch(setPackage(updatedPackageDetails));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return priceDetails;
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
const priceDetailsSlice = createSlice({
|
|
70
|
+
name: "priceDetails",
|
|
71
|
+
initialState: <PriceDetailsState>{
|
|
72
|
+
priceDetails: [],
|
|
73
|
+
notifications: [],
|
|
74
|
+
isBusy: false,
|
|
75
|
+
},
|
|
76
|
+
reducers: {
|
|
77
|
+
setFetchingPriceDetails(state, action: PayloadAction<boolean>) {
|
|
78
|
+
state.isBusy = action.payload;
|
|
79
|
+
},
|
|
80
|
+
setNotifications(
|
|
81
|
+
state,
|
|
82
|
+
action: PayloadAction<BookingProductNotification[]>
|
|
83
|
+
) {
|
|
84
|
+
state.notifications = action.payload;
|
|
85
|
+
},
|
|
86
|
+
resetPriceDetails(state, _: PayloadAction<void>) {
|
|
87
|
+
state.priceDetails = [];
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
extraReducers: (builder) => {
|
|
91
|
+
builder.addCase(fetchPriceDetails.fulfilled, (state, action) => {
|
|
92
|
+
if (action.payload) {
|
|
93
|
+
state.deposit = action.payload.deposit;
|
|
94
|
+
state.priceDetails = action.payload.details;
|
|
95
|
+
state.notifications = action.payload.notifications;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
export const selectPriceDetails = (state: RootState) =>
|
|
102
|
+
state.priceDetails.priceDetails;
|
|
103
|
+
|
|
104
|
+
export const selectPackagePriceDetails = createSelector(
|
|
105
|
+
selectPriceDetails,
|
|
106
|
+
(priceDetails) =>
|
|
107
|
+
priceDetails.filter((priceDetail) => priceDetail.isInPackage)
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
export const selectSeparatePackagePriceDetails = createSelector(
|
|
111
|
+
selectPackagePriceDetails,
|
|
112
|
+
(pricedetails) => {
|
|
113
|
+
const result: BookingPriceDetail[] = [];
|
|
114
|
+
const filteredPriceDetails = pricedetails.filter(
|
|
115
|
+
(priceDetail) => priceDetail.isSeparate
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
filteredPriceDetails.forEach((priceDetail) => {
|
|
119
|
+
const priceDetailToMerge = result.find(
|
|
120
|
+
(x) =>
|
|
121
|
+
x.productCode === priceDetail.productCode &&
|
|
122
|
+
x.accommodationCode === priceDetail.accommodationCode &&
|
|
123
|
+
x.productType === priceDetail.productType
|
|
124
|
+
);
|
|
125
|
+
if (priceDetailToMerge) {
|
|
126
|
+
priceDetailToMerge.total += priceDetail.total;
|
|
127
|
+
priceDetailToMerge.price += priceDetail.price;
|
|
128
|
+
} else {
|
|
129
|
+
result.push(Object.assign({}, priceDetail));
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
return result;
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
export const selectBasePrice = createSelector(
|
|
138
|
+
selectPackagePriceDetails,
|
|
139
|
+
(priceDetails) =>
|
|
140
|
+
sum(
|
|
141
|
+
priceDetails.map((priceDetail) => priceDetail.price * priceDetail.amount)
|
|
142
|
+
)
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
export const selectSeparateExtraPriceDetails = createSelector(
|
|
146
|
+
selectPriceDetails,
|
|
147
|
+
(priceDetails) =>
|
|
148
|
+
priceDetails.filter(
|
|
149
|
+
(priceDetail) => !priceDetail.isInPackage && priceDetail.isSeparate
|
|
150
|
+
)
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
export const selectTotalPrice = createSelector(
|
|
154
|
+
selectBasePrice,
|
|
155
|
+
selectSeparateExtraPriceDetails,
|
|
156
|
+
(basePrice, separatePriceDetails) =>
|
|
157
|
+
sum([
|
|
158
|
+
basePrice,
|
|
159
|
+
...separatePriceDetails.map(
|
|
160
|
+
(priceDetail) => priceDetail.price * priceDetail.amount
|
|
161
|
+
),
|
|
162
|
+
])
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
export const selectDeposit = (state: RootState) => state.priceDetails.deposit;
|
|
166
|
+
|
|
167
|
+
export const selectIsFetchingPriceDetails = (state: RootState) =>
|
|
168
|
+
state.priceDetails.isBusy;
|
|
169
|
+
|
|
170
|
+
export const selectNotifications = (state: RootState) =>
|
|
171
|
+
state.priceDetails.notifications;
|
|
172
|
+
|
|
173
|
+
const { setFetchingPriceDetails } = priceDetailsSlice.actions;
|
|
174
|
+
|
|
175
|
+
export const { resetPriceDetails, setNotifications } =
|
|
176
|
+
priceDetailsSlice.actions;
|
|
177
|
+
|
|
178
|
+
export default priceDetailsSlice.reducer;
|
|
@@ -1,155 +1,155 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BookingOptionGroup,
|
|
3
|
-
BookingOptionPax,
|
|
4
|
-
BookingOptionUnit,
|
|
5
|
-
BookingPackage,
|
|
6
|
-
BookingPackageOption,
|
|
7
|
-
BookingPackageRoom,
|
|
8
|
-
ChangedLine,
|
|
9
|
-
PerBookingPackageOption,
|
|
10
|
-
PerPaxPackageOption,
|
|
11
|
-
PerUnitPackageOption,
|
|
12
|
-
} from "@qite/tide-client/build/types";
|
|
13
|
-
|
|
14
|
-
export const updatePackageDetails = (
|
|
15
|
-
packageDetails: BookingPackage,
|
|
16
|
-
changedLines: ChangedLine[]
|
|
17
|
-
): BookingPackage => {
|
|
18
|
-
return {
|
|
19
|
-
...packageDetails,
|
|
20
|
-
options: packageDetails.options.map((opt) => {
|
|
21
|
-
return {
|
|
22
|
-
...opt,
|
|
23
|
-
rooms: opt.isSelected
|
|
24
|
-
? updateRooms(opt.rooms, changedLines)
|
|
25
|
-
: opt.rooms,
|
|
26
|
-
groups: opt.isSelected
|
|
27
|
-
? updateBookingGroups(opt.groups, changedLines)
|
|
28
|
-
: opt.groups,
|
|
29
|
-
optionUnits: opt.isSelected
|
|
30
|
-
? updateOptionUnits(opt.optionUnits, changedLines)
|
|
31
|
-
: opt.optionUnits,
|
|
32
|
-
optionPax: opt.isSelected
|
|
33
|
-
? updateOptionPax(opt.optionPax, changedLines)
|
|
34
|
-
: opt.optionPax,
|
|
35
|
-
} as BookingPackageOption;
|
|
36
|
-
}),
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
// ROOMS
|
|
41
|
-
const updateRooms = (
|
|
42
|
-
rooms: BookingPackageRoom[],
|
|
43
|
-
changedLines: ChangedLine[]
|
|
44
|
-
) => {
|
|
45
|
-
return rooms.map((room) => ({
|
|
46
|
-
...room,
|
|
47
|
-
options: room.options.map((option) => ({
|
|
48
|
-
...option,
|
|
49
|
-
price:
|
|
50
|
-
changedLines.find((x) => x.entryLineGuid == option.entryLineGuid)
|
|
51
|
-
?.price ?? option.price,
|
|
52
|
-
})),
|
|
53
|
-
}));
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
// PAX
|
|
57
|
-
const updateOptionPax = (
|
|
58
|
-
pax: BookingOptionPax[],
|
|
59
|
-
changedLines: ChangedLine[]
|
|
60
|
-
): BookingOptionPax[] => {
|
|
61
|
-
return pax.map((p) => ({
|
|
62
|
-
...p,
|
|
63
|
-
groups: updatePaxGroups(p.groups, changedLines),
|
|
64
|
-
}));
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const updatePaxGroups = (
|
|
68
|
-
groups: BookingOptionGroup<PerPaxPackageOption>[],
|
|
69
|
-
changedLines: ChangedLine[]
|
|
70
|
-
): BookingOptionGroup<PerPaxPackageOption>[] => {
|
|
71
|
-
return groups.map((g) => ({
|
|
72
|
-
...g,
|
|
73
|
-
options: g.options.map((o) => ({
|
|
74
|
-
...o,
|
|
75
|
-
groups: updatePaxGroups(o.groups, changedLines),
|
|
76
|
-
line: {
|
|
77
|
-
...o.line,
|
|
78
|
-
price:
|
|
79
|
-
changedLines.find((cl) => cl.entryLineGuid === o.line.entryLineGuid)
|
|
80
|
-
?.price ?? o.line.price,
|
|
81
|
-
},
|
|
82
|
-
alternatives: o.alternatives.map((a) => ({
|
|
83
|
-
...a,
|
|
84
|
-
price:
|
|
85
|
-
changedLines.find((cl) => cl.entryLineGuid === a.entryLineGuid)
|
|
86
|
-
?.price ?? a.price,
|
|
87
|
-
})),
|
|
88
|
-
})),
|
|
89
|
-
}));
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
// UNITS
|
|
93
|
-
const updateOptionUnits = (
|
|
94
|
-
units: BookingOptionUnit[],
|
|
95
|
-
changedLines: ChangedLine[]
|
|
96
|
-
): BookingOptionUnit[] => {
|
|
97
|
-
return units.map((u) => ({
|
|
98
|
-
...u,
|
|
99
|
-
groups: updateUnitGroups(u.groups, changedLines),
|
|
100
|
-
}));
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
const updateUnitGroups = (
|
|
104
|
-
groups: BookingOptionGroup<PerUnitPackageOption>[],
|
|
105
|
-
changedLines: ChangedLine[]
|
|
106
|
-
): BookingOptionGroup<PerUnitPackageOption>[] => {
|
|
107
|
-
return groups.map((g) => ({
|
|
108
|
-
...g,
|
|
109
|
-
options: g.options.map((o) => ({
|
|
110
|
-
...o,
|
|
111
|
-
groups: updateUnitGroups(o.groups, changedLines),
|
|
112
|
-
pax: updateOptionPax(o.pax, changedLines),
|
|
113
|
-
line: {
|
|
114
|
-
...o.line,
|
|
115
|
-
price:
|
|
116
|
-
changedLines.find((cl) => cl.entryLineGuid === o.line.entryLineGuid)
|
|
117
|
-
?.price ?? o.line.price,
|
|
118
|
-
},
|
|
119
|
-
alternatives: o.alternatives.map((a) => ({
|
|
120
|
-
...a,
|
|
121
|
-
price:
|
|
122
|
-
changedLines.find((cl) => cl.entryLineGuid === a.entryLineGuid)
|
|
123
|
-
?.price ?? a.price,
|
|
124
|
-
})),
|
|
125
|
-
})),
|
|
126
|
-
}));
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
// BOOKING
|
|
130
|
-
const updateBookingGroups = (
|
|
131
|
-
groups: BookingOptionGroup<PerBookingPackageOption>[],
|
|
132
|
-
changedLines: ChangedLine[]
|
|
133
|
-
): BookingOptionGroup<PerBookingPackageOption>[] => {
|
|
134
|
-
return groups.map((g) => ({
|
|
135
|
-
...g,
|
|
136
|
-
options: g.options.map((o) => ({
|
|
137
|
-
...o,
|
|
138
|
-
groups: updateBookingGroups(o.groups, changedLines),
|
|
139
|
-
units: updateOptionUnits(o.units, changedLines),
|
|
140
|
-
pax: updateOptionPax(o.pax, changedLines),
|
|
141
|
-
line: {
|
|
142
|
-
...o.line,
|
|
143
|
-
price:
|
|
144
|
-
changedLines.find((cl) => cl.entryLineGuid === o.line.entryLineGuid)
|
|
145
|
-
?.price ?? o.line.price,
|
|
146
|
-
},
|
|
147
|
-
alternatives: o.alternatives.map((a) => ({
|
|
148
|
-
...a,
|
|
149
|
-
price:
|
|
150
|
-
changedLines.find((cl) => cl.entryLineGuid === a.entryLineGuid)
|
|
151
|
-
?.price ?? a.price,
|
|
152
|
-
})),
|
|
153
|
-
})),
|
|
154
|
-
}));
|
|
155
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
BookingOptionGroup,
|
|
3
|
+
BookingOptionPax,
|
|
4
|
+
BookingOptionUnit,
|
|
5
|
+
BookingPackage,
|
|
6
|
+
BookingPackageOption,
|
|
7
|
+
BookingPackageRoom,
|
|
8
|
+
ChangedLine,
|
|
9
|
+
PerBookingPackageOption,
|
|
10
|
+
PerPaxPackageOption,
|
|
11
|
+
PerUnitPackageOption,
|
|
12
|
+
} from "@qite/tide-client/build/types";
|
|
13
|
+
|
|
14
|
+
export const updatePackageDetails = (
|
|
15
|
+
packageDetails: BookingPackage,
|
|
16
|
+
changedLines: ChangedLine[]
|
|
17
|
+
): BookingPackage => {
|
|
18
|
+
return {
|
|
19
|
+
...packageDetails,
|
|
20
|
+
options: packageDetails.options.map((opt) => {
|
|
21
|
+
return {
|
|
22
|
+
...opt,
|
|
23
|
+
rooms: opt.isSelected
|
|
24
|
+
? updateRooms(opt.rooms, changedLines)
|
|
25
|
+
: opt.rooms,
|
|
26
|
+
groups: opt.isSelected
|
|
27
|
+
? updateBookingGroups(opt.groups, changedLines)
|
|
28
|
+
: opt.groups,
|
|
29
|
+
optionUnits: opt.isSelected
|
|
30
|
+
? updateOptionUnits(opt.optionUnits, changedLines)
|
|
31
|
+
: opt.optionUnits,
|
|
32
|
+
optionPax: opt.isSelected
|
|
33
|
+
? updateOptionPax(opt.optionPax, changedLines)
|
|
34
|
+
: opt.optionPax,
|
|
35
|
+
} as BookingPackageOption;
|
|
36
|
+
}),
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// ROOMS
|
|
41
|
+
const updateRooms = (
|
|
42
|
+
rooms: BookingPackageRoom[],
|
|
43
|
+
changedLines: ChangedLine[]
|
|
44
|
+
) => {
|
|
45
|
+
return rooms.map((room) => ({
|
|
46
|
+
...room,
|
|
47
|
+
options: room.options.map((option) => ({
|
|
48
|
+
...option,
|
|
49
|
+
price:
|
|
50
|
+
changedLines.find((x) => x.entryLineGuid == option.entryLineGuid)
|
|
51
|
+
?.price ?? option.price,
|
|
52
|
+
})),
|
|
53
|
+
}));
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// PAX
|
|
57
|
+
const updateOptionPax = (
|
|
58
|
+
pax: BookingOptionPax[],
|
|
59
|
+
changedLines: ChangedLine[]
|
|
60
|
+
): BookingOptionPax[] => {
|
|
61
|
+
return pax.map((p) => ({
|
|
62
|
+
...p,
|
|
63
|
+
groups: updatePaxGroups(p.groups, changedLines),
|
|
64
|
+
}));
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const updatePaxGroups = (
|
|
68
|
+
groups: BookingOptionGroup<PerPaxPackageOption>[],
|
|
69
|
+
changedLines: ChangedLine[]
|
|
70
|
+
): BookingOptionGroup<PerPaxPackageOption>[] => {
|
|
71
|
+
return groups.map((g) => ({
|
|
72
|
+
...g,
|
|
73
|
+
options: g.options.map((o) => ({
|
|
74
|
+
...o,
|
|
75
|
+
groups: updatePaxGroups(o.groups, changedLines),
|
|
76
|
+
line: {
|
|
77
|
+
...o.line,
|
|
78
|
+
price:
|
|
79
|
+
changedLines.find((cl) => cl.entryLineGuid === o.line.entryLineGuid)
|
|
80
|
+
?.price ?? o.line.price,
|
|
81
|
+
},
|
|
82
|
+
alternatives: o.alternatives.map((a) => ({
|
|
83
|
+
...a,
|
|
84
|
+
price:
|
|
85
|
+
changedLines.find((cl) => cl.entryLineGuid === a.entryLineGuid)
|
|
86
|
+
?.price ?? a.price,
|
|
87
|
+
})),
|
|
88
|
+
})),
|
|
89
|
+
}));
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// UNITS
|
|
93
|
+
const updateOptionUnits = (
|
|
94
|
+
units: BookingOptionUnit[],
|
|
95
|
+
changedLines: ChangedLine[]
|
|
96
|
+
): BookingOptionUnit[] => {
|
|
97
|
+
return units.map((u) => ({
|
|
98
|
+
...u,
|
|
99
|
+
groups: updateUnitGroups(u.groups, changedLines),
|
|
100
|
+
}));
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const updateUnitGroups = (
|
|
104
|
+
groups: BookingOptionGroup<PerUnitPackageOption>[],
|
|
105
|
+
changedLines: ChangedLine[]
|
|
106
|
+
): BookingOptionGroup<PerUnitPackageOption>[] => {
|
|
107
|
+
return groups.map((g) => ({
|
|
108
|
+
...g,
|
|
109
|
+
options: g.options.map((o) => ({
|
|
110
|
+
...o,
|
|
111
|
+
groups: updateUnitGroups(o.groups, changedLines),
|
|
112
|
+
pax: updateOptionPax(o.pax, changedLines),
|
|
113
|
+
line: {
|
|
114
|
+
...o.line,
|
|
115
|
+
price:
|
|
116
|
+
changedLines.find((cl) => cl.entryLineGuid === o.line.entryLineGuid)
|
|
117
|
+
?.price ?? o.line.price,
|
|
118
|
+
},
|
|
119
|
+
alternatives: o.alternatives.map((a) => ({
|
|
120
|
+
...a,
|
|
121
|
+
price:
|
|
122
|
+
changedLines.find((cl) => cl.entryLineGuid === a.entryLineGuid)
|
|
123
|
+
?.price ?? a.price,
|
|
124
|
+
})),
|
|
125
|
+
})),
|
|
126
|
+
}));
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// BOOKING
|
|
130
|
+
const updateBookingGroups = (
|
|
131
|
+
groups: BookingOptionGroup<PerBookingPackageOption>[],
|
|
132
|
+
changedLines: ChangedLine[]
|
|
133
|
+
): BookingOptionGroup<PerBookingPackageOption>[] => {
|
|
134
|
+
return groups.map((g) => ({
|
|
135
|
+
...g,
|
|
136
|
+
options: g.options.map((o) => ({
|
|
137
|
+
...o,
|
|
138
|
+
groups: updateBookingGroups(o.groups, changedLines),
|
|
139
|
+
units: updateOptionUnits(o.units, changedLines),
|
|
140
|
+
pax: updateOptionPax(o.pax, changedLines),
|
|
141
|
+
line: {
|
|
142
|
+
...o.line,
|
|
143
|
+
price:
|
|
144
|
+
changedLines.find((cl) => cl.entryLineGuid === o.line.entryLineGuid)
|
|
145
|
+
?.price ?? o.line.price,
|
|
146
|
+
},
|
|
147
|
+
alternatives: o.alternatives.map((a) => ({
|
|
148
|
+
...a,
|
|
149
|
+
price:
|
|
150
|
+
changedLines.find((cl) => cl.entryLineGuid === a.entryLineGuid)
|
|
151
|
+
?.price ?? a.price,
|
|
152
|
+
})),
|
|
153
|
+
})),
|
|
154
|
+
}));
|
|
155
|
+
};
|