Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@tiptap/extension-table-row": "^2.22.3",
"@trigger.dev/react-hooks": "3.3.17",
"@trigger.dev/sdk": "3.3.17",
"@trycompai/db": "^1.3.0",
"@trycompai/db": "^1.3.1",
"@types/canvas-confetti": "^1.9.0",
"@types/three": "^0.177.0",
"@uploadthing/react": "^7.3.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,23 @@ interface UpdateTrustPortalFrameworksParams {
soc2?: boolean;
iso27001?: boolean;
gdpr?: boolean;
hipaa?: boolean;
soc2Status?: 'started' | 'in_progress' | 'compliant';
iso27001Status?: 'started' | 'in_progress' | 'compliant';
gdprStatus?: 'started' | 'in_progress' | 'compliant';
hipaaStatus?: 'started' | 'in_progress' | 'compliant';
}

export async function updateTrustPortalFrameworks({
orgId,
soc2,
iso27001,
gdpr,
hipaa,
soc2Status,
iso27001Status,
gdprStatus,
hipaaStatus,
}: UpdateTrustPortalFrameworksParams) {
const session = await auth.api.getSession({
headers: await headers(),
Expand Down Expand Up @@ -50,9 +54,11 @@ export async function updateTrustPortalFrameworks({
soc2: soc2 ?? trustPortal.soc2,
iso27001: iso27001 ?? trustPortal.iso27001,
gdpr: gdpr ?? trustPortal.gdpr,
hipaa: hipaa ?? trustPortal.hipaa,
soc2_status: soc2Status ?? trustPortal.soc2_status,
iso27001_status: iso27001Status ?? trustPortal.iso27001_status,
gdpr_status: gdprStatus ?? trustPortal.gdpr_status,
hipaa_status: hipaaStatus ?? trustPortal.hipaa_status,
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { z } from 'zod';
import { isFriendlyAvailable } from '../actions/is-friendly-available';
import { trustPortalSwitchAction } from '../actions/trust-portal-switch';
import { updateTrustPortalFrameworks } from '../actions/update-trust-portal-frameworks';
import { GDPR, ISO27001, SOC2 } from './logos';
import { GDPR, HIPAA, ISO27001, SOC2 } from './logos';

const trustPortalSwitchSchema = z.object({
enabled: z.boolean(),
Expand All @@ -26,9 +26,11 @@ const trustPortalSwitchSchema = z.object({
soc2: z.boolean(),
iso27001: z.boolean(),
gdpr: z.boolean(),
hipaa: z.boolean(),
soc2Status: z.enum(['started', 'in_progress', 'compliant']),
iso27001Status: z.enum(['started', 'in_progress', 'compliant']),
gdprStatus: z.enum(['started', 'in_progress', 'compliant']),
hipaaStatus: z.enum(['started', 'in_progress', 'compliant']),
});

export function TrustPortalSwitch({
Expand All @@ -41,9 +43,11 @@ export function TrustPortalSwitch({
soc2,
iso27001,
gdpr,
hipaa,
soc2Status,
iso27001Status,
gdprStatus,
hipaaStatus,
friendlyUrl,
}: {
enabled: boolean;
Expand All @@ -55,9 +59,11 @@ export function TrustPortalSwitch({
soc2: boolean;
iso27001: boolean;
gdpr: boolean;
hipaa: boolean;
soc2Status: 'started' | 'in_progress' | 'compliant';
iso27001Status: 'started' | 'in_progress' | 'compliant';
gdprStatus: 'started' | 'in_progress' | 'compliant';
hipaaStatus: 'started' | 'in_progress' | 'compliant';
friendlyUrl: string | null;
}) {
const trustPortalSwitch = useAction(trustPortalSwitchAction, {
Expand All @@ -79,9 +85,11 @@ export function TrustPortalSwitch({
soc2: soc2 ?? false,
iso27001: iso27001 ?? false,
gdpr: gdpr ?? false,
hipaa: hipaa ?? false,
soc2Status: soc2Status ?? 'started',
iso27001Status: iso27001Status ?? 'started',
gdprStatus: gdprStatus ?? 'started',
hipaaStatus: hipaaStatus ?? 'started',
friendlyUrl: friendlyUrl ?? undefined,
},
});
Expand All @@ -90,7 +98,7 @@ export function TrustPortalSwitch({
async (data: z.infer<typeof trustPortalSwitchSchema>) => {
await trustPortalSwitch.execute(data);
},
[trustPortalSwitch],
[], // Remove trustPortalSwitch from dependencies to prevent infinite loop
);

const portalUrl = domainVerified ? `https://${domain}` : `https://trust.inc/${slug}`;
Expand Down Expand Up @@ -148,7 +156,7 @@ export function TrustPortalSwitch({
}
setFriendlyUrlStatus('checking');
checkFriendlyUrl.execute({ friendlyUrl: debouncedFriendlyUrl, orgId });
}, [debouncedFriendlyUrl, orgId, friendlyUrl, checkFriendlyUrl]);
}, [debouncedFriendlyUrl, orgId, friendlyUrl]);
useEffect(() => {
if (checkFriendlyUrl.status === 'executing') return;
if (checkFriendlyUrl.result?.data?.isAvailable === true) {
Expand All @@ -161,7 +169,7 @@ export function TrustPortalSwitch({
} else if (checkFriendlyUrl.result?.data?.isAvailable === false) {
setFriendlyUrlStatus('unavailable');
}
}, [checkFriendlyUrl.status, checkFriendlyUrl.result, autoSave, form, debouncedFriendlyUrl]);
}, [checkFriendlyUrl.status, checkFriendlyUrl.result, debouncedFriendlyUrl, form, autoSave]);

const handleFriendlyUrlBlur = useCallback(
(e: React.FocusEvent<HTMLInputElement>) => {
Expand Down Expand Up @@ -393,6 +401,35 @@ export function TrustPortalSwitch({
}
}}
/>
{/* HIPAA */}
<ComplianceFramework
title="HIPAA"
description="A US regulation that protects sensitive patient health information and medical data."
isEnabled={hipaa}
status={hipaaStatus}
onStatusChange={async (value) => {
try {
await updateTrustPortalFrameworks({
orgId,
hipaaStatus: value as 'started' | 'in_progress' | 'compliant',
});
toast.success('HIPAA status updated');
} catch (error) {
toast.error('Failed to update HIPAA status');
}
}}
onToggle={async (checked) => {
try {
await updateTrustPortalFrameworks({
orgId,
hipaa: checked,
});
toast.success('HIPAA status updated');
} catch (error) {
toast.error('Failed to update HIPAA status');
}
}}
/>
</div>
</div>
</div>
Expand Down Expand Up @@ -422,12 +459,22 @@ function ComplianceFramework({
}) {
const logo =
title === 'SOC 2' ? (
<SOC2 className="h-16 w-16" />
<div className="h-16 w-16 flex items-center justify-center">
<SOC2 className="max-h-full max-w-full" />
</div>
) : title === 'ISO 27001' ? (
<ISO27001 className="h-16 w-16" />
) : (
<GDPR className="h-16 w-16" />
);
<div className="h-16 w-16 flex items-center justify-center">
<ISO27001 className="max-h-full max-w-full" />
</div>
) : title === 'GDPR' ? (
<div className="h-16 w-16 flex items-center justify-center">
<GDPR className="max-h-full max-w-full" />
</div>
) : title === 'HIPAA' ? (
<div className="h-16 w-16 flex items-center justify-center">
<HIPAA className="max-h-full max-w-full" />
</div>
) : null;

return (
<>
Expand Down
Loading
Loading