feat: Implement plan for bug fixes

This commit is contained in:
gpt-engineer-app[bot]
2025-10-21 13:27:23 +00:00
parent 827f0f8ea5
commit ce6c9d6866
14 changed files with 94 additions and 59 deletions

View File

@@ -15,6 +15,8 @@ import {
import { cn } from '@/lib/utils';
import { getErrorMessage } from '@/lib/errorHandler';
import { supabase } from '@/integrations/supabase/client';
import { invokeWithTracking } from '@/lib/edgeFunctionTracking';
import { useAuth } from '@/hooks/useAuth';
interface PhotoUploadProps {
onUploadComplete?: (urls: string[], imageId?: string) => void;
@@ -111,8 +113,9 @@ export function PhotoUpload({
const uploadFile = async (file: File, previewUrl: string): Promise<UploadedImage> => {
try {
const { data: uploadData, error: uploadError } = await supabase.functions.invoke('upload-image', {
body: {
const { data: uploadData, error: uploadError, requestId } = await invokeWithTracking(
'upload-image',
{
metadata: {
filename: file.name,
size: file.size,
@@ -120,8 +123,9 @@ export function PhotoUpload({
uploadedAt: new Date().toISOString()
},
variant: isAvatar ? 'avatar' : 'public'
}
});
},
undefined
);
if (uploadError) {
console.error('Upload URL error:', uploadError);
@@ -239,10 +243,12 @@ export function PhotoUpload({
try {
if (isAvatar && currentImageId) {
try {
await supabase.functions.invoke('upload-image', {
method: 'DELETE',
body: { imageId: currentImageId }
});
await invokeWithTracking(
'upload-image',
{ imageId: currentImageId },
undefined,
'DELETE'
);
} catch (deleteError) {
console.warn('Failed to delete old avatar:', deleteError);
}

View File

@@ -1,4 +1,5 @@
import React, { useState } from 'react';
import { invokeWithTracking } from '@/lib/edgeFunctionTracking';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
@@ -96,9 +97,11 @@ export function UppyPhotoSubmissionUpload({
try {
// Get upload URL from edge function
const { data: uploadData, error: uploadError } = await supabase.functions.invoke('upload-image', {
body: { metadata: { requireSignedURLs: false }, variant: 'public' }
});
const { data: uploadData, error: uploadError } = await invokeWithTracking(
'upload-image',
{ metadata: { requireSignedURLs: false }, variant: 'public' },
user?.id
);
if (uploadError) throw uploadError;

View File

@@ -1,6 +1,7 @@
import React, { useRef, useState } from 'react';
import { supabase } from '@/integrations/supabase/client';
import { useToast } from '@/hooks/use-toast';
import { invokeWithTracking } from '@/lib/edgeFunctionTracking';
import { Button } from '@/components/ui/button';
import { Badge } from '@/components/ui/badge';
import { Upload, X, Eye, Loader2, CheckCircle } from 'lucide-react';
@@ -100,9 +101,7 @@ export function UppyPhotoUpload({
setCurrentFileName(file.name);
// Step 1: Get upload URL from Supabase edge function
const urlResponse = await supabase.functions.invoke('upload-image', {
body: { metadata, variant },
});
const urlResponse = await invokeWithTracking('upload-image', { metadata, variant }, undefined);
if (urlResponse.error) {
throw new Error(`Failed to get upload URL: ${urlResponse.error.message}`);