feat(ui): make company rail items proper links for right-click support

Company rail icons are now <a> tags with href instead of <button>, enabling
right-click "Open in new tab". CompanyContext reads a ?company= URL param on
init so the correct company is selected when opened in a new tab.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Forgotten
2026-02-26 15:41:59 -06:00
parent 9e1e1bcd2e
commit 2327cfb861
2 changed files with 35 additions and 37 deletions

View File

@@ -35,7 +35,22 @@ const CompanyContext = createContext<CompanyContextValue | null>(null);
export function CompanyProvider({ children }: { children: ReactNode }) {
const queryClient = useQueryClient();
const [selectedCompanyId, setSelectedCompanyIdState] = useState<string | null>(
() => localStorage.getItem(STORAGE_KEY)
() => {
// Check URL param first (supports "open in new tab" from company rail)
const urlParams = new URLSearchParams(window.location.search);
const companyParam = urlParams.get("company");
if (companyParam) {
localStorage.setItem(STORAGE_KEY, companyParam);
// Clean up the URL param
urlParams.delete("company");
const newSearch = urlParams.toString();
const newUrl =
window.location.pathname + (newSearch ? `?${newSearch}` : "");
window.history.replaceState({}, "", newUrl);
return companyParam;
}
return localStorage.getItem(STORAGE_KEY);
}
);
const { data: companies = [], isLoading, error } = useQuery({