feat(mvp-rep): formas de pagamento do ERP + suporte offline completo

Formas de pagamento:
- Endpoint GET /catalog/payment-methods lendo vw_formas_pagamento
  filtrado por ativa=1 e integrar_sar=1
- FormaPagamento schema/type no shared api-interface
- Hook useFormasPagamento (staleTime 1h) substituindo lista hardcoded

Offline (FR-4.2 / NFR-2.1–2.4):
- IndexedDB queue: lib/offline/idb.ts + order-queue.ts sem deps externos
- NewOrderPage detecta !navigator.onLine → enqueueOrder() → toast + reset
- useOfflineSync: auto-sync ao reconectar (POST orders + PATCH transmit)
- usePendingOrders: fila reativa via CustomEvents
- AppShell: banner offline + useOfflineSync() global
- OrdersPage: seção de pedidos pendentes com retry/descartar
- sw.js: network-first para API GETs cacheáveis + stale-while-revalidate
  para assets + app shell navigate fallback

Docs:
- architecture.md: documento de decisões de arquitetura do SAR MVP

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-30 21:30:23 +00:00
parent 1647871a39
commit a3c68f9f05
33 changed files with 2175 additions and 173 deletions

View File

@@ -1,4 +1,4 @@
import { Badge, Menu } from 'antd';
import { Menu } from 'antd';
import { useLocation, useNavigate } from '@tanstack/react-router';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import {
@@ -11,10 +11,8 @@ import {
faGear,
faPercent,
faFileInvoiceDollar,
faCheckCircle,
} from '@fortawesome/free-solid-svg-icons';
import type { ItemType } from 'antd/es/menu/interface';
import { useOrderList } from '../../lib/queries/orders';
/**
* Sidebar canônica do SAR (260px fixa — brand.md).
@@ -23,9 +21,6 @@ import { useOrderList } from '../../lib/queries/orders';
export function Sidebar() {
const navigate = useNavigate();
const location = useLocation();
const { data: pendingOrders } = useOrderList({ status: 'pending_approval', limit: 1 });
const pendingCount = pendingOrders?.total ?? 0;
const items: ItemType[] = [
{
key: '/',
@@ -57,18 +52,6 @@ export function Sidebar() {
icon: <FontAwesomeIcon icon={faClipboardList} fixedWidth />,
label: 'Pedidos',
},
{
key: '/aprovacoes',
icon: <FontAwesomeIcon icon={faCheckCircle} fixedWidth />,
label: (
<span>
Aprovações{' '}
{pendingCount > 0 && (
<Badge count={pendingCount} size="small" style={{ marginLeft: 4 }} />
)}
</span>
),
},
{
key: '/comissao',
icon: <FontAwesomeIcon icon={faPercent} fixedWidth />,