Merged in chore/SW-3321-move-selectratecontext-to- (pull request #2729)
chore(SW-3321): Moved Select rate context to booking-flow package * chore(SW-3321): Moved Select rate context to booking-flow package * chore(SW-3321): Optimised code Approved-by: Joakim Jäderberg
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import type { PackageEnum } from "@scandic-hotels/trpc/types/packages"
|
||||
|
||||
import type { DefaultRoomPackage, RoomPackage } from "./types"
|
||||
|
||||
export function getSelectedPackages(
|
||||
availablePackages: (DefaultRoomPackage | RoomPackage)[] | undefined,
|
||||
selectedPackages: PackageEnum[]
|
||||
): RoomPackage[] {
|
||||
if (
|
||||
!availablePackages ||
|
||||
!selectedPackages ||
|
||||
selectedPackages.length === 0
|
||||
) {
|
||||
return []
|
||||
}
|
||||
|
||||
return availablePackages.filter((pack) => {
|
||||
const isSelected = selectedPackages.some(
|
||||
(selected) => selected === pack.code
|
||||
)
|
||||
return isSelected
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user