mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 11:51:14 -05:00
Update plan with remaining phases
This commit is contained in:
@@ -205,7 +205,7 @@ export async function submitParkCreation(
|
|||||||
content: {
|
content: {
|
||||||
action: 'create'
|
action: 'create'
|
||||||
},
|
},
|
||||||
status: 'pending'
|
status: 'pending' as const
|
||||||
})
|
})
|
||||||
.select()
|
.select()
|
||||||
.single();
|
.single();
|
||||||
@@ -223,7 +223,7 @@ export async function submitParkCreation(
|
|||||||
...extractChangedFields(data, {}),
|
...extractChangedFields(data, {}),
|
||||||
images: processedImages as unknown as Json
|
images: processedImages as unknown as Json
|
||||||
},
|
},
|
||||||
status: 'pending',
|
status: 'pending' as const,
|
||||||
order_index: 0
|
order_index: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -297,7 +297,7 @@ export async function submitParkUpdate(
|
|||||||
action: 'edit',
|
action: 'edit',
|
||||||
park_id: parkId
|
park_id: parkId
|
||||||
},
|
},
|
||||||
status: 'pending'
|
status: 'pending' as const
|
||||||
})
|
})
|
||||||
.select()
|
.select()
|
||||||
.single();
|
.single();
|
||||||
@@ -317,7 +317,7 @@ export async function submitParkUpdate(
|
|||||||
images: processedImages as unknown as Json
|
images: processedImages as unknown as Json
|
||||||
},
|
},
|
||||||
original_data: JSON.parse(JSON.stringify(existingPark)),
|
original_data: JSON.parse(JSON.stringify(existingPark)),
|
||||||
status: 'pending',
|
status: 'pending' as const,
|
||||||
order_index: 0
|
order_index: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -377,7 +377,7 @@ export async function submitRideCreation(
|
|||||||
content: {
|
content: {
|
||||||
action: 'create'
|
action: 'create'
|
||||||
},
|
},
|
||||||
status: 'pending'
|
status: 'pending' as const
|
||||||
})
|
})
|
||||||
.select()
|
.select()
|
||||||
.single();
|
.single();
|
||||||
@@ -395,7 +395,7 @@ export async function submitRideCreation(
|
|||||||
...extractChangedFields(data, {}),
|
...extractChangedFields(data, {}),
|
||||||
images: processedImages as unknown as Json
|
images: processedImages as unknown as Json
|
||||||
},
|
},
|
||||||
status: 'pending',
|
status: 'pending' as const,
|
||||||
order_index: 0
|
order_index: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -469,7 +469,7 @@ export async function submitRideUpdate(
|
|||||||
action: 'edit',
|
action: 'edit',
|
||||||
ride_id: rideId
|
ride_id: rideId
|
||||||
},
|
},
|
||||||
status: 'pending'
|
status: 'pending' as const
|
||||||
})
|
})
|
||||||
.select()
|
.select()
|
||||||
.single();
|
.single();
|
||||||
@@ -489,7 +489,7 @@ export async function submitRideUpdate(
|
|||||||
images: processedImages as unknown as Json
|
images: processedImages as unknown as Json
|
||||||
},
|
},
|
||||||
original_data: JSON.parse(JSON.stringify(existingRide)),
|
original_data: JSON.parse(JSON.stringify(existingRide)),
|
||||||
status: 'pending',
|
status: 'pending' as const,
|
||||||
order_index: 0
|
order_index: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -546,7 +546,7 @@ export async function submitRideModelCreation(
|
|||||||
content: {
|
content: {
|
||||||
action: 'create'
|
action: 'create'
|
||||||
},
|
},
|
||||||
status: 'pending'
|
status: 'pending' as const
|
||||||
})
|
})
|
||||||
.select()
|
.select()
|
||||||
.single();
|
.single();
|
||||||
@@ -564,7 +564,7 @@ export async function submitRideModelCreation(
|
|||||||
...extractChangedFields(data, {}),
|
...extractChangedFields(data, {}),
|
||||||
images: processedImages as unknown as Json
|
images: processedImages as unknown as Json
|
||||||
},
|
},
|
||||||
status: 'pending',
|
status: 'pending' as const,
|
||||||
order_index: 0
|
order_index: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -624,7 +624,7 @@ export async function submitRideModelUpdate(
|
|||||||
action: 'edit',
|
action: 'edit',
|
||||||
ride_model_id: rideModelId
|
ride_model_id: rideModelId
|
||||||
},
|
},
|
||||||
status: 'pending'
|
status: 'pending' as const
|
||||||
})
|
})
|
||||||
.select()
|
.select()
|
||||||
.single();
|
.single();
|
||||||
@@ -644,7 +644,7 @@ export async function submitRideModelUpdate(
|
|||||||
images: processedImages as unknown as Json
|
images: processedImages as unknown as Json
|
||||||
},
|
},
|
||||||
original_data: JSON.parse(JSON.stringify(existingModel)),
|
original_data: JSON.parse(JSON.stringify(existingModel)),
|
||||||
status: 'pending',
|
status: 'pending' as const,
|
||||||
order_index: 0
|
order_index: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -683,7 +683,7 @@ export async function submitManufacturerCreation(
|
|||||||
user_id: userId,
|
user_id: userId,
|
||||||
submission_type: 'manufacturer',
|
submission_type: 'manufacturer',
|
||||||
content: { action: 'create' },
|
content: { action: 'create' },
|
||||||
status: 'pending'
|
status: 'pending' as const
|
||||||
})
|
})
|
||||||
.select()
|
.select()
|
||||||
.single();
|
.single();
|
||||||
@@ -701,7 +701,7 @@ export async function submitManufacturerCreation(
|
|||||||
company_type: 'manufacturer',
|
company_type: 'manufacturer',
|
||||||
images: processedImages as unknown as Json
|
images: processedImages as unknown as Json
|
||||||
},
|
},
|
||||||
status: 'pending',
|
status: 'pending' as const,
|
||||||
order_index: 0
|
order_index: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -746,7 +746,7 @@ export async function submitManufacturerUpdate(
|
|||||||
user_id: userId,
|
user_id: userId,
|
||||||
submission_type: 'manufacturer',
|
submission_type: 'manufacturer',
|
||||||
content: { action: 'edit', company_id: companyId },
|
content: { action: 'edit', company_id: companyId },
|
||||||
status: 'pending'
|
status: 'pending' as const
|
||||||
})
|
})
|
||||||
.select()
|
.select()
|
||||||
.single();
|
.single();
|
||||||
@@ -766,7 +766,7 @@ export async function submitManufacturerUpdate(
|
|||||||
images: processedImages as unknown as Json
|
images: processedImages as unknown as Json
|
||||||
},
|
},
|
||||||
original_data: JSON.parse(JSON.stringify(existingCompany)),
|
original_data: JSON.parse(JSON.stringify(existingCompany)),
|
||||||
status: 'pending',
|
status: 'pending' as const,
|
||||||
order_index: 0
|
order_index: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -800,7 +800,7 @@ export async function submitDesignerCreation(
|
|||||||
user_id: userId,
|
user_id: userId,
|
||||||
submission_type: 'designer',
|
submission_type: 'designer',
|
||||||
content: { action: 'create' },
|
content: { action: 'create' },
|
||||||
status: 'pending'
|
status: 'pending' as const
|
||||||
})
|
})
|
||||||
.select()
|
.select()
|
||||||
.single();
|
.single();
|
||||||
@@ -818,7 +818,7 @@ export async function submitDesignerCreation(
|
|||||||
company_type: 'designer',
|
company_type: 'designer',
|
||||||
images: processedImages as unknown as Json
|
images: processedImages as unknown as Json
|
||||||
},
|
},
|
||||||
status: 'pending',
|
status: 'pending' as const,
|
||||||
order_index: 0
|
order_index: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -863,7 +863,7 @@ export async function submitDesignerUpdate(
|
|||||||
user_id: userId,
|
user_id: userId,
|
||||||
submission_type: 'designer',
|
submission_type: 'designer',
|
||||||
content: { action: 'edit', company_id: companyId },
|
content: { action: 'edit', company_id: companyId },
|
||||||
status: 'pending'
|
status: 'pending' as const
|
||||||
})
|
})
|
||||||
.select()
|
.select()
|
||||||
.single();
|
.single();
|
||||||
@@ -883,7 +883,7 @@ export async function submitDesignerUpdate(
|
|||||||
images: processedImages as unknown as Json
|
images: processedImages as unknown as Json
|
||||||
},
|
},
|
||||||
original_data: JSON.parse(JSON.stringify(existingCompany)),
|
original_data: JSON.parse(JSON.stringify(existingCompany)),
|
||||||
status: 'pending',
|
status: 'pending' as const,
|
||||||
order_index: 0
|
order_index: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -917,7 +917,7 @@ export async function submitOperatorCreation(
|
|||||||
user_id: userId,
|
user_id: userId,
|
||||||
submission_type: 'operator',
|
submission_type: 'operator',
|
||||||
content: { action: 'create' },
|
content: { action: 'create' },
|
||||||
status: 'pending'
|
status: 'pending' as const
|
||||||
})
|
})
|
||||||
.select()
|
.select()
|
||||||
.single();
|
.single();
|
||||||
@@ -935,7 +935,7 @@ export async function submitOperatorCreation(
|
|||||||
company_type: 'operator',
|
company_type: 'operator',
|
||||||
images: processedImages as unknown as Json
|
images: processedImages as unknown as Json
|
||||||
},
|
},
|
||||||
status: 'pending',
|
status: 'pending' as const,
|
||||||
order_index: 0
|
order_index: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -980,7 +980,7 @@ export async function submitOperatorUpdate(
|
|||||||
user_id: userId,
|
user_id: userId,
|
||||||
submission_type: 'operator',
|
submission_type: 'operator',
|
||||||
content: { action: 'edit', company_id: companyId },
|
content: { action: 'edit', company_id: companyId },
|
||||||
status: 'pending'
|
status: 'pending' as const
|
||||||
})
|
})
|
||||||
.select()
|
.select()
|
||||||
.single();
|
.single();
|
||||||
@@ -1000,7 +1000,7 @@ export async function submitOperatorUpdate(
|
|||||||
images: processedImages as unknown as Json
|
images: processedImages as unknown as Json
|
||||||
},
|
},
|
||||||
original_data: JSON.parse(JSON.stringify(existingCompany)),
|
original_data: JSON.parse(JSON.stringify(existingCompany)),
|
||||||
status: 'pending',
|
status: 'pending' as const,
|
||||||
order_index: 0
|
order_index: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1034,7 +1034,7 @@ export async function submitPropertyOwnerCreation(
|
|||||||
user_id: userId,
|
user_id: userId,
|
||||||
submission_type: 'property_owner',
|
submission_type: 'property_owner',
|
||||||
content: { action: 'create' },
|
content: { action: 'create' },
|
||||||
status: 'pending'
|
status: 'pending' as const
|
||||||
})
|
})
|
||||||
.select()
|
.select()
|
||||||
.single();
|
.single();
|
||||||
@@ -1052,7 +1052,7 @@ export async function submitPropertyOwnerCreation(
|
|||||||
company_type: 'property_owner',
|
company_type: 'property_owner',
|
||||||
images: processedImages as unknown as Json
|
images: processedImages as unknown as Json
|
||||||
},
|
},
|
||||||
status: 'pending',
|
status: 'pending' as const,
|
||||||
order_index: 0
|
order_index: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1097,7 +1097,7 @@ export async function submitPropertyOwnerUpdate(
|
|||||||
user_id: userId,
|
user_id: userId,
|
||||||
submission_type: 'property_owner',
|
submission_type: 'property_owner',
|
||||||
content: { action: 'edit', company_id: companyId },
|
content: { action: 'edit', company_id: companyId },
|
||||||
status: 'pending'
|
status: 'pending' as const
|
||||||
})
|
})
|
||||||
.select()
|
.select()
|
||||||
.single();
|
.single();
|
||||||
@@ -1117,7 +1117,7 @@ export async function submitPropertyOwnerUpdate(
|
|||||||
images: processedImages as unknown as Json
|
images: processedImages as unknown as Json
|
||||||
},
|
},
|
||||||
original_data: JSON.parse(JSON.stringify(existingCompany)),
|
original_data: JSON.parse(JSON.stringify(existingCompany)),
|
||||||
status: 'pending',
|
status: 'pending' as const,
|
||||||
order_index: 0
|
order_index: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1265,7 +1265,7 @@ export async function submitTimelineEventUpdate(
|
|||||||
action_type: 'edit',
|
action_type: 'edit',
|
||||||
item_data: itemData,
|
item_data: itemData,
|
||||||
original_data: originalEvent,
|
original_data: originalEvent,
|
||||||
status: 'pending',
|
status: 'pending' as const,
|
||||||
order_index: 0,
|
order_index: 0,
|
||||||
}
|
}
|
||||||
] as unknown as Json[],
|
] as unknown as Json[],
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export interface SubmissionItemWithDeps {
|
|||||||
item_data: any; // Complex nested structure - will be typed properly in Phase 5
|
item_data: any; // Complex nested structure - will be typed properly in Phase 5
|
||||||
original_data: any; // Complex nested structure - will be typed properly in Phase 5
|
original_data: any; // Complex nested structure - will be typed properly in Phase 5
|
||||||
action_type?: 'create' | 'edit' | 'delete';
|
action_type?: 'create' | 'edit' | 'delete';
|
||||||
status: 'pending' | 'approved' | 'rejected';
|
status: 'pending' | 'approved' | 'rejected' | 'flagged' | 'skipped'; // Matches ReviewStatus from statuses.ts
|
||||||
depends_on: string | null;
|
depends_on: string | null;
|
||||||
order_index: number;
|
order_index: number;
|
||||||
approved_entity_id: string | null;
|
approved_entity_id: string | null;
|
||||||
@@ -211,7 +211,7 @@ export async function approveSubmissionItems(
|
|||||||
|
|
||||||
// Update item status
|
// Update item status
|
||||||
await updateSubmissionItem(item.id, {
|
await updateSubmissionItem(item.id, {
|
||||||
status: 'approved',
|
status: 'approved' as const,
|
||||||
approved_entity_id: entityId,
|
approved_entity_id: entityId,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -240,7 +240,7 @@ export async function approveSubmissionItems(
|
|||||||
|
|
||||||
// Update item with error status
|
// Update item with error status
|
||||||
await updateSubmissionItem(item.id, {
|
await updateSubmissionItem(item.id, {
|
||||||
status: 'rejected',
|
status: 'rejected' as const,
|
||||||
rejection_reason: `Failed to create entity: ${errorMsg}`,
|
rejection_reason: `Failed to create entity: ${errorMsg}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -890,7 +890,7 @@ export async function resetRejectedItemsToPending(
|
|||||||
const { error: itemsError } = await supabase
|
const { error: itemsError } = await supabase
|
||||||
.from('submission_items')
|
.from('submission_items')
|
||||||
.update({
|
.update({
|
||||||
status: 'pending',
|
status: 'pending' as const,
|
||||||
rejection_reason: null,
|
rejection_reason: null,
|
||||||
updated_at: new Date().toISOString()
|
updated_at: new Date().toISOString()
|
||||||
})
|
})
|
||||||
@@ -905,7 +905,7 @@ export async function resetRejectedItemsToPending(
|
|||||||
const { error: submissionError } = await supabase
|
const { error: submissionError } = await supabase
|
||||||
.from('content_submissions')
|
.from('content_submissions')
|
||||||
.update({
|
.update({
|
||||||
status: 'pending',
|
status: 'pending' as const,
|
||||||
reviewed_at: null,
|
reviewed_at: null,
|
||||||
reviewer_id: null,
|
reviewer_id: null,
|
||||||
reviewer_notes: null,
|
reviewer_notes: null,
|
||||||
@@ -950,7 +950,7 @@ export async function rejectSubmissionItems(
|
|||||||
const { error } = await supabase
|
const { error } = await supabase
|
||||||
.from('submission_items')
|
.from('submission_items')
|
||||||
.update({
|
.update({
|
||||||
status: 'rejected',
|
status: 'rejected' as const,
|
||||||
rejection_reason: reason,
|
rejection_reason: reason,
|
||||||
updated_at: new Date().toISOString(),
|
updated_at: new Date().toISOString(),
|
||||||
})
|
})
|
||||||
@@ -1156,7 +1156,7 @@ export async function escalateSubmission(
|
|||||||
const { error } = await supabase
|
const { error } = await supabase
|
||||||
.from('content_submissions')
|
.from('content_submissions')
|
||||||
.update({
|
.update({
|
||||||
status: 'pending',
|
status: 'pending' as const,
|
||||||
escalation_reason: reason,
|
escalation_reason: reason,
|
||||||
escalated_by: userId,
|
escalated_by: userId,
|
||||||
reviewer_notes: `Escalated: ${reason}`,
|
reviewer_notes: `Escalated: ${reason}`,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { serve } from "https://deno.land/std@0.190.0/http/server.ts";
|
|||||||
import { createClient } from "https://esm.sh/@supabase/supabase-js@2.57.4";
|
import { createClient } from "https://esm.sh/@supabase/supabase-js@2.57.4";
|
||||||
import { validateEntityData, validateEntityDataStrict } from "./validation.ts";
|
import { validateEntityData, validateEntityDataStrict } from "./validation.ts";
|
||||||
import { createErrorResponse } from "../_shared/errorSanitizer.ts";
|
import { createErrorResponse } from "../_shared/errorSanitizer.ts";
|
||||||
import { edgeLogger } from "../_shared/logger.ts";
|
import { edgeLogger, startRequest, endRequest } from "../_shared/logger.ts";
|
||||||
|
|
||||||
const corsHeaders = {
|
const corsHeaders = {
|
||||||
'Access-Control-Allow-Origin': '*',
|
'Access-Control-Allow-Origin': '*',
|
||||||
@@ -47,17 +47,33 @@ const RIDE_MODEL_FIELDS = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
serve(async (req) => {
|
serve(async (req) => {
|
||||||
|
const tracking = startRequest(); // Start request tracking
|
||||||
|
|
||||||
if (req.method === 'OPTIONS') {
|
if (req.method === 'OPTIONS') {
|
||||||
return new Response(null, { headers: corsHeaders });
|
return new Response(null, { headers: corsHeaders });
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
edgeLogger.info('Processing selective approval request', {
|
||||||
|
requestId: tracking.requestId,
|
||||||
|
traceId: tracking.traceId
|
||||||
|
});
|
||||||
|
|
||||||
// Verify authentication first with a client that respects RLS
|
// Verify authentication first with a client that respects RLS
|
||||||
const authHeader = req.headers.get('Authorization');
|
const authHeader = req.headers.get('Authorization');
|
||||||
if (!authHeader) {
|
if (!authHeader) {
|
||||||
|
const duration = endRequest(tracking);
|
||||||
|
edgeLogger.warn('Authentication missing', { requestId: tracking.requestId, duration });
|
||||||
return new Response(
|
return new Response(
|
||||||
JSON.stringify({ error: 'Authentication required. Please log in.' }),
|
JSON.stringify({ error: 'Authentication required. Please log in.', requestId: tracking.requestId }),
|
||||||
{ status: 401, headers: { ...corsHeaders, 'Content-Type': 'application/json' } }
|
{
|
||||||
|
status: 401,
|
||||||
|
headers: {
|
||||||
|
...corsHeaders,
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'X-Request-ID': tracking.requestId
|
||||||
|
}
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user