mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-03-30 19:26:37 +00:00
fix: default sorting on tables (#299)
Co-authored-by: Elias Schneider <login@eliasschneider.com>
This commit is contained in:
@@ -1,9 +1,23 @@
|
||||
import { ACCESS_TOKEN_COOKIE_NAME } from '$lib/constants';
|
||||
import UserService from '$lib/services/user-service';
|
||||
import type { SearchPaginationSortRequest } from '$lib/types/pagination.type';
|
||||
import type { PageServerLoad } from './$types';
|
||||
|
||||
export const load: PageServerLoad = async ({ cookies }) => {
|
||||
const userService = new UserService(cookies.get(ACCESS_TOKEN_COOKIE_NAME));
|
||||
const users = await userService.list();
|
||||
|
||||
// Create request options with default sorting
|
||||
const requestOptions: SearchPaginationSortRequest = {
|
||||
sort: {
|
||||
column: 'firstName',
|
||||
direction: 'asc'
|
||||
},
|
||||
pagination: {
|
||||
page: 1,
|
||||
limit: 10
|
||||
}
|
||||
};
|
||||
|
||||
const users = await userService.list(requestOptions);
|
||||
return users;
|
||||
};
|
||||
|
||||
@@ -17,10 +17,17 @@
|
||||
import OneTimeLinkModal from './one-time-link-modal.svelte';
|
||||
|
||||
let { users = $bindable() }: { users: Paginated<User> } = $props();
|
||||
let requestOptions: SearchPaginationSortRequest | undefined = $state();
|
||||
|
||||
let userIdToCreateOneTimeLink: string | null = $state(null);
|
||||
|
||||
let requestOptions: SearchPaginationSortRequest | undefined = $state({
|
||||
sort: { column: 'firstName', direction: 'asc' },
|
||||
pagination: {
|
||||
page: users.pagination.currentPage,
|
||||
limit: users.pagination.itemsPerPage
|
||||
}
|
||||
});
|
||||
|
||||
const userService = new UserService();
|
||||
|
||||
async function deleteUser(user: User) {
|
||||
@@ -47,6 +54,7 @@
|
||||
<AdvancedTable
|
||||
items={users}
|
||||
{requestOptions}
|
||||
defaultSort={{ column: 'firstName', direction: 'asc' }}
|
||||
onRefresh={async (options) => (users = await userService.list(options))}
|
||||
columns={[
|
||||
{ label: 'First name', sortColumn: 'firstName' },
|
||||
|
||||
Reference in New Issue
Block a user