mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-03-29 10:46:38 +00:00
refactor: adapt api key list to new sort behavior
This commit is contained in:
@@ -11,25 +11,15 @@
|
||||
import { toast } from 'svelte-sonner';
|
||||
|
||||
let {
|
||||
apiKeys: initialApiKeys
|
||||
apiKeys,
|
||||
requestOptions
|
||||
}: {
|
||||
apiKeys: Paginated<ApiKey>;
|
||||
requestOptions: SearchPaginationSortRequest;
|
||||
} = $props();
|
||||
|
||||
let apiKeys = $state<Paginated<ApiKey>>(initialApiKeys);
|
||||
let requestOptions: SearchPaginationSortRequest | undefined = $state({
|
||||
sort: {
|
||||
column: 'lastUsedAt',
|
||||
direction: 'desc'
|
||||
}
|
||||
});
|
||||
const apiKeyService = new ApiKeyService();
|
||||
|
||||
// Update the local state whenever the prop changes
|
||||
$effect(() => {
|
||||
apiKeys = initialApiKeys;
|
||||
});
|
||||
|
||||
function formatDate(dateStr: string | undefined) {
|
||||
if (!dateStr) return 'Never';
|
||||
return new Date(dateStr).toLocaleString();
|
||||
@@ -54,11 +44,6 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
// Initial load uses the server-side data
|
||||
apiKeys = initialApiKeys;
|
||||
});
|
||||
</script>
|
||||
|
||||
<AdvancedTable
|
||||
@@ -66,7 +51,6 @@
|
||||
{requestOptions}
|
||||
onRefresh={async (o) => (apiKeys = await apiKeyService.list(o))}
|
||||
withoutSearch
|
||||
defaultSort={{ column: 'lastUsedAt', direction: 'desc' }}
|
||||
columns={[
|
||||
{ label: 'Name', sortColumn: 'name' },
|
||||
{ label: 'Description' },
|
||||
|
||||
Reference in New Issue
Block a user