fix: allow generating review link for pre-existing posts
All checks were successful
Deploy / deploy (push) Successful in 12s

Show button only when post has no approval token. Once a link exists,
only the link is shown. Server preserves status for non-draft posts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
fahed
2026-03-05 17:41:42 +03:00
parent 593adbbc0b
commit 8eaea27e89
2 changed files with 11 additions and 7 deletions

View File

@@ -436,7 +436,7 @@ export default function PostDetailPanel({ post, onClose, onSave, onDelete, brand
{!isCreateMode && (
<>
{/* Submit for Review */}
{(form.status === 'draft' || form.status === 'rejected') && (
{!reviewUrl && (
<button
onClick={handleSubmitReview}
disabled={submittingReview}

View File

@@ -1480,14 +1480,18 @@ app.post('/api/posts/:id/submit-review', requireAuth, requireOwnerOrRole('posts'
const expiresAt = new Date();
expiresAt.setDate(expiresAt.getDate() + DEFAULTS.tokenExpiryDays);
await nocodb.update('Posts', req.params.id, {
status: 'in_review',
const updateData = {
approval_token: token,
token_expires_at: expiresAt.toISOString(),
approved_by_name: null,
approved_at: null,
feedback: null,
});
};
// Only change status to in_review for draft/rejected posts
if (!existing.status || existing.status === 'draft' || existing.status === 'rejected') {
updateData.status = 'in_review';
updateData.approved_by_name = null;
updateData.approved_at = null;
updateData.feedback = null;
}
await nocodb.update('Posts', req.params.id, updateData);
const reviewUrl = `${req.protocol}://${req.get('host')}/review-post/${token}`;
res.json({ success: true, token, reviewUrl, expiresAt: expiresAt.toISOString() });