Replace box picker with free-text location in audit scan

"Where found" during inventory audit is now a plain text field
(e.g. "каб. 305") stored on the object instead of assigning it to a
box, since audit walks often use room/office labels that don't map
to the box/shelf hierarchy used elsewhere. Box assignment via the
regular object form is unaffected.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
jze9
2026-07-22 15:41:30 +05:00
parent f99949559c
commit d6a7ac0a68
10 changed files with 77 additions and 50 deletions

View File

@@ -1,7 +1,7 @@
import { useCallback, useState } from 'react'
const SESSION_START_KEY = 'inventory_audit_session_start'
const LAST_BOX_KEY = 'inventory_audit_last_box_id'
const LAST_LOCATION_KEY = 'inventory_audit_last_location'
function readSessionStart(): number {
const raw = sessionStorage.getItem(SESSION_START_KEY)
@@ -12,26 +12,26 @@ function readSessionStart(): number {
}
/** Tracks the current audit walk: when it started (for the found/not-found split) and the
* last room/box picked, so the next scanned object can default to the same location. */
* last location typed in, so the next scanned object can default to the same location. */
export function useAuditSession() {
const [sessionStart, setSessionStart] = useState<number>(readSessionStart)
const [lastBoxId, setLastBoxIdState] = useState<string | null>(() =>
sessionStorage.getItem(LAST_BOX_KEY),
const [lastLocation, setLastLocationState] = useState<string | null>(() =>
sessionStorage.getItem(LAST_LOCATION_KEY),
)
const restart = useCallback(() => {
const now = Date.now()
sessionStorage.setItem(SESSION_START_KEY, String(now))
sessionStorage.removeItem(LAST_BOX_KEY)
sessionStorage.removeItem(LAST_LOCATION_KEY)
setSessionStart(now)
setLastBoxIdState(null)
setLastLocationState(null)
}, [])
const setLastBoxId = useCallback((boxId: string | null) => {
if (boxId) sessionStorage.setItem(LAST_BOX_KEY, boxId)
else sessionStorage.removeItem(LAST_BOX_KEY)
setLastBoxIdState(boxId)
const setLastLocation = useCallback((location: string | null) => {
if (location) sessionStorage.setItem(LAST_LOCATION_KEY, location)
else sessionStorage.removeItem(LAST_LOCATION_KEY)
setLastLocationState(location)
}, [])
return { sessionStart, restart, lastBoxId, setLastBoxId }
return { sessionStart, restart, lastLocation, setLastLocation }
}