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('input', input);
|
||||||
placesUrl.searchParams.set('key', apiKey);
|
placesUrl.searchParams.set('key', apiKey);
|
||||||
placesUrl.searchParams.set('language', 'es');
|
placesUrl.searchParams.set('language', 'es');
|
||||||
placesUrl.searchParams.set('types', 'address');
|
placesUrl.searchParams.set('components', 'country:co');
|
||||||
if (location) placesUrl.searchParams.set('location', location);
|
// Bias results strongly to user location (20km circle)
|
||||||
if (location) placesUrl.searchParams.set('radius', '50000');
|
if (location) {
|
||||||
|
placesUrl.searchParams.set('location', location);
|
||||||
|
placesUrl.searchParams.set('radius', '20000');
|
||||||
|
placesUrl.searchParams.set('strictbounds', 'false');
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await fetch(placesUrl.toString(), { cache: 'no-store' });
|
const res = await fetch(placesUrl.toString(), { cache: 'no-store' });
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export class SettingsService {
|
|||||||
|
|
||||||
async getGlobal() {
|
async getGlobal() {
|
||||||
const setting = await this.prisma.settings.findUnique({ where: { key: 'global' } });
|
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>) {
|
async updateGlobal(value: Record<string, any>) {
|
||||||
|
|||||||
Reference in New Issue
Block a user