26 lines
642 B
TypeScript
26 lines
642 B
TypeScript
"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
|
|
}
|