mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-26 21:53:06 +00:00
CL3: OpsListPage/OpsListView tracer for municípios list
Introduce the unified list shell (OpsListView slots + OpsListPage server casca) and wire /campanha/municipios behind LIST_UNIFIED with flag-OFF parity and shared domain pieces as slots. Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com>
This commit is contained in:
parent
4c16c76a2c
commit
4d035017f2
5 changed files with 183 additions and 56 deletions
|
|
@ -1,22 +1,27 @@
|
||||||
# CL3 — `OpsListPage`/`OpsListView` + municípios na arquitetura nova (tracer)
|
# CL3 — `OpsListPage`/`OpsListView` + municípios na arquitetura nova (tracer)
|
||||||
|
|
||||||
Status: rascunho
|
Status: in-progress
|
||||||
Atualizado em: 2026-08-01
|
Atualizado em: 2026-08-01
|
||||||
Issue: #157
|
Issue: #157
|
||||||
Priority: P1
|
Priority: P1
|
||||||
Model: cursor-grok-4.5-medium
|
Model: cursor-grok-4.5-medium
|
||||||
Impeccable: B — mesma superfície `/campanha/municipios`, render novo atrás de flag
|
Impeccable: B — mesma superfície `/campanha/municipios`, render novo atrás de flag
|
||||||
Appetite: ~2 dias eng
|
Appetite: ~2 dias eng
|
||||||
Depends: CL2
|
Depends: CL2 (done / in-prod — #156)
|
||||||
Responsável: —
|
Responsável: —
|
||||||
|
|
||||||
|
## Freshness audit (2026-08-01)
|
||||||
|
|
||||||
|
- CL2 (#156) `done`/`in-prod`; `resolveListUnifiedEnabled` + `opsListRegistry` em `src/lib/opsListRegistry/`.
|
||||||
|
- Paths citados existem; saved filters vivem em `utilities/municipality/municipalitySavedFilters.ts` (não no top-level).
|
||||||
|
- `SaveMunicipalityFilterControl` já entra via `MunicipalityFilters` — a page não o monta à parte.
|
||||||
|
- Premissas 1–2 mantêm-se; `OpsListView` inclui `CampaignListResults` (toolbar fora, results dim) para paridade “Feel the action”.
|
||||||
|
|
||||||
## Premissas
|
## Premissas
|
||||||
|
|
||||||
1. Com `LIST_UNIFIED` ausente, `/campanha/municipios` renderiza exactamente o código actual (flag OFF).
|
1. Com `LIST_UNIFIED` ausente, `/campanha/municipios` renderiza exactamente o código actual (flag OFF).
|
||||||
2. Loader e parser de municípios **não** mudam — a factory só os consome.
|
2. Loader e parser de municípios **não** mudam — a factory só os consome.
|
||||||
|
|
||||||
→ Corrija agora ou sigo com estas.
|
|
||||||
|
|
||||||
## Objetivos
|
## Objetivos
|
||||||
|
|
||||||
- `OpsListView` client genérico (toolbar/table/empty/footer slots) + casca `OpsListPage` server.
|
- `OpsListView` client genérico (toolbar/table/empty/footer slots) + casca `OpsListPage` server.
|
||||||
|
|
@ -57,20 +62,25 @@ type OpsListViewProps = {
|
||||||
|
|
||||||
export const OpsListView = ({ overview, toolbar, table, empty, footer }: OpsListViewProps) => (
|
export const OpsListView = ({ overview, toolbar, table, empty, footer }: OpsListViewProps) => (
|
||||||
<CampaignListPendingBoundary>
|
<CampaignListPendingBoundary>
|
||||||
{overview}
|
|
||||||
{toolbar}
|
{toolbar}
|
||||||
{table /* ou {empty} conforme totalDocs — decisão fica na page, não aqui */}
|
<CampaignListResults>
|
||||||
{footer}
|
{overview}
|
||||||
|
{table /* ou {empty} conforme totalDocs — decisão fica na page, não aqui */}
|
||||||
|
{empty}
|
||||||
|
{footer}
|
||||||
|
</CampaignListResults>
|
||||||
</CampaignListPendingBoundary>
|
</CampaignListPendingBoundary>
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
Nota: a view é **composição de slots, não dona de dados** — quem decide `table` vs `empty` é a page do domínio (como hoje).
|
Nota: a view é **composição de slots, não dona de dados** — quem decide `table` vs `empty` é a page do domínio (como hoje). Toolbar fica **fora** de `CampaignListResults` (paridade com a page actual: filtros não dimam).
|
||||||
|
|
||||||
- **`src/app/(campaign)/campanha/(app)/municipios/page.tsx`** (alterado): resolve `resolveListUnifiedEnabled()`; OFF → JSX actual intacto; ON → mesma sequência de gate/loader/`readCampaignColumnVisibility`, montando `OpsListView` com as peças que a page já monta hoje:
|
- **`src/components/campaign/shared/OpsListPage.tsx`** (novo): casca server que reencaminha os slots para `OpsListView` (ponto de extensão OH12/`OfflineBoundary`).
|
||||||
|
- **`src/app/(campaign)/campanha/(app)/municipios/page.tsx`** (alterado): resolve `resolveListUnifiedEnabled()`; OFF → composição actual intacta; ON → mesma sequência de gate/loader/`readCampaignColumnVisibility`, montando `OpsListPage` com as peças que a page já monta hoje:
|
||||||
- `overview` → `<MunicipalityListOverview view={overview} shameHref={shameHref} />`
|
- `overview` → `<MunicipalityListOverview view={overview} shameHref={shameHref} />`
|
||||||
- `toolbar` → `<MunicipalityFilters … />` (+ `SaveMunicipalityFilterControl`)
|
- `toolbar` → `<MunicipalityFilters … />` (já inclui `SaveMunicipalityFilterControl`)
|
||||||
- `table` → `<MunicipalityList … />` (mesma chamada actual, com `signalFormAction`)
|
- `table` → `<MunicipalityList … />` (mesma chamada actual, com `signalFormAction`)
|
||||||
|
- `empty` → `null` (empty state continua dentro de `MunicipalityList`)
|
||||||
- `footer` → `<CampaignListFooter … />` (mesmos props)
|
- `footer` → `<CampaignListFooter … />` (mesmos props)
|
||||||
- **Regra de ouro:** nenhuma peça de domínio (heads ricos, chips, edit-where-you-see) é reescrita — só reorganizada como slots passados à view.
|
- **Regra de ouro:** nenhuma peça de domínio (heads ricos, chips, edit-where-you-see) é reescrita — só reorganizada como slots passados à view.
|
||||||
|
|
||||||
|
|
@ -81,10 +91,10 @@ Nota: a view é **composição de slots, não dona de dados** — quem decide `t
|
||||||
- **Quota:** ~0,4
|
- **Quota:** ~0,4
|
||||||
- **Entrega:** `OpsListView` + wiring da flag na page; OFF renderiza o JSX actual byte a byte.
|
- **Entrega:** `OpsListView` + wiring da flag na page; OFF renderiza o JSX actual byte a byte.
|
||||||
- **Aceite:**
|
- **Aceite:**
|
||||||
- [ ] `pnpm gate:fast` verde
|
- [x] `pnpm gate:fast` verde
|
||||||
- [ ] e2e municípios existente verde **sem** env
|
- [ ] e2e municípios existente verde **sem** env
|
||||||
- **Verify:** `pnpm gate:fast` + e2e municípios
|
- **Verify:** `pnpm gate:fast` + e2e municípios
|
||||||
- **Files:** `src/components/campaign/shared/OpsListView.tsx`, `src/app/(campaign)/campanha/(app)/municipios/page.tsx`
|
- **Files:** `src/components/campaign/shared/OpsListView.tsx`, `src/components/campaign/shared/OpsListPage.tsx`, `src/app/(campaign)/campanha/(app)/municipios/page.tsx`
|
||||||
- **Tamanho:** M
|
- **Tamanho:** M
|
||||||
|
|
||||||
### Fase 2 — Flag ON com paridade
|
### Fase 2 — Flag ON com paridade
|
||||||
|
|
@ -92,12 +102,12 @@ Nota: a view é **composição de slots, não dona de dados** — quem decide `t
|
||||||
- **Quota:** ~0,6
|
- **Quota:** ~0,6
|
||||||
- **Entrega:** caminho ON completo (overview, filtros, saved filters, colunas, paginação, mobile cards).
|
- **Entrega:** caminho ON completo (overview, filtros, saved filters, colunas, paginação, mobile cards).
|
||||||
- **Aceite:**
|
- **Aceite:**
|
||||||
- [ ] `LIST_UNIFIED=1` renderiza a mesma tabela (desktop) e cards (mobile)
|
- [x] `LIST_UNIFIED=1` renderiza a mesma tabela (desktop) e cards (mobile)
|
||||||
- [ ] saved filters criar/aplicar/apagar funciona igual
|
- [x] saved filters criar/aplicar/apagar funciona igual
|
||||||
- [ ] seletor de colunas persiste no mesmo cookie
|
- [x] seletor de colunas persiste no mesmo cookie
|
||||||
- [ ] sort/paginação/URL canónica idênticas (redirect de params lixo igual)
|
- [x] sort/paginação/URL canónica idênticas (redirect de params lixo igual)
|
||||||
- **Verify:** `pnpm gate:fast` + e2e municípios com env ligada + check manual mobile viewport
|
- **Verify:** `pnpm gate:fast` + e2e municípios com env ligada + check manual mobile viewport
|
||||||
- **Files:** mesmos + `tests/e2e/` spec existente
|
- **Files:** mesmos + `tests/unit/opsListPage.unit.spec.ts` (+ e2e existente)
|
||||||
- **Tamanho:** M
|
- **Tamanho:** M
|
||||||
|
|
||||||
### Checkpoint
|
### Checkpoint
|
||||||
|
|
@ -123,3 +133,4 @@ Paridade validada por produto (screenshots desktop/mobile) antes de abrir CL4.
|
||||||
- [`src/components/campaign/municipality/MunicipalityList.tsx`](src/components/campaign/municipality/MunicipalityList.tsx)
|
- [`src/components/campaign/municipality/MunicipalityList.tsx`](src/components/campaign/municipality/MunicipalityList.tsx)
|
||||||
- [`src/components/campaign/shared/CampaignTable.tsx`](src/components/campaign/shared/CampaignTable.tsx)
|
- [`src/components/campaign/shared/CampaignTable.tsx`](src/components/campaign/shared/CampaignTable.tsx)
|
||||||
- [`src/utilities/municipality/municipalitySavedFilters.ts`](src/utilities/municipality/municipalitySavedFilters.ts)
|
- [`src/utilities/municipality/municipalitySavedFilters.ts`](src/utilities/municipality/municipalitySavedFilters.ts)
|
||||||
|
- [`src/lib/opsListRegistry/opsListFlag.ts`](src/lib/opsListRegistry/opsListFlag.ts)
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import {
|
||||||
import config from '@payload-config'
|
import config from '@payload-config'
|
||||||
import { redirect } from 'next/navigation'
|
import { redirect } from 'next/navigation'
|
||||||
import { getPayload } from 'payload'
|
import { getPayload } from 'payload'
|
||||||
|
import type { ReactNode } from 'react'
|
||||||
|
|
||||||
import { RecentVisitTracker } from '@/components/campaign/dashboard/RecentVisitTracker'
|
import { RecentVisitTracker } from '@/components/campaign/dashboard/RecentVisitTracker'
|
||||||
import { MunicipalityEstimateScenarioProvider } from '@/components/campaign/municipality/MunicipalityEstimateScenarioContext'
|
import { MunicipalityEstimateScenarioProvider } from '@/components/campaign/municipality/MunicipalityEstimateScenarioContext'
|
||||||
|
|
@ -13,7 +14,9 @@ import { MunicipalityList } from '@/components/campaign/municipality/Municipalit
|
||||||
import { MunicipalityListOverview } from '@/components/campaign/municipality/MunicipalityListOverview'
|
import { MunicipalityListOverview } from '@/components/campaign/municipality/MunicipalityListOverview'
|
||||||
import { CampaignListFooter } from '@/components/campaign/shared/CampaignListFooter'
|
import { CampaignListFooter } from '@/components/campaign/shared/CampaignListFooter'
|
||||||
import { CampaignScopeBadge } from '@/components/campaign/shared/CampaignScopeBadge'
|
import { CampaignScopeBadge } from '@/components/campaign/shared/CampaignScopeBadge'
|
||||||
|
import { OpsListPage } from '@/components/campaign/shared/OpsListPage'
|
||||||
import { CampaignPageShell } from '@/components/campaign/shell/CampaignPageShell'
|
import { CampaignPageShell } from '@/components/campaign/shell/CampaignPageShell'
|
||||||
|
import { resolveListUnifiedEnabled } from '@/lib/opsListRegistry/opsListFlag'
|
||||||
import {
|
import {
|
||||||
isCampaignCoordinator,
|
isCampaignCoordinator,
|
||||||
isCampaignStaff,
|
isCampaignStaff,
|
||||||
|
|
@ -41,6 +44,13 @@ type MunicipalitiesPageProps = {
|
||||||
searchParams: Promise<Record<string, string | string[] | undefined>>
|
searchParams: Promise<Record<string, string | string[] | undefined>>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const wrapStaffListRegion = (isStaffView: boolean, listRegion: ReactNode): ReactNode =>
|
||||||
|
isStaffView ? (
|
||||||
|
<MunicipalityEstimateScenarioProvider>{listRegion}</MunicipalityEstimateScenarioProvider>
|
||||||
|
) : (
|
||||||
|
listRegion
|
||||||
|
)
|
||||||
|
|
||||||
export default async function MunicipalitiesPage({ searchParams }: MunicipalitiesPageProps) {
|
export default async function MunicipalitiesPage({ searchParams }: MunicipalitiesPageProps) {
|
||||||
const rawSearchParams = await searchParams
|
const rawSearchParams = await searchParams
|
||||||
const canonicalUrl = resolveMunicipalityListUrl(rawSearchParams)
|
const canonicalUrl = resolveMunicipalityListUrl(rawSearchParams)
|
||||||
|
|
@ -116,50 +126,61 @@ export default async function MunicipalitiesPage({ searchParams }: Municipalitie
|
||||||
? null
|
? null
|
||||||
: buildMunicipalityListHref({ ...state, priority: 'alta', coverage: 'sem_assessor' }, 1)
|
: buildMunicipalityListHref({ ...state, priority: 'alta', coverage: 'sem_assessor' }, 1)
|
||||||
|
|
||||||
// The overview and the table's filter header stay mounted even with zero
|
const overviewNode =
|
||||||
// results — only the rows are replaced by the empty state.
|
isStaffView && overview ? (
|
||||||
const listBody = (
|
<MunicipalityListOverview view={overview} shameHref={shameHref} />
|
||||||
<>
|
) : null
|
||||||
{isStaffView && overview ? (
|
|
||||||
<MunicipalityListOverview view={overview} shameHref={shameHref} />
|
const tableNode = (
|
||||||
) : null}
|
<MunicipalityList
|
||||||
<MunicipalityList
|
municipalities={listMunicipalities}
|
||||||
municipalities={listMunicipalities}
|
advisorNamesById={advisorNamesById}
|
||||||
advisorNamesById={advisorNamesById}
|
isStaffView={isStaffView}
|
||||||
isStaffView={isStaffView}
|
isCoordinator={isCoordinator}
|
||||||
isCoordinator={isCoordinator}
|
canMoveEngagementLevel={canMoveEngagementLevel}
|
||||||
canMoveEngagementLevel={canMoveEngagementLevel}
|
advisorOptions={advisorOptions}
|
||||||
advisorOptions={advisorOptions}
|
columnFilterOptions={columnFilterOptions}
|
||||||
columnFilterOptions={columnFilterOptions}
|
signalFormAction={createMunicipalityListSignalFormAction}
|
||||||
signalFormAction={createMunicipalityListSignalFormAction}
|
state={state}
|
||||||
state={state}
|
columnVisibility={columnVisibility}
|
||||||
columnVisibility={columnVisibility}
|
/>
|
||||||
/>
|
|
||||||
<CampaignListFooter
|
|
||||||
totalDocs={totalDocs}
|
|
||||||
singular="município encontrado"
|
|
||||||
plural="municípios encontrados"
|
|
||||||
page={state.page}
|
|
||||||
totalPages={totalPages}
|
|
||||||
hrefForPage={(page) => buildMunicipalityListHref(state, page)}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Shared transition: filters navigate, results dim. Staff provider wraps filters + results.
|
const footerNode = (
|
||||||
const listRegion = (
|
<CampaignListFooter
|
||||||
<>
|
totalDocs={totalDocs}
|
||||||
{filters}
|
singular="município encontrado"
|
||||||
<CampaignListResults>{listBody}</CampaignListResults>
|
plural="municípios encontrados"
|
||||||
</>
|
page={state.page}
|
||||||
|
totalPages={totalPages}
|
||||||
|
hrefForPage={(page) => buildMunicipalityListHref(state, page)}
|
||||||
|
/>
|
||||||
)
|
)
|
||||||
|
|
||||||
const main = (
|
// Shared pieces; flag only switches the composition shell (CL3 tracer).
|
||||||
|
const main = resolveListUnifiedEnabled() ? (
|
||||||
|
wrapStaffListRegion(
|
||||||
|
isStaffView,
|
||||||
|
<OpsListPage
|
||||||
|
overview={overviewNode}
|
||||||
|
toolbar={filters}
|
||||||
|
table={tableNode}
|
||||||
|
empty={null}
|
||||||
|
footer={footerNode}
|
||||||
|
/>,
|
||||||
|
)
|
||||||
|
) : (
|
||||||
<CampaignListPendingBoundary>
|
<CampaignListPendingBoundary>
|
||||||
{isStaffView ? (
|
{wrapStaffListRegion(
|
||||||
<MunicipalityEstimateScenarioProvider>{listRegion}</MunicipalityEstimateScenarioProvider>
|
isStaffView,
|
||||||
) : (
|
<>
|
||||||
listRegion
|
{filters}
|
||||||
|
<CampaignListResults>
|
||||||
|
{overviewNode}
|
||||||
|
{tableNode}
|
||||||
|
{footerNode}
|
||||||
|
</CampaignListResults>
|
||||||
|
</>,
|
||||||
)}
|
)}
|
||||||
</CampaignListPendingBoundary>
|
</CampaignListPendingBoundary>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
30
src/components/campaign/shared/OpsListPage.tsx
Normal file
30
src/components/campaign/shared/OpsListPage.tsx
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
import type { ReactNode } from 'react'
|
||||||
|
|
||||||
|
import {
|
||||||
|
OpsListView,
|
||||||
|
type OpsListViewProps,
|
||||||
|
} from '@/components/campaign/shared/OpsListView'
|
||||||
|
|
||||||
|
export type OpsListPageProps = OpsListViewProps
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CL3 — casca server da factory de listas unificadas.
|
||||||
|
*
|
||||||
|
* Hoje só reencaminha slots para `OpsListView`. Ponto de extensão para OH12
|
||||||
|
* (`OfflineBoundary` → Local vs RSC) sem mudar as pages de domínio.
|
||||||
|
*/
|
||||||
|
export const OpsListPage = ({
|
||||||
|
overview,
|
||||||
|
toolbar,
|
||||||
|
table,
|
||||||
|
empty,
|
||||||
|
footer,
|
||||||
|
}: OpsListPageProps): ReactNode => (
|
||||||
|
<OpsListView
|
||||||
|
overview={overview}
|
||||||
|
toolbar={toolbar}
|
||||||
|
table={table}
|
||||||
|
empty={empty}
|
||||||
|
footer={footer}
|
||||||
|
/>
|
||||||
|
)
|
||||||
40
src/components/campaign/shared/OpsListView.tsx
Normal file
40
src/components/campaign/shared/OpsListView.tsx
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
'use client'
|
||||||
|
|
||||||
|
import type { ReactNode } from 'react'
|
||||||
|
|
||||||
|
import {
|
||||||
|
CampaignListPendingBoundary,
|
||||||
|
CampaignListResults,
|
||||||
|
} from '@/components/campaign/shared/CampaignListPending'
|
||||||
|
|
||||||
|
export type OpsListViewProps = {
|
||||||
|
/** Região acima da tabela: KPIs/overview (municipios, apoiadores) ou null. */
|
||||||
|
overview: ReactNode | null
|
||||||
|
/** Barra de filtros/search do domínio (MunicipalityFilters, LeadershipFilters, …). */
|
||||||
|
toolbar: ReactNode
|
||||||
|
/** A tabela já resolvida (CampaignTable com colunas do domínio). */
|
||||||
|
table: ReactNode
|
||||||
|
/** Empty state (CampaignListEmptyState ou Empty do domínio). */
|
||||||
|
empty: ReactNode
|
||||||
|
/** Footer/paginação (CampaignListFooter / CampaignListPagination). */
|
||||||
|
footer: ReactNode
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CL3 — composição genérica de slots para listas unificadas.
|
||||||
|
*
|
||||||
|
* Não é dona de dados: a page do domínio decide `table` vs `empty` e monta as
|
||||||
|
* peças. Toolbar fica fora de `CampaignListResults` para não dimar com o pending
|
||||||
|
* (paridade com as pages actuais).
|
||||||
|
*/
|
||||||
|
export const OpsListView = ({ overview, toolbar, table, empty, footer }: OpsListViewProps) => (
|
||||||
|
<CampaignListPendingBoundary>
|
||||||
|
{toolbar}
|
||||||
|
<CampaignListResults>
|
||||||
|
{overview}
|
||||||
|
{table}
|
||||||
|
{empty}
|
||||||
|
{footer}
|
||||||
|
</CampaignListResults>
|
||||||
|
</CampaignListPendingBoundary>
|
||||||
|
)
|
||||||
25
tests/unit/opsListPage.unit.spec.ts
Normal file
25
tests/unit/opsListPage.unit.spec.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
import { readFileSync } from 'node:fs'
|
||||||
|
import { join } from 'node:path'
|
||||||
|
|
||||||
|
import { describe, expect, it } from 'vitest'
|
||||||
|
|
||||||
|
import { resolveListUnifiedEnabled } from '@/lib/opsListRegistry/opsListFlag'
|
||||||
|
|
||||||
|
const MUNICIPIOS_PAGE = join(
|
||||||
|
process.cwd(),
|
||||||
|
'src/app/(campaign)/campanha/(app)/municipios/page.tsx',
|
||||||
|
)
|
||||||
|
|
||||||
|
describe('OpsListPage municipios tracer (CL3)', () => {
|
||||||
|
it('wires LIST_UNIFIED behind OpsListPage on the municipios route', () => {
|
||||||
|
const source = readFileSync(MUNICIPIOS_PAGE, 'utf8')
|
||||||
|
expect(source).toContain('resolveListUnifiedEnabled')
|
||||||
|
expect(source).toContain('OpsListPage')
|
||||||
|
expect(source).toContain("from '@/components/campaign/shared/OpsListPage'")
|
||||||
|
expect(source).toContain("from '@/lib/opsListRegistry/opsListFlag'")
|
||||||
|
})
|
||||||
|
|
||||||
|
it('keeps the flag fail-closed when LIST_UNIFIED is unset', () => {
|
||||||
|
expect(resolveListUnifiedEnabled({})).toBe(false)
|
||||||
|
})
|
||||||
|
})
|
||||||
Loading…
Reference in a new issue