Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(image): search pagination #1668

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/media/MediasSelectModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const MediasSelectModal = ({
{ initialData: { directories: [] } }
)

const [searchValue, setSearchedValue] = useState("")
const {
data: { files: mediaFolderFiles, total },
isLoading: isListMediaFilesLoading,
Expand All @@ -78,6 +79,7 @@ const MediasSelectModal = ({
// returns an index with 1 offset
curPage: curPage - 1,
limit: MEDIA_PAGINATION_SIZE,
search: searchValue,
},
{ initialData: { files: [] } }
)
Expand All @@ -88,7 +90,6 @@ const MediasSelectModal = ({
mediaDirectoryName
)

const [searchValue, setSearchedValue] = useState("")
const filteredDirectories = filterMediaByFileName(
mediaFolderSubdirectories,
searchValue
Expand Down
3 changes: 2 additions & 1 deletion src/services/DirectoryService/DirectoryService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,12 @@ export const getMediaFolderFiles = ({
mediaDirectoryName,
curPage = 0,
limit = 1000,
search = "",
}: MediaDirectoryParams): Promise<GetMediaFilesDto> => {
const endpoint = `/sites/${siteName}/media/${mediaDirectoryName}/files`
return apiService
.get<GetMediaFilesDto>(endpoint, {
params: { page: curPage, limit },
params: { page: curPage, limit, search },
})
.then(({ data }) => data)
}
Expand Down
1 change: 1 addition & 0 deletions src/types/folders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface MediaDirectoryParams {
mediaDirectoryName: string
curPage?: number
limit?: number
search?: string
}

export type DirectoryParams = Omit<FolderUrlParams, "subCollectionName">
Expand Down
Loading