19 lines
570 B
TypeScript
19 lines
570 B
TypeScript
export type CompanySelectionSource = "manual" | "route_sync" | "bootstrap";
|
|
|
|
export function shouldSyncCompanySelectionFromRoute(params: {
|
|
selectionSource: CompanySelectionSource;
|
|
selectedCompanyId: string | null;
|
|
routeCompanyId: string;
|
|
}): boolean {
|
|
const { selectionSource, selectedCompanyId, routeCompanyId } = params;
|
|
|
|
if (selectedCompanyId === routeCompanyId) return false;
|
|
|
|
// Let manual company switches finish their remembered-path navigation first.
|
|
if (selectionSource === "manual" && selectedCompanyId) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|