fix(ui): omnisearch call
This commit is contained in:
parent
4db693a6b2
commit
ebdc2bd08c
3 changed files with 44 additions and 23 deletions
|
|
@ -17,8 +17,13 @@ function SessionSearchField(props: Props) {
|
|||
const isLive =
|
||||
isRoute(ASSIST_ROUTE, window.location.pathname) ||
|
||||
window.location.pathname.includes('multiview');
|
||||
|
||||
const fetchFilterSearch = isLive
|
||||
? searchStoreLive.fetchFilterSearch.bind(searchStoreLive)
|
||||
: searchStore.fetchFilterSearch.bind(searchStore);
|
||||
|
||||
const debounceFetchFilterSearch = React.useCallback(
|
||||
debounce(isLive ? searchStoreLive.fetchFilterSearch : searchStore.fetchFilterSearch, 1000),
|
||||
debounce(fetchFilterSearch, 1000),
|
||||
[]
|
||||
);
|
||||
const [showModal, setShowModal] = useState(false);
|
||||
|
|
|
|||
|
|
@ -140,17 +140,26 @@ class SearchStore {
|
|||
|
||||
fetchFilterSearch(params: any) {
|
||||
this.loadingFilterSearch = true;
|
||||
searchService.fetchFilterSearch(params).then((response: any) => {
|
||||
this.filterSearchList = response.reduce((acc: any, item: any) => {
|
||||
const { projectId, type, value } = item;
|
||||
const key = type;
|
||||
if (!acc[key]) acc[key] = [];
|
||||
acc[key].push({ projectId, value });
|
||||
return acc;
|
||||
}, {}).finally(() => {
|
||||
|
||||
searchService
|
||||
.fetchFilterSearch(params)
|
||||
.then((response: any[]) => {
|
||||
this.filterSearchList = response.reduce(
|
||||
(acc: Record<string, { projectId: number; value: string }[]>, item: any) => {
|
||||
const { projectId, type, value } = item;
|
||||
if (!acc[type]) acc[type] = [];
|
||||
acc[type].push({ projectId, value });
|
||||
return acc;
|
||||
},
|
||||
{}
|
||||
);
|
||||
})
|
||||
.catch((error: any) => {
|
||||
console.error('Error fetching filter search:', error);
|
||||
})
|
||||
.finally(() => {
|
||||
this.loadingFilterSearch = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
updateCurrentPage(page: number) {
|
||||
|
|
|
|||
|
|
@ -72,20 +72,27 @@ class SearchStoreLive {
|
|||
return generateFilterOptions(liveFiltersMap);
|
||||
}
|
||||
|
||||
fetchFilterSearch(params: any) {
|
||||
fetchFilterSearch = async (params: any): Promise<void> => {
|
||||
this.loadingFilterSearch = true;
|
||||
searchService.fetchFilterSearch(params).then((response: any) => {
|
||||
this.filterSearchList = response.reduce((acc: any, item: any) => {
|
||||
const { projectId, type, value } = item;
|
||||
const key = type;
|
||||
if (!acc[key]) acc[key] = [];
|
||||
acc[key].push({ projectId, value });
|
||||
return acc;
|
||||
}, {}).finally(() => {
|
||||
this.loadingFilterSearch = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
const response: any[] = await searchService.fetchFilterSearch(params);
|
||||
|
||||
this.filterSearchList = response.reduce(
|
||||
(acc: Record<string, { projectId: number; value: string }[]>, item: any) => {
|
||||
const { projectId, type, value } = item;
|
||||
if (!acc[type]) acc[type] = [];
|
||||
acc[type].push({ projectId, value });
|
||||
return acc;
|
||||
},
|
||||
{}
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('Error fetching filter search:', error);
|
||||
} finally {
|
||||
this.loadingFilterSearch = false;
|
||||
}
|
||||
};
|
||||
|
||||
edit(instance: Partial<Search>) {
|
||||
this.instance = new Search(Object.assign({ ...this.instance }, instance));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue