Show spinner while loading Public Trust Center
Signed-off-by: gauravjalap <luckyskchirag@gmail.com>
This commit is contained in:
committed by
Sacha Al Himdani
parent
e9f43d4519
commit
78b9cb8085
@@ -11,7 +11,7 @@ import { PageError } from "/components/PageError";
|
|||||||
import { TrustRelayProvider } from "/providers/TrustRelayProvider";
|
import { TrustRelayProvider } from "/providers/TrustRelayProvider";
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { buildEndpoint } from "/providers/RelayProviders";
|
import { buildEndpoint } from "/providers/RelayProviders";
|
||||||
|
import { Spinner } from "@probo/ui";
|
||||||
interface GraphQLError {
|
interface GraphQLError {
|
||||||
message: string;
|
message: string;
|
||||||
path?: string[];
|
path?: string[];
|
||||||
@@ -105,7 +105,9 @@ function PublicTrustCenterContent() {
|
|||||||
const [isAuthenticated, setIsAuthenticated] = useState(false);
|
const [isAuthenticated, setIsAuthenticated] = useState(false);
|
||||||
|
|
||||||
const organizationName = data?.trustCenterBySlug?.organization?.name;
|
const organizationName = data?.trustCenterBySlug?.organization?.name;
|
||||||
usePageTitle(organizationName ? `${organizationName} - Trust Center` : "Trust Center");
|
usePageTitle(
|
||||||
|
organizationName ? `${organizationName} - Trust Center` : "Trust Center"
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!slug) {
|
if (!slug) {
|
||||||
@@ -120,7 +122,7 @@ function PublicTrustCenterContent() {
|
|||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"Accept": "application/json",
|
Accept: "application/json",
|
||||||
},
|
},
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
@@ -129,14 +131,16 @@ function PublicTrustCenterContent() {
|
|||||||
variables: { slug },
|
variables: { slug },
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then(response => response.json())
|
.then((response) => response.json())
|
||||||
.then((result: GraphQLResponse<PublicTrustCenterData>) => {
|
.then((result: GraphQLResponse<PublicTrustCenterData>) => {
|
||||||
const accessDeniedErrors = result.errors?.filter((error: GraphQLError) =>
|
const accessDeniedErrors =
|
||||||
error.message.includes('access denied')
|
result.errors?.filter((error: GraphQLError) =>
|
||||||
|
error.message.includes("access denied")
|
||||||
) || [];
|
) || [];
|
||||||
|
|
||||||
const nonAuthErrors = result.errors?.filter((error: GraphQLError) =>
|
const nonAuthErrors =
|
||||||
!error.message.includes('access denied')
|
result.errors?.filter(
|
||||||
|
(error: GraphQLError) => !error.message.includes("access denied")
|
||||||
) || [];
|
) || [];
|
||||||
|
|
||||||
if (nonAuthErrors.length > 0) {
|
if (nonAuthErrors.length > 0) {
|
||||||
@@ -155,7 +159,7 @@ function PublicTrustCenterContent() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return <div>Loading...</div>;
|
return <Spinner />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
@@ -174,14 +178,11 @@ function PublicTrustCenterContent() {
|
|||||||
|
|
||||||
const { organization } = trustCenterBySlug;
|
const { organization } = trustCenterBySlug;
|
||||||
|
|
||||||
const documents = trustCenterBySlug.documents.edges
|
const documents = trustCenterBySlug.documents.edges.map((edge) => edge.node);
|
||||||
.map(edge => edge.node);
|
|
||||||
|
|
||||||
const audits = trustCenterBySlug.audits.edges
|
const audits = trustCenterBySlug.audits.edges.map((edge) => edge.node);
|
||||||
.map(edge => edge.node);
|
|
||||||
|
|
||||||
const vendors = trustCenterBySlug.vendors.edges
|
const vendors = trustCenterBySlug.vendors.edges.map((edge) => edge.node);
|
||||||
.map(edge => edge.node);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PublicTrustCenterLayout
|
<PublicTrustCenterLayout
|
||||||
@@ -194,7 +195,9 @@ function PublicTrustCenterContent() {
|
|||||||
{sprintf(__("%s Trust Center"), organization.name)}
|
{sprintf(__("%s Trust Center"), organization.name)}
|
||||||
</h1>
|
</h1>
|
||||||
<p className="text-lg text-txt-secondary max-w-2xl mx-auto">
|
<p className="text-lg text-txt-secondary max-w-2xl mx-auto">
|
||||||
{__("Explore our security practices, compliance certifications, and transparency reports.")}
|
{__(
|
||||||
|
"Explore our security practices, compliance certifications, and transparency reports."
|
||||||
|
)}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<PublicTrustCenterAudits
|
<PublicTrustCenterAudits
|
||||||
|
|||||||
Reference in New Issue
Block a user