Skip to content

Commit 3a96213

Browse files
asizikovCopilot
andcommitted
fix: address seat count review feedback
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ec6e49b commit 3a96213

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

src/App.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,16 +284,16 @@ function App() {
284284
setBudgetSimulation(null)
285285
setBudgetSimulationError(null)
286286
setIsApplyingBudgetSimulation(false)
287+
if (!onError) {
288+
setError(null)
289+
}
287290

288291
try {
289292
const nextData = await buildReportData(file, resolvedOverrides)
290293
if (runId !== latestRunIdRef.current) return false
291294

292295
applyProcessedData(nextData)
293296
setSeatOverrides(compactSeatOverrides(resolvedOverrides))
294-
if (!onError) {
295-
setError(null)
296-
}
297297
return true
298298
} catch (err) {
299299
if (runId !== latestRunIdRef.current) return false

src/utils/seatCounts.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@ import { getSeatReductionError, parseSeatCountInput } from './seatCounts'
44
describe('seat count helpers', () => {
55
it('normalizes seat count input to the historical minimum', () => {
66
expect(parseSeatCountInput('', 10)).toBe(10)
7+
expect(parseSeatCountInput(' ', 10)).toBe(10)
8+
expect(parseSeatCountInput(' 12.9 ', 10)).toBe(12)
79
expect(parseSeatCountInput('12.9', 10)).toBe(12)
810
expect(parseSeatCountInput('not-a-number', 10)).toBe(10)
911
expect(parseSeatCountInput('8', 10)).toBe(10)
1012
})
1113

1214
it('reports only reductions below the historical count', () => {
1315
expect(getSeatReductionError('', 10)).toBeNull()
16+
expect(getSeatReductionError(' ', 10)).toBeNull()
1417
expect(getSeatReductionError('10', 10)).toBeNull()
18+
expect(getSeatReductionError(' 12 ', 10)).toBeNull()
1519
expect(getSeatReductionError('12', 10)).toBeNull()
1620
expect(getSeatReductionError('8', 10)).toBe('Cannot go below 10 because that count comes from historical report data.')
1721
})

src/utils/seatCounts.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ export function parseSeatCountInput(raw: string, minimum: number): number {
1414
}
1515

1616
export function getSeatReductionError(value: string, minimum: number): string | null {
17-
if (value === '') return null
17+
const trimmed = value.trim()
18+
if (trimmed === '') return null
1819

19-
const parsed = Number(value)
20+
const parsed = Number(trimmed)
2021
if (!Number.isFinite(parsed) || Math.floor(parsed) >= minimum) return null
2122

2223
return `Cannot go below ${minimum.toLocaleString()} because that count comes from historical report data.`

0 commit comments

Comments
 (0)