diff --git a/sdks/js/packages/core/client/V1Beta1.ts b/sdks/js/packages/core/client/V1Beta1.ts index f6aab51cf..c36ca954d 100644 --- a/sdks/js/packages/core/client/V1Beta1.ts +++ b/sdks/js/packages/core/client/V1Beta1.ts @@ -170,7 +170,9 @@ import { } from './data-contracts'; import { ContentType, HttpClient, RequestParams } from './http-client'; -export class V1Beta1 extends HttpClient { +export class V1Beta1< + SecurityDataType = unknown +> extends HttpClient { /** * @description Lists all the groups from all the organizations in a Frontier instance. It can be filtered by organization and state. * @@ -394,7 +396,10 @@ export class V1Beta1 extends HttpClient + frontierServiceAuthCallback2 = ( + body: V1Beta1AuthCallbackRequest, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/auth/callback`, method: 'POST', @@ -573,7 +578,10 @@ export class V1Beta1 extends HttpClient + frontierServiceAuthToken = ( + body: V1Beta1AuthTokenRequest, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/auth/token`, method: 'POST', @@ -592,7 +600,10 @@ export class V1Beta1 extends HttpClient + frontierServiceBatchCheckPermission = ( + body: V1Beta1BatchCheckPermissionRequest, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/batchcheck`, method: 'POST', @@ -611,7 +622,10 @@ export class V1Beta1 extends HttpClient + frontierServiceCheckResourcePermission = ( + body: V1Beta1CheckResourcePermissionRequest, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/check`, method: 'POST', @@ -630,7 +644,10 @@ export class V1Beta1 extends HttpClient + frontierServiceListGroupPreferences = ( + id: string, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/groups/${id}/preferences`, method: 'GET', @@ -688,7 +705,10 @@ export class V1Beta1 extends HttpClient + frontierServiceCreateMetaSchema = ( + body: V1Beta1MetaSchemaRequestBody, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/meta/schemas`, method: 'POST', @@ -740,7 +760,11 @@ export class V1Beta1 extends HttpClient + frontierServiceUpdateMetaSchema = ( + id: string, + body: V1Beta1MetaSchemaRequestBody, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/meta/schemas/${id}`, method: 'PUT', @@ -849,7 +873,11 @@ export class V1Beta1 extends HttpClient + frontierServiceGetOrganizationAuditLog = ( + orgId: string, + id: string, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/organization/${orgId}/auditlogs/${id}`, method: 'GET', @@ -892,7 +920,10 @@ export class V1Beta1 extends HttpClient + frontierServiceCreateOrganization = ( + body: V1Beta1OrganizationRequestBody, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/organizations`, method: 'POST', @@ -927,7 +958,10 @@ export class V1Beta1 extends HttpClient + frontierServiceDeleteOrganization = ( + id: string, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/organizations/${id}`, method: 'DELETE', @@ -944,7 +978,11 @@ export class V1Beta1 extends HttpClient + frontierServiceUpdateOrganization = ( + id: string, + body: V1Beta1OrganizationRequestBody, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/organizations/${id}`, method: 'PUT', @@ -962,7 +1000,10 @@ export class V1Beta1 extends HttpClient + frontierServiceListOrganizationAdmins = ( + id: string, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/organizations/${id}/admins`, method: 'GET', @@ -979,7 +1020,11 @@ export class V1Beta1 extends HttpClient + frontierServiceDisableOrganization = ( + id: string, + body: object, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/organizations/${id}/disable`, method: 'POST', @@ -997,7 +1042,11 @@ export class V1Beta1 extends HttpClient + frontierServiceEnableOrganization = ( + id: string, + body: object, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/organizations/${id}/enable`, method: 'POST', @@ -1015,7 +1064,10 @@ export class V1Beta1 extends HttpClient + frontierServiceListOrganizationPreferences = ( + id: string, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/organizations/${id}/preferences`, method: 'GET', @@ -1081,7 +1133,10 @@ export class V1Beta1 extends HttpClient + frontierServiceListOrganizationServiceUsers = ( + id: string, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/organizations/${id}/serviceusers`, method: 'GET', @@ -1102,6 +1157,7 @@ export class V1Beta1 extends HttpClient @@ -1148,7 +1204,11 @@ export class V1Beta1 extends HttpClient + frontierServiceRemoveOrganizationUser = ( + id: string, + userId: string, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/organizations/${id}/users/${userId}`, method: 'DELETE', @@ -1216,7 +1276,11 @@ export class V1Beta1 extends HttpClient + frontierServiceGetOrganizationDomain = ( + orgId: string, + id: string, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/organizations/${orgId}/domains/${id}`, method: 'GET', @@ -1233,7 +1297,11 @@ export class V1Beta1 extends HttpClient + frontierServiceDeleteOrganizationDomain = ( + orgId: string, + id: string, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/organizations/${orgId}/domains/${id}`, method: 'DELETE', @@ -1250,7 +1318,12 @@ export class V1Beta1 extends HttpClient + frontierServiceVerifyOrganizationDomain = ( + orgId: string, + id: string, + body: object, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/organizations/${orgId}/domains/${id}/verify`, method: 'POST', @@ -1293,7 +1366,11 @@ export class V1Beta1 extends HttpClient + frontierServiceCreateGroup = ( + orgId: string, + body: V1Beta1GroupRequestBody, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/organizations/${orgId}/groups`, method: 'POST', @@ -1311,7 +1388,11 @@ export class V1Beta1 extends HttpClient + frontierServiceGetGroup = ( + orgId: string, + id: string, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/organizations/${orgId}/groups/${id}`, method: 'GET', @@ -1328,7 +1409,11 @@ export class V1Beta1 extends HttpClient + frontierServiceDeleteGroup = ( + orgId: string, + id: string, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/organizations/${orgId}/groups/${id}`, method: 'DELETE', @@ -1345,7 +1430,12 @@ export class V1Beta1 extends HttpClient + frontierServiceUpdateGroup = ( + orgId: string, + id: string, + body: V1Beta1GroupRequestBody, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/organizations/${orgId}/groups/${id}`, method: 'PUT', @@ -1363,7 +1453,12 @@ export class V1Beta1 extends HttpClient + frontierServiceDisableGroup = ( + orgId: string, + id: string, + body: object, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/organizations/${orgId}/groups/${id}/disable`, method: 'POST', @@ -1381,7 +1476,12 @@ export class V1Beta1 extends HttpClient + frontierServiceEnableGroup = ( + orgId: string, + id: string, + body: object, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/organizations/${orgId}/groups/${id}/enable`, method: 'POST', @@ -1450,7 +1550,12 @@ export class V1Beta1 extends HttpClient + frontierServiceRemoveGroupUser = ( + orgId: string, + id: string, + userId: string, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/organizations/${orgId}/groups/${id}/users/${userId}`, method: 'DELETE', @@ -1522,7 +1627,11 @@ export class V1Beta1 extends HttpClient + frontierServiceGetOrganizationInvitation = ( + orgId: string, + id: string, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/organizations/${orgId}/invitations/${id}`, method: 'GET', @@ -1539,7 +1648,11 @@ export class V1Beta1 extends HttpClient + frontierServiceDeleteOrganizationInvitation = ( + orgId: string, + id: string, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/organizations/${orgId}/invitations/${id}`, method: 'DELETE', @@ -1556,7 +1669,11 @@ export class V1Beta1 extends HttpClient + frontierServiceAcceptOrganizationInvitation = ( + orgId: string, + id: string, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/organizations/${orgId}/invitations/${id}/accept`, method: 'POST', @@ -1573,7 +1690,10 @@ export class V1Beta1 extends HttpClient + frontierServiceJoinOrganization = ( + orgId: string, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/organizations/${orgId}/join`, method: 'POST', @@ -1615,7 +1735,11 @@ export class V1Beta1 extends HttpClient + frontierServiceCreateOrganizationRole = ( + orgId: string, + body: V1Beta1RoleRequestBody, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/organizations/${orgId}/roles`, method: 'POST', @@ -1633,7 +1757,11 @@ export class V1Beta1 extends HttpClient + frontierServiceGetOrganizationRole = ( + orgId: string, + id: string, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/organizations/${orgId}/roles/${id}`, method: 'GET', @@ -1650,7 +1778,11 @@ export class V1Beta1 extends HttpClient + frontierServiceDeleteOrganizationRole = ( + orgId: string, + id: string, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/organizations/${orgId}/roles/${id}`, method: 'DELETE', @@ -1707,7 +1839,10 @@ export class V1Beta1 extends HttpClient + adminServiceCreatePermission = ( + body: V1Beta1CreatePermissionRequest, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/permissions`, method: 'POST', @@ -1760,7 +1895,11 @@ export class V1Beta1 extends HttpClient + adminServiceUpdatePermission = ( + id: string, + body: V1Beta1PermissionRequestBody, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/permissions/${id}`, method: 'PUT', @@ -1811,7 +1950,10 @@ export class V1Beta1 extends HttpClient + frontierServiceCreatePolicy = ( + body: V1Beta1PolicyRequestBody, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/policies`, method: 'POST', @@ -1863,7 +2005,11 @@ export class V1Beta1 extends HttpClient + frontierServiceUpdatePolicy = ( + id: string, + body: V1Beta1PolicyRequestBody, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/policies/${id}`, method: 'PUT', @@ -1898,7 +2044,10 @@ export class V1Beta1 extends HttpClient + adminServiceCreatePreferences = ( + body: V1Beta1CreatePreferencesRequest, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/preferences`, method: 'POST', @@ -1934,7 +2083,10 @@ export class V1Beta1 extends HttpClient + frontierServiceCreateProject = ( + body: V1Beta1ProjectRequestBody, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/projects`, method: 'POST', @@ -1986,7 +2138,11 @@ export class V1Beta1 extends HttpClient + frontierServiceUpdateProject = ( + id: string, + body: V1Beta1ProjectRequestBody, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/projects/${id}`, method: 'PUT', @@ -2021,7 +2177,11 @@ export class V1Beta1 extends HttpClient + frontierServiceDisableProject = ( + id: string, + body: object, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/projects/${id}/disable`, method: 'POST', @@ -2039,7 +2199,11 @@ export class V1Beta1 extends HttpClient + frontierServiceEnableProject = ( + id: string, + body: object, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/projects/${id}/enable`, method: 'POST', @@ -2074,7 +2238,10 @@ export class V1Beta1 extends HttpClient + frontierServiceListProjectPreferences = ( + id: string, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/projects/${id}/preferences`, method: 'GET', @@ -2215,7 +2382,11 @@ export class V1Beta1 extends HttpClient + frontierServiceGetProjectResource = ( + projectId: string, + id: string, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/projects/${projectId}/resources/${id}`, method: 'GET', @@ -2232,7 +2403,11 @@ export class V1Beta1 extends HttpClient + frontierServiceDeleteProjectResource = ( + projectId: string, + id: string, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/projects/${projectId}/resources/${id}`, method: 'DELETE', @@ -2272,7 +2447,10 @@ export class V1Beta1 extends HttpClient + frontierServiceCreateRelation = ( + body: V1Beta1RelationRequestBody, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/relations`, method: 'POST', @@ -2308,7 +2486,12 @@ export class V1Beta1 extends HttpClient + frontierServiceDeleteRelation = ( + relation: string, + object: string, + subject: string, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/relations/${relation}/object/${object}/subject/${subject}`, method: 'DELETE', @@ -2349,7 +2532,10 @@ export class V1Beta1 extends HttpClient + adminServiceCreateRole = ( + body: V1Beta1RoleRequestBody, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/roles`, method: 'POST', @@ -2384,7 +2570,11 @@ export class V1Beta1 extends HttpClient + adminServiceUpdateRole = ( + id: string, + body: V1Beta1RoleRequestBody, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/roles/${id}`, method: 'PUT', @@ -2428,7 +2618,10 @@ export class V1Beta1 extends HttpClient + frontierServiceCreateServiceUser = ( + body: V1Beta1CreateServiceUserRequest, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/serviceusers`, method: 'POST', @@ -2488,7 +2681,10 @@ export class V1Beta1 extends HttpClient + frontierServiceListServiceUserKeys = ( + id: string, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/serviceusers/${id}/keys`, method: 'GET', @@ -2529,7 +2725,11 @@ export class V1Beta1 extends HttpClient + frontierServiceGetServiceUserKey = ( + id: string, + keyId: string, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/serviceusers/${id}/keys/${keyId}`, method: 'GET', @@ -2546,7 +2746,11 @@ export class V1Beta1 extends HttpClient + frontierServiceDeleteServiceUserKey = ( + id: string, + keyId: string, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/serviceusers/${id}/keys/${keyId}`, method: 'DELETE', @@ -2563,7 +2767,10 @@ export class V1Beta1 extends HttpClient + frontierServiceListServiceUserSecrets = ( + id: string, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/serviceusers/${id}/secrets`, method: 'GET', @@ -2604,7 +2811,11 @@ export class V1Beta1 extends HttpClient + frontierServiceDeleteServiceUserSecret = ( + id: string, + secretId: string, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/serviceusers/${id}/secrets/${secretId}`, method: 'DELETE', @@ -2660,7 +2871,10 @@ export class V1Beta1 extends HttpClient + frontierServiceCreateUser = ( + body: V1Beta1UserRequestBody, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/users`, method: 'POST', @@ -2711,7 +2925,11 @@ export class V1Beta1 extends HttpClient + frontierServiceUpdateUser = ( + id: string, + body: V1Beta1UserRequestBody, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/users/${id}`, method: 'PUT', @@ -2729,7 +2947,11 @@ export class V1Beta1 extends HttpClient + frontierServiceDisableUser = ( + id: string, + body: object, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/users/${id}/disable`, method: 'POST', @@ -2747,7 +2969,11 @@ export class V1Beta1 extends HttpClient + frontierServiceEnableUser = ( + id: string, + body: object, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/users/${id}/enable`, method: 'POST', @@ -2790,7 +3016,10 @@ export class V1Beta1 extends HttpClient + frontierServiceListUserInvitations = ( + id: string, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/users/${id}/invitations`, method: 'GET', @@ -2807,7 +3036,10 @@ export class V1Beta1 extends HttpClient + frontierServiceListOrganizationsByUser = ( + id: string, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/users/${id}/organizations`, method: 'GET', @@ -2824,7 +3056,10 @@ export class V1Beta1 extends HttpClient + frontierServiceListUserPreferences = ( + id: string, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/users/${id}/preferences`, method: 'GET', @@ -2865,7 +3100,10 @@ export class V1Beta1 extends HttpClient + frontierServiceListProjectsByUser = ( + id: string, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/users/${id}/projects`, method: 'GET', @@ -2899,7 +3137,10 @@ export class V1Beta1 extends HttpClient + frontierServiceUpdateCurrentUser = ( + body: V1Beta1UserRequestBody, + params: RequestParams = {} + ) => this.request({ path: `/v1beta1/users/self`, method: 'PUT', diff --git a/sdks/js/packages/core/client/data-contracts.ts b/sdks/js/packages/core/client/data-contracts.ts index de9747781..e37f3db64 100644 --- a/sdks/js/packages/core/client/data-contracts.ts +++ b/sdks/js/packages/core/client/data-contracts.ts @@ -639,6 +639,12 @@ export interface V1Beta1ListOrganizationServiceUsersResponse { export interface V1Beta1ListOrganizationUsersResponse { users?: V1Beta1User[]; + rolePairs?: V1Beta1ListOrganizationUsersResponseRolePair[]; +} + +export interface V1Beta1ListOrganizationUsersResponseRolePair { + userId?: string; + roles?: V1Beta1Role[]; } export interface V1Beta1ListOrganizationsByCurrentUserResponse { diff --git a/sdks/js/packages/core/package.json b/sdks/js/packages/core/package.json index 42faf5d0e..bf5d63ca4 100644 --- a/sdks/js/packages/core/package.json +++ b/sdks/js/packages/core/package.json @@ -75,6 +75,7 @@ "@tanstack/react-router": "0.0.1-beta.174", "axios": "^1.5.0", "class-variance-authority": "^0.7.0", + "dayjs": "^1.11.10", "react-hook-form": "^7.46.2", "react-loading-skeleton": "^3.3.1", "sonner": "^0.6.2", diff --git a/sdks/js/packages/core/react/components/organization/domain/domain.columns.tsx b/sdks/js/packages/core/react/components/organization/domain/domain.columns.tsx index 74a43b7a0..d6cf889ef 100644 --- a/sdks/js/packages/core/react/components/organization/domain/domain.columns.tsx +++ b/sdks/js/packages/core/react/components/organization/domain/domain.columns.tsx @@ -6,6 +6,7 @@ import { toast } from 'sonner'; import { useFrontier } from '~/react/contexts/FrontierContext'; import { V1Beta1Domain } from '~/src'; import Skeleton from 'react-loading-skeleton'; +import dayjs from 'dayjs'; export const getColumns: ( canCreateDomain?: boolean, @@ -34,7 +35,9 @@ export const getColumns: ( accessorKey: 'created_at', cell: isLoading ? () => - : info => {info.getValue()} + : info => ( + {dayjs(info.getValue()).format('DD MMM YY, hh:mmA')} + ) }, { header: '', diff --git a/sdks/js/packages/core/react/components/organization/members/index.tsx b/sdks/js/packages/core/react/components/organization/members/index.tsx index 31cd123f6..5d0b3661c 100644 --- a/sdks/js/packages/core/react/components/organization/members/index.tsx +++ b/sdks/js/packages/core/react/components/organization/members/index.tsx @@ -44,7 +44,7 @@ export default function WorkspaceMembers() { }; }, [permissions, resource]); - const { isFetching, members } = useOrganizationMembers({ + const { isFetching, members, memberRoles } = useOrganizationMembers({ showInvitations: canCreateInvite }); @@ -64,6 +64,7 @@ export default function WorkspaceMembers() { isLoading={isFetching} canCreateInvite={canCreateInvite} canDeleteUser={canDeleteUser} + memberRoles={memberRoles} /> ) : null} @@ -89,7 +90,8 @@ const MembersTable = ({ users, canCreateInvite, canDeleteUser, - organizationId + organizationId, + memberRoles }: MembersTableType) => { let navigate = useNavigate({ from: '/members' }); @@ -100,8 +102,8 @@ const MembersTable = ({ ); const columns = useMemo( - () => getColumns(organizationId, canDeleteUser, isLoading), - [organizationId, canDeleteUser, isLoading] + () => getColumns(organizationId, memberRoles, canDeleteUser, isLoading), + [organizationId, memberRoles, canDeleteUser, isLoading] ); return ( diff --git a/sdks/js/packages/core/react/components/organization/members/member.columns.tsx b/sdks/js/packages/core/react/components/organization/members/member.columns.tsx index d2f2f42c2..30056a1dd 100644 --- a/sdks/js/packages/core/react/components/organization/members/member.columns.tsx +++ b/sdks/js/packages/core/react/components/organization/members/member.columns.tsx @@ -6,14 +6,17 @@ import Skeleton from 'react-loading-skeleton'; import { toast } from 'sonner'; import { useFrontier } from '~/react/contexts/FrontierContext'; import { V1Beta1User, V1Beta1Invitation } from '~/src'; +import { Role } from '~/src/types'; import { getInitials } from '~/utils'; export const getColumns: ( id: string, + memberRoles: Record, canDeleteUser?: boolean, isLoading?: boolean ) => ColumnDef[] = ( organizationId, + memberRoles = {}, canDeleteUser = false, isLoading ) => [ @@ -64,15 +67,18 @@ export const getColumns: ( } }, { - header: 'Email', + header: 'Roles', accessorKey: 'email', - meta: {}, cell: isLoading ? () => : ({ row, getValue }) => { return ( - // @ts-ignore - {getValue() || row.original?.user_id} + (row.original?.id && + memberRoles[row.original?.id] && + memberRoles[row.original?.id] + .map((r: any) => r.title || r.name) + .join(', ')) ?? + 'Inherited role' ); } }, diff --git a/sdks/js/packages/core/react/components/organization/members/member.types.tsx b/sdks/js/packages/core/react/components/organization/members/member.types.tsx index 251be5919..5c3e7659f 100644 --- a/sdks/js/packages/core/react/components/organization/members/member.types.tsx +++ b/sdks/js/packages/core/react/components/organization/members/member.types.tsx @@ -1,4 +1,4 @@ -import { User } from '~/src/types'; +import { Role, User } from '~/src/types'; export type MembersType = { users: User[]; @@ -14,4 +14,5 @@ export type MembersTableType = { organizationId: string; canCreateInvite?: boolean; canDeleteUser?: boolean; + memberRoles: Record; }; diff --git a/sdks/js/packages/core/react/hooks/useOrganizationMembers.ts b/sdks/js/packages/core/react/hooks/useOrganizationMembers.ts index b1ab56c6a..66bdd9627 100644 --- a/sdks/js/packages/core/react/hooks/useOrganizationMembers.ts +++ b/sdks/js/packages/core/react/hooks/useOrganizationMembers.ts @@ -2,6 +2,7 @@ import { useRouterState } from '@tanstack/react-router'; import { useCallback, useEffect, useMemo, useState } from 'react'; import { V1Beta1User } from '~/src'; import { useFrontier } from '../contexts/FrontierContext'; +import { Role } from '~/src/types'; export const useOrganizationMembers = ({ showInvitations = false }) => { const [users, setUsers] = useState([]); @@ -9,6 +10,7 @@ export const useOrganizationMembers = ({ showInvitations = false }) => { const [isUsersLoading, setIsUsersLoading] = useState(false); const [isInvitationsLoading, setIsInvitationsLoading] = useState(false); + const [memberRoles, setMemberRoles] = useState>({}); const { client, activeOrganization: organization } = useFrontier(); const routerState = useRouterState(); @@ -19,9 +21,16 @@ export const useOrganizationMembers = ({ showInvitations = false }) => { setIsUsersLoading(true); const { // @ts-ignore - data: { users } - } = await client?.frontierServiceListOrganizationUsers(organization?.id); + data: { users, role_pairs } + } = await client?.frontierServiceListOrganizationUsers(organization?.id, { + withRoles: true + }); setUsers(users); + setMemberRoles( + role_pairs.reduce((previous: any, mr: any) => { + return { ...previous, [mr.user_id]: mr.roles }; + }, {}) + ); } catch (err) { console.error(err); } finally { @@ -75,6 +84,7 @@ export const useOrganizationMembers = ({ showInvitations = false }) => { return { isFetching, - members: updatedUsers + members: updatedUsers, + memberRoles }; }; diff --git a/sdks/js/pnpm-lock.yaml b/sdks/js/pnpm-lock.yaml index cbe195122..1afb92d14 100644 --- a/sdks/js/pnpm-lock.yaml +++ b/sdks/js/pnpm-lock.yaml @@ -48,6 +48,9 @@ importers: class-variance-authority: specifier: ^0.7.0 version: 0.7.0 + dayjs: + specifier: ^1.11.10 + version: 1.11.10 react: specifier: ^18.2.0 version: 18.2.0 @@ -2706,6 +2709,10 @@ packages: resolution: {integrity: sha512-hBSVCvSmWC+QypYObzwGOd9wqdDpOt+0wl0KbU+R+uuZBS1jN8VsD1ss3irQDknRj5NvxiTF6oj/nDRnN/UQNw==} dev: true + /dayjs@1.11.10: + resolution: {integrity: sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==} + dev: false + /debug@3.2.7: resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==} peerDependencies: