/** Where the check is: nothing entered, request in flight, a serviceable or unserviceable answer, or a malformed pincode. */ export type PincodeStatus = "idle" | "checking" | "serviceable" | "unserviceable" | "invalid"; /** The answer for one pincode; structurally the same as the demo fixtures' `PincodeResult`. */ export interface PincodeResult { /** False means the pincode is not serviceable. */ ok: boolean; /** Shown after the pincode in the saved line, e.g. "560001 · Bengaluru". */ city?: string; /** Ready-to-print delivery date such as "Thu, 8 Oct"; never a range of days. */ deliveryBy?: string; /** Cash on delivery available at this pincode. */ cod?: boolean; /** Fee rules, e.g. "Free above ₹999 · ₹49 handling with COD". */ shippingNote?: string; /** Replaces the default wording for an unserviceable or invalid pincode. */ message?: string; } /** Every string the checker renders; override all of them for another language. */ export interface PincodeCheckerLabels { /** Heading (h2) above the field. */ heading: string; /** Visually hidden label of the pincode input. */ inputLabel: string; /** Placeholder of the empty pincode input. */ placeholder: string; /** Text of the submit button. */ check: string; /** Text of the link button that reopens the field after a serviceable result. */ change: string; /** Visible helper under the idle field. */ hint: string; /** Error under the field for a malformed pincode; `PincodeResult.message` replaces it when status is invalid. */ invalid: string; /** Headline for an unserviceable pincode; `PincodeResult.message` replaces it. */ unserviceable: string; /** Visually hidden announcement while a check is in flight. */ checking: string; /** Prefix before the date, e.g. "Delivery by". */ deliveryBy: string; /** Line shown when the result has `cod: true`. */ codAvailable: string; /** Line shown when the result has `cod: false`; omitted when `cod` is undefined. */ codUnavailable: string; /** Prefix in the saved line, e.g. "Deliver to". */ deliverTo: string; /** Helper under the unserviceable message. */ unserviceableHint: string; } /** Six-digit pincode field that answers with a delivery date, COD availability and a shipping note. */ export interface PincodeCheckerProps { /** Controlled pincode digits; pair with `onValueChange`. */ value?: string; /** Starting pincode when uncontrolled, e.g. the shopper's last one. */ defaultValue?: string; /** Fires on every edit with the digits-only value, capped at six digits. */ onValueChange?: (pincode: string) => void; /** Controlled status; omit it and the checker derives the status from what `onCheck` resolves. */ status?: PincodeStatus; /** Controlled result matching `status`; omit it and the checker keeps the last `onCheck` result. */ result?: PincodeResult; /** Runs when a valid pincode is submitted (Check, Enter, or the sixth digit with `autoCheck`). */ onCheck?: (pincode: string) => Promise | PincodeResult | void; /** Checks as soon as the sixth digit is typed; the Check button always works. */ autoCheck?: boolean; /** Runs `onCheck` once on mount when the initial pincode is valid, for a saved pincode. */ checkOnMount?: boolean; /** Overrides for any label; unspecified strings keep the English defaults. */ labels?: Partial; "data-testid"?: string; }