Skip to content

Commit 2e10fb0

Browse files
authored
Merge pull request #1003 from carhartlewis/lewis/comp-trust-portal-tweaks
refactor: update turbo.json formatting and enhance ComplianceHeader c…
2 parents d66a962 + 4792901 commit 2e10fb0

5 files changed

Lines changed: 118 additions & 31 deletions

File tree

apps/trust/src/app/[id]/components/compliance-header.tsx

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,26 @@ interface ComplianceHeaderProps {
1111
title: string;
1212
}
1313

14+
const hasLogo = process.env.LOGO_DEV === 'true';
15+
1416
export default function ComplianceHeader({ organization, title }: ComplianceHeaderProps) {
1517
return (
1618
<div className="border-t-primary flex flex-col gap-4 rounded-sm border border-t-4 p-4">
1719
<div className="flex flex-col items-start justify-between gap-4 md:flex-row md:items-center">
1820
<div className="flex items-center gap-4">
19-
<div className="flex h-10 w-10 items-center justify-center">
20-
{organization.logo ? (
21+
<div className="flex h-14 w-14 items-center justify-center">
22+
{organization.website ? (
2123
<Image
22-
src={organization.logo || '/placeholder.svg'}
24+
src={
25+
organization.logo ||
26+
(hasLogo
27+
? `https://img.logo.dev/${organization.website.replace('https://', '')}?token=${process.env.LOGO_DEV}&retina=true&format=png`
28+
: `https://img.logo.dev/${organization.website.replace('https://', '')}?token=${process.env.LOGO_DEV}&retina=true&format=png`)
29+
}
2330
alt={`${organization.name} logo`}
24-
width={40}
25-
height={40}
26-
className="object-contain"
31+
width={128}
32+
height={128}
33+
className="object-contain rounded-md"
2734
/>
2835
) : (
2936
<div className="bg-muted-foreground flex h-10 w-10 items-center justify-center rounded-md font-bold text-white">
@@ -33,13 +40,11 @@ export default function ComplianceHeader({ organization, title }: ComplianceHead
3340
</div>
3441
<div className="flex flex-col">
3542
<h1 className="text-xl font-bold">{title}</h1>
36-
<ComplianceSummary
37-
text={`Find out the compliance and security posture of ${organization.name}.`}
38-
/>
43+
<ComplianceSummary text={`Compliance and Security Portal for ${organization.name}.`} />
3944
</div>
4045
</div>
4146

42-
<div className="grid gap-2 sm:flex">
47+
<div className="grid gap-2 sm:flex w-full md:justify-end md:w-auto">
4348
<Link
4449
className={buttonVariants({
4550
variant: 'outline',

apps/trust/src/app/[id]/components/compliance-item.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ interface ComplianceItemProps {
55

66
export default function ComplianceItem({ text, isCompliant }: ComplianceItemProps) {
77
return (
8-
<div className="flex items-center justify-between py-1">
9-
<span className="text-sm">{text}</span>
8+
<div className="flex items-center gap-4">
109
{isCompliant ? (
1110
<div className="h-2 w-2 rounded-full bg-green-500" />
1211
) : (
1312
<div className="h-2 w-2 rounded-full bg-red-500" />
1413
)}
14+
<span className="text-sm">{text}</span>
1515
</div>
1616
);
1717
}

apps/trust/src/app/[id]/components/report.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ export default function ComplianceReport({
7676
)}
7777
</div>
7878

79-
<div className="mt-4 grid grid-cols-1 gap-4 md:grid-cols-2">
79+
<div className="mt-4 grid grid-cols-1 gap-4">
8080
{policies.length > 0 && (
8181
<ComplianceSection
8282
title="Policies"
83-
description={`A list of all the policies that ${organization.name} has published.`}
83+
description={`An up to date list of policies published internally by ${organization.name}.`}
8484
isLive
8585
>
86-
<div className="space-y-2">
86+
<div className="grid grid-cols-1 gap-4 md:grid-cols-2">
8787
{policies.map((policy) => (
8888
<ComplianceItem
8989
key={policy.id}
@@ -98,10 +98,10 @@ export default function ComplianceReport({
9898
{controls.length > 0 && (
9999
<ComplianceSection
100100
title="Controls"
101-
description={`A list of all the controls that ${organization.name} has published.`}
101+
description={`An up to date list of controls published internally by ${organization.name}.`}
102102
isLive
103103
>
104-
<div className="space-y-2">
104+
<div className="grid grid-cols-1 gap-4 md:grid-cols-2">
105105
{controls.map((control) => (
106106
<ComplianceItem
107107
key={control.id}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { db } from '@comp/db';
2+
import { NextRequest, NextResponse } from 'next/server';
3+
import { cache } from 'react';
4+
5+
const getCachedSites = cache(async () => {
6+
const sites = await db.trust.findMany({
7+
where: {
8+
status: 'published',
9+
},
10+
select: {
11+
organizationId: true,
12+
},
13+
});
14+
15+
const websites = await db.organization.findMany({
16+
where: {
17+
id: {
18+
in: sites.map((site) => site.organizationId),
19+
},
20+
},
21+
select: {
22+
website: true,
23+
},
24+
});
25+
26+
return websites.map((website) => website.website);
27+
});
28+
29+
export async function GET(request: NextRequest) {
30+
try {
31+
const websites = await getCachedSites();
32+
33+
console.log(websites);
34+
35+
const response = NextResponse.json(websites);
36+
37+
response.headers.set('Cache-Control', 'public, s-maxage=3600, stale-while-revalidate=86400');
38+
response.headers.set('CDN-Cache-Control', 'public, max-age=3600');
39+
response.headers.set('Vercel-CDN-Cache-Control', 'public, max-age=3600');
40+
41+
return response;
42+
} catch (error) {
43+
console.error('Error fetching sites:', error);
44+
return NextResponse.json({ error: 'Failed to fetch sites' }, { status: 500 });
45+
}
46+
}

turbo.json

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"$schema": "https://turborepo.org/schema.json",
3-
"globalDependencies": ["**/.env"],
3+
"globalDependencies": [
4+
"**/.env"
5+
],
46
"ui": "stream",
57
"tasks": {
68
"build": {
@@ -45,25 +47,52 @@
4547
"FLEET_TOKEN",
4648
"FLEET_DEVICE_PATH_MAC",
4749
"FLEET_AGENT_BUCKET_NAME",
48-
"FLEET_DEVICE_PATH_WINDOWS"
50+
"FLEET_DEVICE_PATH_WINDOWS",
51+
"LOGO_DEV"
4952
],
50-
"inputs": ["$TURBO_DEFAULT$", ".env"],
51-
"dependsOn": ["^build", "^db:generate", "^auth:build"],
52-
"outputs": [".next/**", "!.next/cache/**", "next-env.d.ts", "data:build"]
53+
"inputs": [
54+
"$TURBO_DEFAULT$",
55+
".env"
56+
],
57+
"dependsOn": [
58+
"^build",
59+
"^db:generate",
60+
"^auth:build"
61+
],
62+
"outputs": [
63+
".next/**",
64+
"!.next/cache/**",
65+
"next-env.d.ts",
66+
"data:build"
67+
]
5368
},
5469
"db:generate": {
5570
"cache": false
5671
},
5772
"auth:build": {
5873
"cache": false,
59-
"env": ["BETTER_AUTH_SECRET", "BETTER_AUTH_URL", "AUTH_GOOGLE_ID", "AUTH_GOOGLE_SECRET"]
74+
"env": [
75+
"BETTER_AUTH_SECRET",
76+
"BETTER_AUTH_URL",
77+
"AUTH_GOOGLE_ID",
78+
"AUTH_GOOGLE_SECRET"
79+
]
6080
},
6181
"data:build": {
6282
"cache": false,
63-
"env": ["DATABASE_URL"],
64-
"inputs": ["$TURBO_DEFAULT$", ".env"],
65-
"dependsOn": ["^db:generate"],
66-
"outputs": ["data:build"]
83+
"env": [
84+
"DATABASE_URL"
85+
],
86+
"inputs": [
87+
"$TURBO_DEFAULT$",
88+
".env"
89+
],
90+
"dependsOn": [
91+
"^db:generate"
92+
],
93+
"outputs": [
94+
"data:build"
95+
]
6796
},
6897
"db:push": {
6998
"cache": false
@@ -75,19 +104,26 @@
75104
"cache": false
76105
},
77106
"dev": {
78-
"inputs": ["$TURBO_DEFAULT$", ".env"],
79-
"dependsOn": ["^db:generate"],
107+
"inputs": [
108+
"$TURBO_DEFAULT$",
109+
".env"
110+
],
111+
"dependsOn": [
112+
"^db:generate"
113+
],
80114
"persistent": true,
81115
"cache": false
82116
},
83117
"lint": {
84118
"dependsOn": []
85119
},
86120
"typecheck": {
87-
"outputs": ["node_modules/.cache/tsbuildinfo.json"]
121+
"outputs": [
122+
"node_modules/.cache/tsbuildinfo.json"
123+
]
88124
},
89125
"deps:check": {
90126
"cache": false
91127
}
92128
}
93-
}
129+
}

0 commit comments

Comments
 (0)