From 352bb9aa59d8da0121df7068d8e8f7a8790736e3 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sat, 21 Jun 2025 19:50:38 +0000 Subject: [PATCH] Refactor: Split ContactForm into smaller components Refactors ContactForm.tsx into smaller, more manageable components for improved code organization and maintainability. --- src/components/help/ContactForm.tsx | 143 +------ src/components/help/ContactFormFields.tsx | 120 ++++++ src/components/help/ContactFormFileUpload.tsx | 49 +++ src/components/help/ContactFormHeader.tsx | 24 ++ src/components/help/FAQList.tsx | 6 +- src/pages/AdminFAQ.tsx | 394 ++++++------------ 6 files changed, 341 insertions(+), 395 deletions(-) create mode 100644 src/components/help/ContactFormFields.tsx create mode 100644 src/components/help/ContactFormFileUpload.tsx create mode 100644 src/components/help/ContactFormHeader.tsx diff --git a/src/components/help/ContactForm.tsx b/src/components/help/ContactForm.tsx index 383e033..0d09879 100644 --- a/src/components/help/ContactForm.tsx +++ b/src/components/help/ContactForm.tsx @@ -1,19 +1,11 @@ import { useState } from 'react'; -import { ArrowLeft, Upload, X } from 'lucide-react'; +import { ArrowLeft } from 'lucide-react'; import { Button } from '@/components/ui/button'; -import { Input } from '@/components/ui/input'; -import { Textarea } from '@/components/ui/textarea'; -import { Label } from '@/components/ui/label'; -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from '@/components/ui/select'; import { useToast } from '@/hooks/use-toast'; import { supabase } from '@/integrations/supabase/client'; +import ContactFormFields from './ContactFormFields'; +import ContactFormHeader from './ContactFormHeader'; interface ContactFormProps { onBack: () => void; @@ -29,15 +21,6 @@ const ContactForm = ({ onBack }: ContactFormProps) => { const [loading, setLoading] = useState(false); const { toast } = useToast(); - const motivosContato = [ - 'Dúvida sobre funcionalidade', - 'Problema técnico', - 'Sugestão de melhoria', - 'Reclamação', - 'Elogio', - 'Outros' - ]; - const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); @@ -75,7 +58,7 @@ const ContactForm = ({ onBack }: ContactFormProps) => { // Salvar contato no banco const { error } = await supabase - .from('contatos' as any) + .from('contatos') .insert({ assunto: formData.assunto, motivo: formData.motivo, @@ -114,119 +97,15 @@ const ContactForm = ({ onBack }: ContactFormProps) => { } }; - const handleFileChange = (e: React.ChangeEvent) => { - const file = e.target.files?.[0]; - if (file) { - // Validar tamanho (max 5MB) - if (file.size > 5 * 1024 * 1024) { - toast({ - title: "Arquivo muito grande", - description: "O arquivo deve ter no máximo 5MB.", - variant: "destructive" - }); - return; - } - setFormData({ ...formData, anexo: file }); - } - }; - - const removeFile = () => { - setFormData({ ...formData, anexo: null }); - }; - return (
-
- -
-

- Você vai receber a resposta no e-mail que cadastrou aqui -

-
-
- -
-
- - setFormData({ ...formData, assunto: e.target.value })} - required - /> -
- -
- - -
- -
- -