11import React , { useEffect , useState } from 'react' ;
22import { useParams , Link } from 'react-router-dom' ;
3- import { Loader2 , User as UserIcon , Clock , Send } from 'lucide-react' ;
3+ import { Loader2 , User as UserIcon , Clock , Send , Quote } from 'lucide-react' ;
44import { Topic , Post , getTopic , listPosts , createPost } from '../lib/forum' ;
55import { useTranslation } from '../lib/i18n' ;
66import { useAuth } from '../lib/auth' ;
@@ -61,6 +61,10 @@ export function TopicPage() {
6161 setIsReplying ( false ) ;
6262 }
6363 } ;
64+ const handleQuote = ( author : string , body : string ) => {
65+ const quote = `> ${ author } ${ t ( 'said' ) } :\n> ${ body . replace ( / \n / g, '\n> ' ) } \n\n` ;
66+ setReplyBody ( prev => prev + quote ) ;
67+ } ;
6468 if ( isLoading ) {
6569 return (
6670 < div className = "flex justify-center items-center py-20" >
@@ -107,6 +111,15 @@ export function TopicPage() {
107111 </ div >
108112 < div className = "p-6 flex-1" >
109113 < MarkdownContent content = { topic . body } />
114+ { user && (
115+ < button
116+ onClick = { ( ) => handleQuote ( topic . author , topic . body ) }
117+ className = "mt-2 px-3 py-1 text-sm bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-300 rounded flex items-center gap-1"
118+ >
119+ < Quote className = "w-3 h-3" />
120+ { t ( 'quote' ) }
121+ </ button >
122+ ) }
110123 </ div >
111124 </ div >
112125 </ div >
@@ -132,6 +145,15 @@ export function TopicPage() {
132145 </ div >
133146 < div className = "p-6 flex-1" >
134147 < MarkdownContent content = { post . body } />
148+ { user && (
149+ < button
150+ onClick = { ( ) => handleQuote ( post . author , post . body ) }
151+ className = "mt-2 px-3 py-1 text-sm bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-300 rounded flex items-center gap-1"
152+ >
153+ < Quote className = "w-3 h-3" />
154+ { t ( 'quote' ) }
155+ </ button >
156+ ) }
135157 </ div >
136158 </ div >
137159 </ div >
0 commit comments