tools: the quantity rule is written twice — and the two disagree about a blank field

Chiusa
#331 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
1-2 giorni
Idoneità per principianti
30/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
api, frontend

Direzione di ricerca

Read src/components/manage/ToolDetail.tsx and src/engine/cnc/registerCutter.ts to compare how each handles a blank quantity, then check houseClient.InventoryItemSchema for the service's rule. The first step is a maintainer decision on whether a blank field should be refused or read as one, since the issue says that choice is still open. Done means one shared quantity rule and one shared error message, imported by both files, with the blank-field reasoning written down.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug fabrication

Found while implementing #309. The inventory quantity rule is written twice, in two different shapes, and the two do not agree about a blank field.

src/components/manage/ToolDetail.tsx (the inventory editor, #311's surface):

const qty = Number(quantity);
const qtyOk = Number.isInteger(qty) && qty > 0;

src/engine/cnc/registerCutter.ts (#309):

export function quantityOrOne(value: string): number { … }   // blank is ONE
export function quantityProblem(value: string): string | null

The divergence is the blank field. Number('') is 0, so the editor refuses an empty field; quantityOrOne reads blank as one ("a user holding the box has at least one"). Both are defensible in their own context — a save that edits a known count should not guess, a registration is going the other way — but that reasoning is nowhere on the page, so the same empty box behaves differently in two places two clicks apart, and neither comment mentions the other.

The failure message is also duplicated verbatim: 'A quantity is a whole number of cutters, one or more' is hard-coded in ToolDetail.tsx's button title and returned by quantityProblem.

Do — decide which behaviour is right for an empty field, write the reason down, and leave one implementation of the rule and one spelling of its sentence, imported by both. houseClient.InventoryItemSchema (positive integer) is the thing both are approximating; the service is the authority, and it is the same one at both ends.

Not urgent, and not folded into #309 — changing the editor's blank behaviour is a visible change to #311's surface, which is out of a register-cutter issue's scope.

Lingua principale
TypeScript
Stelle
2
Fork
0
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di SlyWombat/CaseMaker

Tutte le issue di SlyWombat/CaseMaker

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.