mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 15:11:13 -05:00
feat: Implement Novu subscriber update
This commit is contained in:
@@ -1069,6 +1069,26 @@ export async function editSubmissionItem(
|
||||
|
||||
if (updateError) throw updateError;
|
||||
|
||||
// CRITICAL: Create version history if this is an entity edit (not photo)
|
||||
// Only create version if this item has already been approved (has approved_entity_id)
|
||||
if (currentItem.item_type !== 'photo' && currentItem.approved_entity_id) {
|
||||
try {
|
||||
await createVersionForApprovedItem(
|
||||
currentItem.item_type,
|
||||
currentItem.approved_entity_id,
|
||||
userId,
|
||||
currentItem.submission_id,
|
||||
true // isEdit = true
|
||||
);
|
||||
|
||||
console.log(`✅ Created version for manual edit of ${currentItem.item_type} ${currentItem.approved_entity_id}`);
|
||||
} catch (versionError) {
|
||||
console.error('Failed to create version for manual edit:', versionError);
|
||||
// Don't fail the entire operation, just log the error
|
||||
// The edit itself is still saved, just without version history
|
||||
}
|
||||
}
|
||||
|
||||
// Log admin action
|
||||
await supabase
|
||||
.from('admin_audit_log')
|
||||
@@ -1079,7 +1099,8 @@ export async function editSubmissionItem(
|
||||
details: {
|
||||
item_id: itemId,
|
||||
item_type: currentItem.item_type,
|
||||
changes: 'Item data updated',
|
||||
changes: 'Item data updated with version history',
|
||||
version_created: !!(currentItem.approved_entity_id && currentItem.item_type !== 'photo'),
|
||||
},
|
||||
});
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user