fix(retail-sale): блок пустого Draft на UI + бэк уже отказывает
Some checks failed
CI / Backend (.NET 8) (push) Successful in 1m18s
CI / Web (React + Vite) (push) Successful in 46s
Docker API / Build + push API (push) Successful in 1m30s
Docker Web / Build + push Web (push) Successful in 44s
Docker API / Deploy API on stage (push) Successful in 19s
Docker Web / Deploy Web on stage (push) Successful in 12s
CI / POS (WPF, Windows) (push) Has been cancelled
Some checks failed
CI / Backend (.NET 8) (push) Successful in 1m18s
CI / Web (React + Vite) (push) Successful in 46s
Docker API / Build + push API (push) Successful in 1m30s
Docker Web / Build + push Web (push) Successful in 44s
Docker API / Deploy API on stage (push) Successful in 19s
Docker Web / Deploy Web on stage (push) Successful in 12s
CI / POS (WPF, Windows) (push) Has been cancelled
Серверная защита от пустого RetailSale пришла вместе с FK-валидацией
(commit 5716829: «Чек должен содержать хотя бы одну позицию» → 400).
Этот коммит — UI-сторона.
В RetailSaleEditPage кнопка «Сохранить» теперь disabled когда
form.lines.length === 0, с tooltip «Добавьте хотя бы одну позицию».
Раньше пользователь мог нажать Сохранить, получить 400 «empty lines»,
не понять что делать.
This commit is contained in:
parent
319a91ff10
commit
bac527d3a8
|
|
@ -196,7 +196,10 @@ export function RetailSaleEditPage() {
|
|||
const removeLine = (i: number) =>
|
||||
setForm({ ...form, lines: form.lines.filter((_, ix) => ix !== i) })
|
||||
|
||||
const canSave = !!form.storeId && !!form.currencyId && isDraft
|
||||
// Сохранять Draft без позиций — бессмысленно (его потом всё равно
|
||||
// нельзя провести). Сервер тоже блокирует это с 400, но UX лучше когда
|
||||
// кнопка disabled с подсказкой.
|
||||
const canSave = !!form.storeId && !!form.currencyId && isDraft && form.lines.length > 0
|
||||
|
||||
return (
|
||||
<form onSubmit={onSubmit} className="flex flex-col h-full">
|
||||
|
|
@ -228,7 +231,12 @@ export function RetailSaleEditPage() {
|
|||
</Button>
|
||||
)}
|
||||
{isDraft && (
|
||||
<Button type="submit" variant="secondary" disabled={!canSave || save.isPending}>
|
||||
<Button
|
||||
type="submit"
|
||||
variant="secondary"
|
||||
disabled={!canSave || save.isPending}
|
||||
title={form.lines.length === 0 ? 'Добавьте хотя бы одну позицию' : undefined}
|
||||
>
|
||||
<Save className="w-4 h-4" /> {save.isPending ? 'Сохраняю…' : 'Сохранить'}
|
||||
</Button>
|
||||
)}
|
||||
|
|
|
|||
Loading…
Reference in a new issue