add buffer numeric text before canonicalizing it.#10
Conversation
|
@lucy-04 is attempting to deploy a commit to the Ateeb Ur Rehman's projects Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughAdds a reusable ChangesNumeric input handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/components/ui/NumberField.tsx`:
- Around line 3-8: Update src/components/ui/NumberField.tsx at lines 3-8, 11-13,
and 36-43: omit onChange with the correct casing, capture remaining native input
props, and spread them onto the internal input while preserving text-based draft
behavior; explicitly exclude or override the unsupported type prop. Review
callers at src/modules/deliveryChallan/CreateDeliveryChallanModule.tsx lines
446-449, src/modules/inventory/InventoryModule.tsx lines 236-241, and
src/modules/invoices/CreateInvoiceModule.tsx lines 521-524, removing
type="number" where callers require native number behavior or otherwise aligning
them with NumberField’s text input contract.
- Around line 22-23: Update the commit validation in the NumberField input
handler to use Number.isFinite(n) instead of the global isNaN check, while
retaining the existing non-empty text requirement and onCommit behavior for
valid finite numbers.
In `@src/modules/deliveryChallan/CreateDeliveryChallanModule.tsx`:
- Around line 446-449: Update the NumberField component to forward its remaining
InputHTMLAttributes onto the underlying input element, preserving its existing
value, commit handling, and fallback behavior so caller-supplied props such as
className are applied.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 9f462908-ba6d-434e-9c7a-e10ac5c0ffef
📒 Files selected for processing (4)
src/components/ui/NumberField.tsxsrc/modules/deliveryChallan/CreateDeliveryChallanModule.tsxsrc/modules/inventory/InventoryModule.tsxsrc/modules/invoices/CreateInvoiceModule.tsx
| interface NumberFieldProps | ||
| extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value' | 'onchange'>{ | ||
| value : number | ||
| onCommit : (n:number) => void | ||
| fallback ?: number | ||
| allowNegative ? :boolean |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== NumberField ==\n'
sed -n '1,220p' src/components/ui/NumberField.tsx
printf '\n== DeliveryChallan usage ==\n'
sed -n '430,470p' src/modules/deliveryChallan/CreateDeliveryChallanModule.tsx
printf '\n== Inventory usage ==\n'
sed -n '220,255p' src/modules/inventory/InventoryModule.tsx
printf '\n== Invoice usage ==\n'
sed -n '500,545p' src/modules/invoices/CreateInvoiceModule.tsxRepository: iTeebot/flow
Length of output: 9237
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== NumberField references ==\n'
rg -n "NumberField|allowNegative|fallback|onCommit|type=\"number\"|required" src/components/ui/NumberField.tsx src/modules/deliveryChallan/CreateDeliveryChallanModule.tsx src/modules/inventory/InventoryModule.tsx src/modules/invoices/CreateInvoiceModule.tsxRepository: iTeebot/flow
Length of output: 2746
Forward native input props from NumberField. The component drops caller-supplied props because it never captures or spreads the rest of React.InputHTMLAttributes, so required, placeholder, className, and similar attributes never reach the DOM input. type="number" is also ignored because the field is hardcoded to type="text" for draft editing.
src/components/ui/NumberField.tsx: fix the prop type omit to useonChange(notonchange), capture the remaining input props, and spread them onto<input />.- Keep the internal text-based draft behavior, but make the unsupported
typeprop explicit or remove it from callers that expect native number input behavior.
📍 Affects 4 files
src/components/ui/NumberField.tsx#L3-L8(this comment)src/components/ui/NumberField.tsx#L11-L13src/components/ui/NumberField.tsx#L36-L43src/modules/deliveryChallan/CreateDeliveryChallanModule.tsx#L446-L449src/modules/inventory/InventoryModule.tsx#L236-L241src/modules/invoices/CreateInvoiceModule.tsx#L521-L524
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/components/ui/NumberField.tsx` around lines 3 - 8, Update
src/components/ui/NumberField.tsx at lines 3-8, 11-13, and 36-43: omit onChange
with the correct casing, capture remaining native input props, and spread them
onto the internal input while preserving text-based draft behavior; explicitly
exclude or override the unsupported type prop. Review callers at
src/modules/deliveryChallan/CreateDeliveryChallanModule.tsx lines 446-449,
src/modules/inventory/InventoryModule.tsx lines 236-241, and
src/modules/invoices/CreateInvoiceModule.tsx lines 521-524, removing
type="number" where callers require native number behavior or otherwise aligning
them with NumberField’s text input contract.
| const n = Number(text) | ||
| if(text != '' && !isNaN(n)) onCommit(n); |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Locate and inspect the file in question.
git ls-files src/components/ui/NumberField.tsx
wc -l src/components/ui/NumberField.tsx
cat -n src/components/ui/NumberField.tsx | sed -n '1,220p'Repository: iTeebot/flow
Length of output: 1804
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Find local usages of NumberField and inspect the call sites.
rg -n --hidden --glob '!node_modules' --glob '!dist' --glob '!build' \
'NumberField' src
# Also inspect the component's immediate neighbors for context if any.
rg -n --hidden --glob '!node_modules' --glob '!dist' --glob '!build' \
'onCommit\(|fallback|allowNegative|inputMode="decimal"' src/components src | sed -n '1,200p'Repository: iTeebot/flow
Length of output: 3087
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Search for local call sites to understand whether Infinity would affect money/quantity flows.
rg -n --hidden --glob '!node_modules' --glob '!dist' --glob '!build' \
'<NumberField|NumberField\\s*\\(' src
# Show surrounding lines for each hit.
for f in $(rg -l --hidden --glob '!node_modules' --glob '!dist' --glob '!build' \
'<NumberField|NumberField\\s*\\(' src); do
echo "===== $f ====="
cat -n "$f" | sed -n '1,240p'
doneRepository: iTeebot/flow
Length of output: 263
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Probe the number semantics that drive the bug claim.
node - <<'JS'
const samples = [
'9'.repeat(307),
'9'.repeat(308),
'1e309',
'',
'123.45',
'-123',
'abc',
];
for (const s of samples) {
const n = Number(s);
console.log(JSON.stringify({s, n, isNaN: isNaN(n), finite: Number.isFinite(n)}));
}
JS
# Find every local reference to NumberField to understand impact.
rg -n --hidden --glob '!node_modules' --glob '!dist' --glob '!build' 'NumberField' srcRepository: iTeebot/flow
Length of output: 1873
🏁 Script executed:
#!/bin/bash
set -euo pipefail
node - <<'JS'
for (const len of [308, 309, 310, 320]) {
const s = '9'.repeat(len);
const n = Number(s);
console.log(len, String(n), Number.isFinite(n), isNaN(n));
}
JSRepository: iTeebot/flow
Length of output: 247
Reject non-finite numeric values. Number(text) overflows to Infinity for very long digit strings, and isNaN(Infinity) still passes. That can commit non-finite values into quantities and amounts; use Number.isFinite(n) here.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/components/ui/NumberField.tsx` around lines 22 - 23, Update the commit
validation in the NumberField input handler to use Number.isFinite(n) instead of
the global isNaN check, while retaining the existing non-empty text requirement
and onCommit behavior for valid finite numbers.
| <NumberField | ||
| value={item.quantity} | ||
| onCommit={(n) => handleSetItemQty(item.product_id, n)} | ||
| fallback={1} |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Map the relevant files and inspect the shared component plus the caller.
git ls-files 'src/components/ui/NumberField.tsx' 'src/modules/deliveryChallan/CreateDeliveryChallanModule.tsx'
echo
echo '--- NumberField outline ---'
ast-grep outline src/components/ui/NumberField.tsx --view expanded || true
echo
echo '--- CreateDeliveryChallanModule outline (focused) ---'
ast-grep outline src/modules/deliveryChallan/CreateDeliveryChallanModule.tsx --view expanded | sed -n '1,220p'
echo
echo '--- NumberField source ---'
wc -l src/components/ui/NumberField.tsx
cat -n src/components/ui/NumberField.tsx
echo
echo '--- Caller lines around usage ---'
sed -n '430,470p' src/modules/deliveryChallan/CreateDeliveryChallanModule.tsxRepository: iTeebot/flow
Length of output: 5341
Forward native input props in NumberField
NumberField accepts InputHTMLAttributes, but the props are never spread onto the <input>, so caller-supplied attributes like className are ignored. Pass the remaining props through in src/components/ui/NumberField.tsx.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/modules/deliveryChallan/CreateDeliveryChallanModule.tsx` around lines 446
- 449, Update the NumberField component to forward its remaining
InputHTMLAttributes onto the underlying input element, preserving its existing
value, commit handling, and fallback behavior so caller-supplied props such as
className are applied.
|
@lucy-04 Can you see this so i will merge the PR
|
created a new Number Field that will add the numbered text to a buffer enabling number like -1 or 0.5 in the required fields
Summary by CodeRabbit
New Features
Bug Fixes