Skip to content

Commit 8a062d8

Browse files
committed
Update ModelApiKeysCard.tsx
1 parent f374c36 commit 8a062d8

File tree

1 file changed

+62
-9
lines changed

1 file changed

+62
-9
lines changed

packages/wizard/src/demo/RequiredActionCards/ModelApiKeysCard.tsx

Lines changed: 62 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,72 @@
11
import React from 'react';
2+
import { format } from 'date-fns';
23

3-
import { useLeafyGreenTable } from '@leafygreen-ui/table';
4+
import {
5+
CellContext,
6+
LGColumnDef,
7+
LGTableDataType,
8+
useLeafyGreenTable,
9+
} from '@leafygreen-ui/table';
410
import { Description } from '@leafygreen-ui/typography';
511

612
import { BasicTable } from '../../HELPERS/BasicTable';
713
import { useFetchRequiredActionTableData } from '../hooks/useFetchRequiredActionTableData';
814
import { RequiredActionCard, TitleEm } from '../RequiredActionCard';
915

10-
const modelApiKeysColumns = [
11-
{ accessorKey: 'name', header: 'Key Name' },
12-
{ accessorKey: 'created', header: 'Created' },
16+
const DateCell = (
17+
cellData: CellContext<
18+
LGTableDataType<ModelAPIKeyTableData>,
19+
Date | undefined
20+
>,
21+
) => {
22+
const val = cellData.getValue() as Date | undefined;
23+
24+
if (!val) return <>Never</>;
25+
26+
return <>{format(val, 'yyyy-MM-dd')}</>;
27+
};
28+
29+
interface ModelAPIKeyTableData {
30+
keyName: string;
31+
createdDate: Date;
32+
lastUsedDate?: Date;
33+
createdBy: string;
34+
}
35+
36+
const modelApiKeysColumns: Array<LGColumnDef<ModelAPIKeyTableData>> = [
37+
{ accessorKey: 'keyName', header: 'Key Name' },
38+
{ accessorKey: 'key', header: 'Secret key', cell: () => <>********</> },
39+
{
40+
accessorKey: 'createdDate',
41+
header: 'Created on (UTC)',
42+
cell: DateCell,
43+
},
44+
{
45+
accessorKey: 'lastUsedDate',
46+
header: 'Last used (UTC)',
47+
cell: DateCell,
48+
},
49+
{ accessorKey: 'createdBy', header: 'Created by' },
1350
];
1451

15-
const demoModelApiKeysData = [
16-
{ name: 'api-key-1', created: '01/15/2025' },
17-
{ name: 'api-key-2', created: '01/20/2025' },
18-
{ name: 'api-key-3', created: '01/22/2025' },
52+
const demoModelApiKeysData: Array<LGTableDataType<ModelAPIKeyTableData>> = [
53+
{
54+
keyName: 'voyage-api-key-1',
55+
createdDate: new Date('2019-04-22'),
56+
lastUsedDate: new Date(),
57+
createdBy: 'Mike Waltzer',
58+
},
59+
{
60+
keyName: 'voyage-api-key-2',
61+
createdDate: new Date('2022-08-29'),
62+
lastUsedDate: new Date(),
63+
createdBy: 'Lauren Fox',
64+
},
65+
{
66+
keyName: 'voyage-api-key-3',
67+
createdDate: new Date('2021-06-07'),
68+
createdBy: 'Adam Thompson',
69+
},
1970
];
2071

2172
export const ModelApiKeysCard = () => {
@@ -30,9 +81,11 @@ export const ModelApiKeysCard = () => {
3081

3182
return (
3283
<RequiredActionCard
84+
isLoading={isLoading}
85+
loadingTitle="Checking for Model API keys"
3386
title={
3487
<>
35-
Delete <TitleEm>3</TitleEm> Model API keys
88+
Delete <TitleEm>{tableData?.length}</TitleEm> Model API keys
3689
</>
3790
}
3891
description={

0 commit comments

Comments
 (0)