Update trust webapp to work in both mode
Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { useTranslate } from "@probo/i18n";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useNavigate, useParams, useSearchParams } from "react-router";
|
||||
import { useNavigate, useSearchParams } from "react-router";
|
||||
import { buildEndpoint } from "/providers/RelayProviders";
|
||||
import { PageError } from "/components/PageError";
|
||||
import { Spinner } from "@probo/ui";
|
||||
@@ -10,16 +10,12 @@ import { Spinner } from "@probo/ui";
|
||||
*/
|
||||
export function AccessPage() {
|
||||
const { __ } = useTranslate();
|
||||
const { slug } = useParams<{ slug: string }>();
|
||||
const [searchParams] = useSearchParams();
|
||||
const token = searchParams.get("token");
|
||||
const navigate = useNavigate();
|
||||
|
||||
const isValidRequest = !!(slug && token);
|
||||
const isValidRequest = !!token;
|
||||
const [error, setError] = useState<string | null>(() => {
|
||||
if (!slug) {
|
||||
return __("Invalid trust center");
|
||||
}
|
||||
if (!token) {
|
||||
return __("Invalid access token");
|
||||
}
|
||||
@@ -57,7 +53,7 @@ export function AccessPage() {
|
||||
})
|
||||
.then((data) => {
|
||||
if (data.success) {
|
||||
navigate(`/trust/${slug}`);
|
||||
navigate("/overview");
|
||||
return;
|
||||
}
|
||||
throw new Error(data.message ?? __("Authentication failed"));
|
||||
@@ -65,7 +61,7 @@ export function AccessPage() {
|
||||
.catch((error) => {
|
||||
setError(error.message);
|
||||
});
|
||||
}, [isValidRequest, slug, token, __, navigate]);
|
||||
}, [isValidRequest, token, __, navigate]);
|
||||
|
||||
if (error) {
|
||||
return <PageError error={error} />;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { type PreloadedQuery, usePreloadedQuery } from "react-relay";
|
||||
import { trustDocumentsQuery } from "/queries/TrustGraph";
|
||||
import type { TrustGraphDocumentsQuery } from "/queries/__generated__/TrustGraphDocumentsQuery.graphql.ts";
|
||||
import { currentTrustDocumentsQuery } from "/queries/TrustGraph";
|
||||
import type { TrustGraphCurrentDocumentsQuery } from "/queries/__generated__/TrustGraphCurrentDocumentsQuery.graphql.ts";
|
||||
import { groupBy, objectEntries } from "@probo/helpers";
|
||||
import { documentTypeLabel } from "/helpers/documents";
|
||||
import { useTranslate } from "@probo/i18n";
|
||||
@@ -10,16 +10,19 @@ import { Rows } from "/components/Rows.tsx";
|
||||
import { RowHeader } from "/components/RowHeader.tsx";
|
||||
|
||||
type Props = {
|
||||
queryRef: PreloadedQuery<TrustGraphDocumentsQuery>;
|
||||
queryRef: PreloadedQuery<TrustGraphCurrentDocumentsQuery>;
|
||||
};
|
||||
|
||||
export function DocumentsPage({ queryRef }: Props) {
|
||||
const { __ } = useTranslate();
|
||||
const data = usePreloadedQuery(trustDocumentsQuery, queryRef);
|
||||
const data = usePreloadedQuery<TrustGraphCurrentDocumentsQuery>(
|
||||
currentTrustDocumentsQuery,
|
||||
queryRef
|
||||
);
|
||||
const documents =
|
||||
data.trustCenterBySlug?.documents.edges.map((edge) => edge.node) ?? [];
|
||||
data.currentTrustCenter?.documents.edges.map((edge) => edge.node) ?? [];
|
||||
const documentsPerType = groupBy(documents, (document) =>
|
||||
documentTypeLabel(document.documentType, __),
|
||||
documentTypeLabel(document.documentType, __)
|
||||
);
|
||||
return (
|
||||
<div>
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
import { type PreloadedQuery, usePreloadedQuery } from "react-relay";
|
||||
import { trustVendorsQuery } from "/queries/TrustGraph";
|
||||
import { currentTrustVendorsQuery } from "/queries/TrustGraph";
|
||||
import { sprintf } from "@probo/helpers";
|
||||
import { useTranslate } from "@probo/i18n";
|
||||
import type { TrustGraphVendorsQuery } from "/queries/__generated__/TrustGraphVendorsQuery.graphql";
|
||||
import type { TrustGraphCurrentVendorsQuery } from "/queries/__generated__/TrustGraphCurrentVendorsQuery.graphql";
|
||||
import { VendorRow } from "/components/VendorRow";
|
||||
import { Rows } from "/components/Rows.tsx";
|
||||
|
||||
type Props = {
|
||||
queryRef: PreloadedQuery<TrustGraphVendorsQuery>;
|
||||
queryRef: PreloadedQuery<TrustGraphCurrentVendorsQuery>;
|
||||
};
|
||||
|
||||
export function SubprocessorsPage({ queryRef }: Props) {
|
||||
const { __ } = useTranslate();
|
||||
const data = usePreloadedQuery(trustVendorsQuery, queryRef);
|
||||
const data = usePreloadedQuery(currentTrustVendorsQuery, queryRef);
|
||||
const vendors =
|
||||
data.trustCenterBySlug?.vendors.edges.map((edge) => edge.node) ?? [];
|
||||
data.currentTrustCenter?.vendors.edges.map((edge) => edge.node) ?? [];
|
||||
return (
|
||||
<div>
|
||||
<h2 className="font-medium mb-1">{__("Subprocessors")}</h2>
|
||||
<p className="text-sm text-txt-secondary mb-4">
|
||||
{sprintf(
|
||||
__("Third-party subprocessors %s work with:"),
|
||||
data.trustCenterBySlug?.organization.name ?? "",
|
||||
data.currentTrustCenter?.organization.name ?? ""
|
||||
)}
|
||||
</p>
|
||||
<Rows>
|
||||
|
||||
Reference in New Issue
Block a user