Add trust center files
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import { documentTypeLabel } from "/helpers/documents";
|
||||
import { useTranslate } from "@probo/i18n";
|
||||
import { Fragment } from "react";
|
||||
import { DocumentRow } from "/components/DocumentRow";
|
||||
import { TrustCenterFileRow } from "/components/TrustCenterFileRow";
|
||||
import { Rows } from "/components/Rows.tsx";
|
||||
import { RowHeader } from "/components/RowHeader.tsx";
|
||||
|
||||
@@ -21,9 +22,12 @@ export function DocumentsPage({ queryRef }: Props) {
|
||||
);
|
||||
const documents =
|
||||
data.currentTrustCenter?.documents.edges.map((edge) => edge.node) ?? [];
|
||||
const files =
|
||||
data.currentTrustCenter?.trustCenterFiles.edges.map((edge) => edge.node) ?? [];
|
||||
const documentsPerType = groupBy(documents, (document) =>
|
||||
documentTypeLabel(document.documentType, __)
|
||||
);
|
||||
const filesPerCategory = groupBy(files, (file) => file.category);
|
||||
return (
|
||||
<div>
|
||||
<h2 className="font-medium mb-1">{__("Documents")}</h2>
|
||||
@@ -39,6 +43,14 @@ export function DocumentsPage({ queryRef }: Props) {
|
||||
))}
|
||||
</Fragment>
|
||||
))}
|
||||
{objectEntries(filesPerCategory).map(([category, files]) => (
|
||||
<Fragment key={category}>
|
||||
<RowHeader>{category}</RowHeader>
|
||||
{files.map((file) => (
|
||||
<TrustCenterFileRow key={file.id} file={file} />
|
||||
))}
|
||||
</Fragment>
|
||||
))}
|
||||
</Rows>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -18,6 +18,7 @@ import { AuditRow } from "/components/AuditRow";
|
||||
import { documentTypeLabel } from "/helpers/documents";
|
||||
import { Fragment } from "react";
|
||||
import { DocumentRow } from "/components/DocumentRow";
|
||||
import { TrustCenterFileRow } from "/components/TrustCenterFileRow";
|
||||
import { VendorRow } from "/components/VendorRow";
|
||||
import { RowHeader } from "/components/RowHeader.tsx";
|
||||
import { Rows } from "/components/Rows.tsx";
|
||||
@@ -52,6 +53,15 @@ const overviewFragment = graphql`
|
||||
}
|
||||
}
|
||||
}
|
||||
trustCenterFiles(first: 5) {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
category
|
||||
...TrustCenterFileRowFragment
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -69,6 +79,7 @@ export function OverviewPage() {
|
||||
<Documents
|
||||
audits={trustCenter.audits.edges}
|
||||
documents={fragment.documents.edges}
|
||||
files={fragment.trustCenterFiles.edges}
|
||||
url={getTrustCenterUrl("documents")}
|
||||
/>
|
||||
<Subprocessors
|
||||
@@ -82,10 +93,12 @@ export function OverviewPage() {
|
||||
|
||||
function Documents({
|
||||
documents,
|
||||
files,
|
||||
audits,
|
||||
url,
|
||||
}: {
|
||||
documents: OverviewPageFragment$data["documents"]["edges"];
|
||||
files: OverviewPageFragment$data["trustCenterFiles"]["edges"];
|
||||
audits: NonNullable<
|
||||
TrustGraphQuery$data["trustCenterBySlug"]
|
||||
>["audits"]["edges"];
|
||||
@@ -96,8 +109,12 @@ function Documents({
|
||||
documents.map((edge) => edge.node),
|
||||
(node) => documentTypeLabel(node.documentType, __)
|
||||
);
|
||||
const filesPerCategory = groupBy(
|
||||
files.map((edge) => edge.node),
|
||||
(node) => node.category
|
||||
);
|
||||
const hasAudits = audits.length > 0;
|
||||
const hasDocuments = hasAudits || documents.length > 0;
|
||||
const hasDocuments = hasAudits || documents.length > 0 || files.length > 0;
|
||||
|
||||
if (!hasDocuments) {
|
||||
return null;
|
||||
@@ -126,6 +143,14 @@ function Documents({
|
||||
))}
|
||||
</Fragment>
|
||||
))}
|
||||
{objectEntries(filesPerCategory).map(([category, files]) => (
|
||||
<Fragment key={category}>
|
||||
<RowHeader>{category}</RowHeader>
|
||||
{files.map((file) => (
|
||||
<TrustCenterFileRow key={file.id} file={file} />
|
||||
))}
|
||||
</Fragment>
|
||||
))}
|
||||
<Link to={url} className="text-sm font-medium flex gap-2 items-center">
|
||||
{__("See all documents")}
|
||||
<IconChevronRight size={16} />
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<7b1972657d83c7bb17b997e287f575d8>>
|
||||
* @generated SignedSource<<cde79d7c929ba1be8e0d033c90e7eeb7>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -32,6 +32,15 @@ export type OverviewPageFragment$data = {
|
||||
};
|
||||
}>;
|
||||
};
|
||||
readonly trustCenterFiles: {
|
||||
readonly edges: ReadonlyArray<{
|
||||
readonly node: {
|
||||
readonly category: string;
|
||||
readonly id: string;
|
||||
readonly " $fragmentSpreads": FragmentRefs<"TrustCenterFileRowFragment">;
|
||||
};
|
||||
}>;
|
||||
};
|
||||
readonly vendors: {
|
||||
readonly edges: ReadonlyArray<{
|
||||
readonly node: {
|
||||
@@ -55,7 +64,14 @@ var v0 = {
|
||||
"kind": "ScalarField",
|
||||
"name": "id",
|
||||
"storageKey": null
|
||||
};
|
||||
},
|
||||
v1 = [
|
||||
{
|
||||
"kind": "Literal",
|
||||
"name": "first",
|
||||
"value": 5
|
||||
}
|
||||
];
|
||||
return {
|
||||
"argumentDefinitions": [],
|
||||
"kind": "Fragment",
|
||||
@@ -177,13 +193,7 @@ return {
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": [
|
||||
{
|
||||
"kind": "Literal",
|
||||
"name": "first",
|
||||
"value": 5
|
||||
}
|
||||
],
|
||||
"args": (v1/*: any*/),
|
||||
"concreteType": "DocumentConnection",
|
||||
"kind": "LinkedField",
|
||||
"name": "documents",
|
||||
@@ -226,6 +236,52 @@ return {
|
||||
}
|
||||
],
|
||||
"storageKey": "documents(first:5)"
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v1/*: any*/),
|
||||
"concreteType": "TrustCenterFileConnection",
|
||||
"kind": "LinkedField",
|
||||
"name": "trustCenterFiles",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "TrustCenterFileEdge",
|
||||
"kind": "LinkedField",
|
||||
"name": "edges",
|
||||
"plural": true,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"concreteType": "TrustCenterFile",
|
||||
"kind": "LinkedField",
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v0/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "category",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"args": null,
|
||||
"kind": "FragmentSpread",
|
||||
"name": "TrustCenterFileRowFragment"
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": "trustCenterFiles(first:5)"
|
||||
}
|
||||
],
|
||||
"type": "TrustCenter",
|
||||
@@ -233,6 +289,6 @@ return {
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "0bda7993ef3be4cfe86083658fc77813";
|
||||
(node as any).hash = "0f4e9ac02d068ba971bb1f5be5fdaccf";
|
||||
|
||||
export default node;
|
||||
|
||||
Reference in New Issue
Block a user