mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 16:31:12 -05:00
Fix: Resolve TypeScript errors
This commit is contained in:
@@ -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'
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -78,7 +78,7 @@ const SidebarProvider = React.forwardRef<
|
||||
state,
|
||||
open,
|
||||
setOpen,
|
||||
isMobile,
|
||||
isMobile: isMobile ?? false,
|
||||
openMobile,
|
||||
setOpenMobile,
|
||||
toggleSidebar,
|
||||
|
||||
@@ -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' : ''}`);
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user