From 42bb07150a4f78d97e8b4a45719f4e09a0082d91 Mon Sep 17 00:00:00 2001 From: Kishore <42832651+kishore03109@users.noreply.github.com> Date: Fri, 10 Nov 2023 13:38:52 +0800 Subject: [PATCH] fix(image): search pagination --- src/components/media/MediasSelectModal.jsx | 3 ++- src/services/DirectoryService/DirectoryService.ts | 3 ++- src/types/folders.ts | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/media/MediasSelectModal.jsx b/src/components/media/MediasSelectModal.jsx index ce993f0c7..225a1ac2a 100644 --- a/src/components/media/MediasSelectModal.jsx +++ b/src/components/media/MediasSelectModal.jsx @@ -68,6 +68,7 @@ const MediasSelectModal = ({ { initialData: { directories: [] } } ) + const [searchValue, setSearchedValue] = useState("") const { data: { files: mediaFolderFiles, total }, isLoading: isListMediaFilesLoading, @@ -78,6 +79,7 @@ const MediasSelectModal = ({ // returns an index with 1 offset curPage: curPage - 1, limit: MEDIA_PAGINATION_SIZE, + search: searchValue, }, { initialData: { files: [] } } ) @@ -88,7 +90,6 @@ const MediasSelectModal = ({ mediaDirectoryName ) - const [searchValue, setSearchedValue] = useState("") const filteredDirectories = filterMediaByFileName( mediaFolderSubdirectories, searchValue diff --git a/src/services/DirectoryService/DirectoryService.ts b/src/services/DirectoryService/DirectoryService.ts index 1a4286d84..53641b451 100644 --- a/src/services/DirectoryService/DirectoryService.ts +++ b/src/services/DirectoryService/DirectoryService.ts @@ -101,11 +101,12 @@ export const getMediaFolderFiles = ({ mediaDirectoryName, curPage = 0, limit = 1000, + search = "", }: MediaDirectoryParams): Promise => { const endpoint = `/sites/${siteName}/media/${mediaDirectoryName}/files` return apiService .get(endpoint, { - params: { page: curPage, limit }, + params: { page: curPage, limit, search }, }) .then(({ data }) => data) } diff --git a/src/types/folders.ts b/src/types/folders.ts index f4178bf5e..fb4f35d86 100644 --- a/src/types/folders.ts +++ b/src/types/folders.ts @@ -11,6 +11,7 @@ export interface MediaDirectoryParams { mediaDirectoryName: string curPage?: number limit?: number + search?: string } export type DirectoryParams = Omit