feat: redesign superadmin agencies list, implement flat design, add date filters, and fix UI bugs
This commit is contained in:
@@ -10,33 +10,7 @@ export async function middleware(request: NextRequest) {
|
||||
// Extrair subdomínio
|
||||
const subdomain = hostname.split('.')[0];
|
||||
|
||||
// Se for dash.localhost - rotas administrativas (SUPERADMIN)
|
||||
if (subdomain === 'dash') {
|
||||
// Permitir acesso a /superadmin, /cadastro, /login
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
// Se for agência ({subdomain}.localhost) - validar se existe
|
||||
if (hostname.includes('.')) {
|
||||
try {
|
||||
const res = await fetch(`${apiBase}/api/tenant/check?subdomain=${subdomain}`);
|
||||
if (!res.ok) {
|
||||
const baseHost = hostname.split('.').slice(1).join('.') || hostname;
|
||||
const redirectUrl = new URL(url.toString());
|
||||
redirectUrl.hostname = baseHost;
|
||||
redirectUrl.pathname = '/';
|
||||
return NextResponse.redirect(redirectUrl);
|
||||
}
|
||||
} catch (err) {
|
||||
const baseHost = hostname.split('.').slice(1).join('.') || hostname;
|
||||
const redirectUrl = new URL(url.toString());
|
||||
redirectUrl.hostname = baseHost;
|
||||
redirectUrl.pathname = '/';
|
||||
return NextResponse.redirect(redirectUrl);
|
||||
}
|
||||
}
|
||||
|
||||
// Permitir /dashboard, /login, /clientes, etc.
|
||||
// Apenas SUPERADMIN (dash.localhost)
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user