Reverted to commit cd76e30ed9

This commit is contained in:
gpt-engineer-app[bot]
2025-09-30 14:08:41 +00:00
parent b0d3af234e
commit a7288a0d4c
5 changed files with 32 additions and 664 deletions

View File

@@ -4,10 +4,8 @@ import { Button } from '@/components/ui/button';
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group';
import { Label } from '@/components/ui/label';
import { Alert, AlertDescription } from '@/components/ui/alert';
import { AlertCircle, Loader2 } from 'lucide-react';
import { toast } from 'sonner';
import { type DependencyConflict, type SubmissionItemWithDeps, resolveConflicts } from '@/lib/submissionItemsService';
import { useAuth } from '@/hooks/useAuth';
import { AlertCircle } from 'lucide-react';
import { type DependencyConflict, type SubmissionItemWithDeps } from '@/lib/submissionItemsService';
interface ConflictResolutionDialogProps {
open: boolean;
@@ -24,9 +22,7 @@ export function ConflictResolutionDialog({
items,
onResolve,
}: ConflictResolutionDialogProps) {
const { user } = useAuth();
const [resolutions, setResolutions] = useState<Record<string, string>>({});
const [isProcessing, setIsProcessing] = useState(false);
const handleResolutionChange = (itemId: string, action: string) => {
setResolutions(prev => ({ ...prev, [itemId]: action }));
@@ -36,36 +32,10 @@ export function ConflictResolutionDialog({
conflict => resolutions[conflict.itemId]
);
const handleApply = async () => {
if (!user) {
toast.error('You must be logged in to resolve conflicts');
return;
}
setIsProcessing(true);
try {
const { updatedItems, newConflicts } = await resolveConflicts(
conflicts,
resolutions,
items,
user.id
);
if (newConflicts.length > 0) {
toast.error(`Resolution completed with ${newConflicts.length} remaining conflicts`);
} else {
toast.success('All conflicts resolved successfully');
}
onResolve();
onOpenChange(false);
} catch (error) {
console.error('Error resolving conflicts:', error);
toast.error(error instanceof Error ? error.message : 'Failed to resolve conflicts');
} finally {
setIsProcessing(false);
}
const handleApply = () => {
// TODO: Apply resolutions
onResolve();
onOpenChange(false);
};
return (
@@ -113,12 +83,11 @@ export function ConflictResolutionDialog({
</div>
<DialogFooter>
<Button variant="outline" onClick={() => onOpenChange(false)} disabled={isProcessing}>
<Button variant="outline" onClick={() => onOpenChange(false)}>
Cancel
</Button>
<Button onClick={handleApply} disabled={!allConflictsResolved || isProcessing}>
{isProcessing && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
{isProcessing ? 'Processing...' : 'Apply & Approve'}
<Button onClick={handleApply} disabled={!allConflictsResolved}>
Apply & Approve
</Button>
</DialogFooter>
</DialogContent>

View File

@@ -1,215 +0,0 @@
import { useState } from 'react';
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog';
import { Sheet, SheetContent, SheetHeader, SheetTitle } from '@/components/ui/sheet';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import { Button } from '@/components/ui/button';
import { ParkForm } from '@/components/admin/ParkForm';
import { RideForm } from '@/components/admin/RideForm';
import { ManufacturerForm } from '@/components/admin/ManufacturerForm';
import { DesignerForm } from '@/components/admin/DesignerForm';
import { OperatorForm } from '@/components/admin/OperatorForm';
import { PropertyOwnerForm } from '@/components/admin/PropertyOwnerForm';
import { RideModelForm } from '@/components/admin/RideModelForm';
import { PhotoCaptionEditor } from '@/components/upload/PhotoCaptionEditor';
import { useIsMobile } from '@/hooks/use-mobile';
import { editSubmissionItem } from '@/lib/submissionItemsService';
import { useAuth } from '@/hooks/useAuth';
import { toast } from '@/hooks/use-toast';
import type { SubmissionItemWithDeps } from '@/lib/submissionItemsService';
interface ItemEditDialogProps {
open: boolean;
onOpenChange: (open: boolean) => void;
item: SubmissionItemWithDeps | null;
onEditComplete: () => void;
}
export function ItemEditDialog({ open, onOpenChange, item, onEditComplete }: ItemEditDialogProps) {
const isMobile = useIsMobile();
const { user } = useAuth();
const [isSubmitting, setIsSubmitting] = useState(false);
if (!item) return null;
const handleFormSubmit = async (data: any) => {
if (!user) {
toast({
title: "Authentication Required",
description: "You must be logged in to edit items.",
variant: "destructive"
});
return;
}
setIsSubmitting(true);
try {
await editSubmissionItem(item.id, data, user.id);
toast({
title: "Item Updated",
description: "The submission item has been updated successfully."
});
onOpenChange(false);
onEditComplete();
} catch (error: any) {
toast({
title: "Error",
description: error.message || "Failed to update submission item.",
variant: "destructive"
});
} finally {
setIsSubmitting(false);
}
};
const handleCancel = () => {
if (!isSubmitting) {
onOpenChange(false);
}
};
const renderForm = () => {
const itemData = item.item_data as any;
switch (item.item_type) {
case 'park':
return (
<ParkForm
initialData={itemData}
onSubmit={handleFormSubmit}
onCancel={handleCancel}
isEditing={true}
/>
);
case 'ride':
return (
<RideForm
initialData={itemData}
onSubmit={handleFormSubmit}
onCancel={handleCancel}
isEditing={true}
/>
);
case 'manufacturer':
return (
<ManufacturerForm
initialData={itemData}
onSubmit={handleFormSubmit}
onCancel={handleCancel}
/>
);
case 'designer':
return (
<DesignerForm
initialData={itemData}
onSubmit={handleFormSubmit}
onCancel={handleCancel}
/>
);
case 'operator':
return (
<OperatorForm
initialData={itemData}
onSubmit={handleFormSubmit}
onCancel={handleCancel}
/>
);
case 'property_owner':
return (
<PropertyOwnerForm
initialData={itemData}
onSubmit={handleFormSubmit}
onCancel={handleCancel}
/>
);
case 'ride_model':
return (
<RideModelForm
manufacturerName={itemData.manufacturer_name || 'Unknown'}
manufacturerId={itemData.manufacturer_id}
initialData={itemData}
onSubmit={handleFormSubmit}
onCancel={handleCancel}
/>
);
case 'photo':
return (
<div className="space-y-4 p-4">
<div className="space-y-2">
<Label htmlFor="caption">Caption</Label>
<Input
id="caption"
defaultValue={itemData.caption || ''}
onChange={(e) => {
itemData.caption = e.target.value;
}}
placeholder="Enter photo caption"
/>
</div>
{itemData.image_url && (
<img
src={itemData.image_url}
alt="Preview"
className="w-full rounded-md"
/>
)}
<div className="flex gap-2 justify-end">
<Button variant="outline" onClick={handleCancel}>Cancel</Button>
<Button onClick={() => handleFormSubmit(itemData)}>Save</Button>
</div>
</div>
);
default:
return (
<div className="p-4 text-center text-muted-foreground">
Form not available for item type: {item.item_type}
</div>
);
}
};
const content = (
<>
{isMobile ? (
<SheetHeader>
<SheetTitle>Edit {item.item_type.replace('_', ' ')}</SheetTitle>
</SheetHeader>
) : (
<DialogHeader>
<DialogTitle>Edit {item.item_type.replace('_', ' ')}</DialogTitle>
</DialogHeader>
)}
<div className="mt-4 max-h-[calc(100vh-150px)] overflow-y-auto">
{renderForm()}
</div>
</>
);
if (isMobile) {
return (
<Sheet open={open} onOpenChange={onOpenChange}>
<SheetContent side="bottom" className="h-[95vh]">
{content}
</SheetContent>
</Sheet>
);
}
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="max-w-4xl max-h-[90vh] overflow-y-auto">
{content}
</DialogContent>
</Dialog>
);
}

View File

@@ -141,11 +141,6 @@ export function ItemReviewCard({ item, onEdit, onStatusChange }: ItemReviewCardP
<Edit className="w-3 h-3" />
</Button>
)}
{item.original_data && (
<Badge variant="secondary" className="text-xs">
Edited
</Badge>
)}
</div>
</div>
</CardHeader>

View File

@@ -27,7 +27,6 @@ import { DependencyVisualizer } from './DependencyVisualizer';
import { ConflictResolutionDialog } from './ConflictResolutionDialog';
import { EscalationDialog } from './EscalationDialog';
import { RejectionDialog } from './RejectionDialog';
import { ItemEditDialog } from './ItemEditDialog';
interface SubmissionReviewManagerProps {
submissionId: string;
@@ -49,8 +48,6 @@ export function SubmissionReviewManager({
const [showConflictDialog, setShowConflictDialog] = useState(false);
const [showEscalationDialog, setShowEscalationDialog] = useState(false);
const [showRejectionDialog, setShowRejectionDialog] = useState(false);
const [showEditDialog, setShowEditDialog] = useState(false);
const [editingItem, setEditingItem] = useState<SubmissionItemWithDeps | null>(null);
const [activeTab, setActiveTab] = useState<'items' | 'dependencies'>('items');
const { toast } = useToast();
@@ -243,12 +240,6 @@ export function SubmissionReviewManager({
}
};
const handleEditComplete = async () => {
// Reload items after edit
await loadSubmissionItems();
setEditingItem(null);
};
const pendingCount = items.filter(item => item.status === 'pending').length;
const selectedCount = selectedItemIds.size;
@@ -301,13 +292,6 @@ export function SubmissionReviewManager({
)}
onReject={handleReject}
/>
<ItemEditDialog
open={showEditDialog}
onOpenChange={setShowEditDialog}
item={editingItem}
onEditComplete={handleEditComplete}
/>
</>
);
@@ -347,10 +331,7 @@ export function SubmissionReviewManager({
/>
<ItemReviewCard
item={item}
onEdit={() => {
setEditingItem(item);
setShowEditDialog(true);
}}
onEdit={() => {/* TODO: Implement editing */}}
onStatusChange={(status) => {/* TODO: Update status */}}
/>
</div>