Skip to content

EventTypeDepositFields

Renders a labeled fieldset with two inputs — a fixed deposit in cents and a percentage of price — plus a live preview of the resolved deposit amount and the remaining balance. Mirrors the resolution rule in @thebookingkit/core’s computeDepositAmount: percentage wins when both are set, and the deposit is capped at the event price.

Terminal window
npx thebookingkit add event-type-deposit-fields

Drop it into any event-type editor. The component is fully controlled — wire each input to your form state:

import { EventTypeDepositFields } from "@/components/event-type-deposit-fields";
export function EventTypeForm({ form }: { form: EventTypeFormState }) {
return (
<EventTypeDepositFields
depositCents={form.depositCents}
depositPercentage={form.depositPercentage}
priceCents={form.priceCents}
currency={form.currency}
onDepositCentsChange={form.setDepositCents}
onDepositPercentageChange={form.setDepositPercentage}
/>
);
}

When persisting, write the values straight to event_types.deposit_cents / event_types.deposit_percentage — the server-side requiresDeposit and computeDepositAmount helpers consume the same shape.

export interface EventTypeDepositFieldsProps {
/** Fixed deposit amount in cents (or null if unset) */
depositCents: number | null;
/** Deposit as a percentage of price (0–100), or null if unset */
depositPercentage: number | null;
/** Event-type price in cents — used to preview the resolved deposit */
priceCents: number;
/** ISO 4217 currency for preview formatting */
currency: string;
/** Called when the fixed deposit changes */
onDepositCentsChange: (value: number | null) => void;
/** Called when the percentage deposit changes */
onDepositPercentageChange: (value: number | null) => void;
/** Disable both inputs */
disabled?: boolean;
/** Additional CSS class name */
className?: string;
/** Inline styles */
style?: React.CSSProperties;
}

The resolved deposit is computed live as the user types and matches computeDepositAmount exactly:

depositCentsdepositPercentagepriceCentsResolved
null / 0null / 0any0 (no deposit)
2500null / 0any2500
null / 025100002500
500025100002500 (percentage wins)
9999901000010000 (capped at price)