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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
f66b1a9bc1
commit
46fcb57edf
@@ -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' });
|
||||
|
||||
@@ -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<string, any>) ?? {};
|
||||
}
|
||||
|
||||
async updateGlobal(value: Record<string, any>) {
|
||||
|
||||
Reference in New Issue
Block a user