mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 23:11:12 -05:00
Update company search navigation to handle missing identifiers gracefully
Modify AutocompleteSearch.tsx to remove direct use of companyId for navigation, instead handling unknown company types and missing identifiers by showing a toast and returning to search results. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 567218be-0199-4aaa-af7e-8307f67d4453 Replit-Commit-Checkpoint-Type: intermediate_checkpoint
This commit is contained in:
@@ -157,7 +157,6 @@ export function AutocompleteSearch({
|
|||||||
case 'company':
|
case 'company':
|
||||||
const companyType = (searchResult.data as any)?.company_type;
|
const companyType = (searchResult.data as any)?.company_type;
|
||||||
const companySlug = searchResult.slug;
|
const companySlug = searchResult.slug;
|
||||||
const companyId = searchResult.id;
|
|
||||||
|
|
||||||
if (companyType && companySlug) {
|
if (companyType && companySlug) {
|
||||||
switch (companyType) {
|
switch (companyType) {
|
||||||
@@ -174,23 +173,17 @@ export function AutocompleteSearch({
|
|||||||
navigate(`/designers/${companySlug}`);
|
navigate(`/designers/${companySlug}`);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (companyId) {
|
toast({
|
||||||
navigate(`/companies/${companyId}`);
|
title: "Unknown Company Type",
|
||||||
} else {
|
description: `Unable to navigate to this company type. Showing search results instead.`,
|
||||||
toast({
|
variant: "default",
|
||||||
title: "Navigation Error",
|
});
|
||||||
description: "Unable to navigate to this company. Missing company identifier.",
|
navigate(`/search?q=${encodeURIComponent(searchResult.title)}`);
|
||||||
variant: "destructive",
|
|
||||||
});
|
|
||||||
navigate(`/search?q=${encodeURIComponent(searchResult.title)}`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (companyId) {
|
|
||||||
navigate(`/companies/${companyId}`);
|
|
||||||
} else {
|
} else {
|
||||||
toast({
|
toast({
|
||||||
title: "Navigation Error",
|
title: "Navigation Error",
|
||||||
description: "Unable to navigate to this company. Missing company identifier.",
|
description: "Unable to navigate to this company. Missing required information.",
|
||||||
variant: "destructive",
|
variant: "destructive",
|
||||||
});
|
});
|
||||||
navigate(`/search?q=${encodeURIComponent(searchResult.title)}`);
|
navigate(`/search?q=${encodeURIComponent(searchResult.title)}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user