Skip to content

Commit

Permalink
Merge pull request #1726 from bcgov/feature/ALCS-1990
Browse files Browse the repository at this point in the history
Change search failure toast message
  • Loading branch information
dhaselhan authored May 29, 2024
2 parents ede242a + 7af3606 commit 4e93436
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions portal-frontend/src/app/services/search/search.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { environment } from '../../../environments/environment';
import { ToastService } from '../toast/toast.service';
import {
AdvancedSearchEntityResponseDto,
SearchResponseDto,
BaseSearchResultDto,
NoticeOfIntentSearchResultDto,
NotificationSearchResultDto,
SearchRequestDto,
SearchResponseDto,
} from './search.dto';

@Injectable({
Expand All @@ -18,26 +18,29 @@ import {
export class SearchService {
private baseUrl = `${environment.authUrl}/public/search`;

constructor(private http: HttpClient, private toastService: ToastService) {}
constructor(
private http: HttpClient,
private toastService: ToastService,
) {}

async search(searchDto: SearchRequestDto) {
try {
return await firstValueFrom(this.http.post<SearchResponseDto>(`${this.baseUrl}`, searchDto));
} catch (e) {
console.error(e);
this.toastService.showErrorToast(`Search failed. Please refresh the page and try again`);
this.toastService.showErrorToast(`Search failed. Please add more criteria to narrow your search and try again.`);
return undefined;
}
}

async searchApplications(searchDto: SearchRequestDto) {
try {
return await firstValueFrom(
this.http.post<AdvancedSearchEntityResponseDto<BaseSearchResultDto>>(`${this.baseUrl}/application`, searchDto)
this.http.post<AdvancedSearchEntityResponseDto<BaseSearchResultDto>>(`${this.baseUrl}/application`, searchDto),
);
} catch (e) {
console.error(e);
this.toastService.showErrorToast(`Search failed. Please refresh the page and try again`);
this.toastService.showErrorToast(`Search failed. Please add more criteria to narrow your search and try again.`);
return undefined;
}
}
Expand All @@ -47,12 +50,12 @@ export class SearchService {
return await firstValueFrom(
this.http.post<AdvancedSearchEntityResponseDto<NoticeOfIntentSearchResultDto>>(
`${this.baseUrl}/notice-of-intent`,
searchDto
)
searchDto,
),
);
} catch (e) {
console.error(e);
this.toastService.showErrorToast(`Search failed. Please refresh the page and try again`);
this.toastService.showErrorToast(`Search failed. Please add more criteria to narrow your search and try again.`);
return undefined;
}
}
Expand All @@ -62,12 +65,12 @@ export class SearchService {
return await firstValueFrom(
this.http.post<AdvancedSearchEntityResponseDto<NotificationSearchResultDto>>(
`${this.baseUrl}/notifications`,
searchDto
)
searchDto,
),
);
} catch (e) {
console.error(e);
this.toastService.showErrorToast(`Search failed. Please refresh the page and try again`);
this.toastService.showErrorToast(`Search failed. Please add more criteria to narrow your search and try again.`);
return undefined;
}
}
Expand Down

0 comments on commit 4e93436

Please sign in to comment.