From aeb8c91a3d72e9ba80bd82bfa8271a8e5e78105f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paola=20Estefan=C3=ADa=20de=20Campos?= Date: Thu, 7 Nov 2024 15:57:59 +0100 Subject: [PATCH] feat: persist just first name and trim to render just first name in case full name already in db --- src/app/solicitar-ayuda/_components/Form/FormContainer.tsx | 4 ++-- src/app/solicitar-ayuda/_components/Form/FormRenderer.tsx | 2 +- src/components/SolicitudCard.tsx | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/solicitar-ayuda/_components/Form/FormContainer.tsx b/src/app/solicitar-ayuda/_components/Form/FormContainer.tsx index 3d07fa02..ce94b157 100644 --- a/src/app/solicitar-ayuda/_components/Form/FormContainer.tsx +++ b/src/app/solicitar-ayuda/_components/Form/FormContainer.tsx @@ -33,7 +33,7 @@ export function FormContainer() { const session = useSession(); const [formData, setFormData] = useState({ - nombre: session?.user?.user_metadata?.full_name || '', + nombre: session?.user?.user_metadata?.full_name.split(" ")[0]|| '', ubicacion: '', coordinates: null, tiposDeAyuda: new Map(TIPOS_DE_AYUDA.map(({ id }) => [id, false])), @@ -91,7 +91,7 @@ export function FormContainer() { try { const helpRequestData: Database['public']['Tables']['help_requests']['Insert'] = { type: 'necesita', - name: formData.nombre, + name: formData.nombre.split(" ")[0], location: formData.ubicacion, latitude: formData.coordinates ? parseFloat(formData.coordinates.lat) : null, longitude: formData.coordinates ? parseFloat(formData.coordinates.lng) : null, diff --git a/src/app/solicitar-ayuda/_components/Form/FormRenderer.tsx b/src/app/solicitar-ayuda/_components/Form/FormRenderer.tsx index 27423596..e0196b30 100644 --- a/src/app/solicitar-ayuda/_components/Form/FormRenderer.tsx +++ b/src/app/solicitar-ayuda/_components/Form/FormRenderer.tsx @@ -61,7 +61,7 @@ export function FormRenderer({
- +
-
{caso.name || 'Necesita Ayuda'}
+
{caso?.name?.split(" ")[0] || 'Necesita Ayuda'}
{new Date(caso.created_at!).toLocaleDateString() + ' ' +