feat(number-field): add min prop to NumberField and implement minimum value validation in ServiceDataCard
- Introduced a `min` prop to the NumberField component to enforce minimum value constraints. - Updated ServiceDataCard to set the minimum price to 0, enhancing input validation for service pricing.
This commit is contained in:
parent
c52e991e3f
commit
2e849857f2
@ -39,6 +39,7 @@ export function ServiceDataCard({ serviceId }: Readonly<Props>) {
|
||||
<NumberField
|
||||
id="price"
|
||||
label="Цена (₽)"
|
||||
min={0}
|
||||
onChange={(price) => mutate({ data: { price } })}
|
||||
value={service?.price ?? null}
|
||||
/>
|
||||
|
||||
@ -9,6 +9,7 @@ type FieldProps = {
|
||||
readonly disabled?: boolean;
|
||||
readonly id: string;
|
||||
readonly label: string;
|
||||
readonly min?: number;
|
||||
readonly onChange?: (value: null | number) => Promise<void> | void;
|
||||
readonly readOnly?: boolean;
|
||||
readonly value: null | number;
|
||||
@ -18,6 +19,7 @@ export function NumberField({
|
||||
disabled = false,
|
||||
id,
|
||||
label,
|
||||
min,
|
||||
onChange,
|
||||
readOnly,
|
||||
value: initialValue,
|
||||
@ -46,6 +48,7 @@ export function NumberField({
|
||||
className="bg-secondary outline-none focus:ring-0 focus:ring-offset-0"
|
||||
disabled={disabled || isPending}
|
||||
id={id}
|
||||
min={min}
|
||||
onChange={handleChange}
|
||||
readOnly={readOnly}
|
||||
ref={inputRef}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user