From 486512155893a98383115dac9855c6b04251ed8a Mon Sep 17 00:00:00 2001 From: 230417 <230417@epvc.pt> Date: Wed, 29 Apr 2026 09:53:17 +0100 Subject: [PATCH] refactor: remove avatar upload functionality and profile settings tab from Profile page --- web/src/pages/Profile.tsx | 121 ++++---------------------------------- 1 file changed, 11 insertions(+), 110 deletions(-) diff --git a/web/src/pages/Profile.tsx b/web/src/pages/Profile.tsx index 1aba7a0..57d8451 100644 --- a/web/src/pages/Profile.tsx +++ b/web/src/pages/Profile.tsx @@ -10,7 +10,7 @@ import { Badge } from '../components/ui/badge' import { Button } from '../components/ui/button' import { currency } from '../lib/format' import { useApp } from '../context/AppContext' -import { Calendar, ShoppingBag, User, Clock, Heart, Star, MapPin, CheckCircle2, Scissors, Settings, Camera, Upload } from 'lucide-react' +import { Calendar, ShoppingBag, User, Clock, Heart, Star, MapPin, CheckCircle2, Bell, Scissors } from 'lucide-react' import { supabase } from '../lib/supabase' import { ReviewModal } from '../components/ReviewModal' @@ -29,7 +29,7 @@ const statusLabel: Record = { } export default function Profile() { - const { user, appointments, orders, shops, favorites, submitReview, notifications, markNotificationRead } = useApp() + const { appointments, orders, shops, favorites, submitReview, notifications, markNotificationRead } = useApp() const navigate = useNavigate() const [authEmail, setAuthEmail] = useState('') @@ -40,8 +40,7 @@ export default function Profile() { const [reviewedAppointments, setReviewedAppointments] = useState>(new Set()) const [reviewTarget, setReviewTarget] = useState<{ appointmentId: string; shopId: string; shopName: string } | null>(null) - // Avatar local - const [avatarBase64, setAvatarBase64] = useState(null) + useEffect(() => { let mounted = true @@ -62,9 +61,6 @@ export default function Profile() { if (reviews) { setReviewedAppointments(new Set(reviews.map((r: any) => r.appointment_id).filter(Boolean))) } - // Load local avatar - const savedAvatar = localStorage.getItem('avatar_' + data.user.id) - if (savedAvatar) setAvatarBase64(savedAvatar) } setLoadingAuth(false) })() @@ -97,43 +93,7 @@ export default function Profile() { setReviewTarget(null) } - const [activeTab, setActiveTab] = useState<'favoritos' | 'agenda' | 'pedidos' | 'definicoes'>('favoritos') - const [editName, setEditName] = useState('') - const [isSaving, setIsSaving] = useState(false) - - useEffect(() => { - if (user?.name) { - setEditName(user.name) - } else if (authEmail) { - setEditName(authEmail.split('@')[0]) - } - }, [user, authEmail]) - - const handleSaveProfile = async () => { - if (!authId || !editName.trim()) return - setIsSaving(true) - const { error } = await supabase.from('profiles').update({ name: editName.trim() }).eq('id', authId) - setIsSaving(false) - if (error) { - alert('Erro ao atualizar perfil: ' + error.message) - } else { - alert('Perfil atualizado com sucesso!') - window.location.reload() - } - } - - const handleAvatarChange = (e: React.ChangeEvent) => { - const file = e.target.files?.[0] - if (!file || !authId) return - - const reader = new FileReader() - reader.onload = (event) => { - const base64 = event.target?.result as string - setAvatarBase64(base64) - localStorage.setItem('avatar_' + authId, base64) - } - reader.readAsDataURL(file) - } + const [activeTab, setActiveTab] = useState<'favoritos' | 'agenda' | 'pedidos'>('favoritos') if (loadingAuth) { return ( @@ -165,7 +125,7 @@ export default function Profile() { ) } - const displayName = user?.name || (authEmail ? authEmail.split('@')[0] : 'Utilizador') + const displayName = authEmail ? authEmail.split('@')[0] : 'Utilizador' return ( <> @@ -189,40 +149,20 @@ export default function Profile() {
-