"use client"; import { useEffect, useState } from "react"; import { useFormState } from "react-dom"; import { useRouter } from "next/navigation"; import { updateBtcpayCheckoutStyleAction, type BtcpayCheckoutPreferenceState, } from "../app/(app)/dashboard/actions"; type BtcpayCheckoutStyle = "standard" | "btcpay_classic"; type BtcpayCheckoutStyleSectionProps = { initialStyle: BtcpayCheckoutStyle; }; const initialState = ( style: BtcpayCheckoutStyle ): BtcpayCheckoutPreferenceState => ({ style, error: null, success: null, }); export default function BtcpayCheckoutStyleSection({ initialStyle, }: BtcpayCheckoutStyleSectionProps) { const router = useRouter(); const [state, formAction] = useFormState( updateBtcpayCheckoutStyleAction, initialState(initialStyle) ); const [style, setStyle] = useState(initialStyle); useEffect(() => { if (state.success) { router.refresh(); } }, [router, state.success]); useEffect(() => { setStyle(initialStyle); }, [initialStyle]); return (

BTCPay checkout layout

This setting only applies to BTCPay checkouts (invoices created via the BTCPay compatibility endpoints).

The classic layout mirrors the BTCPay checkout screen for drop-in migration.

{state.error ? (

{state.error}

) : null} {state.success ? (

{state.success}

) : null}
); }