Skip to content

Commit bf74fb3

Browse files
authored
Merge pull request #559 from trycompai/lewis/comp-fix-policy-editor-trust-portal
[dev] [carhartlewis] lewis/comp-fix-policy-editor-trust-portal
2 parents 43bddfe + 6f4f1c4 commit bf74fb3

File tree

17 files changed

+32802
-664
lines changed

17 files changed

+32802
-664
lines changed

apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/[policyId]/editor/components/PolicyDetails.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function PolicyPageEditor({
3333
};
3434

3535
return (
36-
<div className="flex flex-col h-full border p-2">
36+
<div className="flex flex-col h-full border">
3737
<PolicyEditor
3838
content={formattedContent}
3939
onSave={handleSavePolicy}

apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/settings/trust-portal/page.tsx

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,22 @@ import { TrustPortalSwitch } from "./components/TrustPortalSwitch";
1010
export default async function TrustPortalSettings({
1111
params,
1212
}: {
13-
params: Promise<{ locale: string }>;
13+
params: Promise<{ locale: string; orgId: string }>;
1414
}) {
15-
const { locale } = await params;
15+
const { locale, orgId } = await params;
1616
setStaticParamsLocale(locale);
1717
const t = await getI18n();
1818

19-
const trustPortal = await getTrustPortal();
19+
const trustPortal = await getTrustPortal(orgId);
2020

2121
return (
2222
<div className="mx-auto max-w-7xl">
23-
<TrustPortalSwitch enabled={trustPortal?.enabled ?? false} slug={trustPortal?.slug ?? ""} />
23+
<TrustPortalSwitch enabled={trustPortal?.enabled ?? false} slug={orgId} />
2424
</div>
2525
);
2626
}
2727

28-
export async function generateMetadata({
29-
params,
30-
}: {
31-
params: Promise<{ locale: string }>;
32-
}): Promise<Metadata> {
33-
const { locale } = await params;
34-
setStaticParamsLocale(locale);
35-
const t = await getI18n();
36-
37-
return {
38-
title: "Trust Portal",
39-
};
40-
}
41-
const getTrustPortal = cache(async () => {
28+
const getTrustPortal = cache(async (orgId: string) => {
4229
const session = await auth.api.getSession({
4330
headers: await headers(),
4431
});
@@ -47,31 +34,34 @@ const getTrustPortal = cache(async () => {
4734
return null;
4835
}
4936

50-
const slug = await db.organization.findUnique({
51-
where: {
52-
id: session.session.activeOrganizationId,
53-
},
54-
select: {
55-
slug: true,
56-
},
57-
});
58-
5937
const trustPortal = await db.trust.findUnique({
6038
where: {
61-
organizationId: session.session.activeOrganizationId,
39+
organizationId: orgId,
6240
status: "published",
6341
},
6442
});
6543

6644
if (!trustPortal) {
6745
return {
6846
enabled: false,
69-
slug: slug?.slug,
7047
};
7148
}
7249

7350
return {
7451
enabled: true,
75-
slug: slug?.slug,
7652
};
77-
});
53+
});
54+
55+
export async function generateMetadata({
56+
params,
57+
}: {
58+
params: Promise<{ locale: string }>;
59+
}): Promise<Metadata> {
60+
const { locale } = await params;
61+
setStaticParamsLocale(locale);
62+
const t = await getI18n();
63+
64+
return {
65+
title: "Trust Portal",
66+
};
67+
}

apps/app/src/components/editor/advanced-editor.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ const AdvancedEditor = ({
7676
if (!initialContent) return null;
7777

7878
return (
79-
<div className="relative w-full max-w-screen-lg">
79+
<div className="relative w-full bg-background p-4">
8080
<div className="flex absolute right-5 top-5 z-10 mb-5 gap-2">
8181
<div className="bg-accent px-2 py-1 text-sm text-muted-foreground">
8282
{saveStatus}
@@ -96,14 +96,14 @@ const AdvancedEditor = ({
9696
immediatelyRender={false}
9797
initialContent={initialContent}
9898
extensions={extensions}
99-
className="relative min-h-[500px] w-full max-w-screen-lg bg-background sm:mb-[calc(20vh)] p-2"
99+
className="relative min-h-[500px] max-h-[500px] w-full bg-bakground p-2 overflow-y-auto overflow-x-hidden"
100100
editorProps={{
101101
handleDOMEvents: {
102102
keydown: (_view, event) =>
103103
handleCommandNavigation(event),
104104
},
105105
attributes: {
106-
class: "prose prose-lg dark:prose-invert prose-headings:font-title font-default focus:outline-none max-w-full",
106+
class: "max-h-[500px] prose prose-lg dark:prose-invert prose-headings:font-title font-default focus:outline-none max-w-full",
107107
},
108108
}}
109109
onUpdate={({ editor }) => {

apps/app/src/components/editor/policy-editor.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ export function PolicyEditor({
2525
Array.isArray(content) && content.length > 0
2626
? content
2727
: [
28-
{
29-
type: "paragraph",
30-
content: [{ type: "text", text: "" }],
31-
},
32-
],
28+
{
29+
type: "paragraph",
30+
content: [{ type: "text", text: "" }],
31+
},
32+
],
3333
};
3434

3535
const handleUpdate = (updatedContent: JSONContent) => {
@@ -49,11 +49,13 @@ export function PolicyEditor({
4949
};
5050

5151
return (
52-
<AdvancedEditor
53-
initialContent={documentContent}
54-
onUpdate={handleUpdate}
55-
onSave={handleSave}
56-
readOnly={readOnly}
57-
/>
52+
<>
53+
<AdvancedEditor
54+
initialContent={documentContent}
55+
onUpdate={handleUpdate}
56+
onSave={handleSave}
57+
readOnly={readOnly}
58+
/>
59+
</>
5860
);
5961
}

apps/app/src/components/editor/selectors/node-selector.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ import {
1414
import { EditorBubbleItem, useEditor } from "novel";
1515

1616
import { Button } from "@comp/ui/button";
17-
import { PopoverContent, PopoverTrigger } from "@comp/ui/popover";
18-
import { Popover } from "@radix-ui/react-popover";
17+
import { Popover, PopoverContent, PopoverTrigger } from "@comp/ui/popover";
1918

2019
export type SelectorItem = {
2120
name: string;

apps/trust/package.json

Lines changed: 66 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,79 @@
11
{
22
"name": "@comp/trust",
3-
"version": "0.1.0",
43
"private": true,
54
"scripts": {
6-
"dev": "next dev --turbopack --port 3003",
5+
"dev": "next dev --port 3003",
76
"build": "next build",
87
"start": "next start",
9-
"lint": "next lint"
8+
"lint": "next lint",
9+
"typecheck": "tsc --noEmit"
1010
},
1111
"dependencies": {
12-
"react": "^19.1.0",
13-
"react-dom": "^19.1.0",
14-
"next": "15.3.2"
15-
},
16-
"devDependencies": {
1712
"@comp/db": "workspace:*",
1813
"@comp/ui": "workspace:*",
19-
"typescript": "^5.8.3",
20-
"@types/node": "^20.17.46",
21-
"@types/react": "^19.1.3",
22-
"@types/react-dom": "^19.1.3",
14+
"@hookform/resolvers": "^3.9.1",
15+
"@radix-ui/react-accordion": "1.2.2",
16+
"@radix-ui/react-alert-dialog": "1.1.4",
17+
"@radix-ui/react-aspect-ratio": "1.1.1",
18+
"@radix-ui/react-avatar": "1.1.2",
19+
"@radix-ui/react-checkbox": "latest",
20+
"@radix-ui/react-collapsible": "latest",
21+
"@radix-ui/react-context-menu": "2.2.4",
22+
"@radix-ui/react-dialog": "1.1.4",
23+
"@radix-ui/react-dropdown-menu": "2.1.4",
24+
"@radix-ui/react-hover-card": "1.1.4",
25+
"@radix-ui/react-label": "2.1.1",
26+
"@radix-ui/react-menubar": "1.1.4",
27+
"@radix-ui/react-navigation-menu": "1.2.3",
28+
"@radix-ui/react-popover": "1.1.4",
29+
"@radix-ui/react-progress": "1.1.1",
30+
"@radix-ui/react-radio-group": "1.2.2",
31+
"@radix-ui/react-scroll-area": "1.2.2",
32+
"@radix-ui/react-select": "2.1.4",
33+
"@radix-ui/react-separator": "1.1.1",
34+
"@radix-ui/react-slider": "1.2.2",
35+
"@radix-ui/react-slot": "1.1.1",
36+
"@radix-ui/react-switch": "1.1.2",
37+
"@radix-ui/react-tabs": "1.1.2",
38+
"@radix-ui/react-toast": "1.2.4",
39+
"@radix-ui/react-toggle": "1.1.1",
40+
"@radix-ui/react-toggle-group": "1.1.1",
41+
"@radix-ui/react-tooltip": "1.1.6",
42+
"@tanstack/react-virtual": "^3.13.8",
43+
"autoprefixer": "^10.4.21",
44+
"class-variance-authority": "^0.7.1",
45+
"clsx": "^2.1.1",
46+
"cmdk": "1.0.4",
47+
"date-fns": "4.1.0",
48+
"embla-carousel-react": "8.5.1",
49+
"file-saver": "latest",
50+
"input-otp": "1.4.1",
51+
"jszip": "latest",
52+
"lucide-react": "^0.454.0",
53+
"next": "^15.3.2",
54+
"next-themes": "^0.4.4",
55+
"react": "^19",
56+
"react-day-picker": "8.10.1",
57+
"react-dom": "^19",
58+
"react-resizable-panels": "^2.1.7",
59+
"recharts": "2.15.0",
60+
"sonner": "^1.7.1",
61+
"tailwind-merge": "^2.5.5",
62+
"tailwindcss-animate": "^1.0.7",
63+
"vaul": "^0.9.6",
64+
"zod": "latest"
65+
},
66+
"peerDependencies": {
67+
"react": "^19",
68+
"react-dom": "^19",
69+
"react-hook-form": "^7.56.3"
70+
},
71+
"devDependencies": {
72+
"@types/node": "^22",
73+
"@types/react": "^19",
74+
"@types/react-dom": "^19",
2375
"postcss": "^8.5.3",
24-
"tailwindcss": "^3.4.17"
76+
"tailwindcss": "3",
77+
"typescript": "^5"
2578
}
2679
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import Image from "next/image"
22
import { buttonVariants } from "@comp/ui/button"
33
import type { Organization } from "@comp/db/types"
44
import Link from "next/link"
5-
import { Globe, ExternalLink, Mail } from "lucide-react"
6-
import { Badge } from "@comp/ui/badge"
5+
import { Globe } from "lucide-react"
76

87
interface ComplianceHeaderProps {
98
organization: Organization

apps/trust/src/app/[id]/lib/data.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
"use server";
2+
13
import { db } from "@comp/db";
24

3-
export const findOrganization = async (subdomain: string) => {
5+
export const findOrganization = async (id: string) => {
46
const organization = await db.organization.findFirst({
5-
where: { slug: subdomain },
7+
where: { id: id },
68
});
79

8-
const isPublished = await db.trust.findFirst({
10+
const isPublished = await db.trust.findUnique({
911
where: { organizationId: organization?.id, status: "published" },
1012
});
1113

apps/trust/src/app/[id]/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { findOrganization, getPublishedControls, getPublishedPolicies } from "./lib/data";
22
import ComplianceReport from './components/report';
33

4-
export default async function Page({ params }: { params: Promise<{ subdomain: string }> }) {
5-
const subdomain = (await params).subdomain;
4+
export default async function Page({ params }: { params: Promise<{ id: string }> }) {
5+
const id = (await params).id;
66

7-
const organization = await findOrganization(subdomain);
7+
const organization = await findOrganization(id);
88

99
if (!organization) {
1010
return <div>Organization not found</div>;

apps/trust/src/app/global-error.tsx

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)