Refactor: Implement cleanup plan

This commit is contained in:
gpt-engineer-app[bot]
2025-10-03 13:54:27 +00:00
parent c51c848da4
commit f061bb9d5f
9 changed files with 49 additions and 155 deletions

View File

@@ -20,14 +20,7 @@ export function UppyPhotoSubmissionUpload({
entityId,
entityType,
parentId,
// Legacy props (deprecated)
parkId,
rideId,
}: UppyPhotoSubmissionUploadProps) {
// Support legacy props
const finalEntityId = entityId || rideId || parkId || '';
const finalEntityType = entityType || (rideId ? 'ride' : parkId ? 'park' : 'ride');
const finalParentId = parentId || (rideId ? parkId : undefined);
const [title, setTitle] = useState('');
const [photos, setPhotos] = useState<PhotoWithCaption[]>([]);
const [isSubmitting, setIsSubmitting] = useState(false);
@@ -203,9 +196,9 @@ export function UppyPhotoSubmissionUpload({
.from('photo_submissions')
.insert({
submission_id: submissionData.id,
entity_type: finalEntityType,
entity_id: finalEntityId,
parent_id: finalParentId || null,
entity_type: entityType,
entity_id: entityId,
parent_id: parentId || null,
title: title.trim() || null,
})
.select()
@@ -239,8 +232,8 @@ export function UppyPhotoSubmissionUpload({
console.log('✅ Photo submission created:', {
submission_id: submissionData.id,
photo_submission_id: photoSubmissionData.id,
entity_type: finalEntityType,
entity_id: finalEntityId,
entity_type: entityType,
entity_id: entityId,
photo_count: photoItems.length,
});
@@ -285,12 +278,9 @@ export function UppyPhotoSubmissionUpload({
const metadata = {
submissionType: 'photo',
entityId: finalEntityId,
entityType: finalEntityType,
parentId: finalParentId,
// Legacy support
parkId: finalEntityType === 'park' ? finalEntityId : finalParentId,
rideId: finalEntityType === 'ride' ? finalEntityId : undefined,
entityId,
entityType,
parentId,
userId: user?.id,
};