diff --git a/packages/console/src/pages/Users/components/ApplicationName/index.tsx b/packages/console/src/pages/Users/components/ApplicationName/index.tsx new file mode 100644 index 000000000..d9fa49f42 --- /dev/null +++ b/packages/console/src/pages/Users/components/ApplicationName/index.tsx @@ -0,0 +1,15 @@ +import { Application } from '@logto/schemas'; +import React from 'react'; +import useSWR from 'swr'; + +type Props = { + applicationId: string; +}; + +const ApplicationName = ({ applicationId }: Props) => { + const { data } = useSWR(`/api/applications/${applicationId}`); + + return {data?.name ?? '-'}; +}; + +export default ApplicationName; diff --git a/packages/console/src/pages/Users/index.tsx b/packages/console/src/pages/Users/index.tsx index f95a4c1bc..f15c3a6cc 100644 --- a/packages/console/src/pages/Users/index.tsx +++ b/packages/console/src/pages/Users/index.tsx @@ -23,6 +23,7 @@ import Plus from '@/icons/Plus'; import * as modalStyles from '@/scss/modal.module.scss'; import * as tableStyles from '@/scss/table.module.scss'; +import ApplicationName from './components/ApplicationName'; import CreateForm from './components/CreateForm'; import * as styles from './index.module.scss'; @@ -113,7 +114,7 @@ const Users = () => { /> )} - {users?.map(({ id, name, username, lastSignInAt }) => ( + {users?.map(({ id, name, username, lastSignInAt, applicationId }) => ( { size="compact" /> - Application + {applicationId ? : '-'} {lastSignInAt} diff --git a/packages/schemas/src/types/user.ts b/packages/schemas/src/types/user.ts index 5a0e2946c..2b06f56b4 100644 --- a/packages/schemas/src/types/user.ts +++ b/packages/schemas/src/types/user.ts @@ -11,6 +11,7 @@ export const userInfoSelectFields = Object.freeze([ 'customData', 'identities', 'lastSignInAt', + 'applicationId', ] as const); export type UserInfo = Pick<