From 176bd9db18522a07e76c9eced1b73c7fae3bf6ec Mon Sep 17 00:00:00 2001 From: Markus Thielker Date: Wed, 4 Dec 2024 11:43:08 +0100 Subject: [PATCH] NORY-15: show identities in data-table --- dashboard/src/app/user/data-table.tsx | 86 +++++++++++++++++++++++++++ dashboard/src/app/user/page.tsx | 24 +++++++- 2 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 dashboard/src/app/user/data-table.tsx diff --git a/dashboard/src/app/user/data-table.tsx b/dashboard/src/app/user/data-table.tsx new file mode 100644 index 0000000..124e07d --- /dev/null +++ b/dashboard/src/app/user/data-table.tsx @@ -0,0 +1,86 @@ +'use client'; + +import { ColumnDef } from '@tanstack/react-table'; +import { Identity } from '@ory/client'; +import { DataTable } from '@/components/ui/data-table'; +import { CircleCheck, CircleX } from 'lucide-react'; +import { HoverCard, HoverCardContent, HoverCardTrigger } from '@/components/ui/hover-card'; + +interface IdentityDataTableProps { + data: Identity[]; +} + +export function IdentityDataTable({ data }: IdentityDataTableProps) { + + const columns: ColumnDef[] = [ + { + id: 'id', + accessorKey: 'id', + header: 'ID', + }, + { + id: 'active', + header: 'Active', + cell: ({ row }) => { + + const identity = row.original; + + if (identity.state === 'active') { + return ; + } else { + return ; + } + }, + }, + { + id: 'name', + accessorKey: 'traits.name', + header: 'Name', + }, + { + id: 'email', + header: 'Email', + cell: ({ row }) => { + + const identity = row.original; + const email = identity.verifiable_addresses ? + identity.verifiable_addresses[0] : undefined; + + if (!email) { + return

Something went wrong

; + } else { + return ( +
+ {email.value} + { + email.verified ? + + + + + + This email was confirmed at + {new Date(email.verified_at!!).toLocaleString()} + + + : + + + + + + This email is not confirmed yet + + + } +
+ ); + } + }, + }, + ]; + + return ( + + ); +} diff --git a/dashboard/src/app/user/page.tsx b/dashboard/src/app/user/page.tsx index 2beb9f6..e0cb1e5 100644 --- a/dashboard/src/app/user/page.tsx +++ b/dashboard/src/app/user/page.tsx @@ -1,3 +1,25 @@ +import React, { Suspense } from 'react'; +import { DataTableFallback } from '@/components/ui/data-table-fallback'; +import { IdentityDataTable } from '@/app/user/data-table'; +import { getIdentityApi } from '@/ory/sdk/server'; + export default async function UserPage() { - return <>; + + const identityApi = await getIdentityApi(); + + const { data } = await identityApi.listIdentities(); + + return ( +
+
+

Users

+

See and manage all identities registered with your Ory Kratos + instance

+
+ + }> + + +
+ ); }