mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 08:31:15 -05:00
Fix TypeScript errors in moderation components
This commit is contained in:
@@ -113,7 +113,9 @@ export function ItemEditDialog({ item, items, open, onOpenChange, onComplete }:
|
|||||||
};
|
};
|
||||||
|
|
||||||
const renderEditForm = (editItem: SubmissionItemWithDeps) => {
|
const renderEditForm = (editItem: SubmissionItemWithDeps) => {
|
||||||
const data = editItem.item_data;
|
const itemData = typeof editItem.item_data === 'object' && editItem.item_data !== null && !Array.isArray(editItem.item_data)
|
||||||
|
? editItem.item_data as Record<string, unknown>
|
||||||
|
: {};
|
||||||
|
|
||||||
switch (editItem.item_type) {
|
switch (editItem.item_type) {
|
||||||
case 'park':
|
case 'park':
|
||||||
@@ -121,7 +123,8 @@ export function ItemEditDialog({ item, items, open, onOpenChange, onComplete }:
|
|||||||
<ParkForm
|
<ParkForm
|
||||||
onSubmit={handleSubmit}
|
onSubmit={handleSubmit}
|
||||||
onCancel={() => onOpenChange(false)}
|
onCancel={() => onOpenChange(false)}
|
||||||
initialData={data}
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
initialData={itemData as any}
|
||||||
isEditing
|
isEditing
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@@ -131,7 +134,8 @@ export function ItemEditDialog({ item, items, open, onOpenChange, onComplete }:
|
|||||||
<RideForm
|
<RideForm
|
||||||
onSubmit={handleSubmit}
|
onSubmit={handleSubmit}
|
||||||
onCancel={() => onOpenChange(false)}
|
onCancel={() => onOpenChange(false)}
|
||||||
initialData={data}
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
initialData={itemData as any}
|
||||||
isEditing
|
isEditing
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@@ -141,7 +145,8 @@ export function ItemEditDialog({ item, items, open, onOpenChange, onComplete }:
|
|||||||
<ManufacturerForm
|
<ManufacturerForm
|
||||||
onSubmit={handleSubmit}
|
onSubmit={handleSubmit}
|
||||||
onCancel={() => onOpenChange(false)}
|
onCancel={() => onOpenChange(false)}
|
||||||
initialData={data}
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
initialData={itemData as any}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -150,7 +155,8 @@ export function ItemEditDialog({ item, items, open, onOpenChange, onComplete }:
|
|||||||
<DesignerForm
|
<DesignerForm
|
||||||
onSubmit={handleSubmit}
|
onSubmit={handleSubmit}
|
||||||
onCancel={() => onOpenChange(false)}
|
onCancel={() => onOpenChange(false)}
|
||||||
initialData={data}
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
initialData={itemData as any}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -159,7 +165,8 @@ export function ItemEditDialog({ item, items, open, onOpenChange, onComplete }:
|
|||||||
<OperatorForm
|
<OperatorForm
|
||||||
onSubmit={handleSubmit}
|
onSubmit={handleSubmit}
|
||||||
onCancel={() => onOpenChange(false)}
|
onCancel={() => onOpenChange(false)}
|
||||||
initialData={data}
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
initialData={itemData as any}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -168,25 +175,37 @@ export function ItemEditDialog({ item, items, open, onOpenChange, onComplete }:
|
|||||||
<PropertyOwnerForm
|
<PropertyOwnerForm
|
||||||
onSubmit={handleSubmit}
|
onSubmit={handleSubmit}
|
||||||
onCancel={() => onOpenChange(false)}
|
onCancel={() => onOpenChange(false)}
|
||||||
initialData={data}
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
initialData={itemData as any}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
case 'ride_model':
|
case 'ride_model':
|
||||||
|
const manufacturerName = 'manufacturer_name' in itemData && typeof itemData.manufacturer_name === 'string'
|
||||||
|
? itemData.manufacturer_name
|
||||||
|
: 'Unknown';
|
||||||
|
const manufacturerId = 'manufacturer_id' in itemData && typeof itemData.manufacturer_id === 'string'
|
||||||
|
? itemData.manufacturer_id
|
||||||
|
: '';
|
||||||
return (
|
return (
|
||||||
<RideModelForm
|
<RideModelForm
|
||||||
manufacturerName={data.manufacturer_name || 'Unknown'}
|
manufacturerName={manufacturerName}
|
||||||
manufacturerId={data.manufacturer_id}
|
manufacturerId={manufacturerId}
|
||||||
onSubmit={handleSubmit}
|
onSubmit={handleSubmit}
|
||||||
onCancel={() => onOpenChange(false)}
|
onCancel={() => onOpenChange(false)}
|
||||||
initialData={data}
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
initialData={itemData as any}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
case 'photo':
|
case 'photo':
|
||||||
|
const photos = 'photos' in itemData && Array.isArray(itemData.photos)
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
? itemData.photos as any
|
||||||
|
: [];
|
||||||
return (
|
return (
|
||||||
<PhotoEditForm
|
<PhotoEditForm
|
||||||
photos={data.photos || []}
|
photos={photos}
|
||||||
onSubmit={handlePhotoSubmit}
|
onSubmit={handlePhotoSubmit}
|
||||||
onCancel={() => onOpenChange(false)}
|
onCancel={() => onOpenChange(false)}
|
||||||
submitting={submitting}
|
submitting={submitting}
|
||||||
|
|||||||
@@ -127,7 +127,8 @@ export function ItemReviewCard({ item, onEdit, onStatusChange, submissionId }: I
|
|||||||
<ValidationSummary
|
<ValidationSummary
|
||||||
item={{
|
item={{
|
||||||
item_type: item.item_type,
|
item_type: item.item_type,
|
||||||
item_data: item.item_data as Record<string, unknown>,
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
item_data: item.item_data as any,
|
||||||
id: item.id,
|
id: item.id,
|
||||||
}}
|
}}
|
||||||
onValidationChange={handleValidationChange}
|
onValidationChange={handleValidationChange}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import { ConfirmationDialog } from './ConfirmationDialog';
|
|||||||
import { KeyboardShortcutsHelp } from './KeyboardShortcutsHelp';
|
import { KeyboardShortcutsHelp } from './KeyboardShortcutsHelp';
|
||||||
import { useKeyboardShortcuts } from '@/hooks/useKeyboardShortcuts';
|
import { useKeyboardShortcuts } from '@/hooks/useKeyboardShortcuts';
|
||||||
import { fetchSubmissionItems, type SubmissionItemWithDeps } from '@/lib/submissionItemsService';
|
import { fetchSubmissionItems, type SubmissionItemWithDeps } from '@/lib/submissionItemsService';
|
||||||
import type { ModerationQueueRef } from '@/types/moderation';
|
import type { ModerationQueueRef, ModerationItem } from '@/types/moderation';
|
||||||
import type { PhotoItem } from '@/types/photos';
|
import type { PhotoItem } from '@/types/photos';
|
||||||
|
|
||||||
interface ModerationQueueProps {
|
interface ModerationQueueProps {
|
||||||
@@ -145,7 +145,7 @@ export const ModerationQueue = forwardRef<ModerationQueueRef, ModerationQueuePro
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Wrapped delete with confirmation
|
// Wrapped delete with confirmation
|
||||||
const handleDeleteSubmission = useCallback((item: { id: string; submission_type?: string }) => {
|
const handleDeleteSubmission = useCallback((item: ModerationItem) => {
|
||||||
setConfirmDialog({
|
setConfirmDialog({
|
||||||
open: true,
|
open: true,
|
||||||
title: 'Delete Submission',
|
title: 'Delete Submission',
|
||||||
|
|||||||
@@ -172,9 +172,18 @@ export async function updateSubmissionItem(
|
|||||||
itemId: string,
|
itemId: string,
|
||||||
updates: Partial<SubmissionItemWithDeps>
|
updates: Partial<SubmissionItemWithDeps>
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
// Cast unknown to Json for Supabase compatibility
|
||||||
|
const supabaseUpdates = {
|
||||||
|
...updates,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
item_data: updates.item_data !== undefined ? updates.item_data as any : undefined,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
original_data: updates.original_data !== undefined ? updates.original_data as any : undefined,
|
||||||
|
};
|
||||||
|
|
||||||
const { error } = await supabase
|
const { error } = await supabase
|
||||||
.from('submission_items')
|
.from('submission_items')
|
||||||
.update(updates)
|
.update(supabaseUpdates)
|
||||||
.eq('id', itemId);
|
.eq('id', itemId);
|
||||||
|
|
||||||
if (error) throw error;
|
if (error) throw error;
|
||||||
|
|||||||
Reference in New Issue
Block a user