Add overview page

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-01-28 13:46:10 +04:00
parent 3d25343508
commit 12913fb65e
10 changed files with 1146 additions and 0 deletions

View File

@@ -0,0 +1,113 @@
/**
* @generated SignedSource<<f34032526d9b51e3b675aad1041d3796>>
* @lightSyntaxTransform
* @nogrep
*/
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
import { ReaderFragment } from 'relay-runtime';
import { FragmentRefs } from "relay-runtime";
export type CompliancePageNDASectionFragment$data = {
readonly compliancePage: {
readonly canDeleteNDA: boolean;
readonly canUpdate: boolean;
readonly canUploadNDA: boolean;
readonly id: string;
readonly ndaFileName: string | null | undefined;
readonly ndaFileUrl: string | null | undefined;
} | null | undefined;
readonly " $fragmentType": "CompliancePageNDASectionFragment";
};
export type CompliancePageNDASectionFragment$key = {
readonly " $data"?: CompliancePageNDASectionFragment$data;
readonly " $fragmentSpreads": FragmentRefs<"CompliancePageNDASectionFragment">;
};
const node: ReaderFragment = {
"argumentDefinitions": [],
"kind": "Fragment",
"metadata": null,
"name": "CompliancePageNDASectionFragment",
"selections": [
{
"alias": "compliancePage",
"args": null,
"concreteType": "TrustCenter",
"kind": "LinkedField",
"name": "trustCenter",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "id",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "ndaFileName",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "ndaFileUrl",
"storageKey": null
},
{
"alias": "canUpdate",
"args": [
{
"kind": "Literal",
"name": "action",
"value": "core:trust-center:update"
}
],
"kind": "ScalarField",
"name": "permission",
"storageKey": "permission(action:\"core:trust-center:update\")"
},
{
"alias": "canUploadNDA",
"args": [
{
"kind": "Literal",
"name": "action",
"value": "core:trust-center:upload-nda"
}
],
"kind": "ScalarField",
"name": "permission",
"storageKey": "permission(action:\"core:trust-center:upload-nda\")"
},
{
"alias": "canDeleteNDA",
"args": [
{
"kind": "Literal",
"name": "action",
"value": "core:trust-center:delete-nda"
}
],
"kind": "ScalarField",
"name": "permission",
"storageKey": "permission(action:\"core:trust-center:delete-nda\")"
}
],
"storageKey": null
}
],
"type": "Organization",
"abstractKey": null
};
(node as any).hash = "3a55696877cb2d258edf0b9ed615de91";
export default node;

View File

@@ -0,0 +1,313 @@
/**
* @generated SignedSource<<18bb7ea1b507c374c33d9f4f7a56db2d>>
* @lightSyntaxTransform
* @nogrep
*/
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
import { ConcreteRequest } from 'relay-runtime';
import { FragmentRefs } from "relay-runtime";
export type CompliancePageOverviewPageQuery$variables = {
organizationId: string;
};
export type CompliancePageOverviewPageQuery$data = {
readonly organization: {
readonly compliancePage?: {
readonly canGetNDA: boolean;
} | null | undefined;
readonly " $fragmentSpreads": FragmentRefs<"CompliancePageNDASectionFragment" | "CompliancePageSlackSectionFragment" | "CompliancePageStatusSectionFragment">;
};
};
export type CompliancePageOverviewPageQuery = {
response: CompliancePageOverviewPageQuery$data;
variables: CompliancePageOverviewPageQuery$variables;
};
const node: ConcreteRequest = (function(){
var v0 = [
{
"defaultValue": null,
"kind": "LocalArgument",
"name": "organizationId"
}
],
v1 = [
{
"kind": "Variable",
"name": "id",
"variableName": "organizationId"
}
],
v2 = {
"alias": "canGetNDA",
"args": [
{
"kind": "Literal",
"name": "action",
"value": "core:trust-center:get-nda"
}
],
"kind": "ScalarField",
"name": "permission",
"storageKey": "permission(action:\"core:trust-center:get-nda\")"
},
v3 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "id",
"storageKey": null
};
return {
"fragment": {
"argumentDefinitions": (v0/*: any*/),
"kind": "Fragment",
"metadata": null,
"name": "CompliancePageOverviewPageQuery",
"selections": [
{
"alias": "organization",
"args": (v1/*: any*/),
"concreteType": null,
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
{
"kind": "InlineFragment",
"selections": [
{
"alias": "compliancePage",
"args": null,
"concreteType": "TrustCenter",
"kind": "LinkedField",
"name": "trustCenter",
"plural": false,
"selections": [
(v2/*: any*/)
],
"storageKey": null
}
],
"type": "Organization",
"abstractKey": null
},
{
"args": null,
"kind": "FragmentSpread",
"name": "CompliancePageStatusSectionFragment"
},
{
"args": null,
"kind": "FragmentSpread",
"name": "CompliancePageNDASectionFragment"
},
{
"args": null,
"kind": "FragmentSpread",
"name": "CompliancePageSlackSectionFragment"
}
],
"storageKey": null
}
],
"type": "Query",
"abstractKey": null
},
"kind": "Request",
"operation": {
"argumentDefinitions": (v0/*: any*/),
"kind": "Operation",
"name": "CompliancePageOverviewPageQuery",
"selections": [
{
"alias": "organization",
"args": (v1/*: any*/),
"concreteType": null,
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "__typename",
"storageKey": null
},
{
"kind": "InlineFragment",
"selections": [
{
"alias": "compliancePage",
"args": null,
"concreteType": "TrustCenter",
"kind": "LinkedField",
"name": "trustCenter",
"plural": false,
"selections": [
(v2/*: any*/),
(v3/*: any*/),
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "active",
"storageKey": null
},
{
"alias": "canUpdate",
"args": [
{
"kind": "Literal",
"name": "action",
"value": "core:trust-center:update"
}
],
"kind": "ScalarField",
"name": "permission",
"storageKey": "permission(action:\"core:trust-center:update\")"
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "ndaFileName",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "ndaFileUrl",
"storageKey": null
},
{
"alias": "canUploadNDA",
"args": [
{
"kind": "Literal",
"name": "action",
"value": "core:trust-center:upload-nda"
}
],
"kind": "ScalarField",
"name": "permission",
"storageKey": "permission(action:\"core:trust-center:upload-nda\")"
},
{
"alias": "canDeleteNDA",
"args": [
{
"kind": "Literal",
"name": "action",
"value": "core:trust-center:delete-nda"
}
],
"kind": "ScalarField",
"name": "permission",
"storageKey": "permission(action:\"core:trust-center:delete-nda\")"
}
],
"storageKey": null
},
{
"alias": null,
"args": null,
"concreteType": "CustomDomain",
"kind": "LinkedField",
"name": "customDomain",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "domain",
"storageKey": null
},
(v3/*: any*/)
],
"storageKey": null
},
{
"alias": null,
"args": [
{
"kind": "Literal",
"name": "first",
"value": 100
}
],
"concreteType": "SlackConnectionConnection",
"kind": "LinkedField",
"name": "slackConnections",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "SlackConnectionEdge",
"kind": "LinkedField",
"name": "edges",
"plural": true,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "SlackConnection",
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
(v3/*: any*/),
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "channel",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "createdAt",
"storageKey": null
}
],
"storageKey": null
}
],
"storageKey": null
}
],
"storageKey": "slackConnections(first:100)"
}
],
"type": "Organization",
"abstractKey": null
},
(v3/*: any*/)
],
"storageKey": null
}
]
},
"params": {
"cacheID": "0041132d3ac46a3193d9acbd6f27bdf5",
"id": null,
"metadata": {},
"name": "CompliancePageOverviewPageQuery",
"operationKind": "query",
"text": "query CompliancePageOverviewPageQuery(\n $organizationId: ID!\n) {\n organization: node(id: $organizationId) {\n __typename\n ... on Organization {\n compliancePage: trustCenter {\n canGetNDA: permission(action: \"core:trust-center:get-nda\")\n id\n }\n }\n ...CompliancePageStatusSectionFragment\n ...CompliancePageNDASectionFragment\n ...CompliancePageSlackSectionFragment\n id\n }\n}\n\nfragment CompliancePageNDASectionFragment on Organization {\n compliancePage: trustCenter {\n id\n ndaFileName\n ndaFileUrl\n canUpdate: permission(action: \"core:trust-center:update\")\n canUploadNDA: permission(action: \"core:trust-center:upload-nda\")\n canDeleteNDA: permission(action: \"core:trust-center:delete-nda\")\n }\n}\n\nfragment CompliancePageSlackSectionFragment on Organization {\n compliancePage: trustCenter {\n canUpdate: permission(action: \"core:trust-center:update\")\n id\n }\n slackConnections(first: 100) {\n edges {\n node {\n id\n channel\n createdAt\n }\n }\n }\n}\n\nfragment CompliancePageStatusSectionFragment on Organization {\n customDomain {\n domain\n id\n }\n compliancePage: trustCenter {\n id\n active\n canUpdate: permission(action: \"core:trust-center:update\")\n }\n}\n"
}
};
})();
(node as any).hash = "689133b7f1c380266e6f15a60c527c91";
export default node;

View File

@@ -0,0 +1,130 @@
/**
* @generated SignedSource<<b25caa52d25189aca17270cef3c0303e>>
* @lightSyntaxTransform
* @nogrep
*/
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
import { ReaderFragment } from 'relay-runtime';
import { FragmentRefs } from "relay-runtime";
export type CompliancePageSlackSectionFragment$data = {
readonly compliancePage: {
readonly canUpdate: boolean;
} | null | undefined;
readonly slackConnections: {
readonly edges: ReadonlyArray<{
readonly node: {
readonly channel: string | null | undefined;
readonly createdAt: string;
readonly id: string;
};
}>;
};
readonly " $fragmentType": "CompliancePageSlackSectionFragment";
};
export type CompliancePageSlackSectionFragment$key = {
readonly " $data"?: CompliancePageSlackSectionFragment$data;
readonly " $fragmentSpreads": FragmentRefs<"CompliancePageSlackSectionFragment">;
};
const node: ReaderFragment = {
"argumentDefinitions": [],
"kind": "Fragment",
"metadata": null,
"name": "CompliancePageSlackSectionFragment",
"selections": [
{
"alias": "compliancePage",
"args": null,
"concreteType": "TrustCenter",
"kind": "LinkedField",
"name": "trustCenter",
"plural": false,
"selections": [
{
"alias": "canUpdate",
"args": [
{
"kind": "Literal",
"name": "action",
"value": "core:trust-center:update"
}
],
"kind": "ScalarField",
"name": "permission",
"storageKey": "permission(action:\"core:trust-center:update\")"
}
],
"storageKey": null
},
{
"alias": null,
"args": [
{
"kind": "Literal",
"name": "first",
"value": 100
}
],
"concreteType": "SlackConnectionConnection",
"kind": "LinkedField",
"name": "slackConnections",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "SlackConnectionEdge",
"kind": "LinkedField",
"name": "edges",
"plural": true,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "SlackConnection",
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "id",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "channel",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "createdAt",
"storageKey": null
}
],
"storageKey": null
}
],
"storageKey": null
}
],
"storageKey": "slackConnections(first:100)"
}
],
"type": "Organization",
"abstractKey": null
};
(node as any).hash = "48af0130884a7e0070e64ead2afe5046";
export default node;

View File

@@ -0,0 +1,98 @@
/**
* @generated SignedSource<<a2a78b5520cedc03e02d257a902e5ee6>>
* @lightSyntaxTransform
* @nogrep
*/
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
import { ReaderFragment } from 'relay-runtime';
import { FragmentRefs } from "relay-runtime";
export type CompliancePageStatusSectionFragment$data = {
readonly compliancePage: {
readonly active: boolean;
readonly canUpdate: boolean;
readonly id: string;
} | null | undefined;
readonly customDomain: {
readonly domain: string;
} | null | undefined;
readonly " $fragmentType": "CompliancePageStatusSectionFragment";
};
export type CompliancePageStatusSectionFragment$key = {
readonly " $data"?: CompliancePageStatusSectionFragment$data;
readonly " $fragmentSpreads": FragmentRefs<"CompliancePageStatusSectionFragment">;
};
const node: ReaderFragment = {
"argumentDefinitions": [],
"kind": "Fragment",
"metadata": null,
"name": "CompliancePageStatusSectionFragment",
"selections": [
{
"alias": null,
"args": null,
"concreteType": "CustomDomain",
"kind": "LinkedField",
"name": "customDomain",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "domain",
"storageKey": null
}
],
"storageKey": null
},
{
"alias": "compliancePage",
"args": null,
"concreteType": "TrustCenter",
"kind": "LinkedField",
"name": "trustCenter",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "id",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "active",
"storageKey": null
},
{
"alias": "canUpdate",
"args": [
{
"kind": "Literal",
"name": "action",
"value": "core:trust-center:update"
}
],
"kind": "ScalarField",
"name": "permission",
"storageKey": "permission(action:\"core:trust-center:update\")"
}
],
"storageKey": null
}
],
"type": "Organization",
"abstractKey": null
};
(node as any).hash = "07af542e3be959de0daf6fcb165830b0";
export default node;

View File

@@ -0,0 +1,44 @@
import { type PreloadedQuery, usePreloadedQuery } from "react-relay";
import { graphql } from "relay-runtime";
import type { CompliancePageOverviewPageQuery } from "#/__generated__/core/CompliancePageOverviewPageQuery.graphql";
import { CompliancePageNDASection } from "./_components/CompliancePageNDASection";
import { CompliancePageSlackSection } from "./_components/CompliancePageSlackSection";
import { CompliancePageStatusSection } from "./_components/CompliancePageStatusSection";
export const compliancePageOverviewPageQuery = graphql`
query CompliancePageOverviewPageQuery($organizationId: ID!) {
organization: node(id: $organizationId) {
... on Organization {
compliancePage: trustCenter {
canGetNDA: permission(action: "core:trust-center:get-nda")
}
}
...CompliancePageStatusSectionFragment
...CompliancePageNDASectionFragment
...CompliancePageSlackSectionFragment
}
}
`;
export function CompliancePageOverviewPage(props: { queryRef: PreloadedQuery<CompliancePageOverviewPageQuery> }) {
const { queryRef } = props;
const { organization } = usePreloadedQuery<CompliancePageOverviewPageQuery>(
compliancePageOverviewPageQuery,
queryRef,
);
return (
<div className="space-y-6">
<CompliancePageStatusSection fragmentRef={organization} />
{organization.compliancePage?.canGetNDA && (
<CompliancePageNDASection fragmentRef={organization} />
)}
<CompliancePageSlackSection fragmentRef={organization} />
</div>
);
}

View File

@@ -0,0 +1,32 @@
import { useEffect } from "react";
import { useQueryLoader } from "react-relay";
import type { CompliancePageOverviewPageQuery } from "#/__generated__/core/CompliancePageOverviewPageQuery.graphql";
import { LinkCardSkeleton } from "#/components/skeletons/LinkCardSkeleton";
import { useOrganizationId } from "#/hooks/useOrganizationId";
import { CoreRelayProvider } from "#/providers/CoreRelayProvider";
import { CompliancePageOverviewPage, compliancePageOverviewPageQuery } from "./CompliancePageOverviewPage";
function CompliancePageOverviewPageQueryLoader() {
const organizationId = useOrganizationId();
const [queryRef, loadQuery] = useQueryLoader<CompliancePageOverviewPageQuery>(compliancePageOverviewPageQuery);
useEffect(() => {
if (!queryRef) {
loadQuery({ organizationId });
}
});
if (!queryRef) return <LinkCardSkeleton />;
return <CompliancePageOverviewPage queryRef={queryRef} />;
}
export default function CompliancePageOverviewPageLoader() {
return (
<CoreRelayProvider>
<CompliancePageOverviewPageQueryLoader />
</CoreRelayProvider>
);
}

View File

@@ -0,0 +1,175 @@
import { useTranslate } from "@probo/i18n";
import { Button, Card, Dropzone, IconTrashCan, Spinner, useToast } from "@probo/ui";
import { useFragment } from "react-relay";
import { graphql } from "relay-runtime";
import type { CompliancePageNDASectionFragment$key } from "#/__generated__/core/CompliancePageNDASectionFragment.graphql";
import { useDeleteTrustCenterNDAMutation, useUploadTrustCenterNDAMutation } from "#/hooks/graph/TrustCenterGraph";
const fragment = graphql`
fragment CompliancePageNDASectionFragment on Organization {
compliancePage: trustCenter {
id
ndaFileName
ndaFileUrl
canUpdate: permission(action: "core:trust-center:update")
canUploadNDA: permission(action: "core:trust-center:upload-nda")
canDeleteNDA: permission(action: "core:trust-center:delete-nda")
}
}
`;
export function CompliancePageNDASection(props: { fragmentRef: CompliancePageNDASectionFragment$key }) {
const { fragmentRef } = props;
const { __ } = useTranslate();
const { toast } = useToast();
const organization = useFragment<CompliancePageNDASectionFragment$key>(fragment, fragmentRef);
const [uploadNDA, isUploadingNDA] = useUploadTrustCenterNDAMutation();
const [deleteNDA, isDeletingNDA] = useDeleteTrustCenterNDAMutation();
const handleNDAUpload = async (files: File[]) => {
if (!organization.compliancePage?.id) {
toast({
title: __("Error"),
description: __("Trust center not found"),
variant: "error",
});
return;
}
if (files.length === 0) return;
const file = files[0];
await uploadNDA({
variables: {
input: {
trustCenterId: organization.compliancePage.id,
fileName: file.name,
file: null,
},
},
uploadables: {
"input.file": file,
},
});
};
const handleNDADelete = async () => {
if (!organization.compliancePage?.id) {
toast({
title: __("Error"),
description: __("Trust center not found"),
variant: "error",
});
return;
}
if (!confirm(__("Are you sure you want to delete the NDA file?"))) {
return;
}
await deleteNDA({
variables: {
input: {
trustCenterId: organization.compliancePage.id,
},
},
});
};
return (
<div className="space-y-4">
<div className="flex items-center justify-between">
<h2 className="text-base font-medium">
{__("Non-Disclosure Agreement")}
</h2>
{(isUploadingNDA || isDeletingNDA) && <Spinner />}
</div>
<Card padded className="space-y-4">
<div className="space-y-2">
{!organization.compliancePage?.ndaFileName
&& organization.compliancePage?.canUploadNDA
? (
<p className="text-sm text-txt-tertiary">
{__(
"Upload a Non-Disclosure Agreement that visitors must accept before accessing your trust center",
)}
</p>
)
: (
<></>
)}
{organization.compliancePage?.ndaFileName
? (
<div className="space-y-3">
<div className="flex items-center justify-between">
<div className="space-y-1">
<div className="flex items-center gap-2">
<p className="text-sm font-medium">
{organization.compliancePage.ndaFileName
|| __("Non-Disclosure Agreement")}
</p>
</div>
<p className="text-xs text-txt-tertiary">
{__(
"Visitors will need to accept this NDA before accessing your trust center",
)}
</p>
</div>
<div className="flex items-center gap-2">
<Button
type="button"
variant="secondary"
onClick={() => {
if (organization.compliancePage?.ndaFileUrl) {
window.open(
organization.compliancePage.ndaFileUrl,
"_blank",
);
}
}}
>
{__("Download PDF")}
</Button>
{organization.compliancePage?.canDeleteNDA && (
<Button
variant="quaternary"
icon={IconTrashCan}
onClick={() => void handleNDADelete()}
disabled={isDeletingNDA}
/>
)}
</div>
</div>
</div>
)
: (
<>
{organization.compliancePage?.canUpdate
? (
<Dropzone
description={__("Upload PDF files up to 10MB")}
isUploading={isUploadingNDA}
onDrop={files => void handleNDAUpload(files)}
accept={{
"application/pdf": [".pdf"],
}}
maxSize={10}
/>
)
: (
<p className="text-sm text-txt-tertiary">
{__("No NDA file uploaded")}
</p>
)}
</>
)}
</div>
</Card>
</div>
);
}

View File

@@ -0,0 +1,102 @@
import { sprintf } from "@probo/helpers";
import { useTranslate } from "@probo/i18n";
import { Badge, Button, Card } from "@probo/ui";
import { useFragment } from "react-relay";
import { graphql } from "relay-runtime";
import type { CompliancePageSlackSectionFragment$key } from "#/__generated__/core/CompliancePageSlackSectionFragment.graphql";
import { useOrganizationId } from "#/hooks/useOrganizationId";
const fragment = graphql`
fragment CompliancePageSlackSectionFragment on Organization {
compliancePage: trustCenter {
canUpdate: permission(action: "core:trust-center:update")
}
slackConnections(first: 100) {
edges {
node {
id
channel
createdAt
}
}
}
}
`;
export function CompliancePageSlackSection(props: { fragmentRef: CompliancePageSlackSectionFragment$key }) {
const { fragmentRef } = props;
const organizationId = useOrganizationId();
const { __, dateTimeFormat } = useTranslate();
const organization = useFragment<CompliancePageSlackSectionFragment$key>(fragment, fragmentRef);
return (
<div className="space-y-4">
<h2 className="text-base font-medium">{__("Integrations")}</h2>
<Card padded>
<div className="space-y-2">
{organization.slackConnections.edges.map(({ node: slackConnection }) => (
<Card
key={slackConnection.id}
padded
className="flex items-center gap-3"
>
<div>
<img src={`/${slackConnection.id.toLowerCase()}.png`} alt="" />
</div>
<div className="mr-auto">
<h3 className="text-base font-semibold">Slack</h3>
<p className="text-sm text-txt-tertiary">
{slackConnection.createdAt
? (
<>
{sprintf(
__("Connected on %s"),
dateTimeFormat(slackConnection.createdAt),
)}
{slackConnection.channel && (
<>
{" • "}
{sprintf(__("Channel: %s"), slackConnection.channel)}
</>
)}
</>
)
: __("Manage your trust center access with slack")}
</p>
</div>
{slackConnection.createdAt
? (
<div>
<Badge variant="success" size="md">
{__("Connected")}
</Badge>
</div>
)
: (
organization.compliancePage?.canUpdate && (
<Button variant="secondary" asChild>
<a href={getSlackConnectionUrl(organizationId)}>{__("Connect")}</a>
</Button>
)
)}
</Card>
))}
</div>
</Card>
</div>
);
}
function getSlackConnectionUrl(organizationId: string): string {
const baseUrl = import.meta.env.VITE_API_URL || window.location.origin;
const url = new URL("/api/console/v1/connectors/initiate", baseUrl);
url.searchParams.append("organization_id", organizationId);
url.searchParams.append("provider", "SLACK");
const redirectUrl = `/organizations/${organizationId}/compliance-page`;
url.searchParams.append("continue", redirectUrl);
const finalUrl = url.toString();
return finalUrl;
};

View File

@@ -0,0 +1,131 @@
import { useTranslate } from "@probo/i18n";
import { Button, Card, Checkbox, Spinner, useToast } from "@probo/ui";
import { useFragment } from "react-relay";
import { graphql } from "relay-runtime";
import type { CompliancePageStatusSectionFragment$key } from "#/__generated__/core/CompliancePageStatusSectionFragment.graphql";
import { useUpdateTrustCenterMutation } from "#/hooks/graph/TrustCenterGraph";
const fragment = graphql`
fragment CompliancePageStatusSectionFragment on Organization {
customDomain {
domain
}
compliancePage: trustCenter {
id
active
canUpdate: permission(action: "core:trust-center:update")
}
}
`;
export function CompliancePageStatusSection(props: {
fragmentRef: CompliancePageStatusSectionFragment$key;
}) {
const { fragmentRef } = props;
const { __ } = useTranslate();
const { toast } = useToast();
const organization = useFragment<CompliancePageStatusSectionFragment$key>(
fragment,
fragmentRef,
);
const compliancePageUrl = organization.compliancePage?.id
? organization.customDomain?.domain
? `https://${organization.customDomain.domain}`
: `${window.location.origin}/trust/${organization.compliancePage.id}`
: null;
const [updateCompliancePage, isUpdating] = useUpdateTrustCenterMutation();
const handleToggleActive = async (active: boolean) => {
if (!organization.compliancePage?.id) {
toast({
title: __("Error"),
description: __("Trust center not found"),
variant: "error",
});
return;
}
await updateCompliancePage({
variables: {
input: {
trustCenterId: organization.compliancePage.id,
active,
},
},
});
};
return (
<div className="space-y-4">
<div className="flex items-center justify-between">
<h2 className="text-base font-medium">{__("Trust Center Status")}</h2>
{isUpdating && <Spinner />}
</div>
<Card padded className="space-y-4">
<div className="flex items-center justify-between">
<div className="space-y-1">
<h3 className="font-medium">{__("Activate Compliance Page")}</h3>
<p className="text-sm text-txt-tertiary">
{__(
"Make your Compliance Page publicly accessible to build customer confidence",
)}
</p>
</div>
<Checkbox
checked={!!organization.compliancePage?.active}
onChange={checked => void handleToggleActive(checked)}
disabled={!organization.compliancePage?.canUpdate}
/>
</div>
{organization.compliancePage?.active && compliancePageUrl && (
<div className="mt-4 p-4 bg-accent-light rounded-lg border border-accent">
<div className="flex items-center justify-between">
<div>
<h4 className="font-medium text-accent-dark">
{__("Your Compliance Page is live!")}
</h4>
<p className="text-sm text-accent-dark mt-1">
{__("Your customers can now access your compliance page at:")}
</p>
<a
href={compliancePageUrl}
target="_blank"
rel="noopener noreferrer"
className="text-sm font-mono text-accent underline hover:no-underline"
>
{compliancePageUrl}
</a>
</div>
<Button
variant="secondary"
onClick={() =>
window.open(compliancePageUrl, "_blank", "noopener,noreferrer")}
>
{__("View")}
</Button>
</div>
</div>
)}
{!organization.compliancePage?.active && (
<div className="mt-4 p-4 bg-tertiary rounded-lg border border-border-solid">
<h4 className="font-medium text-txt-secondary">
{__("Compliance Page is inactive")}
</h4>
<p className="text-sm text-txt-tertiary mt-1">
{__(
"Your Compliance Page is currently not accessible to the public. Enable it to start sharing your compliance status.",
)}
</p>
</div>
)}
</Card>
</div>
);
}

View File

@@ -1,5 +1,6 @@
import { lazy } from "@probo/react-lazy";
import { LinkCardSkeleton } from "#/components/skeletons/LinkCardSkeleton";
import { PageSkeleton } from "#/components/skeletons/PageSkeleton";
export const compliancePageRoutes = [
@@ -7,5 +8,12 @@ export const compliancePageRoutes = [
path: "compliance-page",
Fallback: PageSkeleton,
Component: lazy(() => import("#/pages/organizations/compliance-page/CompliancePageLayoutLoader")),
children: [
{
index: true,
Fallback: LinkCardSkeleton,
Component: lazy(() => import("#/pages/organizations/compliance-page/overview/CompliancePageOverviewPageLoader")),
},
],
},
];