Merged in chore/remove-unused-code (pull request #2229)
Remove unused code * Remove unused scandic-web files * Remove unused exports Approved-by: Joakim Jäderberg
This commit is contained in:
@@ -11,7 +11,6 @@ import { type RoomRate } from "@/types/components/hotelReservation/enterDetails/
|
||||
import type { Price } from "@/types/components/hotelReservation/price"
|
||||
import type { SelectRateSearchParams } from "@/types/components/hotelReservation/selectRate/selectRate"
|
||||
import { CurrencyEnum } from "@/types/enums/currency"
|
||||
import { StepEnum } from "@/types/enums/step"
|
||||
import type { Package } from "@/types/requests/packages"
|
||||
import type { PersistedState, RoomState } from "@/types/stores/enter-details"
|
||||
import type { SafeUser } from "@/types/user"
|
||||
@@ -65,56 +64,6 @@ export function add(...nums: (number | string | undefined)[]) {
|
||||
}, 0)
|
||||
}
|
||||
|
||||
export function subtract(...nums: (number | string | undefined)[]) {
|
||||
return nums.reduce((total: number, num, idx) => {
|
||||
if (typeof num === "undefined") {
|
||||
num = 0
|
||||
}
|
||||
if (idx === 0) {
|
||||
return parseInt(`${num}`)
|
||||
}
|
||||
total = total - parseInt(`${num}`)
|
||||
if (total < 0) {
|
||||
return 0
|
||||
}
|
||||
return total
|
||||
}, 0)
|
||||
}
|
||||
|
||||
export function getCurrency(roomRate: RoomRate) {
|
||||
if ("corporateCheque" in roomRate) {
|
||||
return {
|
||||
localCurrency: CurrencyEnum.CC,
|
||||
requestedCurrency: CurrencyEnum.CC,
|
||||
}
|
||||
} else if ("redemption" in roomRate) {
|
||||
return {
|
||||
localCurrency: CurrencyEnum.POINTS,
|
||||
requestedCurrency: CurrencyEnum.POINTS,
|
||||
}
|
||||
} else if ("voucher" in roomRate) {
|
||||
return {
|
||||
localCurrency: CurrencyEnum.Voucher,
|
||||
requestedCurrency: CurrencyEnum.Voucher,
|
||||
}
|
||||
} else if ("public" in roomRate && roomRate.public) {
|
||||
return {
|
||||
localCurrency: roomRate.public.localPrice.currency,
|
||||
requestedCurrency: roomRate.public.requestedPrice?.currency,
|
||||
}
|
||||
} else if ("member" in roomRate && roomRate.member) {
|
||||
return {
|
||||
localCurrency: roomRate.member.localPrice.currency,
|
||||
requestedCurrency: roomRate.member.requestedPrice?.currency,
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
localCurrency: CurrencyEnum.Unknown,
|
||||
requestedCurrency: CurrencyEnum.Unknown,
|
||||
}
|
||||
}
|
||||
|
||||
export function getRoomPrice(roomRate: RoomRate, isMember: boolean) {
|
||||
if (isMember && "member" in roomRate && roomRate.member) {
|
||||
return {
|
||||
@@ -596,23 +545,6 @@ export function calcTotalPrice(
|
||||
)
|
||||
}
|
||||
|
||||
export function getFirstInteractiveStepOfRoom(room: RoomState["room"]) {
|
||||
if (!room.bedType) {
|
||||
return StepEnum.selectBed
|
||||
}
|
||||
if (room.breakfast !== false) {
|
||||
return StepEnum.breakfast
|
||||
}
|
||||
return StepEnum.details
|
||||
}
|
||||
|
||||
export function findNextInvalidStep(roomState: RoomState) {
|
||||
return (
|
||||
Object.values(roomState.steps).find((stp) => !stp.isValid)?.step ??
|
||||
getFirstInteractiveStepOfRoom(roomState.room)
|
||||
)
|
||||
}
|
||||
|
||||
export const checkRoomProgress = (steps: RoomState["steps"]) => {
|
||||
return Object.values(steps)
|
||||
.filter(Boolean)
|
||||
|
||||
Reference in New Issue
Block a user