Rework people list and trust center access list + edit dialog

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-03-05 14:32:28 +04:00
parent 4279f92d96
commit 0d1bcd21aa
17 changed files with 707 additions and 578 deletions

View File

@@ -1,5 +1,5 @@
/**
* @generated SignedSource<<7c575bd72e0d697cf92b9dd57038995c>>
* @generated SignedSource<<b9fc06fe9a0b5d316298bb77804e29b1>>
* @lightSyntaxTransform
* @nogrep
*/
@@ -31,12 +31,8 @@ export type CompliancePageAccessEditDialogUpdateMutation$data = {
readonly trustCenterAccess: {
readonly activeCount: number;
readonly createdAt: string;
readonly email: string;
readonly hasAcceptedNonDisclosureAgreement: boolean;
readonly id: string;
readonly name: string;
readonly pendingRequestCount: number;
readonly state: TrustCenterAccessState;
readonly updatedAt: string;
};
};
@@ -84,34 +80,6 @@ v1 = [
"name": "id",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "email",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "name",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "state",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "hasAcceptedNonDisclosureAgreement",
"storageKey": null
},
{
"alias": null,
"args": null,
@@ -165,16 +133,16 @@ return {
"selections": (v1/*: any*/)
},
"params": {
"cacheID": "e8401f17211bce414eee9048b939235a",
"cacheID": "39cf57753ab2bd46878a9200ef892894",
"id": null,
"metadata": {},
"name": "CompliancePageAccessEditDialogUpdateMutation",
"operationKind": "mutation",
"text": "mutation CompliancePageAccessEditDialogUpdateMutation(\n $input: UpdateTrustCenterAccessInput!\n) {\n updateTrustCenterAccess(input: $input) {\n trustCenterAccess {\n id\n email\n name\n state\n hasAcceptedNonDisclosureAgreement\n createdAt\n updatedAt\n pendingRequestCount\n activeCount\n }\n }\n}\n"
"text": "mutation CompliancePageAccessEditDialogUpdateMutation(\n $input: UpdateTrustCenterAccessInput!\n) {\n updateTrustCenterAccess(input: $input) {\n trustCenterAccess {\n id\n createdAt\n updatedAt\n pendingRequestCount\n activeCount\n }\n }\n}\n"
}
};
})();
(node as any).hash = "e511d9060cc29db26cd6ff281fe2722b";
(node as any).hash = "896760c6c5c2d6adfca8ffcd7c7e22c7";
export default node;

View File

@@ -1,5 +1,5 @@
/**
* @generated SignedSource<<97bc9b075b82bb1543c80843430ced5d>>
* @generated SignedSource<<382df5177a666b0cc6c3feef198c8354>>
* @lightSyntaxTransform
* @nogrep
*/
@@ -10,20 +10,22 @@
import { ReaderFragment } from 'relay-runtime';
export type ElectronicSignatureStatus = "ACCEPTED" | "COMPLETED" | "FAILED" | "PENDING" | "PROCESSING";
export type TrustCenterAccessState = "ACTIVE" | "INACTIVE";
export type ProfileState = "ACTIVE" | "INACTIVE";
import { FragmentRefs } from "relay-runtime";
export type CompliancePageAccessListItemFragment$data = {
readonly activeCount: number;
readonly canUpdate: boolean;
readonly createdAt: string;
readonly email: string;
readonly id: string;
readonly name: string;
readonly ndaSignature: {
readonly status: ElectronicSignatureStatus;
} | null | undefined;
readonly pendingRequestCount: number;
readonly state: TrustCenterAccessState;
readonly profile: {
readonly emailAddress: string;
readonly fullName: string;
readonly state: ProfileState;
};
readonly " $fragmentType": "CompliancePageAccessListItemFragment";
};
export type CompliancePageAccessListItemFragment$key = {
@@ -44,20 +46,6 @@ const node: ReaderFragment = {
"name": "id",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "name",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "email",
"storageKey": null
},
{
"alias": null,
"args": null,
@@ -68,8 +56,33 @@ const node: ReaderFragment = {
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "state",
"concreteType": "Profile",
"kind": "LinkedField",
"name": "profile",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "fullName",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "emailAddress",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "state",
"storageKey": null
}
],
"storageKey": null
},
{
@@ -122,6 +135,6 @@ const node: ReaderFragment = {
"abstractKey": null
};
(node as any).hash = "9047d3d3f232d43c6f951c74b0395b58";
(node as any).hash = "a08d6999781177cb0896f372c570fca8";
export default node;

View File

@@ -1,5 +1,5 @@
/**
* @generated SignedSource<<ca74f6c0f80146a4ed4e90bcee385300>>
* @generated SignedSource<<2f95db3fc1f72db6d38bed52fb1e89bd>>
* @lightSyntaxTransform
* @nogrep
*/
@@ -9,6 +9,7 @@
// @ts-nocheck
import { ConcreteRequest } from 'relay-runtime';
export type ProfileState = "ACTIVE" | "INACTIVE";
export type TrustCenterAccessState = "ACTIVE" | "INACTIVE";
export type TrustCenterDocumentAccessStatus = "GRANTED" | "REJECTED" | "REQUESTED" | "REVOKED";
export type UpdateTrustCenterAccessInput = {
@@ -31,12 +32,13 @@ export type CompliancePageAccessListItemUpdateMutation$data = {
readonly trustCenterAccess: {
readonly activeCount: number;
readonly createdAt: string;
readonly email: string;
readonly hasAcceptedNonDisclosureAgreement: boolean;
readonly id: string;
readonly name: string;
readonly pendingRequestCount: number;
readonly state: TrustCenterAccessState;
readonly profile: {
readonly emailAddress: string;
readonly fullName: string;
readonly state: ProfileState;
};
readonly updatedAt: string;
};
};
@@ -56,104 +58,116 @@ var v0 = [
],
v1 = [
{
"alias": null,
"args": [
{
"kind": "Variable",
"name": "input",
"variableName": "input"
}
],
"concreteType": "UpdateTrustCenterAccessPayload",
"kind": "LinkedField",
"name": "updateTrustCenterAccess",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "TrustCenterAccess",
"kind": "LinkedField",
"name": "trustCenterAccess",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "id",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "email",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "name",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "state",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "hasAcceptedNonDisclosureAgreement",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "createdAt",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "updatedAt",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "pendingRequestCount",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "activeCount",
"storageKey": null
}
],
"storageKey": null
}
],
"storageKey": null
"kind": "Variable",
"name": "input",
"variableName": "input"
}
];
],
v2 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "id",
"storageKey": null
},
v3 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "createdAt",
"storageKey": null
},
v4 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "updatedAt",
"storageKey": null
},
v5 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "pendingRequestCount",
"storageKey": null
},
v6 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "activeCount",
"storageKey": null
},
v7 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "fullName",
"storageKey": null
},
v8 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "emailAddress",
"storageKey": null
},
v9 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "state",
"storageKey": null
};
return {
"fragment": {
"argumentDefinitions": (v0/*: any*/),
"kind": "Fragment",
"metadata": null,
"name": "CompliancePageAccessListItemUpdateMutation",
"selections": (v1/*: any*/),
"selections": [
{
"alias": null,
"args": (v1/*: any*/),
"concreteType": "UpdateTrustCenterAccessPayload",
"kind": "LinkedField",
"name": "updateTrustCenterAccess",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "TrustCenterAccess",
"kind": "LinkedField",
"name": "trustCenterAccess",
"plural": false,
"selections": [
(v2/*: any*/),
(v3/*: any*/),
(v4/*: any*/),
(v5/*: any*/),
(v6/*: any*/),
{
"alias": null,
"args": null,
"concreteType": "Profile",
"kind": "LinkedField",
"name": "profile",
"plural": false,
"selections": [
(v7/*: any*/),
(v8/*: any*/),
(v9/*: any*/)
],
"storageKey": null
}
],
"storageKey": null
}
],
"storageKey": null
}
],
"type": "Mutation",
"abstractKey": null
},
@@ -162,19 +176,62 @@ return {
"argumentDefinitions": (v0/*: any*/),
"kind": "Operation",
"name": "CompliancePageAccessListItemUpdateMutation",
"selections": (v1/*: any*/)
"selections": [
{
"alias": null,
"args": (v1/*: any*/),
"concreteType": "UpdateTrustCenterAccessPayload",
"kind": "LinkedField",
"name": "updateTrustCenterAccess",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "TrustCenterAccess",
"kind": "LinkedField",
"name": "trustCenterAccess",
"plural": false,
"selections": [
(v2/*: any*/),
(v3/*: any*/),
(v4/*: any*/),
(v5/*: any*/),
(v6/*: any*/),
{
"alias": null,
"args": null,
"concreteType": "Profile",
"kind": "LinkedField",
"name": "profile",
"plural": false,
"selections": [
(v7/*: any*/),
(v8/*: any*/),
(v9/*: any*/),
(v2/*: any*/)
],
"storageKey": null
}
],
"storageKey": null
}
],
"storageKey": null
}
]
},
"params": {
"cacheID": "a943d051a8be76541af43131995defbe",
"cacheID": "f8d08c05c3a5c935c68ca7ef509cf376",
"id": null,
"metadata": {},
"name": "CompliancePageAccessListItemUpdateMutation",
"operationKind": "mutation",
"text": "mutation CompliancePageAccessListItemUpdateMutation(\n $input: UpdateTrustCenterAccessInput!\n) {\n updateTrustCenterAccess(input: $input) {\n trustCenterAccess {\n id\n email\n name\n state\n hasAcceptedNonDisclosureAgreement\n createdAt\n updatedAt\n pendingRequestCount\n activeCount\n }\n }\n}\n"
"text": "mutation CompliancePageAccessListItemUpdateMutation(\n $input: UpdateTrustCenterAccessInput!\n) {\n updateTrustCenterAccess(input: $input) {\n trustCenterAccess {\n id\n createdAt\n updatedAt\n pendingRequestCount\n activeCount\n profile {\n fullName\n emailAddress\n state\n id\n }\n }\n }\n}\n"
}
};
})();
(node as any).hash = "82b5fb2e5d6ff48f7cf660007b4366ed";
(node as any).hash = "2912ca422f9edc3806a7e1ca6cb21028";
export default node;

View File

@@ -1,5 +1,5 @@
/**
* @generated SignedSource<<42b8a91e3553bb30392c749d440cc0c0>>
* @generated SignedSource<<e4c451eec4363f38b74a938be21a9939>>
* @lightSyntaxTransform
* @nogrep
*/
@@ -231,20 +231,6 @@ return {
"plural": false,
"selections": [
(v8/*: any*/),
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "name",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "email",
"storageKey": null
},
{
"alias": null,
"args": null,
@@ -255,8 +241,34 @@ return {
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "state",
"concreteType": "Profile",
"kind": "LinkedField",
"name": "profile",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "fullName",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "emailAddress",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "state",
"storageKey": null
},
(v8/*: any*/)
],
"storageKey": null
},
{
@@ -348,12 +360,12 @@ return {
]
},
"params": {
"cacheID": "e4ac357eef4246850b334e1f8f1faab2",
"cacheID": "59b4c338efea592e4e15305f84158cce",
"id": null,
"metadata": {},
"name": "CompliancePageAccessListQuery",
"operationKind": "query",
"text": "query CompliancePageAccessListQuery(\n $after: CursorKey = null\n $first: Int = 10\n $order: TrustCenterAccessOrder = {field: CREATED_AT, direction: DESC}\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...CompliancePageAccessListFragment_gOVF5\n id\n }\n}\n\nfragment CompliancePageAccessListFragment_gOVF5 on TrustCenter {\n accesses(first: $first, after: $after, orderBy: $order) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n edges {\n cursor\n node {\n id\n ...CompliancePageAccessListItemFragment\n __typename\n }\n }\n }\n id\n}\n\nfragment CompliancePageAccessListItemFragment on TrustCenterAccess {\n id\n name\n email\n createdAt\n state\n activeCount\n pendingRequestCount\n ndaSignature {\n status\n id\n }\n canUpdate: permission(action: \"core:trust-center-access:update\")\n}\n"
"text": "query CompliancePageAccessListQuery(\n $after: CursorKey = null\n $first: Int = 10\n $order: TrustCenterAccessOrder = {field: CREATED_AT, direction: DESC}\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...CompliancePageAccessListFragment_gOVF5\n id\n }\n}\n\nfragment CompliancePageAccessListFragment_gOVF5 on TrustCenter {\n accesses(first: $first, after: $after, orderBy: $order) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n edges {\n cursor\n node {\n id\n ...CompliancePageAccessListItemFragment\n __typename\n }\n }\n }\n id\n}\n\nfragment CompliancePageAccessListItemFragment on TrustCenterAccess {\n id\n createdAt\n profile {\n fullName\n emailAddress\n state\n id\n }\n activeCount\n pendingRequestCount\n ndaSignature {\n status\n id\n }\n canUpdate: permission(action: \"core:trust-center-access:update\")\n}\n"
}
};
})();

View File

@@ -1,5 +1,5 @@
/**
* @generated SignedSource<<d2b21f03826cd218a7115b28f58ca0ae>>
* @generated SignedSource<<d32c91bec3630db95573556172f06d35>>
* @lightSyntaxTransform
* @nogrep
*/
@@ -240,20 +240,6 @@ return {
"plural": false,
"selections": [
(v3/*: any*/),
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "name",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "email",
"storageKey": null
},
{
"alias": null,
"args": null,
@@ -264,8 +250,34 @@ return {
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "state",
"concreteType": "Profile",
"kind": "LinkedField",
"name": "profile",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "fullName",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "emailAddress",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "state",
"storageKey": null
},
(v3/*: any*/)
],
"storageKey": null
},
{
@@ -361,12 +373,12 @@ return {
]
},
"params": {
"cacheID": "ad9508484592b38254e9cc66941b926e",
"cacheID": "c556c1f73c80950e432e5298b7aa1162",
"id": null,
"metadata": {},
"name": "CompliancePageAccessPageQuery",
"operationKind": "query",
"text": "query CompliancePageAccessPageQuery(\n $organizationId: ID!\n) {\n organization: node(id: $organizationId) {\n __typename\n ... on Organization {\n compliancePage: trustCenter {\n id\n canCreateAccess: permission(action: \"core:trust-center-access:create\")\n ...CompliancePageAccessListFragment\n }\n }\n id\n }\n}\n\nfragment CompliancePageAccessListFragment on TrustCenter {\n accesses(first: 10, orderBy: {field: CREATED_AT, direction: DESC}) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n edges {\n cursor\n node {\n id\n ...CompliancePageAccessListItemFragment\n __typename\n }\n }\n }\n id\n}\n\nfragment CompliancePageAccessListItemFragment on TrustCenterAccess {\n id\n name\n email\n createdAt\n state\n activeCount\n pendingRequestCount\n ndaSignature {\n status\n id\n }\n canUpdate: permission(action: \"core:trust-center-access:update\")\n}\n"
"text": "query CompliancePageAccessPageQuery(\n $organizationId: ID!\n) {\n organization: node(id: $organizationId) {\n __typename\n ... on Organization {\n compliancePage: trustCenter {\n id\n canCreateAccess: permission(action: \"core:trust-center-access:create\")\n ...CompliancePageAccessListFragment\n }\n }\n id\n }\n}\n\nfragment CompliancePageAccessListFragment on TrustCenter {\n accesses(first: 10, orderBy: {field: CREATED_AT, direction: DESC}) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n edges {\n cursor\n node {\n id\n ...CompliancePageAccessListItemFragment\n __typename\n }\n }\n }\n id\n}\n\nfragment CompliancePageAccessListItemFragment on TrustCenterAccess {\n id\n createdAt\n profile {\n fullName\n emailAddress\n state\n id\n }\n activeCount\n pendingRequestCount\n ndaSignature {\n status\n id\n }\n canUpdate: permission(action: \"core:trust-center-access:update\")\n}\n"
}
};
})();

View File

@@ -1,5 +1,5 @@
/**
* @generated SignedSource<<9b82b09c2b56467a1dfa0fcdf809bc34>>
* @generated SignedSource<<eab35c7d6cd3334dc38eae117619b5ec>>
* @lightSyntaxTransform
* @nogrep
*/
@@ -156,20 +156,6 @@ return {
"plural": false,
"selections": [
(v4/*: any*/),
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "name",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "email",
"storageKey": null
},
{
"alias": null,
"args": null,
@@ -180,8 +166,34 @@ return {
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "state",
"concreteType": "Profile",
"kind": "LinkedField",
"name": "profile",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "fullName",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "emailAddress",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "state",
"storageKey": null
},
(v4/*: any*/)
],
"storageKey": null
},
{
@@ -258,12 +270,12 @@ return {
]
},
"params": {
"cacheID": "685bbdb5f629501f61631592530f46a7",
"cacheID": "da08cb11a0a3e5668078201ca7c634ef",
"id": null,
"metadata": {},
"name": "NewCompliancePageAccessDialogMutation",
"operationKind": "mutation",
"text": "mutation NewCompliancePageAccessDialogMutation(\n $input: CreateTrustCenterAccessInput!\n) {\n createTrustCenterAccess(input: $input) {\n trustCenterAccessEdge {\n cursor\n node {\n id\n ...CompliancePageAccessListItemFragment\n }\n }\n }\n}\n\nfragment CompliancePageAccessListItemFragment on TrustCenterAccess {\n id\n name\n email\n createdAt\n state\n activeCount\n pendingRequestCount\n ndaSignature {\n status\n id\n }\n canUpdate: permission(action: \"core:trust-center-access:update\")\n}\n"
"text": "mutation NewCompliancePageAccessDialogMutation(\n $input: CreateTrustCenterAccessInput!\n) {\n createTrustCenterAccess(input: $input) {\n trustCenterAccessEdge {\n cursor\n node {\n id\n ...CompliancePageAccessListItemFragment\n }\n }\n }\n}\n\nfragment CompliancePageAccessListItemFragment on TrustCenterAccess {\n id\n createdAt\n profile {\n fullName\n emailAddress\n state\n id\n }\n activeCount\n pendingRequestCount\n ndaSignature {\n status\n id\n }\n canUpdate: permission(action: \"core:trust-center-access:update\")\n}\n"
}
};
})();

View File

@@ -9,7 +9,6 @@ import {
Dialog,
DialogContent,
DialogFooter,
Field,
Spinner,
} from "@probo/ui";
import { Suspense, useCallback, useEffect, useState } from "react";
@@ -19,12 +18,10 @@ import {
useQueryLoader,
} from "react-relay";
import { graphql } from "relay-runtime";
import { z } from "zod";
import type { CompliancePageAccessEditDialogQuery as CompliancePageAccessEditDialogQueryType } from "#/__generated__/core/CompliancePageAccessEditDialogQuery.graphql";
import type { CompliancePageAccessEditDialogUpdateMutation } from "#/__generated__/core/CompliancePageAccessEditDialogUpdateMutation.graphql";
import type { CompliancePageAccessListItemFragment$data } from "#/__generated__/core/CompliancePageAccessListItemFragment.graphql";
import { useFormWithSchema } from "#/hooks/useFormWithSchema";
import { useMutationWithToasts } from "#/hooks/useMutationWithToasts";
import { CompliancePageDocumentAccessList } from "#/pages/organizations/compliance-page/access/_components/CompliancePageDocumentAccessList";
import { ElectronicSignatureSection } from "#/pages/organizations/compliance-page/access/_components/ElectronicSignatureSection";
@@ -80,10 +77,6 @@ const updateAccessMutation = graphql`
updateTrustCenterAccess(input: $input) {
trustCenterAccess {
id
email
name
state
hasAcceptedNonDisclosureAgreement
createdAt
updatedAt
pendingRequestCount
@@ -118,7 +111,7 @@ export function CompliancePageAccessEditDialog(props: {
}, [access.id, loadQuery]);
return (
<Dialog defaultOpen={true} title={__("Edit Access")} onClose={onClose}>
<Dialog defaultOpen={true} title={__(`Edit Access for ${access.profile.emailAddress}`)} onClose={onClose}>
{queryRef && (
<Suspense>
<CompliancePageAccessEditForm
@@ -196,17 +189,6 @@ function CompliancePageAccessEditForm(props: {
);
}, [initialStatusByID]);
const editSchema = z.object({
name: z
.string()
.min(1, __("Name is required"))
.min(2, __("Name must be at least 2 characters long")),
active: z.boolean(),
});
const editForm = useFormWithSchema(editSchema, {
defaultValues: { name: access.name, active: access.state === "ACTIVE" },
});
const [updateTrustCenterAccess, isUpdating] = useMutationWithToasts<CompliancePageAccessEditDialogUpdateMutation>(
updateAccessMutation,
{
@@ -215,7 +197,7 @@ function CompliancePageAccessEditForm(props: {
},
);
const handleSubmit = editForm.handleSubmit(async (data) => {
const handleSubmit = async () => {
const documents: { id: string; status: TrustCenterDocumentAccessStatus }[]
= [];
const reports: { id: string; status: TrustCenterDocumentAccessStatus }[]
@@ -248,8 +230,6 @@ function CompliancePageAccessEditForm(props: {
variables: {
input: {
id: access.id,
name: data.name.trim(),
state: data.active ? "ACTIVE" : "INACTIVE",
documents,
reports,
trustCenterFiles,
@@ -257,26 +237,11 @@ function CompliancePageAccessEditForm(props: {
},
onSuccess: onSubmit,
});
});
};
return (
<form onSubmit={e => void handleSubmit(e)}>
<>
<DialogContent padded className="space-y-6">
<div>
<p className="text-txt-secondary text-sm mb-4">
{__("Update access settings and document permissions")}
</p>
<Field
label={__("Full Name")}
required
error={editForm.formState.errors.name?.message}
{...editForm.register("name")}
placeholder={__("John Doe")}
/>
</div>
{data.node.ndaSignature && (
<ElectronicSignatureSection fragmentRef={data.node.ndaSignature} />
)}
@@ -291,11 +256,11 @@ function CompliancePageAccessEditForm(props: {
</DialogContent>
<DialogFooter>
<Button type="submit" disabled={isUpdating}>
<Button type="button" disabled={isUpdating} onClick={() => void handleSubmit()}>
{isUpdating && <Spinner />}
{__("Update Access")}
</Button>
</DialogFooter>
</form>
</>
);
}

View File

@@ -15,10 +15,12 @@ import { NdaSignatureBadge } from "./NdaSignatureBadge";
const fragment = graphql`
fragment CompliancePageAccessListItemFragment on TrustCenterAccess {
id
name
email
createdAt
state
profile {
fullName
emailAddress
state
}
activeCount
pendingRequestCount
ndaSignature {
@@ -35,14 +37,15 @@ const toggleAccessStateMutation = graphql`
updateTrustCenterAccess(input: $input) {
trustCenterAccess {
id
email
name
state
hasAcceptedNonDisclosureAgreement
createdAt
updatedAt
pendingRequestCount
activeCount
profile {
fullName
emailAddress
state
}
}
}
}
@@ -59,7 +62,7 @@ export function CompliancePageAccessListItem(props: {
const access = useFragment<CompliancePageAccessListItemFragment$key>(fragment, fragmentRef);
const isActive = access.state === "ACTIVE";
const isActive = access.profile.state === "ACTIVE";
const [toggleAccessState, isToggling] = useMutationWithToasts<CompliancePageAccessListItemUpdateMutation>(
toggleAccessStateMutation,
@@ -78,12 +81,11 @@ export function CompliancePageAccessListItem(props: {
variables: {
input: {
id: access.id,
name: access.name,
state: isActive ? "INACTIVE" : "ACTIVE",
},
},
});
}, [toggleAccessState, access.id, access.name, isActive]);
}, [toggleAccessState, access.id, isActive]);
return (
<>
@@ -92,8 +94,8 @@ export function CompliancePageAccessListItem(props: {
onClick={() => access.canUpdate && isActive && setDialogOpen(true)}
className={`cursor-pointer hover:bg-bg-secondary transition-colors${!isActive ? " opacity-50" : ""}`}
>
<Td className="font-medium">{access.name}</Td>
<Td>{access.email}</Td>
<Td className="font-medium">{access.profile.fullName}</Td>
<Td>{access.profile.emailAddress}</Td>
<Td>{formatDate(access.createdAt)}</Td>
<Td className="text-center">{access.activeCount}</Td>
<Td className="text-center">