ux: stop persisting hidden operational filters
This commit is contained in:
@@ -10,31 +10,18 @@ interface OperationalContextValue {
|
||||
clearContext: () => void;
|
||||
}
|
||||
|
||||
const STORAGE_KEY = 'dhv2.operational-context';
|
||||
const LEGACY_STORAGE_KEY = 'dhv2.operational-context';
|
||||
const OperationalContext = createContext<OperationalContextValue | null>(null);
|
||||
|
||||
function readStoredContext(): { areaId: string; companyId: string } {
|
||||
try {
|
||||
const raw = window.localStorage.getItem(STORAGE_KEY);
|
||||
if (!raw) return { areaId: '', companyId: '' };
|
||||
const parsed = JSON.parse(raw) as { areaId?: unknown; companyId?: unknown };
|
||||
return {
|
||||
areaId: typeof parsed.areaId === 'string' ? parsed.areaId : '',
|
||||
companyId: typeof parsed.companyId === 'string' ? parsed.companyId : '',
|
||||
};
|
||||
} catch {
|
||||
return { areaId: '', companyId: '' };
|
||||
}
|
||||
}
|
||||
|
||||
export function OperationalContextProvider({ children }: PropsWithChildren) {
|
||||
const initial = useMemo(readStoredContext, []);
|
||||
const [areaId, setAreaState] = useState(initial.areaId);
|
||||
const [companyId, setCompanyState] = useState(initial.companyId);
|
||||
const [areaId, setAreaState] = useState('');
|
||||
const [companyId, setCompanyState] = useState('');
|
||||
|
||||
useEffect(() => {
|
||||
window.localStorage.setItem(STORAGE_KEY, JSON.stringify({ areaId, companyId }));
|
||||
}, [areaId, companyId]);
|
||||
// F6.2 retiró la barra global Área/Operadora. Un contexto persistido sin
|
||||
// controles visibles podía seguir filtrando pantallas de forma inesperada.
|
||||
window.localStorage.removeItem(LEGACY_STORAGE_KEY);
|
||||
}, []);
|
||||
|
||||
const value = useMemo<OperationalContextValue>(() => ({
|
||||
areaId,
|
||||
|
||||
Reference in New Issue
Block a user