Display countries on trust center
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -125,7 +125,7 @@ function VendorRow(props: {
|
|||||||
const { __ } = useTranslate();
|
const { __ } = useTranslate();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tr to={`/organizations/${organizationId}/vendors/${vendor.id}`}>
|
<Tr to={`/organizations/${organizationId}/vendors/${vendor.id}/overview`}>
|
||||||
<Td>
|
<Td>
|
||||||
<div className="flex gap-4 items-center">
|
<div className="flex gap-4 items-center">
|
||||||
{vendor.name}
|
{vendor.name}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useQuery, useMutation } from "@tanstack/react-query";
|
import { useQuery, useMutation } from "@tanstack/react-query";
|
||||||
import { GraphQLError } from "graphql";
|
import { GraphQLError } from "graphql";
|
||||||
import { buildEndpoint } from "/providers/RelayProviders";
|
import { buildEndpoint } from "/providers/RelayProviders";
|
||||||
|
import { type CountryCode } from "@probo/helpers";
|
||||||
|
|
||||||
export interface TrustCenterDocument {
|
export interface TrustCenterDocument {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -25,6 +26,7 @@ export interface TrustCenterVendor {
|
|||||||
category: string;
|
category: string;
|
||||||
privacyPolicyUrl?: string | null;
|
privacyPolicyUrl?: string | null;
|
||||||
websiteUrl?: string | null;
|
websiteUrl?: string | null;
|
||||||
|
countries: CountryCode[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TrustCenterQueryData {
|
interface TrustCenterQueryData {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
Th,
|
Th,
|
||||||
} from "@probo/ui";
|
} from "@probo/ui";
|
||||||
import { useTranslate } from "@probo/i18n";
|
import { useTranslate } from "@probo/i18n";
|
||||||
import { faviconUrl, sprintf } from "@probo/helpers";
|
import { faviconUrl, sprintf, getCountryName, type CountryCode } from "@probo/helpers";
|
||||||
import type { TrustCenterVendor } from "../pages/PublicTrustCenterPage";
|
import type { TrustCenterVendor } from "../pages/PublicTrustCenterPage";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@@ -19,6 +19,8 @@ type Props = {
|
|||||||
export function PublicTrustCenterVendors({ vendors, organizationName }: Props) {
|
export function PublicTrustCenterVendors({ vendors, organizationName }: Props) {
|
||||||
const { __ } = useTranslate();
|
const { __ } = useTranslate();
|
||||||
|
|
||||||
|
const hasCountriesData = vendors.some(vendor => vendor.countries && vendor.countries.length > 0);
|
||||||
|
|
||||||
if (vendors.length === 0) {
|
if (vendors.length === 0) {
|
||||||
return (
|
return (
|
||||||
<Card padded>
|
<Card padded>
|
||||||
@@ -50,6 +52,7 @@ export function PublicTrustCenterVendors({ vendors, organizationName }: Props) {
|
|||||||
<Tr>
|
<Tr>
|
||||||
<Th>{__("Company")}</Th>
|
<Th>{__("Company")}</Th>
|
||||||
<Th>{__("Website")}</Th>
|
<Th>{__("Website")}</Th>
|
||||||
|
{hasCountriesData && <Th>{__("Countries")}</Th>}
|
||||||
</Tr>
|
</Tr>
|
||||||
</Thead>
|
</Thead>
|
||||||
<Tbody>
|
<Tbody>
|
||||||
@@ -66,6 +69,10 @@ export function PublicTrustCenterVendors({ vendors, organizationName }: Props) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const formatCountries = (countries: CountryCode[]) => {
|
||||||
|
return countries.map(code => getCountryName(__, code)).join(", ");
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tr key={vendor.id}>
|
<Tr key={vendor.id}>
|
||||||
<Td>
|
<Td>
|
||||||
@@ -98,6 +105,13 @@ export function PublicTrustCenterVendors({ vendors, organizationName }: Props) {
|
|||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</Td>
|
</Td>
|
||||||
|
{hasCountriesData && (
|
||||||
|
<Td>
|
||||||
|
<span className="text-txt-secondary text-sm">
|
||||||
|
{formatCountries(vendor.countries)}
|
||||||
|
</span>
|
||||||
|
</Td>
|
||||||
|
)}
|
||||||
</Tr>
|
</Tr>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
Reference in New Issue
Block a user