feat: Implement Novu subscriber update

This commit is contained in:
gpt-engineer-app[bot]
2025-10-15 16:49:58 +00:00
parent fca235269f
commit 4b697fe45a
6 changed files with 128 additions and 118 deletions

View File

@@ -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 {