Skip to content

Commit

Permalink
Additional pagination fixes (#572)
Browse files Browse the repository at this point in the history
  • Loading branch information
pushchris authored Dec 9, 2024
1 parent 4899668 commit 18c8653
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion apps/platform/src/core/Model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export default class Model {
.when(!!id?.length, qb => qb.whereIn('id', id!))

const makeCursor = (result: any, sort?: string) => {
if (!sort || sort === 'id') return `${result.id}`
if (!sort || sort === 'id' || sort === `${this.tableName}.id`) return `${result.id}`
let sortCursor = result[sort]
if (sortCursor instanceof Date) {
sortCursor = formatISO(sortCursor)
Expand Down
4 changes: 3 additions & 1 deletion apps/platform/src/lists/ListService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ export const getListUsers = async (id: number, params: PageParams, projectId: nu
b => b.leftJoin('users', 'user_list.user_id', 'users.id')
.where('project_id', projectId)
.where('list_id', id)
.select('users.*', 'user_list.created_at'),
.select('users.*', 'user_list.created_at', 'user_list.id', 'user_list.user_id'),
App.main.db,
(item) => ({ ...item, id: item.user_id }) as any,
)
}

Expand Down
12 changes: 7 additions & 5 deletions apps/ui/src/ui/SearchTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,13 @@ export function SearchTable<T extends Record<string, any>>({
setParams({ ...prevParams, ...onSort })
}} />
{results && (
<Pagination
nextCursor={results.nextCursor}
prevCursor={results.prevCursor}
onPrev={cursor => setParams({ ...params, cursor, page: 'prev' })}
onNext={cursor => setParams({ ...params, cursor, page: 'next' })} />
<div>
<Pagination
nextCursor={results.nextCursor}
prevCursor={results.prevCursor}
onPrev={cursor => setParams({ ...params, cursor, page: 'prev' })}
onNext={cursor => setParams({ ...params, cursor, page: 'next' })} />
</div>
)}
</>
)
Expand Down

0 comments on commit 18c8653

Please sign in to comment.