modify search function for all files search
This commit is contained in:
@@ -23,6 +23,7 @@ export function FileSearchPanel({ fileId, ref }: { fileId: string | null, ref: a
|
||||
const [paginationLoading, setPaginationLoading] = useState<boolean>(false);
|
||||
const [showGlobalSearch, setShowGlobalSearch] = useState<boolean>(false);
|
||||
const queryClient = useQueryClient();
|
||||
const [errorMessage, setErrorMessage] = useState<string | null>(null);
|
||||
|
||||
const [searchTotalPages, setSearchTotalPages] = useState<number>(0);
|
||||
const [searchCurrentPages, setSearchCurrentPages] = useState<number>(1);
|
||||
@@ -41,20 +42,21 @@ export function FileSearchPanel({ fileId, ref }: { fileId: string | null, ref: a
|
||||
|
||||
|
||||
const handlerSearchUserFile = useCallback(async (fileId: string, page: number): Promise<void> => {
|
||||
setErrorMessage(null);
|
||||
|
||||
try {
|
||||
let result = await searchUserFiles(fileId);
|
||||
|
||||
if (result.content.length) {
|
||||
setSearchedUserFiles(result.content);
|
||||
setShowGlobalSearch(true);
|
||||
handlerSearchGlobalFile(fileId, page)
|
||||
} else {
|
||||
setSearchedUserFilesShowNull(true);
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
setErrorMessage('error');
|
||||
}
|
||||
setShowGlobalSearch(true);
|
||||
handlerSearchGlobalFile(fileId, page)
|
||||
|
||||
}, [fileId])
|
||||
|
||||
@@ -106,6 +108,12 @@ export function FileSearchPanel({ fileId, ref }: { fileId: string | null, ref: a
|
||||
>
|
||||
Начать поиск
|
||||
</button>
|
||||
|
||||
{errorMessage && (
|
||||
<div className='mt-2 text-red-600 text-sm'>
|
||||
Ошибка поиска
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{(searchedUserFiles.length !== 0) && (
|
||||
|
||||
Reference in New Issue
Block a user