diff --git a/src/components/companies/DesignerPhotoGallery.tsx b/src/components/companies/DesignerPhotoGallery.tsx new file mode 100644 index 00000000..4c6ff083 --- /dev/null +++ b/src/components/companies/DesignerPhotoGallery.tsx @@ -0,0 +1,23 @@ +import { EntityPhotoGallery } from '@/components/upload/EntityPhotoGallery'; + +interface DesignerPhotoGalleryProps { + designerId: string; + designerName: string; +} + +/** + * Wrapper for designer photo galleries + * Uses the generic EntityPhotoGallery component internally + */ +export function DesignerPhotoGallery({ + designerId, + designerName +}: DesignerPhotoGalleryProps) { + return ( + + ); +} diff --git a/src/components/companies/ManufacturerPhotoGallery.tsx b/src/components/companies/ManufacturerPhotoGallery.tsx new file mode 100644 index 00000000..ae1555fd --- /dev/null +++ b/src/components/companies/ManufacturerPhotoGallery.tsx @@ -0,0 +1,23 @@ +import { EntityPhotoGallery } from '@/components/upload/EntityPhotoGallery'; + +interface ManufacturerPhotoGalleryProps { + manufacturerId: string; + manufacturerName: string; +} + +/** + * Wrapper for manufacturer photo galleries + * Uses the generic EntityPhotoGallery component internally + */ +export function ManufacturerPhotoGallery({ + manufacturerId, + manufacturerName +}: ManufacturerPhotoGalleryProps) { + return ( + + ); +} diff --git a/src/components/companies/OperatorPhotoGallery.tsx b/src/components/companies/OperatorPhotoGallery.tsx new file mode 100644 index 00000000..7488f788 --- /dev/null +++ b/src/components/companies/OperatorPhotoGallery.tsx @@ -0,0 +1,23 @@ +import { EntityPhotoGallery } from '@/components/upload/EntityPhotoGallery'; + +interface OperatorPhotoGalleryProps { + operatorId: string; + operatorName: string; +} + +/** + * Wrapper for operator photo galleries + * Uses the generic EntityPhotoGallery component internally + */ +export function OperatorPhotoGallery({ + operatorId, + operatorName +}: OperatorPhotoGalleryProps) { + return ( + + ); +} diff --git a/src/components/companies/PropertyOwnerPhotoGallery.tsx b/src/components/companies/PropertyOwnerPhotoGallery.tsx new file mode 100644 index 00000000..8338e8c0 --- /dev/null +++ b/src/components/companies/PropertyOwnerPhotoGallery.tsx @@ -0,0 +1,23 @@ +import { EntityPhotoGallery } from '@/components/upload/EntityPhotoGallery'; + +interface PropertyOwnerPhotoGalleryProps { + propertyOwnerId: string; + propertyOwnerName: string; +} + +/** + * Wrapper for property owner photo galleries + * Uses the generic EntityPhotoGallery component internally + */ +export function PropertyOwnerPhotoGallery({ + propertyOwnerId, + propertyOwnerName +}: PropertyOwnerPhotoGalleryProps) { + return ( + + ); +} diff --git a/src/components/moderation/ModerationQueue.tsx b/src/components/moderation/ModerationQueue.tsx index 7820b4a1..c722d83f 100644 --- a/src/components/moderation/ModerationQueue.tsx +++ b/src/components/moderation/ModerationQueue.tsx @@ -172,8 +172,10 @@ export const ModerationQueue = forwardRef((props, ref) => { // Handle both old format (context as object) and new format (context as string) let contextType = null; + let entityId = null; let rideId = null; let parkId = null; + let companyId = null; if (typeof contentObj.context === 'object' && contentObj.context !== null) { // OLD FORMAT: context is an object like {ride_id: "...", park_id: "..."} @@ -183,11 +185,20 @@ export const ModerationQueue = forwardRef((props, ref) => { } else if (typeof contentObj.context === 'string') { // NEW FORMAT: context is a string, IDs are at top level contextType = contentObj.context; + entityId = contentObj.entity_id; rideId = contentObj.ride_id; parkId = contentObj.park_id; + companyId = contentObj.company_id; } - if (contextType === 'ride' && rideId) { + // Determine entity ID based on context type + if (!entityId) { + if (contextType === 'ride') entityId = rideId; + else if (contextType === 'park') entityId = parkId; + else if (['manufacturer', 'operator', 'designer', 'property_owner'].includes(contextType)) entityId = companyId; + } + + if (contextType === 'ride' && entityId) { const { data: rideData } = await supabase .from('rides') .select(` @@ -196,23 +207,34 @@ export const ModerationQueue = forwardRef((props, ref) => { name ) `) - .eq('id', rideId) + .eq('id', entityId) .single(); if (rideData) { (submission as any).entity_name = rideData.name; (submission as any).park_name = rideData.parks?.name; } - } else if (contextType === 'park' && parkId) { + } else if (contextType === 'park' && entityId) { const { data: parkData } = await supabase .from('parks') .select('name') - .eq('id', parkId) + .eq('id', entityId) .single(); if (parkData) { (submission as any).entity_name = parkData.name; } + } else if (['manufacturer', 'operator', 'designer', 'property_owner'].includes(contextType) && entityId) { + const { data: companyData } = await supabase + .from('companies') + .select('name, company_type') + .eq('id', entityId) + .single(); + + if (companyData) { + (submission as any).entity_name = companyData.name; + (submission as any).company_type = companyData.company_type; + } } } } diff --git a/src/components/parks/ParkPhotoGallery.tsx b/src/components/parks/ParkPhotoGallery.tsx new file mode 100644 index 00000000..694067ce --- /dev/null +++ b/src/components/parks/ParkPhotoGallery.tsx @@ -0,0 +1,20 @@ +import { EntityPhotoGallery } from '@/components/upload/EntityPhotoGallery'; + +interface ParkPhotoGalleryProps { + parkId: string; + parkName: string; +} + +/** + * Backwards-compatible wrapper for ParkPhotoGallery + * Uses the generic EntityPhotoGallery component internally + */ +export function ParkPhotoGallery({ parkId, parkName }: ParkPhotoGalleryProps) { + return ( + + ); +} diff --git a/src/components/upload/PhotoSubmissionUpload.tsx b/src/components/upload/PhotoSubmissionUpload.tsx index c53dd031..85f8a871 100644 --- a/src/components/upload/PhotoSubmissionUpload.tsx +++ b/src/components/upload/PhotoSubmissionUpload.tsx @@ -1,3 +1,12 @@ +/** + * @deprecated This component is deprecated. Use UppyPhotoSubmissionUpload instead. + * This file is kept for backwards compatibility only. + * + * For new implementations, use: + * - UppyPhotoSubmissionUpload for direct uploads + * - EntityPhotoGallery for entity-specific photo galleries + */ + import { useState } from 'react'; import { Upload, X, Camera } from 'lucide-react'; import { Button } from '@/components/ui/button'; diff --git a/src/components/upload/UppyPhotoSubmissionUpload.tsx b/src/components/upload/UppyPhotoSubmissionUpload.tsx index 618bccfe..e61dc9a9 100644 --- a/src/components/upload/UppyPhotoSubmissionUpload.tsx +++ b/src/components/upload/UppyPhotoSubmissionUpload.tsx @@ -207,6 +207,15 @@ export function UppyPhotoSubmissionUpload({ }, }; + // Debug logging for verification + console.log('Photo Submission Data:', { + entity_id: finalEntityId, + context: finalEntityType, + parent_id: finalParentId, + photo_count: photos.length, + submission_data: submissionData + }); + const { error } = await supabase .from('content_submissions') .insert(submissionData); diff --git a/src/pages/ParkDetail.tsx b/src/pages/ParkDetail.tsx index 6768ea53..2a21189c 100644 --- a/src/pages/ParkDetail.tsx +++ b/src/pages/ParkDetail.tsx @@ -11,6 +11,7 @@ import { ReviewsSection } from '@/components/reviews/ReviewsSection'; import { RideCard } from '@/components/rides/RideCard'; import { Park, Ride } from '@/types/database'; import { ParkLocationMap } from '@/components/maps/ParkLocationMap'; +import { EntityPhotoGallery } from '@/components/upload/EntityPhotoGallery'; import { supabase } from '@/integrations/supabase/client'; export default function ParkDetail() { const { @@ -424,13 +425,11 @@ export default function ParkDetail() { -
- -

Photo Gallery Coming Soon

-

- Photo galleries and media uploads will be available soon -

-
+
diff --git a/src/pages/RideDetail.tsx b/src/pages/RideDetail.tsx index f30df8d7..d8f22e70 100644 --- a/src/pages/RideDetail.tsx +++ b/src/pages/RideDetail.tsx @@ -627,6 +627,7 @@ export default function RideDetail() {