fix(web): corrige warnings do console — AntD deprecations, keys duplicadas, 404
- DevLogin: Space orientation (era direction), Alert title (era message), keys únicas por role (rep-29/sup-29/mgr-29), loading key alinhado - router: notFoundComponent configurado — elimina aviso do TanStack Router Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -7,14 +7,14 @@ import { apiFetch } from '../../lib/api-client';
|
|||||||
import { authStore } from '../../lib/auth-store';
|
import { authStore } from '../../lib/auth-store';
|
||||||
import { AuthTokenResponseSchema } from '@sar/api-interface';
|
import { AuthTokenResponseSchema } from '@sar/api-interface';
|
||||||
|
|
||||||
type DevUser = { userId: string; role: string; label: string };
|
type DevUser = { key: string; userId: string; role: string; label: string };
|
||||||
|
|
||||||
// userId = cod_vendedor como string; idEmpresa = empresa no ERP (dev default = 1)
|
// userId = cod_vendedor como string; idEmpresa = empresa no ERP (dev default = 1)
|
||||||
// Em dev, o backend força DEV_REP_CODE=29 independente do userId enviado.
|
// Em dev, o backend força DEV_REP_CODE=29 independente do userId enviado.
|
||||||
const DEV_USERS: DevUser[] = [
|
const DEV_USERS: DevUser[] = [
|
||||||
{ userId: '29', role: 'rep', label: 'PAVEI COMERCIO (cod 29)' },
|
{ key: 'rep-29', userId: '29', role: 'rep', label: 'PAVEI COMERCIO (cod 29)' },
|
||||||
{ userId: '29', role: 'supervisor', label: 'PAVEI — Supervisor (cod 29)' },
|
{ key: 'sup-29', userId: '29', role: 'supervisor', label: 'PAVEI — Supervisor (cod 29)' },
|
||||||
{ userId: '29', role: 'manager', label: 'PAVEI — Gerente (cod 29)' },
|
{ key: 'mgr-29', userId: '29', role: 'manager', label: 'PAVEI — Gerente (cod 29)' },
|
||||||
];
|
];
|
||||||
|
|
||||||
export function DevLogin({ onLogin }: { onLogin: () => void }) {
|
export function DevLogin({ onLogin }: { onLogin: () => void }) {
|
||||||
@@ -22,7 +22,7 @@ export function DevLogin({ onLogin }: { onLogin: () => void }) {
|
|||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
async function handleLogin(user: DevUser) {
|
async function handleLogin(user: DevUser) {
|
||||||
setLoading(user.userId);
|
setLoading(user.key);
|
||||||
setError(null);
|
setError(null);
|
||||||
try {
|
try {
|
||||||
const raw = await apiFetch('/auth/dev/token', {
|
const raw = await apiFetch('/auth/dev/token', {
|
||||||
@@ -42,24 +42,24 @@ export function DevLogin({ onLogin }: { onLogin: () => void }) {
|
|||||||
return (
|
return (
|
||||||
<Flex justify="center" align="center" style={{ minHeight: '100vh' }}>
|
<Flex justify="center" align="center" style={{ minHeight: '100vh' }}>
|
||||||
<Card style={{ width: 380 }}>
|
<Card style={{ width: 380 }}>
|
||||||
<Space direction="vertical" size={16} style={{ width: '100%' }}>
|
<Space orientation="vertical" size={16} style={{ width: '100%' }}>
|
||||||
<Typography.Title level={3} style={{ margin: 0 }}>
|
<Typography.Title level={3} style={{ margin: 0 }}>
|
||||||
SAR · Login Dev
|
SAR · Login Dev
|
||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
<Alert
|
<Alert
|
||||||
type="warning"
|
type="warning"
|
||||||
message="Ambiente de desenvolvimento"
|
title="Ambiente de desenvolvimento"
|
||||||
description="Este login automático não existe em produção."
|
description="Este login automático não existe em produção."
|
||||||
showIcon
|
showIcon
|
||||||
/>
|
/>
|
||||||
{error && <Alert type="error" message={error} showIcon />}
|
{error && <Alert type="error" title={error} showIcon />}
|
||||||
<Divider style={{ margin: '4px 0' }}>Entrar como</Divider>
|
<Divider style={{ margin: '4px 0' }}>Entrar como</Divider>
|
||||||
{DEV_USERS.map((u) => (
|
{DEV_USERS.map((u) => (
|
||||||
<Button
|
<Button
|
||||||
key={u.userId}
|
key={u.key}
|
||||||
block
|
block
|
||||||
type={u.role === 'rep' ? 'primary' : 'default'}
|
type={u.role === 'rep' ? 'primary' : 'default'}
|
||||||
loading={loading === u.userId}
|
loading={loading === u.key}
|
||||||
onClick={() => void handleLogin(u)}
|
onClick={() => void handleLogin(u)}
|
||||||
>
|
>
|
||||||
{u.label}
|
{u.label}
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
import { createRouter, createRootRoute, createRoute, Outlet } from '@tanstack/react-router';
|
import {
|
||||||
|
createRouter,
|
||||||
|
createRootRoute,
|
||||||
|
createRoute,
|
||||||
|
Outlet,
|
||||||
|
notFound,
|
||||||
|
} from '@tanstack/react-router';
|
||||||
|
import { Typography } from 'antd';
|
||||||
import { AppShell } from '../components/layout/AppShell';
|
import { AppShell } from '../components/layout/AppShell';
|
||||||
import { RafaelPainel } from '../cockpits/rafael/RafaelPainel';
|
import { RafaelPainel } from '../cockpits/rafael/RafaelPainel';
|
||||||
import { ClientsPage } from '../cockpits/rafael/ClientsPage';
|
import { ClientsPage } from '../cockpits/rafael/ClientsPage';
|
||||||
@@ -27,12 +34,26 @@ function HomeRoute() {
|
|||||||
return role === 'supervisor' || role === 'manager' ? <SandraPainel /> : <RafaelPainel />;
|
return role === 'supervisor' || role === 'manager' ? <SandraPainel /> : <RafaelPainel />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function NotFoundPage() {
|
||||||
|
return (
|
||||||
|
<div style={{ padding: 48, textAlign: 'center' }}>
|
||||||
|
<Typography.Title level={3} type="secondary">
|
||||||
|
Página não encontrada
|
||||||
|
</Typography.Title>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Suprime aviso de notFound não utilizado — usado via throw notFound() em loaders futuros.
|
||||||
|
void notFound;
|
||||||
|
|
||||||
const rootRoute = createRootRoute({
|
const rootRoute = createRootRoute({
|
||||||
component: () => (
|
component: () => (
|
||||||
<AppShell>
|
<AppShell>
|
||||||
<Outlet />
|
<Outlet />
|
||||||
</AppShell>
|
</AppShell>
|
||||||
),
|
),
|
||||||
|
notFoundComponent: NotFoundPage,
|
||||||
});
|
});
|
||||||
|
|
||||||
const indexRoute = createRoute({
|
const indexRoute = createRoute({
|
||||||
|
|||||||
Reference in New Issue
Block a user