diff --git a/docs/plans/cl7-apoiadores-organizacoes.md b/docs/plans/cl7-apoiadores-organizacoes.md index b9588e44..81b58535 100644 --- a/docs/plans/cl7-apoiadores-organizacoes.md +++ b/docs/plans/cl7-apoiadores-organizacoes.md @@ -1,6 +1,6 @@ # CL7 — Migrar apoiadores e organizações para a factory -Status: rascunho +Status: entregue Atualizado em: 2026-08-01 Issue: #161 Priority: P1 diff --git a/src/app/(campaign)/campanha/(app)/apoiadores/page.tsx b/src/app/(campaign)/campanha/(app)/apoiadores/page.tsx index 09596943..620cf3a3 100644 --- a/src/app/(campaign)/campanha/(app)/apoiadores/page.tsx +++ b/src/app/(campaign)/campanha/(app)/apoiadores/page.tsx @@ -1,7 +1,3 @@ -import { - CampaignListPendingBoundary, - CampaignListResults, -} from '@/components/campaign/shared/CampaignListPending' import config from '@payload-config' import { FileUpIcon, PlusIcon, SearchXIcon } from 'lucide-react' import Link from 'next/link' @@ -10,12 +6,18 @@ import { getPayload } from 'payload' import { CampaignListEmptyState } from '@/components/campaign/shared/CampaignListEmptyState' import { CampaignListFooter } from '@/components/campaign/shared/CampaignListFooter' +import { + CampaignListPendingBoundary, + CampaignListResults, +} from '@/components/campaign/shared/CampaignListPending' import { CampaignScopeBadge } from '@/components/campaign/shared/CampaignScopeBadge' +import { OpsListPage } from '@/components/campaign/shared/OpsListPage' import { CampaignPageShell } from '@/components/campaign/shell/CampaignPageShell' import { SupporterFilters } from '@/components/campaign/supporter/SupporterFilters' import { SupporterList } from '@/components/campaign/supporter/SupporterList' import { SupporterListOverview } from '@/components/campaign/supporter/SupporterListOverview' import { Button } from '@/components/ui/button' +import { resolveListUnifiedEnabled } from '@/lib/opsListRegistry/opsListFlag' import { isCampaignCoordinator, isCampaignUnrestricted } from '@/utilities/campaignAccess' import { readCampaignColumnVisibility } from '@/utilities/campaignColumnVisibilityCookie' import { requireCampaignPageActor } from '@/utilities/campaignPageActor' @@ -45,37 +47,64 @@ export default async function SupportersPage({ searchParams }: SupportersPagePro if (redirectHref) redirect(redirectHref) const columnVisibility = await readCampaignColumnVisibility('apoiadores') - const listBody = ( - <> - {result.docs.length > 0 && overview ? ( - - ) : null} - toSupporterListItemViewModel(supporter))} - columnVisibility={columnVisibility} - empty={ - - - - } + const overviewNode = + result.docs.length > 0 && overview ? : null + + const toolbarNode = ( + + ) + + const tableNode = ( + toSupporterListItemViewModel(supporter))} + columnVisibility={columnVisibility} + empty={ + + + + } + /> + ) + + const footerNode = + result.docs.length > 0 ? ( + buildSupporterListHref(state, page)} /> - {result.docs.length > 0 ? ( - buildSupporterListHref(state, page)} - /> - ) : null} - + ) : null + + const main = resolveListUnifiedEnabled() ? ( + + ) : ( + + {toolbarNode} + + {overviewNode} + {tableNode} + {footerNode} + + ) return ( @@ -110,15 +139,7 @@ export default async function SupportersPage({ searchParams }: SupportersPagePro - - - - {listBody} - + {main} ) } diff --git a/src/app/(campaign)/campanha/(app)/organizacoes/page.tsx b/src/app/(campaign)/campanha/(app)/organizacoes/page.tsx index 29928f38..64ca9af7 100644 --- a/src/app/(campaign)/campanha/(app)/organizacoes/page.tsx +++ b/src/app/(campaign)/campanha/(app)/organizacoes/page.tsx @@ -11,9 +11,11 @@ import { } from '@/components/campaign/shared/CampaignListPending' import { CampaignSearchForm } from '@/components/campaign/shared/CampaignSearchForm' import { CampaignTable, type CampaignTableColumn } from '@/components/campaign/shared/CampaignTable' +import { OpsListPage } from '@/components/campaign/shared/OpsListPage' import { CampaignPageShell } from '@/components/campaign/shell/CampaignPageShell' import { Badge } from '@/components/ui/Badge' import { Button } from '@/components/ui/button' +import { resolveListUnifiedEnabled } from '@/lib/opsListRegistry/opsListFlag' import { organizationKindLabels } from '@/lib/schemas/organization' import { readCampaignColumnVisibility } from '@/utilities/campaignColumnVisibilityCookie' import { requireCampaignPageActor } from '@/utilities/campaignPageActor' @@ -72,6 +74,73 @@ export default async function OrganizationsPage({ searchParams }: OrganizationsP const { rows, totalDocs, totalPages } = await loadOrganizationListPageData(payload, user, state) const columnVisibility = await readCampaignColumnVisibility('organizacoes') + const toolbarNode = ( + + ) + + const tableNode = ( + row.id} + empty={ + + + + } + /> + ) + + const footerNode = rows.length ? ( + buildOrganizationListHref(state, page)} + /> + ) : null + + const main = resolveListUnifiedEnabled() ? ( + + ) : ( + + {toolbarNode} + + {tableNode} + {footerNode} + + + ) + return (
@@ -90,53 +159,7 @@ export default async function OrganizationsPage({ searchParams }: OrganizationsP
- - - - - row.id} - empty={ - - - - } - /> - {rows.length ? ( - buildOrganizationListHref(state, page)} - /> - ) : null} - - + {main}
) } diff --git a/tests/unit/opsListPage.unit.spec.ts b/tests/unit/opsListPage.unit.spec.ts index a8038c55..957c3519 100644 --- a/tests/unit/opsListPage.unit.spec.ts +++ b/tests/unit/opsListPage.unit.spec.ts @@ -9,6 +9,8 @@ const ROUTE_PAGES = { dobradinhas: join(process.cwd(), 'src/app/(campaign)/campanha/(app)/dobradinhas/page.tsx'), demandas: join(process.cwd(), 'src/app/(campaign)/campanha/(app)/demandas/page.tsx'), assessores: join(process.cwd(), 'src/app/(campaign)/campanha/(app)/assessores/page.tsx'), + apoiadores: join(process.cwd(), 'src/app/(campaign)/campanha/(app)/apoiadores/page.tsx'), + organizacoes: join(process.cwd(), 'src/app/(campaign)/campanha/(app)/organizacoes/page.tsx'), } as const const expectOpsListPageWiring = (source: string) => { @@ -40,3 +42,12 @@ describe('OpsListPage assessores (CL5)', () => { expect(source).toContain('resolveAdvisorListUrl') }) }) + +describe('OpsListPage CL7 routes', () => { + it.each(['apoiadores', 'organizacoes'] as const)( + 'wires LIST_UNIFIED behind OpsListPage on the %s route', + (route) => { + expectOpsListPageWiring(readFileSync(ROUTE_PAGES[route], 'utf8')) + }, + ) +})