fix(templates): fix template details page#1940
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile OverviewGreptile SummaryThis PR refactors the template details page from server-side rendering (SSR) to client-side rendering (CSR). The main changes include:
Critical Issue Found: Confidence Score: 1/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant User
participant Browser
participant Page as page.tsx (Server)
participant Template as template.tsx (Client)
participant API as /api/templates/[id]
participant AuthAPI as /api/auth/get-session
User->>Browser: Navigate to template detail page
Browser->>Page: Request page
Page->>Template: Render TemplateDetails component
Template->>Browser: Show loading state
par Fetch template and session in parallel
Template->>API: GET /api/templates/{id}
API-->>Template: Return template data
and
Template->>AuthAPI: GET /api/auth/get-session
AuthAPI--xTemplate: 404 - Endpoint does not exist ❌
end
Template->>Browser: Display template (without user session)
alt User clicks "Use Template"
Template->>Template: Check if currentUserId exists
Note over Template: currentUserId will be null due to failed auth fetch
Template->>Browser: Redirect to login
end
|
|
|
||
| const fetchCurrentUser = async () => { | ||
| try { | ||
| const response = await fetch('/api/auth/get-session') |
There was a problem hiding this comment.
logic: /api/auth/get-session endpoint does not exist in the codebase. Use getSession() from @/lib/auth instead (server-side only), or access session data from a different client-side pattern.
For client-side components, session should either be:
- Passed as a prop from a server component
- Accessed via a proper session provider/context
- Or the component should remain server-side
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/app/workspace/[workspaceId]/templates/[id]/template.tsx
Line: 164:164
Comment:
**logic:** `/api/auth/get-session` endpoint does not exist in the codebase. Use `getSession()` from `@/lib/auth` instead (server-side only), or access session data from a different client-side pattern.
For client-side components, session should either be:
1. Passed as a prop from a server component
2. Accessed via a proper session provider/context
3. Or the component should remain server-side
How can I resolve this? If you propose a fix, please make it concise.
Summary
Fix template details page
Type of Change
Testing
Manual
Checklist