import { Show } from "solid-js" import type { PaymentMethodState } from "@/lib/paymentMethod" // Style/label lookups for a payment method's state, co-located with the row that // consumes them so any future remodel of PaymentMethodState is a single-file // change. const methodStatusStyles: Record = { not_set_up: "bg-gray-100 text-gray-500 border-gray-200", ok: "bg-green-50 text-green-700 border-green-200", error: "bg-red-50 text-red-700 border-red-200", } const methodStatusLabels: Record = { not_set_up: "not set up", ok: "ok", error: "error", } // Presentational payment-method list row (title, optional error line, status // badge, Set up/Update CTA). Props are reactive only when read lazily, so access // props.* inside JSX, never destructure at the top. type PaymentMethodRowProps = { title: string state: PaymentMethodState onAction: () => void } export default function PaymentMethodRow(props: PaymentMethodRowProps) { return (
  • {props.title}

    {(props.state as { message: string }).message}

    {methodStatusLabels[props.state.kind]}
  • ) }