import { PlusCircle } from "lucide-react"; import { Button } from "@/src/components/ui/button"; import { FormDescription, FormLabel } from "@/src/components/ui/form"; import { Accordion } from "@/src/components/ui/accordion"; import { TierAccordionItem } from "./TierAccordionItem"; import { TierPriceEditor } from "./TierPriceEditor"; import { TierPrefillButtons } from "./TierPrefillButtons"; import type { UseFormReturn, UseFieldArrayReturn } from "react-hook-form"; import type { FormUpsertModel } from "../../validation"; type PricingSectionProps = { fields: UseFieldArrayReturn["fields"]; form: UseFormReturn; remove: UseFieldArrayReturn["remove"]; addTier: () => void; }; export type { PricingSectionProps }; export function PricingSection({ fields, form, remove, addTier, }: PricingSectionProps) { const hasMultipleTiers = fields.length > 1; const defaultTierIndex = fields.findIndex((f) => f.isDefault); if (!hasMultipleTiers) { // SIMPLE VIEW: Just show prices for the single default tier return (
Prices Set prices per usage type for this model. Usage types must exactly match the keys of the ingested usage details.
); } // ACCORDION VIEW: Multiple tiers return (
Pricing Tiers Define pricing rules evaluated in priority order. Tiers are checked from top to bottom until conditions match.
`tier-${i}`)} // All expanded className="space-y-2" > {fields.map((field, index) => ( ))}
); }