Entrega dashboard e correccoes transversais preservando Ofertas instalado
tests / ci (push) Canceled after 0s
tests / ci (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
export type NavigationFocus = {
|
||||
case_id: string;
|
||||
step_code: string | null;
|
||||
version: number;
|
||||
};
|
||||
const key = (actor: number) => `investmoz-navigation-focus:${actor}`;
|
||||
/** A per-tab hint, never authority to access a dossier. Recheck the server listing. */
|
||||
export function readNavigationFocus(
|
||||
actor: number,
|
||||
allowed: string[],
|
||||
): NavigationFocus | null {
|
||||
try {
|
||||
const value = JSON.parse(sessionStorage.getItem(key(actor)) ?? 'null');
|
||||
if (
|
||||
!value ||
|
||||
!allowed.includes(value.case_id) ||
|
||||
!Number.isSafeInteger(value.version) ||
|
||||
value.version < 0
|
||||
)
|
||||
return null;
|
||||
if (
|
||||
value.step_code !== null &&
|
||||
!/^S(0[1-9]|1[0-9])$/.test(value.step_code)
|
||||
)
|
||||
return null;
|
||||
return {
|
||||
case_id: value.case_id,
|
||||
step_code: value.step_code,
|
||||
version: value.version,
|
||||
};
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
export function rememberNavigationFocus(
|
||||
actor: number,
|
||||
focus: NavigationFocus | null,
|
||||
): void {
|
||||
try {
|
||||
if (focus) sessionStorage.setItem(key(actor), JSON.stringify(focus));
|
||||
else sessionStorage.removeItem(key(actor));
|
||||
} catch {
|
||||
// The current consultation remains usable when browser storage is blocked.
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user