Type Alias: SubmittedPriceTierFormValue
type SubmittedPriceTierFormValue = Omit<PriceTierFormValue, "defaultPrice"> & {
defaultPrice?: Omit<PriceTierDefaultPrice, "durationUnit"> & {
durationUnit: DurationPricingUnit | null;
};
};Defined in: shared/pricing/types/tier-form.ts:363
What PriceTierDialog actually hands to onSubmit — the same shape as
PriceTierFormValue, except defaultPrice.durationUnit is required.
Why the input and output types differ
They are the same schema on the way IN and a narrowed one on the way OUT, because the two directions have opposite safety requirements for this one field:
- In (
initialValue) it must be optional, or everydefaultPriceliteral written before the duration axis existed stops compiling. - Out (
onSubmit) it must be required, because the consumer's next move is to forward it tosetCellPrice'sper— whereundefinedmeans preserve the cell's existing axis and onlynullmeans remove it.
With one optional type for both, setCellPrice({ ..., per: value.defaultPrice ?.durationUnit }) type-checks while being wrong: an operator clears the
Duration select, the consumer forwards undefined, and the cell goes on
charging per-attendee-per-hour with nothing reporting it. The dialog already
always emits the key — this makes the TYPE say so, so a consumer cannot
accidentally build a value that drops it.
Consumers writing a handler should annotate it with this type rather than
PriceTierFormValue; assigning the handler to onSubmit gets it either way.
Type Declaration
defaultPrice?
optional defaultPrice?: Omit<PriceTierDefaultPrice, "durationUnit"> & {
durationUnit: DurationPricingUnit | null;
};Type Declaration
durationUnit
durationUnit: DurationPricingUnit | null;