import type { PriceFormat } from "../Commerce/commerceTypes"; /** Where the coupon is in its lifecycle; the parent owns it because validation is a server call. */ export type CouponStatus = "idle" | "applying" | "applied" | "error"; /** A coupon the shopper can apply with one tap. */ export interface CouponSuggestion { /** Coupon code, shown in a badge and passed to `onApply` when the suggestion is tapped. */ code: string; /** Offer headline shown beside the code, e.g. "10% off". */ title: string; /** Terms line, e.g. "Min. order ₹999". */ detail?: string; } /** Visible copy; override every string for another language. */ export interface CouponFieldLabels { /** Text of the collapsed toggle row; default "Have a coupon?". */ prompt: string; /** Accessible name of the code input; default "Coupon code". */ inputLabel: string; /** Input placeholder; default "Enter code". */ placeholder: string; /** Apply button text, also the hint on each suggestion; default "Apply". */ apply: string; /** Remove button text in the applied state; default "Remove". */ remove: string; /** Heading above the suggestion list; default "Available offers". */ suggestionsTitle: string; /** Status text once applied, given the code. */ applied: (code: string) => string; /** Saving text once applied, given the formatted amount. */ saved: (amount: string) => string; /** Accessible name of a suggestion, given its code. */ applySuggestion: (code: string) => string; } /** Controlled coupon entry: a collapsed "Have a coupon?" row that opens into a field, then settles into an applied chip. */ export interface CouponFieldProps extends PriceFormat { /** Lifecycle state; default "idle". "applying" disables the input and shows a spinner, "error" shows `error`, "applied" collapses to the chip. */ status?: CouponStatus; /** The code shown in the applied state. */ appliedCode?: string; /** Saving from the applied code; shown as "You saved ₹150". */ savedAmount?: number; /** Message shown under the field while `status` is "error"; announced as an alert. */ error?: string; /** Called with the upper-cased code from the button, Enter, or a suggestion; set `status` to "applying" while it resolves. */ onApply?: (code: string) => void; /** Called from the Remove button shown in the applied state; the parent should then reset `status`. */ onRemove?: () => void; /** Offers listed under the field, each applied in one tap; the list is hidden when empty. */ suggestions?: CouponSuggestion[]; /** Input text when controlled. */ value?: string; /** Initial input text when uncontrolled; default empty. */ defaultValue?: string; /** Called with the code as typed or picked; whitespace is stripped and letters upper-cased first. */ onValueChange?: (value: string) => void; /** Open state of the collapsed row when controlled; the field is always open while applying or in error. */ expanded?: boolean; /** Whether the field starts open when `expanded` is not controlled; default false. */ defaultExpanded?: boolean; /** Called with the new open state when the prompt row is toggled. */ onExpandedChange?: (expanded: boolean) => void; /** Per-string copy overrides; unset keys keep the English defaults. */ labels?: Partial; "data-testid"?: string; }