Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extra help types + others text field #105

Merged
merged 2 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
210 changes: 105 additions & 105 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions src/components/OfferHelp.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default function OfferHelp({
email: data.additional_info?.email || session?.user?.user_metadata?.email || '',
ubicacion: data.location || '',
tiposAyuda: data.help_type || [],
otraAyuda: data.other_help || '',
vehiculo: data.resources?.vehicle || '',
disponibilidad: data.resources?.availability || [],
radio: data.resources?.radius || 1,
Expand Down Expand Up @@ -118,6 +119,7 @@ export default function OfferHelp({
latitude: formData.coordinates ? parseFloat(formData.coordinates.lat) : null,
longitude: formData.coordinates ? parseFloat(formData.coordinates.lng) : null,
help_type: formData.tiposAyuda,
other_help: formData.otraAyuda,
town_id: formData.pueblo,
status: formData.status,
};
Expand All @@ -142,6 +144,7 @@ export default function OfferHelp({
email: '',
ubicacion: '',
tiposAyuda: [],
otraAyuda: '',
vehiculo: '',
disponibilidad: [],
radio: 1,
Expand Down Expand Up @@ -287,6 +290,20 @@ export default function OfferHelp({
</div>
</div>

{formData.tiposAyuda.includes('otros') && (
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">¿Qué tipo de ayuda?</label>
<textarea
name="otraAyuda"
value={formData.otraAyuda}
onChange={(e) => setFormData({ ...formData, otraAyuda: e.target.value })}
className="w-full p-2 border rounded focus:ring-2 focus:ring-red-500"
rows="3"
placeholder="Especifica qué tipo de ayuda..."
/>
</div>
)}

{/* Vehículo */}
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">Vehículo disponible</label>
Expand Down
2 changes: 2 additions & 0 deletions src/helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export const tiposAyudaOptions = {
medica: 'Asistencia médica',
psicologico: 'Apoyo psicológico',
logistico: 'Apoyo logístico',
reparto: 'Labores de reparto de alimentos a domicilio',
donaciones: 'Labores de organización de donaciones',
otros: 'Ayuda general',
};

Expand Down
4 changes: 4 additions & 0 deletions supabase/migrations/20241106184930_add-help-types.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ALTER TYPE "public"."help_type_enum" ADD VALUE 'reparto';
ALTER TYPE "public"."help_type_enum" ADD VALUE 'donaciones';

ALTER TABLE "public"."help_requests" ADD COLUMN "other_help" text DEFAULT NULL;