Skip to content

Commit

Permalink
merged main
Browse files Browse the repository at this point in the history
  • Loading branch information
ARADDCC002 committed Jan 10, 2025
1 parent 33b95fe commit 5dda340
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion backend/src/routes/v2/model/getModelsSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const getModelsSearch = [
async (req: Request, res: Response<GetModelsResponse>) => {
req.audit = AuditInfo.SearchModels
const {
query: { kind, libraries, filters, search, task, allowTemplating, schemaId, currentPage = 0, pageSize = 10 },
query: { kind, libraries, filters, search, task, allowTemplating, schemaId, currentPage = 1, pageSize = 10 },
} = parse(req, getModelsSearchSchema)

const foundModels = await searchModels(
Expand Down
4 changes: 2 additions & 2 deletions frontend/actions/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ErrorInfo, fetcher } from '../utils/fetcher'
const emptyModelList = []

export interface EntrySearchResults {
models: EntrySearchResult[]
results: EntrySearchResult[]
totalEntries: number
}

Expand Down Expand Up @@ -52,7 +52,7 @@ export function useListModels(

return {
mutateModels: mutate,
models: data ? data.models : emptyModelList,
models: data ? data.results : emptyModelList,
totalModels: data ? data.totalEntries : 0,
isModelsLoading: isLoading,
isModelsError: error,
Expand Down
13 changes: 4 additions & 9 deletions frontend/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,10 @@ export default function Marketplace() {

const handleCurrentPageChange = useCallback(
(newPage: number) => {
setCurrentPage(newPage)
updateQueryParams('currentPage', newPage.toString())
if (newPage > 0) {
setCurrentPage(newPage)
updateQueryParams('currentPage', newPage.toString())
}
},
[updateQueryParams],
)
Expand Down Expand Up @@ -275,13 +277,6 @@ export default function Marketplace() {
</Tabs>
</Box>
<Stack spacing={2}>
<PaginationSelector
currentPage={currentPage}
onCurrentPageChange={(newValue) => handleCurrentPageChange(newValue)}
totalEntries={totalModels}
pageSize={pageSize}
onPageSizeChange={(newValue) => handlePageSizeChange(newValue)}
/>
{(isModelsLoading || isDataCardsLoading) && <Loading />}
{!isModelsLoading && selectedTab === EntryKind.MODEL && (
<div data-test='modelListBox'>
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/common/PaginationSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,13 @@ export default function PaginationSelector({
}, [lastPage])

return (
<Stack spacing={2} direction='row' sx={{ width: '100%', p: 2 }} justifyContent='center' alignItems='center'>
<Stack
spacing={2}
direction={{ xs: 'column', sm: 'row' }}
sx={{ py: 2 }}
justifyContent='center'
alignItems='center'
>
<IconButton size='small' color='primary' onClick={handleBackPage}>
<ArrowBack />
</IconButton>
Expand Down

0 comments on commit 5dda340

Please sign in to comment.