Skip to content

Commit 24a4694

Browse files
committed
feat: add reply
1 parent 31609f2 commit 24a4694

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

src/lib/i18n.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ const translations = {
4242
link: 'Link',
4343
list: 'Bullet List',
4444
orderedList: 'Numbered List',
45-
quote: 'Quote'
45+
quote: 'Quote',
46+
said: 'said'
4647
},
4748
ru: {
4849
login: 'Войти',
@@ -84,7 +85,8 @@ const translations = {
8485
link: 'Ссылка',
8586
list: 'Маркированный список',
8687
orderedList: 'Нумерованный список',
87-
quote: 'Цитата'
88+
quote: 'Цитата',
89+
said: 'сказал'
8890
}
8991
};
9092

src/pages/TopicPage.tsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useEffect, useState } from 'react';
22
import { 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';
44
import { Topic, Post, getTopic, listPosts, createPost } from '../lib/forum';
55
import { useTranslation } from '../lib/i18n';
66
import { 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

Comments
 (0)