mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-13 21:01:21 +08:00
added default sorting to tables
This commit is contained in:
parent
372bd3296a
commit
85d167ed3c
@ -100,10 +100,19 @@ const columns: ColumnDef<ExtendedApiKeySet>[] = [
|
||||
];
|
||||
|
||||
export function ApiKeyTable(props: { apiKeys: ApiKeySet[] }) {
|
||||
const extendedApiKeys = useMemo(() => props.apiKeys.map((apiKey) => ({
|
||||
...apiKey,
|
||||
status: ({ 'valid': 'valid', 'manually-revoked': 'revoked', 'expired': 'expired' } as const)[apiKey.whyInvalid() || 'valid'],
|
||||
} satisfies ExtendedApiKeySet)), [props.apiKeys]);
|
||||
const extendedApiKeys = useMemo(() => {
|
||||
const keys = props.apiKeys.map((apiKey) => ({
|
||||
...apiKey,
|
||||
status: ({ 'valid': 'valid', 'manually-revoked': 'revoked', 'expired': 'expired' } as const)[apiKey.whyInvalid() || 'valid'],
|
||||
} satisfies ExtendedApiKeySet));
|
||||
// first soft based on status, then by expiresAt
|
||||
return keys.sort((a, b) => {
|
||||
if (a.status === b.status) {
|
||||
return a.expiresAt < b.expiresAt ? 1 : -1;
|
||||
}
|
||||
return a.status === 'valid' ? -1 : 1;
|
||||
});
|
||||
}, [props.apiKeys]);
|
||||
|
||||
return <DataTable data={extendedApiKeys} columns={columns} toolbarRender={toolbarRender} />;
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
'use client';;
|
||||
import { useState } from "react";
|
||||
import { useMemo, useState } from "react";
|
||||
import * as yup from "yup";
|
||||
import { ServerTeam } from '@stackframe/stack';
|
||||
import { ColumnDef, Row, Table } from "@tanstack/react-table";
|
||||
@ -124,5 +124,7 @@ const columns: ColumnDef<ServerTeam>[] = [
|
||||
];
|
||||
|
||||
export function TeamTable(props: { teams: ServerTeam[] }) {
|
||||
const teams = useMemo(() => props.teams.sort((a, b) => b.createdAt - a.createdAt), [props.teams]);
|
||||
|
||||
return <DataTable data={props.teams} columns={columns} toolbarRender={toolbarRender} />;
|
||||
}
|
||||
@ -187,7 +187,7 @@ export function extendUsers(users: ServerUser[]): ExtendedServerUser[] {
|
||||
...user,
|
||||
authType: (user.authWithEmail ? "email" : user.oauthProviders[0]) || "",
|
||||
emailVerified: user.primaryEmailVerified ? "verified" : "unverified",
|
||||
}));
|
||||
})).sort((a, b) => b.signedUpAt - a.signedUpAt);
|
||||
}
|
||||
|
||||
export function UserTable(props: { users: ServerUser[] }) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user