@@ -7,25 +7,28 @@ import Link from 'next/link';
7
7
import { Button } from '@/components/ui/button' ;
8
8
import { Plus } from 'lucide-react' ;
9
9
import ConversationHistory from '@/components/ConversationHistory' ;
10
+ import { useParams } from 'next/navigation' ;
10
11
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 ;
12
15
const [ conversations , setConversations ] = useState < Conversation [ ] > ( [ ] ) ;
13
16
14
17
useEffect ( ( ) => {
15
18
const fetchConversations = async ( ) => {
16
19
try {
17
- const response = await fetchFromApi ( `/api/projects/conversations/${ params . projectId } ` ) ;
20
+ const response = await fetchFromApi ( `/api/projects/conversations/${ projectId } ` ) ;
18
21
setConversations ( response ) ;
19
22
} catch ( error ) {
20
- console . error ( `Error fetching conversations for project ${ params . projectId } ` , error ) ;
23
+ console . error ( `Error fetching conversations for project ${ projectId } ` , error ) ;
21
24
setConversations ( [ ] ) ;
22
25
}
23
26
} ;
24
27
25
- if ( params . projectId ) {
28
+ if ( projectId ) {
26
29
fetchConversations ( ) ;
27
30
}
28
- } , [ params . projectId ] ) ;
31
+ } , [ projectId ] ) ;
29
32
30
33
const handleDeleteConversation = async ( conversationId : string ) => {
31
34
try {
@@ -47,7 +50,7 @@ export default function ProjectPastConversationsPage({ params }: { params: { pro
47
50
Browse and manage your previous conversations for this project.
48
51
</ p >
49
52
</ div >
50
- < Link href = { `/projects/${ params . projectId } ` } >
53
+ < Link href = { `/projects/${ projectId } ` } >
51
54
< Button variant = "outline" >
52
55
< Plus className = "mr-2 h-4 w-4" /> New Chat
53
56
</ Button >
@@ -56,7 +59,7 @@ export default function ProjectPastConversationsPage({ params }: { params: { pro
56
59
< ConversationHistory
57
60
conversations = { conversations }
58
61
onDelete = { handleDeleteConversation }
59
- hrefGenerator = { ( conversation ) => `/projects/${ params . projectId } /conversations/${ conversation . id } ` }
62
+ hrefGenerator = { ( conversation ) => `/projects/${ projectId } /conversations/${ conversation . id } ` }
60
63
/>
61
64
</ div >
62
65
) ;
0 commit comments