From 46fcb57edfa2231a4303c834817a9c864d691528 Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Sat, 27 Jun 2026 10:11:13 -0500 Subject: [PATCH] fix: settings siempre retorna objeto, autocomplete Colombia con bias de ubicacion - GET /settings retorna {} en lugar de undefined cuando no hay configuracion (evita error jsonDecode en Flutter que dejaba soporte en gris) - Autocomplete: agrega components=country:co, radius 20km, remove types=address para mostrar mas resultados cercanos al usuario Co-Authored-By: Claude Sonnet 4.6 --- admin/src/app/autocomplete/route.ts | 10 +++++++--- backend/src/settings/settings.service.ts | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/admin/src/app/autocomplete/route.ts b/admin/src/app/autocomplete/route.ts index 30eeb28..baab857 100644 --- a/admin/src/app/autocomplete/route.ts +++ b/admin/src/app/autocomplete/route.ts @@ -43,9 +43,13 @@ export async function GET(req: NextRequest) { placesUrl.searchParams.set('input', input); placesUrl.searchParams.set('key', apiKey); placesUrl.searchParams.set('language', 'es'); - placesUrl.searchParams.set('types', 'address'); - if (location) placesUrl.searchParams.set('location', location); - if (location) placesUrl.searchParams.set('radius', '50000'); + placesUrl.searchParams.set('components', 'country:co'); + // Bias results strongly to user location (20km circle) + if (location) { + placesUrl.searchParams.set('location', location); + placesUrl.searchParams.set('radius', '20000'); + placesUrl.searchParams.set('strictbounds', 'false'); + } try { const res = await fetch(placesUrl.toString(), { cache: 'no-store' }); diff --git a/backend/src/settings/settings.service.ts b/backend/src/settings/settings.service.ts index 0247058..c013f20 100644 --- a/backend/src/settings/settings.service.ts +++ b/backend/src/settings/settings.service.ts @@ -10,7 +10,7 @@ export class SettingsService { async getGlobal() { const setting = await this.prisma.settings.findUnique({ where: { key: 'global' } }); - return setting?.value; + return (setting?.value as Record) ?? {}; } async updateGlobal(value: Record) {