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