Fix: Resolve TypeScript errors

This commit is contained in:
gpt-engineer-app[bot]
2025-11-03 02:28:57 +00:00
parent f6c409fac4
commit 9e8e8719b4
14 changed files with 48 additions and 30 deletions

View File

@@ -253,7 +253,7 @@ export function EmailChangeDialog({ open, onOpenChange, currentEmail, userId }:
metadata: {
currentEmail,
newEmail: data.newEmail,
errorType: error.constructor.name
errorType: error instanceof Error ? error.constructor.name : 'Unknown'
}
}
);

View File

@@ -78,7 +78,7 @@ const SidebarProvider = React.forwardRef<
state,
open,
setOpen,
isMobile,
isMobile: isMobile ?? false,
openMobile,
setOpenMobile,
toggleSidebar,

View File

@@ -86,7 +86,7 @@ export function EntityMultiImageUploader({
.from('photos')
.select('id, cloudflare_image_url, cloudflare_image_id, caption, title')
.eq('entity_type', entityType)
.eq('entity_id', entityId)
.eq('entity_id', entityId || '')
.order('created_at', { ascending: false });
if (error) throw error;
@@ -314,7 +314,7 @@ export function EntityMultiImageUploader({
const existingCount = value.uploaded.filter(img => !img.isLocal).length;
const newCount = value.uploaded.filter(img => img.isLocal).length;
const parts = [];
const parts: string[] = [];
if (mode === 'edit' && existingCount > 0) {
parts.push(`${existingCount} existing photo${existingCount !== 1 ? 's' : ''}`);

View File

@@ -68,7 +68,7 @@ export function EntityPhotoGallery({
url: photo.cloudflare_image_url,
caption: photo.caption || undefined,
title: photo.title || undefined,
user_id: photo.submitted_by,
user_id: photo.submitted_by || '',
created_at: photo.created_at,
})) || [];
@@ -148,7 +148,7 @@ export function EntityPhotoGallery({
</p>
</div>
<div className="flex flex-col sm:flex-row gap-2 w-full sm:w-auto">
{isModerator && photos.length > 0 && (
{isModerator() && photos.length > 0 && (
<Button onClick={() => setShowManagement(true)} variant="outline" className="gap-2 w-full sm:w-auto">
<Settings className="w-4 h-4" />
<span className="sm:inline">Manage</span>

View File

@@ -78,7 +78,11 @@ export function PhotoManagementDialog({
.order('order_index', { ascending: true });
if (error) throw error;
setPhotos(data || []);
setPhotos((data || []).map(p => ({
...p,
order_index: p.order_index ?? 0,
is_featured: p.is_featured ?? false
})) as Photo[]);
} catch (error: unknown) {
toast({
title: 'Error',

View File

@@ -110,6 +110,9 @@ export function UppyPhotoSubmissionUpload({
const { uploadURL, id: cloudflareId } = uploadData;
// Upload file to Cloudflare
if (!photo.file) {
throw new Error('Photo file is missing');
}
const formData = new FormData();
formData.append('file', photo.file);