feat: add city/state/country to complex, new settings page with sidebar, and Biome linting

- Added city, state, and country optional fields to Complex model
- Updated onboarding to include optional location fields
- Created new settings page with sidebar navigation (Datos del Complejo, Canchas)
- Replaced ESLint with Biome for frontend and backend linting
- Added parallel dev script with concurrently
- Migrated register-routes to use direct app.route() pattern
This commit is contained in:
Jose Selesan
2026-04-10 15:36:15 -03:00
parent 77004b14b0
commit 9ee98a4cb4
129 changed files with 2929 additions and 3186 deletions

View File

@@ -1,35 +1,32 @@
import type { MiddlewareHandler } from 'hono'
import { db } from '@/lib/prisma'
import { supabase } from '@/lib/supabase'
import type { AppEnv } from '@/types/hono'
import { db } from '@/lib/prisma';
import { supabase } from '@/lib/supabase';
import type { AppEnv } from '@/types/hono';
import type { MiddlewareHandler } from 'hono';
function getBearerToken(value: string | undefined): string | null {
if (!value) return null
const [scheme, token] = value.split(' ')
if (scheme?.toLowerCase() !== 'bearer' || !token) return null
return token
if (!value) return null;
const [scheme, token] = value.split(' ');
if (scheme?.toLowerCase() !== 'bearer' || !token) return null;
return token;
}
export const requireAuth: MiddlewareHandler<AppEnv> = async (
c,
next,
) => {
const token = getBearerToken(c.req.header('authorization'))
export const requireAuth: MiddlewareHandler<AppEnv> = async (c, next) => {
const token = getBearerToken(c.req.header('authorization'));
if (!token) {
return c.json({ message: 'Missing bearer token.' }, 403)
return c.json({ message: 'Missing bearer token.' }, 403);
}
const { data, error } = await supabase.auth.getUser(token)
const { data, error } = await supabase.auth.getUser(token);
if (error || !data.user) {
return c.json({ message: 'Invalid or expired token.' }, 403)
return c.json({ message: 'Invalid or expired token.' }, 403);
}
const email = data.user.email?.toLowerCase()
const email = data.user.email?.toLowerCase();
if (!email) {
return c.json({ message: 'Auth user does not contain email.' }, 403)
return c.json({ message: 'Auth user does not contain email.' }, 403);
}
const appUser = await db.user.findFirst({
@@ -38,13 +35,13 @@ export const requireAuth: MiddlewareHandler<AppEnv> = async (
email,
},
select: { id: true },
})
});
if (!appUser) {
return c.json({ message: 'User not provisioned in backend.' }, 403)
return c.json({ message: 'User not provisioned in backend.' }, 403);
}
c.set('authUser', data.user)
c.set('appUserId', appUser.id)
await next()
}
c.set('authUser', data.user);
c.set('appUserId', appUser.id);
await next();
};

View File

@@ -1,35 +1,29 @@
import type { MiddlewareHandler } from 'hono'
import type { AppEnv } from '@/types/hono'
import type { AppEnv } from '@/types/hono';
import type { MiddlewareHandler } from 'hono';
function getSuperAdminEmails(): Set<string> {
const raw = Bun.env.SUPER_ADMIN_EMAILS ?? ''
const raw = Bun.env.SUPER_ADMIN_EMAILS ?? '';
const emails = raw
.split(',')
.map((value) => value.trim().toLowerCase())
.filter(Boolean)
return new Set(emails)
.filter(Boolean);
return new Set(emails);
}
export const requireSuperAdmin: MiddlewareHandler<AppEnv> = async (
c,
next,
) => {
const authUser = c.get('authUser')
const role =
typeof authUser.app_metadata?.role === 'string'
? authUser.app_metadata.role
: null
const email = authUser.email?.toLowerCase()
export const requireSuperAdmin: MiddlewareHandler<AppEnv> = async (c, next) => {
const authUser = c.get('authUser');
const role = typeof authUser.app_metadata?.role === 'string' ? authUser.app_metadata.role : null;
const email = authUser.email?.toLowerCase();
if (role === 'super_admin') {
await next()
return
await next();
return;
}
if (email && getSuperAdminEmails().has(email)) {
await next()
return
await next();
return;
}
return c.json({ message: 'Este recurso requiere permisos de super admin.' }, 403)
}
return c.json({ message: 'Este recurso requiere permisos de super admin.' }, 403);
};