From 60d12385343c7fd4a98f397950971578cfd8a515 Mon Sep 17 00:00:00 2001 From: Sacha Al Himdani Date: Wed, 1 Oct 2025 09:37:22 +0200 Subject: [PATCH] Remove unused trust center code Signed-off-by: Sacha Al Himdani --- .../src/hooks/useTrustCenterQueries.ts | 415 ------------------ .../src/pages/TrustCenterAccessPage.tsx | 142 ------ apps/console/src/routes.tsx | 12 - .../trust/components/NDAAcceptanceDialog.tsx | 187 -------- .../PublicTrustCenterAccessRequestDialog.tsx | 121 ----- .../components/PublicTrustCenterAudits.tsx | 148 ------- .../components/PublicTrustCenterDocuments.tsx | 137 ------ .../components/PublicTrustCenterVendors.tsx | 122 ----- .../src/trust/pages/PublicTrustCenterPage.tsx | 115 ----- 9 files changed, 1399 deletions(-) delete mode 100644 apps/console/src/hooks/useTrustCenterQueries.ts delete mode 100644 apps/console/src/pages/TrustCenterAccessPage.tsx delete mode 100644 apps/console/src/trust/components/NDAAcceptanceDialog.tsx delete mode 100644 apps/console/src/trust/components/PublicTrustCenterAccessRequestDialog.tsx delete mode 100644 apps/console/src/trust/components/PublicTrustCenterAudits.tsx delete mode 100644 apps/console/src/trust/components/PublicTrustCenterDocuments.tsx delete mode 100644 apps/console/src/trust/components/PublicTrustCenterVendors.tsx delete mode 100644 apps/console/src/trust/pages/PublicTrustCenterPage.tsx diff --git a/apps/console/src/hooks/useTrustCenterQueries.ts b/apps/console/src/hooks/useTrustCenterQueries.ts deleted file mode 100644 index ae72d3730..000000000 --- a/apps/console/src/hooks/useTrustCenterQueries.ts +++ /dev/null @@ -1,415 +0,0 @@ -import { useQuery, useMutation } from "@tanstack/react-query"; -import { GraphQLError } from "graphql"; -import { buildEndpoint } from "/providers/RelayProviders"; -import { type CountryCode } from "@probo/helpers"; - -export interface TrustCenterDocument { - id: string; - title: string; - documentType: string; -} - -export interface TrustCenterAudit { - id: string; - framework: { - name: string; - }; - report: { - id: string; - filename: string; - } | null; -} - -export interface TrustCenterVendor { - id: string; - name: string; - category: string; - privacyPolicyUrl?: string | null; - websiteUrl?: string | null; - countries: CountryCode[]; -} - -interface TrustCenterQueryData { - trustCenterBySlug: { - id: string; - active: boolean; - slug: string; - isUserAuthenticated: boolean; - hasAcceptedNonDisclosureAgreement: boolean; - ndaFileName: string | null; - ndaFileUrl: string | null; - organization: { - id: string; - name: string; - logoUrl: string | null; - }; - documents: { - edges: Array<{ - node: TrustCenterDocument; - }>; - }; - audits: { - edges: Array<{ - node: TrustCenterAudit; - }>; - }; - vendors: { - edges: Array<{ - node: TrustCenterVendor; - }>; - }; - } | null; -} - -interface GraphQLResponse { - data?: T; - errors?: GraphQLError[]; -} - -interface ExportDocumentPDFData { - exportDocumentPDF: { - data: string; - }; -} - -interface ExportReportPDFData { - exportReportPDF: { - data: string; - }; -} - -interface CreateTrustCenterAccessData { - createTrustCenterAccess: { - trustCenterAccess: { - id: string; - email: string; - name: string; - }; - }; -} - -interface TrustCenterQueryVariables { - slug: string; -} - -interface ExportDocumentPDFVariables { - input: { - documentId: string; - }; -} - -interface CreateTrustCenterAccessVariables { - input: { - trustCenterId: string; - email: string; - name: string; - }; -} - -interface AcceptNonDisclosureAgreementData { - acceptNonDisclosureAgreement: { - success: boolean; - }; -} - -interface AcceptNonDisclosureAgreementVariables { - input: { - trustCenterId: string; - }; -} - -interface ExportReportPDFVariables { - input: { - reportId: string; - }; -} - -type GraphQLVariables = TrustCenterQueryVariables | ExportDocumentPDFVariables | ExportReportPDFVariables | CreateTrustCenterAccessVariables | AcceptNonDisclosureAgreementVariables | Record; - -async function trustCenterGraphQLRequest( - operationName: string, - query: string, - variables: GraphQLVariables = {} -): Promise> { - const response = await fetch(buildEndpoint("/api/trust/v1/graphql"), { - method: "POST", - credentials: "include", - headers: { - Accept: "application/graphql-response+json; charset=utf-8, application/json; charset=utf-8", - "Content-Type": "application/json", - }, - body: JSON.stringify({ - operationName, - query, - variables, - }), - }); - - if (!response.ok) { - throw new Error(`HTTP error! status: ${response.status}`); - } - - const result = await response.json(); - return result; -} - -function isCriticalError(error: GraphQLError): boolean { - const message = error.message?.toLowerCase() || ''; - - if ( - message.includes('access denied') || - message.includes('authentication required') || - message.includes('user has not accepted nda') || - message.includes('no nda file found') - ) { - return false; - } - - return true; -} - -const TRUST_CENTER_QUERY = ` - query PublicTrustCenterPageQuery($slug: String!) { - trustCenterBySlug(slug: $slug) { - id - active - slug - isUserAuthenticated - hasAcceptedNonDisclosureAgreement - ndaFileName - ndaFileUrl - organization { - id - name - logoUrl - description - websiteUrl - email - headquarterAddress - } - documents(first: 100) { - edges { - node { - id - title - documentType - } - } - } - audits(first: 100) { - edges { - node { - id - framework { - name - } - report { - id - filename - } - } - } - } - vendors(first: 100) { - edges { - node { - id - name - category - websiteUrl - privacyPolicyUrl - countries - } - } - } - references(first: 100) { - edges { - node { - id - name - description - websiteUrl - logoUrl - } - } - } - } - } -`; - -const EXPORT_DOCUMENT_PDF_MUTATION = ` - mutation PublicTrustCenterDocumentsExportPDFMutation( - $input: ExportDocumentPDFInput! - ) { - exportDocumentPDF(input: $input) { - data - } - } -`; - -const EXPORT_REPORT_PDF_MUTATION = ` - mutation PublicTrustCenterAuditsExportReportPDFMutation( - $input: ExportReportPDFInput! - ) { - exportReportPDF(input: $input) { - data - } - } -`; - -const CREATE_TRUST_CENTER_ACCESS_MUTATION = ` - mutation PublicTrustCenterAccessRequestDialogMutation( - $input: CreateTrustCenterAccessInput! - ) { - createTrustCenterAccess(input: $input) { - trustCenterAccess { - id - email - name - } - } - } -`; - -const ACCEPT_NDA_MUTATION = ` - mutation AcceptNonDisclosureAgreementMutation( - $input: AcceptNonDisclosureAgreementInput! - ) { - acceptNonDisclosureAgreement(input: $input) { - success - } - } -`; - -export function useTrustCenterQuery(slug: string) { - return useQuery({ - queryKey: ["trust-center", slug], - queryFn: async () => { - const result = await trustCenterGraphQLRequest( - "PublicTrustCenterPageQuery", - TRUST_CENTER_QUERY, - { slug } - ); - - if (result.errors && result.errors.length > 0) { - const criticalErrors = result.errors.filter(isCriticalError); - - if (criticalErrors.length > 0) { - throw new Error( - `GraphQL error: ${criticalErrors.map((e) => e.message).join(", ")}` - ); - } - } - - if (!result.data) { - throw new Error("No data returned from GraphQL query"); - } - - return result.data; - }, - enabled: !!slug, - staleTime: 5 * 60 * 1000, // 5 minutes - retry: (failureCount, error) => { - if (error.message.includes("UNAUTHENTICATED") || error.message.includes("401")) { - return false; - } - return failureCount < 3; - }, - }); -} - -export function useExportDocumentPDF() { - return useMutation({ - mutationFn: async (documentId: string) => { - const result = await trustCenterGraphQLRequest( - "PublicTrustCenterDocumentsExportPDFMutation", - EXPORT_DOCUMENT_PDF_MUTATION, - { input: { documentId } } - ); - - if (result.errors && result.errors.length > 0) { - throw new Error( - `GraphQL error: ${result.errors.map((e) => e.message).join(", ")}` - ); - } - - if (!result.data) { - throw new Error("No data returned from mutation"); - } - - return result.data; - }, - }); -} - -export function useExportReportPDF() { - return useMutation({ - mutationFn: async (reportId: string) => { - const result = await trustCenterGraphQLRequest( - "PublicTrustCenterAuditsExportReportPDFMutation", - EXPORT_REPORT_PDF_MUTATION, - { input: { reportId } } - ); - - if (result.errors && result.errors.length > 0) { - throw new Error( - `GraphQL error: ${result.errors.map((e) => e.message).join(", ")}` - ); - } - - if (!result.data) { - throw new Error("No data returned from mutation"); - } - - return result.data; - }, - }); -} - -export function useCreateTrustCenterAccess() { - return useMutation({ - mutationFn: async (input: { trustCenterId: string; email: string; name: string }) => { - const result = await trustCenterGraphQLRequest( - "PublicTrustCenterAccessRequestDialogMutation", - CREATE_TRUST_CENTER_ACCESS_MUTATION, - { input } - ); - - if (result.errors && result.errors.length > 0) { - throw new Error( - `GraphQL error: ${result.errors.map((e) => e.message).join(", ")}` - ); - } - - if (!result.data) { - throw new Error("No data returned from mutation"); - } - - return result.data; - }, - }); -} - -export function useAcceptNonDisclosureAgreement() { - return useMutation({ - mutationFn: async (input: { trustCenterId: string }) => { - const result = await trustCenterGraphQLRequest( - "AcceptNonDisclosureAgreementMutation", - ACCEPT_NDA_MUTATION, - { input } - ); - - if (result.errors && result.errors.length > 0) { - throw new Error( - `GraphQL error: ${result.errors.map((e) => e.message).join(", ")}` - ); - } - - if (!result.data) { - throw new Error("No data returned from mutation"); - } - - return result.data; - }, - }); -} diff --git a/apps/console/src/pages/TrustCenterAccessPage.tsx b/apps/console/src/pages/TrustCenterAccessPage.tsx deleted file mode 100644 index 5074a2a5c..000000000 --- a/apps/console/src/pages/TrustCenterAccessPage.tsx +++ /dev/null @@ -1,142 +0,0 @@ -import { useTranslate } from "@probo/i18n"; -import { useParams, useNavigate, useSearchParams } from "react-router"; -import { useState, useEffect } from "react"; -import { PageSkeleton } from "/components/skeletons/PageSkeleton"; -import { PageError } from "/components/PageError"; -import { buildEndpoint } from "/providers/RelayProviders"; -import { IconClock, IconWarning } from "@probo/ui"; - -function TokenErrorPage({ error }: { error: string }) { - const { __ } = useTranslate(); - - const isExpiredToken = error.toLowerCase().includes('expired'); - - return ( -
-
-
- {isExpiredToken ? ( -
-
- -
-

- {__("Access Link Expired")} -

-

- {__("This access link has expired. Trust center access links are valid for 7 days for security reasons.")} -

-
- ) : ( -
-
- -
-

- {__("Invalid Access Link")} -

-

- {__("This access link is not valid. It may have been revoked or the link might be incorrect.")} -

-
- )} -
- -
-

{__("What can you do?")}

-
    -
  • - • - {__("Contact the person who sent you this link to request a new access invitation")} -
  • -
  • - • - {__("Check if you received a newer email with an updated access link")} -
  • -
  • - • - {__("Verify that you copied the entire link correctly from the email")} -
  • -
-
-
-
- ); -} - -export default function TrustCenterAccessPage() { - const { __ } = useTranslate(); - const { slug } = useParams<{ slug: string }>(); - const [searchParams] = useSearchParams(); - const token = searchParams.get('token'); - const navigate = useNavigate(); - - const [loading, setLoading] = useState(true); - const [error, setError] = useState(null); - - useEffect(() => { - if (!slug) { - setError(__("Invalid trust center")); - setLoading(false); - return; - } - - if (!token) { - setError(__("Invalid or missing access token")); - setLoading(false); - return; - } - - fetch(buildEndpoint('/api/trust/v1/auth/authenticate'), { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - credentials: 'include', - body: JSON.stringify({ token }), - }) - .then(async response => { - if (!response.ok) { - try { - const errorData = await response.json(); - throw new Error(errorData.message || `HTTP ${response.status}: ${response.statusText}`); - } catch { - throw new Error(`HTTP ${response.status}: ${response.statusText}`); - } - } - return response.json(); - }) - .then(data => { - if (data.success) { - navigate(`/trust/${slug}`); - } else { - setError(data.message || __("Authentication failed")); - setLoading(false); - } - }) - .catch((error) => { - setError(error.message || __("Authentication failed")); - setLoading(false); - }); - }, [slug, token, __, navigate]); - - if (loading) { - return ; - } - - if (error) { - const isTokenError = error.toLowerCase().includes('token') || - error.toLowerCase().includes('expired') || - error.toLowerCase().includes('invalid') || - error.toLowerCase().includes('401') || - error.toLowerCase().includes('unauthorized'); - - if (isTokenError) { - return ; - } - - return ; - } - - return
{__("Redirecting to trust center...")}
; -} diff --git a/apps/console/src/routes.tsx b/apps/console/src/routes.tsx index 9824d5259..2e83a6704 100644 --- a/apps/console/src/routes.tsx +++ b/apps/console/src/routes.tsx @@ -111,18 +111,6 @@ const routes = [ }, ], }, - { - path: "/trust/:slug", - ErrorBoundary: ErrorBoundary, - fallback: PageSkeleton, - Component: lazy(() => import("./trust/pages/PublicTrustCenterPage")), - }, - { - path: "/trust/:slug/access", - ErrorBoundary: ErrorBoundary, - fallback: PageSkeleton, - Component: lazy(() => import("./pages/TrustCenterAccessPage")), - }, { path: "/organizations/:organizationId", Component: MainLayout, diff --git a/apps/console/src/trust/components/NDAAcceptanceDialog.tsx b/apps/console/src/trust/components/NDAAcceptanceDialog.tsx deleted file mode 100644 index 32ee16f36..000000000 --- a/apps/console/src/trust/components/NDAAcceptanceDialog.tsx +++ /dev/null @@ -1,187 +0,0 @@ -import { useState, useEffect } from "react"; -import { - Dialog, - DialogContent, - DialogFooter, - Button, - Checkbox, - IconLock, - IconArrowDown, - useToast, - useDialogRef -} from "@probo/ui"; -import { useTranslate } from "@probo/i18n"; -import { useAcceptNonDisclosureAgreement } from "/hooks/useTrustCenterQueries"; -import { buildEndpoint } from "/providers/RelayProviders"; -import { sprintf } from "@probo/helpers"; - -type Props = { - trustCenterId: string; - organizationName: string; - ndaFileName?: string | null; - ndaFileUrl?: string | null; -}; - -export function NDAAcceptanceDialog({ trustCenterId, organizationName, ndaFileName, ndaFileUrl }: Props) { - const { __ } = useTranslate(); - const { toast } = useToast(); - const [isChecked, setIsChecked] = useState(false); - const dialogRef = useDialogRef(); - const acceptNdaMutation = useAcceptNonDisclosureAgreement(); - - useEffect(() => { - dialogRef.current?.open(); - }, []); - - const handleLogout = async () => { - try { - const response = await fetch(buildEndpoint('/api/trust/v1/auth/logout'), { - method: 'DELETE', - headers: { - 'Content-Type': 'application/json', - }, - credentials: 'include', - }); - - if (!response.ok) { - throw new Error("Logout failed"); - } - - window.location.reload(); - } catch (error) { - toast({ - title: __("Error"), - description: __("Logout failed"), - variant: "error", - }); - } - }; - - const handleAccept = () => { - if (!isChecked) { - toast({ - title: __("Agreement Required"), - description: __("Please check the box to confirm your agreement"), - variant: "error", - }); - return; - } - - acceptNdaMutation.mutate( - { trustCenterId }, - { - onSuccess: () => { - window.location.reload(); - }, - onError: () => { - toast({ - title: __("Error"), - description: __("Failed to accept the Non-Disclosure Agreement"), - variant: "error", - }); - }, - } - ); - }; - - const handleCancel = () => { - handleLogout(); - }; - - return ( - - -
-
-
- -
-

- {__("Non-Disclosure Agreement")} -

-

- {sprintf(__("To access %s's trust center, you must accept the Non-Disclosure Agreement."), organizationName)} -

-
- -
- {ndaFileName && ndaFileUrl ? ( -
-

- {__("Please review and download the Non-Disclosure Agreement:")} -

-
- -
-
- ) : ( - <> -

- {__("By accepting this agreement, you commit to:")} -

-
    -
  • - - {__("Keep confidential information secure")} -
  • -
  • - - {__("Not share or disclose sensitive data")} -
  • -
  • - - {__("Use information only for authorized purposes")} -
  • -
- - )} -
- -
-
- -
- -
-
-
- - - - -
- ); -} diff --git a/apps/console/src/trust/components/PublicTrustCenterAccessRequestDialog.tsx b/apps/console/src/trust/components/PublicTrustCenterAccessRequestDialog.tsx deleted file mode 100644 index c3ebcba00..000000000 --- a/apps/console/src/trust/components/PublicTrustCenterAccessRequestDialog.tsx +++ /dev/null @@ -1,121 +0,0 @@ -import { useState } from "react"; -import { - Dialog, - DialogFooter, - DialogContent, - Button, - Field, - useToast, - useDialogRef, -} from "@probo/ui"; -import { useTranslate } from "@probo/i18n"; -import { sprintf } from "@probo/helpers"; -import { useFormWithSchema } from "/hooks/useFormWithSchema"; -import { z } from "zod"; -import { useCreateTrustCenterAccess } from "/hooks/useTrustCenterQueries"; - -type Props = { - trigger: React.ReactNode; - trustCenterId: string; - organizationName: string; -}; - -export function PublicTrustCenterAccessRequestDialog({ - trigger, - trustCenterId, - organizationName -}: Props) { - const { __ } = useTranslate(); - const { toast } = useToast(); - const [isSubmitting, setIsSubmitting] = useState(false); - const dialogRef = useDialogRef(); - - const mutation = useCreateTrustCenterAccess(); - - const schema = z.object({ - name: z.string().min(1, __("Name is required")).min(2, __("Name must be at least 2 characters long")), - email: z.string().min(1, __("Email is required")).email(__("Please enter a valid email address")), - }); - - const { register, handleSubmit, formState, reset } = useFormWithSchema(schema, { - defaultValues: { name: "", email: "" }, - }); - - const onSubmit = handleSubmit(async (data) => { - setIsSubmitting(true); - mutation.mutate( - { - trustCenterId, - email: data.email, - name: data.name, - }, - { - onSuccess: (result) => { - if (result.createTrustCenterAccess) { - toast({ - title: __("Request Submitted"), - description: __("Your access request has been submitted. You will receive an email if your request is approved."), - variant: "success", - }); - - reset(); - dialogRef.current?.close(); - } - setIsSubmitting(false); - }, - onError: (_: Error) => { - toast({ - title: __("Error"), - description: __("An error occurred while submitting your request."), - variant: "error", - }); - setIsSubmitting(false); - }, - } - ); - }); - - return ( - -
- -
- {sprintf(__("Request access to %s's Trust Center. Your request will be reviewed and you will receive an email notification with access instructions if approved."), organizationName)} -
- - - - -
- - - - -
-
- ); -} diff --git a/apps/console/src/trust/components/PublicTrustCenterAudits.tsx b/apps/console/src/trust/components/PublicTrustCenterAudits.tsx deleted file mode 100644 index 650611723..000000000 --- a/apps/console/src/trust/components/PublicTrustCenterAudits.tsx +++ /dev/null @@ -1,148 +0,0 @@ -import { - Card, - Tr, - Td, - Table, - Thead, - Tbody, - Th, - Button, - IconArrowDown, - IconLock, - useToast, -} from "@probo/ui"; -import { useTranslate } from "@probo/i18n"; -import { sprintf } from "@probo/helpers"; -import { FrameworkLogo } from "/components/FrameworkLogo"; -import { PublicTrustCenterAccessRequestDialog } from "./PublicTrustCenterAccessRequestDialog"; -import { useExportReportPDF } from "../../hooks/useTrustCenterQueries"; -import type { TrustCenterAudit } from "../pages/PublicTrustCenterPage"; - -type Props = { - audits: TrustCenterAudit[]; - organizationName: string; - isAuthenticated: boolean; - trustCenterId: string; -}; - -export function PublicTrustCenterAudits({ - audits, - organizationName, - isAuthenticated, - trustCenterId -}: Props) { - const { __ } = useTranslate(); - const { toast } = useToast(); - - const mutation = useExportReportPDF(); - - const handleDownload = (report: NonNullable) => { - mutation.mutate(report.id, { - onSuccess: (data) => { - if (data.exportReportPDF?.data) { - const link = window.document.createElement("a"); - link.href = data.exportReportPDF.data; - link.download = `${report.filename}`; - window.document.body.appendChild(link); - link.click(); - window.document.body.removeChild(link); - } - }, - onError: () => { - toast({ - title: __("Download Failed"), - description: __("Unable to download the report. Please try again."), - variant: "error", - }); - }, - }); - }; - - if (audits.length === 0) { - return ( - -
-

- {__("Compliance")} -

-

- {__("No compliance reports are currently available.")} -

-
-
- ); - } - - return ( - -
-

- {__("Compliance")} -

-

- {sprintf(__("%s is compliant with the following frameworks"), organizationName)} -

-
- - - - - - - - - - {audits.map((audit) => { - const hasReport = audit.report !== null; - - return ( - - - - - ); - })} - -
{__("Framework")}{__("Report")}
-
-
-
- -
-
-
- {audit.framework.name} -
-
-
- {!hasReport ? ( - - {__("No report")} - - ) : !isAuthenticated ? ( - - {__("Request Access")} - - } - trustCenterId={trustCenterId} - organizationName={organizationName} - /> - ) : ( - - )} -
-
- ); -} diff --git a/apps/console/src/trust/components/PublicTrustCenterDocuments.tsx b/apps/console/src/trust/components/PublicTrustCenterDocuments.tsx deleted file mode 100644 index e574ec8bd..000000000 --- a/apps/console/src/trust/components/PublicTrustCenterDocuments.tsx +++ /dev/null @@ -1,137 +0,0 @@ -import { - Card, - Tr, - Td, - Table, - Thead, - Tbody, - Th, - DocumentTypeBadge, - Button, - IconArrowDown, - IconLock, - useToast, -} from "@probo/ui"; -import { useTranslate } from "@probo/i18n"; -import { useExportDocumentPDF, type TrustCenterDocument } from "/hooks/useTrustCenterQueries"; -import { PublicTrustCenterAccessRequestDialog } from "./PublicTrustCenterAccessRequestDialog"; - -type Props = { - documents: TrustCenterDocument[]; - isAuthenticated: boolean; - trustCenterId: string; - organizationName: string; -}; - -export function PublicTrustCenterDocuments({ - documents, - isAuthenticated, - trustCenterId, - organizationName -}: Props) { - const { __ } = useTranslate(); - const { toast } = useToast(); - - const mutation = useExportDocumentPDF(); - - const handleDownload = (document: TrustCenterDocument) => { - mutation.mutate(document.id, { - onSuccess: (data) => { - if (data.exportDocumentPDF?.data) { - const link = window.document.createElement("a"); - link.href = data.exportDocumentPDF.data; - link.download = `${document.title}.pdf`; - window.document.body.appendChild(link); - link.click(); - window.document.body.removeChild(link); - } - }, - onError: () => { - toast({ - title: __("Download Failed"), - description: __("Unable to download the document. Please try again."), - variant: "error", - }); - }, - }); - }; - - if (documents.length === 0) { - return ( - -
-

- {__("Documents")} -

-

- {__("No documents are currently available.")} -

-
-
- ); - } - - return ( - -
-

- {__("Documents")} -

-

- {__("Security and compliance documentation")} -

-
- - - - - - - - - - - {documents.map((document) => { - return ( - - - - - - ); - })} - -
{__("Document")}{__("Type")}{__("Download")}
-
- {document.title} -
-
- - - {!isAuthenticated ? ( - - {__("Request Access")} - - } - trustCenterId={trustCenterId} - organizationName={organizationName} - /> - ) : ( - - )} -
-
- ); -} diff --git a/apps/console/src/trust/components/PublicTrustCenterVendors.tsx b/apps/console/src/trust/components/PublicTrustCenterVendors.tsx deleted file mode 100644 index 672aaee77..000000000 --- a/apps/console/src/trust/components/PublicTrustCenterVendors.tsx +++ /dev/null @@ -1,122 +0,0 @@ -import { - Card, - Tr, - Td, - Table, - Thead, - Tbody, - Th, -} from "@probo/ui"; -import { useTranslate } from "@probo/i18n"; -import { faviconUrl, sprintf, getCountryName, type CountryCode } from "@probo/helpers"; -import type { TrustCenterVendor } from "../pages/PublicTrustCenterPage"; - -type Props = { - vendors: TrustCenterVendor[]; - organizationName: string; -}; - -export function PublicTrustCenterVendors({ vendors, organizationName }: Props) { - const { __ } = useTranslate(); - - const hasCountriesData = vendors.some(vendor => vendor.countries && vendor.countries.length > 0); - - if (vendors.length === 0) { - return ( - -
-

- {__("Subcontractors")} -

-

- {__("No subcontractor information is currently available.")} -

-
-
- ); - } - - return ( - -
-

- {__("Subcontractors")} -

-

- {sprintf(__("Third-party subcontractors %s work with"), organizationName)} -

-
- - - - - - - {hasCountriesData && } - - - - {vendors.map((vendor) => { - const url = vendor.privacyPolicyUrl || vendor.websiteUrl; - const logo = faviconUrl(vendor.websiteUrl); - - const getCleanUrl = (url: string) => { - try { - const parsedUrl = new URL(url); - return parsedUrl.hostname + parsedUrl.pathname + parsedUrl.search; - } catch { - return url.replace(/^https?:\/\//, ''); - } - }; - - const formatCountries = (countries: CountryCode[]) => { - return countries.map(code => getCountryName(__, code)).join(", "); - }; - - return ( - - - - {hasCountriesData && ( - - )} - - ); - })} - -
{__("Company")}{__("Website")}{__("Countries")}
-
- {logo && ( - {`${vendor.name} - )} -
- {vendor.name} -
-
-
- {url ? ( - - {getCleanUrl(url)} - - ) : ( - - {__("No website available")} - - )} - - - {formatCountries(vendor.countries)} - -
-
- ); -} diff --git a/apps/console/src/trust/pages/PublicTrustCenterPage.tsx b/apps/console/src/trust/pages/PublicTrustCenterPage.tsx deleted file mode 100644 index 758137cbc..000000000 --- a/apps/console/src/trust/pages/PublicTrustCenterPage.tsx +++ /dev/null @@ -1,115 +0,0 @@ -import { useParams, Navigate } from "react-router"; -import { usePageTitle } from "@probo/hooks"; -import { useTranslate } from "@probo/i18n"; -import { PublicTrustCenterLayout } from "/layouts/PublicTrustCenterLayout"; -import { PublicTrustCenterAudits } from "../components/PublicTrustCenterAudits"; -import { PublicTrustCenterVendors } from "../components/PublicTrustCenterVendors"; -import { PublicTrustCenterDocuments } from "../components/PublicTrustCenterDocuments"; -import { NDAAcceptanceDialog } from "../components/NDAAcceptanceDialog"; -import { Spinner } from "@probo/ui"; -import { useTrustCenterQuery, type TrustCenterDocument, type TrustCenterAudit, type TrustCenterVendor } from "/hooks/useTrustCenterQueries"; - -export type { TrustCenterDocument, TrustCenterAudit, TrustCenterVendor }; - -export default function PublicTrustCenterPage() { - const { __ } = useTranslate(); - const { slug } = useParams<{ slug: string }>(); - - const { data, isLoading, error } = useTrustCenterQuery(slug || ""); - - const organization = data?.trustCenterBySlug?.organization; - const organizationName = organization?.name || ""; - - usePageTitle( - organizationName ? `${organizationName} - Trust Center` : "Trust Center" - ); - - if (!slug) { - return ; - } - - if (isLoading) { - return ( -
- -
- ); - } - - if (error) { - return ( -
-
-

- {__("Error Loading Trust Center")} -

-

- {__("There was an error loading the trust center. Please try again later.")} -

-
-
- ); - } - - if (!data?.trustCenterBySlug) { - return ( -
-
-

- {__("Trust Center Not Found")} -

-

- {__("The trust center you're looking for doesn't exist.")} -

-
-
- ); - } - - const { trustCenterBySlug } = data; - const { documents, audits, vendors, isUserAuthenticated, hasAcceptedNonDisclosureAgreement } = trustCenterBySlug; - - const trustCenterDocuments = documents.edges.map((edge) => edge.node) as TrustCenterDocument[]; - const trustCenterAudits = audits.edges.map((edge) => edge.node) as TrustCenterAudit[]; - const trustCenterVendors = vendors.edges.map((edge) => edge.node) as TrustCenterVendor[]; - - const showNdaDialog = isUserAuthenticated && !hasAcceptedNonDisclosureAgreement; - - return ( - <> - {showNdaDialog && ( - - )} - - -
- - - -
-
- - ); -}