mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 20:51:13 -05:00
feat: Implement submission reset functionality
This commit is contained in:
@@ -733,6 +733,45 @@ function resolveDependencies(data: any, dependencyMap: Map<string, string>): any
|
||||
return resolved;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset rejected items back to pending status
|
||||
*/
|
||||
export async function resetRejectedItemsToPending(
|
||||
submissionId: string
|
||||
): Promise<void> {
|
||||
// Reset rejected submission items to pending
|
||||
const { error: itemsError } = await supabase
|
||||
.from('submission_items')
|
||||
.update({
|
||||
status: 'pending',
|
||||
rejection_reason: null,
|
||||
updated_at: new Date().toISOString()
|
||||
})
|
||||
.eq('submission_id', submissionId)
|
||||
.eq('status', 'rejected');
|
||||
|
||||
if (itemsError) {
|
||||
throw new Error(`Failed to reset items: ${itemsError.message}`);
|
||||
}
|
||||
|
||||
// Reset parent submission to pending
|
||||
const { error: submissionError } = await supabase
|
||||
.from('content_submissions')
|
||||
.update({
|
||||
status: 'pending',
|
||||
reviewed_at: null,
|
||||
reviewer_id: null,
|
||||
reviewer_notes: null,
|
||||
updated_at: new Date().toISOString()
|
||||
})
|
||||
.eq('id', submissionId)
|
||||
.in('status', ['rejected', 'partially_approved']);
|
||||
|
||||
if (submissionError) {
|
||||
throw new Error(`Failed to reset submission: ${submissionError.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reject multiple items with optional cascade to dependents
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user