Files
web/apps/scandic-web/hooks/booking/useAvailablePaymentOptions.ts
Anton Gunnarsson e4ad0d3466 Update typescript
2025-05-22 14:00:38 +02:00

26 lines
615 B
TypeScript

"use client"
import { useEffect, useState } from "react"
import { PaymentMethodEnum } from "@/constants/booking"
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
}