Skip to content

Commit b240aa1

Browse files
committed
fix params retrieval in project conversation page
1 parent c62d893 commit b240aa1

File tree

1 file changed

+10
-7
lines changed
  • client/src/app/(main)/project/[projectId]/past

1 file changed

+10
-7
lines changed

client/src/app/(main)/project/[projectId]/past/page.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,28 @@ import Link from 'next/link';
77
import { Button } from '@/components/ui/button';
88
import { Plus } from 'lucide-react';
99
import ConversationHistory from '@/components/ConversationHistory';
10+
import { useParams } from 'next/navigation';
1011

11-
export default function ProjectPastConversationsPage({ params }: { params: { projectId: string } }) {
12+
export default function ProjectPastConversationsPage() {
13+
const params = useParams();
14+
const projectId = params.projectId as string;
1215
const [conversations, setConversations] = useState<Conversation[]>([]);
1316

1417
useEffect(() => {
1518
const fetchConversations = async () => {
1619
try {
17-
const response = await fetchFromApi(`/api/projects/conversations/${params.projectId}`);
20+
const response = await fetchFromApi(`/api/projects/conversations/${projectId}`);
1821
setConversations(response);
1922
} catch (error) {
20-
console.error(`Error fetching conversations for project ${params.projectId}`, error);
23+
console.error(`Error fetching conversations for project ${projectId}`, error);
2124
setConversations([]);
2225
}
2326
};
2427

25-
if (params.projectId) {
28+
if (projectId) {
2629
fetchConversations();
2730
}
28-
}, [params.projectId]);
31+
}, [projectId]);
2932

3033
const handleDeleteConversation = async (conversationId: string) => {
3134
try {
@@ -47,7 +50,7 @@ export default function ProjectPastConversationsPage({ params }: { params: { pro
4750
Browse and manage your previous conversations for this project.
4851
</p>
4952
</div>
50-
<Link href={`/projects/${params.projectId}`}>
53+
<Link href={`/projects/${projectId}`}>
5154
<Button variant="outline">
5255
<Plus className="mr-2 h-4 w-4" /> New Chat
5356
</Button>
@@ -56,7 +59,7 @@ export default function ProjectPastConversationsPage({ params }: { params: { pro
5659
<ConversationHistory
5760
conversations={conversations}
5861
onDelete={handleDeleteConversation}
59-
hrefGenerator={(conversation) => `/projects/${params.projectId}/conversations/${conversation.id}`}
62+
hrefGenerator={(conversation) => `/projects/${projectId}/conversations/${conversation.id}`}
6063
/>
6164
</div>
6265
);

0 commit comments

Comments
 (0)