Merged in feat/SW-755-price-change-non-happy (pull request #957)
Feat/SW-755 price change non happy * fix(SW-755): dont show field error if checkbox has no children * feat(SW-755): Price change route + dialog WIP * fix(SW-755): minor refactoring * fix(SW-755): added logging to price change route * fix(SW-755): remove redundant search param logic * fix(SW-755): moved enum cast to zod instead * fix(SW-755): move prop type to types folder * fix(SW-755): Added suspense to Payment and refactored payment options hook * fix(SW-755): seperated terms and conditions copy from the checkbox label * fix(SW-755): add currency format and fixed wrong translation * fix(SW-755): change from undefined to null * fix(SW-755): added extra type safety to payment options Approved-by: Christian Andolf Approved-by: Simon.Emanuelsson
This commit is contained in:
23
hooks/booking/useAvailablePaymentOptions.ts
Normal file
23
hooks/booking/useAvailablePaymentOptions.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
"use client"
|
||||
|
||||
import { useEffect, useState } from "react"
|
||||
|
||||
import { PaymentMethodEnum } from "@/constants/booking"
|
||||
|
||||
export function useAvailablePaymentOptions(
|
||||
otherPaymentOptions: PaymentMethodEnum[]
|
||||
) {
|
||||
const [availablePaymentOptions, setAvailablePaymentOptions] = useState(
|
||||
otherPaymentOptions.filter(
|
||||
(option) => option !== PaymentMethodEnum.applePay
|
||||
)
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (window.ApplePaySession) {
|
||||
setAvailablePaymentOptions(otherPaymentOptions)
|
||||
}
|
||||
}, [otherPaymentOptions, setAvailablePaymentOptions])
|
||||
|
||||
return availablePaymentOptions
|
||||
}
|
||||
@@ -10,18 +10,20 @@ export function useHandleBookingStatus({
|
||||
expectedStatus,
|
||||
maxRetries,
|
||||
retryInterval,
|
||||
enabled,
|
||||
}: {
|
||||
confirmationNumber: string | null
|
||||
expectedStatus: BookingStatusEnum
|
||||
maxRetries: number
|
||||
retryInterval: number
|
||||
enabled: boolean
|
||||
}) {
|
||||
const retries = useRef(0)
|
||||
|
||||
const query = trpc.booking.status.useQuery(
|
||||
{ confirmationNumber: confirmationNumber ?? "" },
|
||||
{
|
||||
enabled: !!confirmationNumber,
|
||||
enabled,
|
||||
refetchInterval: (query) => {
|
||||
retries.current = query.state.dataUpdateCount
|
||||
|
||||
|
||||
@@ -43,6 +43,6 @@ export function usePaymentFailedToast() {
|
||||
|
||||
const queryParams = new URLSearchParams(searchParams.toString())
|
||||
queryParams.delete("errorCode")
|
||||
router.replace(`${pathname}?${queryParams.toString()}`)
|
||||
}, [searchParams, router, pathname, errorCode, errorMessage])
|
||||
router.push(`${pathname}?${queryParams.toString()}`)
|
||||
}, [searchParams, pathname, errorCode, errorMessage, router])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user