@qite/tide-booking-component 1.0.39 → 1.0.41

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.
@@ -7754,6 +7754,16 @@ var bookingSlice = toolkit.createSlice({
7754
7754
  activeOption_1.rooms[i].options = activeOption_1.rooms[i].options.map(function (ro) { return (__assign(__assign({}, ro), { isSelected: ro.accommodationCode == room.accommodationCode &&
7755
7755
  ro.regimeCode == room.regimeCode })); });
7756
7756
  }
7757
+ // Fall back to an option that has the requested accommodation OR regime if the requested option is not available. If no fallback is available, select the first option.
7758
+ if (!activeOption_1.rooms[i].options.some(function (x) { return x.isSelected; })) {
7759
+ var fallbackOption = activeOption_1.rooms[i].options.find(function (x) { return x.accommodationCode == room.accommodationCode || x.regimeCode == room.regimeCode; });
7760
+ if (fallbackOption) {
7761
+ fallbackOption.isSelected = true;
7762
+ }
7763
+ else {
7764
+ activeOption_1.rooms[i].options[0].isSelected = true;
7765
+ }
7766
+ }
7757
7767
  });
7758
7768
  }
7759
7769
  state.package = packageDetails;
@@ -7743,6 +7743,16 @@ var bookingSlice = createSlice({
7743
7743
  activeOption_1.rooms[i].options = activeOption_1.rooms[i].options.map(function (ro) { return (__assign(__assign({}, ro), { isSelected: ro.accommodationCode == room.accommodationCode &&
7744
7744
  ro.regimeCode == room.regimeCode })); });
7745
7745
  }
7746
+ // Fall back to an option that has the requested accommodation OR regime if the requested option is not available. If no fallback is available, select the first option.
7747
+ if (!activeOption_1.rooms[i].options.some(function (x) { return x.isSelected; })) {
7748
+ var fallbackOption = activeOption_1.rooms[i].options.find(function (x) { return x.accommodationCode == room.accommodationCode || x.regimeCode == room.regimeCode; });
7749
+ if (fallbackOption) {
7750
+ fallbackOption.isSelected = true;
7751
+ }
7752
+ else {
7753
+ activeOption_1.rooms[i].options[0].isSelected = true;
7754
+ }
7755
+ }
7746
7756
  });
7747
7757
  }
7748
7758
  state.package = packageDetails;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qite/tide-booking-component",
3
- "version": "1.0.39",
3
+ "version": "1.0.41",
4
4
  "description": "React BookingWizard component for Tide",
5
5
  "main": "build/build-cjs/index.js",
6
6
  "module": "build/build-esm/index.js",
@@ -399,6 +399,16 @@ const bookingSlice = createSlice({
399
399
  })
400
400
  );
401
401
  }
402
+
403
+ // Fallback to an option that has the requested accommodation OR regime if the requested option is not available. If no fallback is available, select the first option.
404
+ if (!activeOption.rooms[i].options.some(x => x.isSelected)) {
405
+ const fallbackOption = activeOption.rooms[i].options.find(x => x.accommodationCode == room.accommodationCode || x.regimeCode == room.regimeCode);
406
+ if (fallbackOption) {
407
+ fallbackOption.isSelected = true;
408
+ } else {
409
+ activeOption.rooms[i].options[0].isSelected = true;
410
+ }
411
+ }
402
412
  });
403
413
  }
404
414
 
@@ -72,12 +72,14 @@ const OptionRoom: React.FC<OptionRoomProps> = ({
72
72
  const regimes = uniqBy(
73
73
  compact(
74
74
  packageRoom &&
75
- packageRoom.options.map((option) => {
76
- return {
77
- regimeCode: option.regimeCode,
78
- regimeName: option.regimeName,
79
- };
80
- })
75
+ packageRoom.options
76
+ .filter(x => !selectedOption || x.accommodationCode == selectedOption.accommodationCode)
77
+ .map((option) => {
78
+ return {
79
+ regimeCode: option.regimeCode,
80
+ regimeName: option.regimeName,
81
+ };
82
+ })
81
83
  ),
82
84
  "regimeCode"
83
85
  );