fix: review link always visible for posts with approval token
All checks were successful
Deploy / deploy (push) Successful in 12s

Derived from post.approval_token instead of transient state, so it
persists when the panel is closed and reopened.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
fahed
2026-03-05 17:34:37 +03:00
parent 6203bf36e6
commit 593adbbc0b

View File

@@ -23,7 +23,6 @@ export default function PostDetailPanel({ post, onClose, onSave, onDelete, brand
// Review state // Review state
const [submittingReview, setSubmittingReview] = useState(false) const [submittingReview, setSubmittingReview] = useState(false)
const [reviewUrl, setReviewUrl] = useState('')
const [copied, setCopied] = useState(false) const [copied, setCopied] = useState(false)
// Attachments state // Attachments state
@@ -36,6 +35,7 @@ export default function PostDetailPanel({ post, onClose, onSave, onDelete, brand
const postId = post?._id || post?.id const postId = post?._id || post?.id
const isCreateMode = !postId const isCreateMode = !postId
const reviewUrl = post?.approval_token ? `${window.location.origin}/review-post/${post.approval_token}` : ''
useEffect(() => { useEffect(() => {
if (post) { if (post) {
@@ -149,8 +149,7 @@ export default function PostDetailPanel({ post, onClose, onSave, onDelete, brand
if (dirty) await handleSave() if (dirty) await handleSave()
setSubmittingReview(true) setSubmittingReview(true)
try { try {
const res = await api.post(`/posts/${postId}/submit-review`) await api.post(`/posts/${postId}/submit-review`)
setReviewUrl(res.reviewUrl || '')
setForm(f => ({ ...f, status: 'in_review' })) setForm(f => ({ ...f, status: 'in_review' }))
toast.success(t('posts.submittedForReview')) toast.success(t('posts.submittedForReview'))
onSave(postId, {}) // reload parent onSave(postId, {}) // reload parent