Import source: app/src/admin/ReviewPanel

Import the existing local project snapshot. This commit organizes existing files; it does not represent newly developed functionality.
This commit is contained in:
arsam
2026-09-18 23:24:08 +03:30
parent 9c1b3d2435
commit e596d55237
+27
View File
@@ -0,0 +1,27 @@
import { useState, useEffect } from 'react';
import { useToast, pillBtn } from '../../teknav-ui.jsx';
import { adminApi } from '../lib/admin-api.js';
import { BRAND, PanelState } from './Shared.jsx';
function ReviewsPanel() {
const [items, setItems] = useState([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(false);
const load = () => adminApi.listReviews().then(setItems).catch(() => setError(true)).finally(() => setLoading(false));
useEffect(() => { load(); }, []);
const update = async (articleId, status) => { await adminApi.updateReview(articleId, { status }); load(); };
if (loading || error || items.length === 0) return <PanelState loading={loading} error={error} empty={!loading && !error && items.length === 0} emptyTitle="موردی در گردش بررسی وجود ندارد" />;
return items.map(item => (
<div key={item.id} style={{ background: '#fff', border: '1px solid #E4DDD2', borderRadius: 12, padding: 16, marginBottom: 12, direction: 'rtl' }}>
<div style={{ fontWeight: 900, color: BRAND.ink, marginBottom: 4 }}>{item.article?.title}</div>
<div style={{ fontSize: 12, color: '#5F6B6D', marginBottom: 12 }}>{item.status} · {item.reviewer?.name ?? 'بدون بازبین'}</div>
<div style={{ display: 'flex', gap: 8, flexWrap: 'wrap' }}>
<button onClick={() => update(item.article.id, 'approved')} style={{ ...pillBtn, background: '#0F6B73', color: '#fff' }}>تأیید</button>
<button onClick={() => update(item.article.id, 'revision_requested')} style={{ ...pillBtn, background: '#F4EFE6', color: '#C46A4D', border: '1px solid #E4DDD2' }}>نیاز به اصلاح</button>
<button onClick={() => update(item.article.id, 'rejected')} style={{ ...pillBtn, background: '#C94C4C', color: '#fff' }}>رد</button>
</div>
</div>
));
}
export { ReviewsPanel };