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:
@@ -7,6 +7,10 @@ import {
|
||||
type ReactNode,
|
||||
} from 'react';
|
||||
import { contextApi, type DossierContext } from '@/lib/investor-context';
|
||||
import {
|
||||
readNavigationFocus,
|
||||
rememberNavigationFocus,
|
||||
} from '@/lib/navigation-focus';
|
||||
export type NavigationView = {
|
||||
case: { id: string; title: string; version: number };
|
||||
phases: Record<string, string>;
|
||||
@@ -129,7 +133,15 @@ export function NavigationContextProvider({
|
||||
new URL(url, 'https://context.invalid').searchParams.get(
|
||||
'context',
|
||||
);
|
||||
let focus = pref.focus;
|
||||
const localFocus = readNavigationFocus(
|
||||
actor,
|
||||
listing.contexts.map((c) => c.id),
|
||||
);
|
||||
// The server preference seeds a new tab, but another tab cannot
|
||||
// replace this tab's deliberate dossier choice on navigation/reload.
|
||||
let focus = localFocus
|
||||
? { ...localFocus, version: pref.focus?.version ?? 0 }
|
||||
: pref.focus;
|
||||
const code = /^#S(0[1-9]|1[0-9])$/.test(window.location.hash)
|
||||
? window.location.hash.slice(1)
|
||||
: null;
|
||||
@@ -157,6 +169,7 @@ export function NavigationContextProvider({
|
||||
)
|
||||
: null;
|
||||
if (!stopped) {
|
||||
rememberNavigationFocus(actor, focus);
|
||||
setLoaded({ actor, cases: listing.contexts, focus, view });
|
||||
if (pref.message) setError(pref.message);
|
||||
}
|
||||
@@ -182,16 +195,22 @@ export function NavigationContextProvider({
|
||||
if (!actor || !current?.cases.some((c) => c.id === id)) return;
|
||||
setBusy(true);
|
||||
setError('');
|
||||
void contextApi(
|
||||
void contextApi<{ focus: Focus | null }>(
|
||||
'/investimentos/contexto-atual',
|
||||
{
|
||||
case_id: id,
|
||||
step_code: step,
|
||||
version: current.focus?.version ?? 0,
|
||||
},
|
||||
'PUT',
|
||||
)
|
||||
.then(() => {
|
||||
.then((pref) =>
|
||||
contextApi<{ focus: Focus }>(
|
||||
'/investimentos/contexto-atual',
|
||||
{
|
||||
case_id: id,
|
||||
step_code: step,
|
||||
version: pref.focus?.version ?? 0,
|
||||
},
|
||||
'PUT',
|
||||
),
|
||||
)
|
||||
.then(({ focus }) => {
|
||||
rememberNavigationFocus(actor, focus);
|
||||
const target = `/investimentos/${id}${step ? '#' + step : ''}`;
|
||||
if (url !== target) router.visit(target);
|
||||
else setReload((x) => x + 1);
|
||||
|
||||
Reference in New Issue
Block a user