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