Merged in feat/sw-2874-move-select-rate (pull request #2750)
Approved-by: Joakim Jäderberg
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { type Dayjs, dt } from "@scandic-hotels/common/dt"
|
||||
import { hasOverlappingDates } from "@scandic-hotels/common/dt/utils/hasOverlappingDates"
|
||||
import {
|
||||
MaterialIcon,
|
||||
type MaterialIconSetIconProps,
|
||||
@@ -100,44 +101,3 @@ export function filterOverlappingDates<
|
||||
hasOverlappingDates(item, startDate, endDate)
|
||||
)
|
||||
}
|
||||
|
||||
export function hasOverlappingDates(
|
||||
dateRangeItem: {
|
||||
startDate: Date | Dayjs | string | undefined | null
|
||||
endDate: Date | Dayjs | string | undefined | null
|
||||
},
|
||||
fromDate: Date | Dayjs,
|
||||
toDate: Date | Dayjs
|
||||
) {
|
||||
const startDate = dt(fromDate)
|
||||
const endDate = dt(toDate)
|
||||
|
||||
if (dateRangeItem.endDate && dateRangeItem.startDate) {
|
||||
const itemStartDate = dt(dateRangeItem.startDate)
|
||||
const itemEndDate = dt(dateRangeItem.endDate)
|
||||
|
||||
const fromDateIsBetweenItemDates = startDate.isBetween(
|
||||
itemStartDate,
|
||||
itemEndDate,
|
||||
"date",
|
||||
"[]"
|
||||
)
|
||||
const toDateIsBetweenItemDates = endDate.isBetween(
|
||||
itemStartDate,
|
||||
itemEndDate,
|
||||
"date",
|
||||
"[]"
|
||||
)
|
||||
|
||||
const itemFullyContained =
|
||||
startDate.isSameOrBefore(itemStartDate, "date") &&
|
||||
endDate.isSameOrAfter(itemEndDate, "date")
|
||||
|
||||
return (
|
||||
fromDateIsBetweenItemDates ||
|
||||
toDateIsBetweenItemDates ||
|
||||
itemFullyContained
|
||||
)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
9
packages/booking-flow/lib/utils/nuqs.ts
Normal file
9
packages/booking-flow/lib/utils/nuqs.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
// We re-export the NuqsAdapter here to work around issues
|
||||
// with the consuming apps using nuqs from another module.
|
||||
// See: https://github.com/47ng/nuqs/issues/798
|
||||
|
||||
// We should fix this another way, but moving it to peerDeps
|
||||
// didn't seem to work so the next solution would be to move
|
||||
// nuqs to a custom workspace package.
|
||||
|
||||
export { NuqsAdapter } from "nuqs/adapters/next/app"
|
||||
Reference in New Issue
Block a user