import React from "react" import Badge from "../../fundamentals/badge" enum RequirementType { MAX_SUBTOTAL = "max_subtotal", MIN_SUBTOTAL = "min_subtotal", } type OptionType = { name: string price_type: "flat_rate" | "calculated" data: { name?: string } amount: number admin_only: boolean requirements: { type: RequirementType amount: number }[] } type ShippingOptionProps = { option: OptionType currency_code: string onEdit: React.ButtonHTMLAttributes["onClick"] } const ShippingOption: React.FC = ({ option, currency_code, onEdit, }) => { return (

{option.name} {option.data.name && `(${option.data.name})`}{" "}

{option.admin_only && Not on website}

{option.price_type === "flat_rate" ? "Flat Rate" : "Calculated"}:{" "} {option.amount !== undefined && `${option.amount / 100} ${currency_code.toUpperCase()}`} {option.requirements.length ? option.requirements.map((r) => { const type = r.type === "max_subtotal" ? "Max. subtotal" : "Min. subtotal" return ` - ${type}: ${ r.amount / 100 } ${currency_code.toUpperCase()}` }) : null}

) } export default ShippingOption