import { SystemStyleObject } from "@chakra-ui/react"; import { ReactNode } from "react"; /** The built-in fields plus any customValues, sent to onSubmit and/or POSTed to apiKey. */ export type ContactFormPayload = { /** Built by the form as `firstName` and `lastName` joined by a space. */ name: string; /** Required field. */ firstName: string; /** Optional; an empty string when left blank. */ lastName: string; /** Optional; checked for address format when filled, otherwise an empty string. */ email: string; /** Required, digits only, 7-15 long; validated before submit. */ phone: string; /** Text of the Enquiry field; may be empty. */ message: string; /** Copied from the `customerId` prop; `getCustomValues` cannot override it. */ customerId: string | number; /** Copied from the `organizationId` prop; `getCustomValues` cannot override it. */ organizationId: string | number; [key: string]: unknown; }; /** apiKey is optional — omitting it (with no onSubmit either) fails with an inline "API key missing" alert, not a thrown error. */ export interface ContactFormProps { /** The POST endpoint URL the form fetches to when no onSubmit is given — not an auth token. */ apiKey?: string; /** Called with the submitted payload before/instead of the apiKey fetch; awaited if it returns a promise. */ onSubmit?: (payload: ContactFormPayload) => void | Promise; /** Sent unchanged in every payload to identify the customer; not shown in the form. */ customerId: string | number; /** Sent unchanged in every payload to identify the organization; not shown in the form. */ organizationId: string | number; /** Disables the submit button and blocks submission; fields stay editable. Defaults to false. */ isDisabled?: boolean; /** Rendered markup only — its values are never read automatically; pair with getCustomValues or they're dropped from the submitted payload. */ customFields?: ReactNode; /** Return value spreads into the payload after the built-in fields — a key like "email" silently overwrites the typed value; customerId/organizationId can't be overridden this way. */ getCustomValues?: () => Record; /** Colour scheme of the Send Message button. Defaults to "primary". */ buttonColorScheme?: "primary" | "blue" | "cyan" | "gray" | "green" | "orange" | "pink" | "purple" | "red" | "teal" | "yellow" | "secondary" | "tertiary" | undefined; /** Chakra style object applied to the Send Message button. */ buttonSx?: SystemStyleObject; }