Skip to content

Commit 55eaa35

Browse files
makeitrainaclaude
andcommitted
fix: handle internal user preview mode before validating clientId/companyId
When internalUserId is provided in the token payload, the user is viewing company or client details pages that don't support preview. This should show the "CRM preview is not available" message instead of throwing an error about missing clientId or companyId. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f143f0c commit 55eaa35

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/app/client-preview/page.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,17 @@ export default async function ClientPreviewPage({
6060
const token = tokenParsed.data
6161
const copilotClient = new CopilotAPI(token)
6262
const tokenPayload = await copilotClient.getTokenPayload()
63-
if (!tokenPayload || !tokenPayload.clientId || !tokenPayload.companyId) {
63+
if (!tokenPayload) {
6464
console.info('Failing token payload', tokenPayload)
6565
throw new Error('Failed to parse token payload')
6666
}
6767
if (getPreviewMode(tokenPayload)) {
6868
return <NoPreviewSupport />
6969
}
70+
if (!tokenPayload.clientId || !tokenPayload.companyId) {
71+
console.info('Missing clientId or companyId in token payload', tokenPayload)
72+
throw new Error('Failed to parse token payload')
73+
}
7074

7175
const clientId = z.string().uuid().parse(tokenPayload.clientId)
7276

0 commit comments

Comments
 (0)