mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 08:11:13 -05:00
Fix moderation queue issues
This commit is contained in:
@@ -8,8 +8,16 @@
|
||||
import { z } from 'zod';
|
||||
import { logger } from '@/lib/logger';
|
||||
|
||||
// Profile schema
|
||||
// Profile schema (matches database JSONB structure)
|
||||
const ProfileSchema = z.object({
|
||||
user_id: z.string().uuid(),
|
||||
username: z.string(),
|
||||
display_name: z.string().optional().nullable(),
|
||||
avatar_url: z.string().optional().nullable(),
|
||||
});
|
||||
|
||||
// Legacy profile schema (for backward compatibility)
|
||||
const LegacyProfileSchema = z.object({
|
||||
username: z.string(),
|
||||
display_name: z.string().optional().nullable(),
|
||||
avatar_url: z.string().optional().nullable(),
|
||||
@@ -31,19 +39,42 @@ export const ModerationItemSchema = z.object({
|
||||
status: z.enum(['pending', 'approved', 'rejected', 'partially_approved', 'flagged']),
|
||||
type: z.string(),
|
||||
submission_type: z.string(),
|
||||
|
||||
// Accept both created_at and submitted_at for flexibility
|
||||
created_at: z.string(),
|
||||
submitted_at: z.string().optional(),
|
||||
updated_at: z.string().optional().nullable(),
|
||||
reviewed_at: z.string().optional().nullable(),
|
||||
|
||||
content: z.record(z.string(), z.any()),
|
||||
submitter_id: z.string().uuid(),
|
||||
|
||||
// User fields (support both old and new naming)
|
||||
submitter_id: z.string().uuid().optional(),
|
||||
user_id: z.string().uuid().optional(),
|
||||
|
||||
assigned_to: z.string().uuid().optional().nullable(),
|
||||
locked_until: z.string().optional().nullable(),
|
||||
reviewed_at: z.string().optional().nullable(),
|
||||
reviewed_by: z.string().uuid().optional().nullable(),
|
||||
reviewer_notes: z.string().optional().nullable(),
|
||||
submission_items: z.array(SubmissionItemSchema).optional(),
|
||||
|
||||
// Escalation fields
|
||||
escalated: z.boolean().optional().default(false),
|
||||
escalation_reason: z.string().optional().nullable(),
|
||||
|
||||
// Profile objects (new structure from view)
|
||||
submitter_profile: ProfileSchema.optional().nullable(),
|
||||
assigned_profile: ProfileSchema.optional().nullable(),
|
||||
reviewer_profile: ProfileSchema.optional().nullable(),
|
||||
|
||||
// Legacy profile support
|
||||
user_profile: LegacyProfileSchema.optional().nullable(),
|
||||
|
||||
// Submission items
|
||||
submission_items: z.array(SubmissionItemSchema).optional(),
|
||||
|
||||
// Entity names
|
||||
entity_name: z.string().optional(),
|
||||
park_name: z.string().optional(),
|
||||
});
|
||||
|
||||
export const ModerationItemArraySchema = z.array(ModerationItemSchema);
|
||||
|
||||
Reference in New Issue
Block a user