Merged in chore/move-enter-details (pull request #2778)

Chore/move enter details

Approved-by: Anton Gunnarsson
This commit is contained in:
Joakim Jäderberg
2025-09-11 07:16:24 +00:00
parent 15711cb3a4
commit 7dee6d5083
238 changed files with 1656 additions and 1602 deletions

View File

@@ -1,25 +0,0 @@
"use client"
import { useEffect, useState } from "react"
import { PaymentMethodEnum } from "@scandic-hotels/common/constants/paymentMethod"
export function useAvailablePaymentOptions(
otherPaymentOptions: PaymentMethodEnum[]
) {
const [availablePaymentOptions, setAvailablePaymentOptions] = useState<
PaymentMethodEnum[]
>(
otherPaymentOptions.filter(
(option) => option !== PaymentMethodEnum.applePay
)
)
useEffect(() => {
if (window.ApplePaySession) {
setAvailablePaymentOptions(otherPaymentOptions)
}
}, [otherPaymentOptions, setAvailablePaymentOptions])
return availablePaymentOptions
}

View File

@@ -2,13 +2,12 @@ import { useRouter } from "next/navigation"
import { useCallback, useEffect, useState } from "react"
import { useIntl } from "react-intl"
import { trackEvent } from "@scandic-hotels/common/tracking/base"
import { useHandleBookingStatus } from "@scandic-hotels/booking-flow/hooks/useHandleBookingStatus"
import { toast } from "@scandic-hotels/design-system/Toast"
import { trackEvent } from "@scandic-hotels/tracking/base"
import { trpc } from "@scandic-hotels/trpc/client"
import { BookingStatusEnum } from "@scandic-hotels/trpc/enums/bookingStatus"
import { useHandleBookingStatus } from "@/hooks/booking/useHandleBookingStatus"
const maxRetries = 15
const retryInterval = 2000

View File

@@ -1,62 +0,0 @@
"use client"
import { useRef } from "react"
import { trpc } from "@scandic-hotels/trpc/client"
import useLang from "@/hooks/useLang"
import type { BookingStatusEnum } from "@scandic-hotels/trpc/enums/bookingStatus"
export function useHandleBookingStatus({
refId,
expectedStatuses,
maxRetries,
retryInterval,
enabled,
}: {
refId: string | null
expectedStatuses: BookingStatusEnum[]
maxRetries: number
retryInterval: number
enabled: boolean
}) {
const lang = useLang()
const retries = useRef(0)
const query = trpc.booking.status.useQuery(
{
lang,
refId: refId ?? "",
},
{
enabled,
refetchInterval: (query) => {
retries.current = query.state.dataUpdateCount
if (query.state.error || query.state.dataUpdateCount >= maxRetries) {
return false
}
if (
expectedStatuses.includes(
query.state.data?.booking.reservationStatus as BookingStatusEnum
)
) {
return false
}
return retryInterval
},
refetchIntervalInBackground: true,
refetchOnWindowFocus: false,
refetchOnMount: false,
retry: false,
}
)
return {
...query,
isTimeout: retries.current >= maxRetries,
}
}