mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-28 15:43:10 +00:00
CL7 — Migrar apoiadores e organizações para OpsListPage
Wire LIST_UNIFIED flag on /campanha/apoiadores and /campanha/organizacoes behind OpsListPage with full slot parity (KPI overview, filters, table, footer). Registry entries were already present from CL2; this completes the route delegation. Pins CL7 routes in opsListPage.unit.spec.ts. Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com>
This commit is contained in:
parent
d5ab7d0b51
commit
f49e8e3c55
4 changed files with 152 additions and 92 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
# CL7 — Migrar apoiadores e organizações para a factory
|
# CL7 — Migrar apoiadores e organizações para a factory
|
||||||
|
|
||||||
Status: rascunho
|
Status: entregue
|
||||||
Atualizado em: 2026-08-01
|
Atualizado em: 2026-08-01
|
||||||
Issue: #161
|
Issue: #161
|
||||||
Priority: P1
|
Priority: P1
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,3 @@
|
||||||
import {
|
|
||||||
CampaignListPendingBoundary,
|
|
||||||
CampaignListResults,
|
|
||||||
} from '@/components/campaign/shared/CampaignListPending'
|
|
||||||
import config from '@payload-config'
|
import config from '@payload-config'
|
||||||
import { FileUpIcon, PlusIcon, SearchXIcon } from 'lucide-react'
|
import { FileUpIcon, PlusIcon, SearchXIcon } from 'lucide-react'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
|
|
@ -10,12 +6,18 @@ import { getPayload } from 'payload'
|
||||||
|
|
||||||
import { CampaignListEmptyState } from '@/components/campaign/shared/CampaignListEmptyState'
|
import { CampaignListEmptyState } from '@/components/campaign/shared/CampaignListEmptyState'
|
||||||
import { CampaignListFooter } from '@/components/campaign/shared/CampaignListFooter'
|
import { CampaignListFooter } from '@/components/campaign/shared/CampaignListFooter'
|
||||||
|
import {
|
||||||
|
CampaignListPendingBoundary,
|
||||||
|
CampaignListResults,
|
||||||
|
} from '@/components/campaign/shared/CampaignListPending'
|
||||||
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 { SupporterFilters } from '@/components/campaign/supporter/SupporterFilters'
|
import { SupporterFilters } from '@/components/campaign/supporter/SupporterFilters'
|
||||||
import { SupporterList } from '@/components/campaign/supporter/SupporterList'
|
import { SupporterList } from '@/components/campaign/supporter/SupporterList'
|
||||||
import { SupporterListOverview } from '@/components/campaign/supporter/SupporterListOverview'
|
import { SupporterListOverview } from '@/components/campaign/supporter/SupporterListOverview'
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
|
import { resolveListUnifiedEnabled } from '@/lib/opsListRegistry/opsListFlag'
|
||||||
import { isCampaignCoordinator, isCampaignUnrestricted } from '@/utilities/campaignAccess'
|
import { isCampaignCoordinator, isCampaignUnrestricted } from '@/utilities/campaignAccess'
|
||||||
import { readCampaignColumnVisibility } from '@/utilities/campaignColumnVisibilityCookie'
|
import { readCampaignColumnVisibility } from '@/utilities/campaignColumnVisibilityCookie'
|
||||||
import { requireCampaignPageActor } from '@/utilities/campaignPageActor'
|
import { requireCampaignPageActor } from '@/utilities/campaignPageActor'
|
||||||
|
|
@ -45,37 +47,65 @@ export default async function SupportersPage({ searchParams }: SupportersPagePro
|
||||||
if (redirectHref) redirect(redirectHref)
|
if (redirectHref) redirect(redirectHref)
|
||||||
const columnVisibility = await readCampaignColumnVisibility('apoiadores')
|
const columnVisibility = await readCampaignColumnVisibility('apoiadores')
|
||||||
|
|
||||||
const listBody = (
|
const overviewNode =
|
||||||
<>
|
result.docs.length > 0 && overview ? (
|
||||||
{result.docs.length > 0 && overview ? (
|
<SupporterListOverview view={overview} now={now} />
|
||||||
<SupporterListOverview view={overview} now={now} />
|
) : null
|
||||||
) : null}
|
|
||||||
<SupporterList
|
const toolbarNode = (
|
||||||
supporters={result.docs.map((supporter) => toSupporterListItemViewModel(supporter))}
|
<SupporterFilters
|
||||||
columnVisibility={columnVisibility}
|
key={buildSupporterFiltersKey(state)}
|
||||||
empty={
|
state={state}
|
||||||
<CampaignListEmptyState
|
municipalityOptions={municipalityOptions}
|
||||||
icon={SearchXIcon}
|
/>
|
||||||
title="Nenhum apoiador encontrado"
|
)
|
||||||
description="Ajuste a busca ou os filtros. Você só vê apoiadores dentro do seu escopo."
|
|
||||||
>
|
const tableNode = (
|
||||||
<Button asChild variant="outline" className="min-h-11">
|
<SupporterList
|
||||||
<Link href="/campanha/apoiadores">Limpar busca e filtros</Link>
|
supporters={result.docs.map((supporter) => toSupporterListItemViewModel(supporter))}
|
||||||
</Button>
|
columnVisibility={columnVisibility}
|
||||||
</CampaignListEmptyState>
|
empty={
|
||||||
}
|
<CampaignListEmptyState
|
||||||
/>
|
icon={SearchXIcon}
|
||||||
{result.docs.length > 0 ? (
|
title="Nenhum apoiador encontrado"
|
||||||
<CampaignListFooter
|
description="Ajuste a busca ou os filtros. Você só vê apoiadores dentro do seu escopo."
|
||||||
totalDocs={result.totalDocs}
|
>
|
||||||
singular="apoiador encontrado"
|
<Button asChild variant="outline" className="min-h-11">
|
||||||
plural="apoiadores encontrados"
|
<Link href="/campanha/apoiadores">Limpar busca e filtros</Link>
|
||||||
page={state.page}
|
</Button>
|
||||||
totalPages={result.totalPages}
|
</CampaignListEmptyState>
|
||||||
hrefForPage={(page) => buildSupporterListHref(state, page)}
|
}
|
||||||
/>
|
/>
|
||||||
) : null}
|
)
|
||||||
</>
|
|
||||||
|
const footerNode = result.docs.length > 0 ? (
|
||||||
|
<CampaignListFooter
|
||||||
|
totalDocs={result.totalDocs}
|
||||||
|
singular="apoiador encontrado"
|
||||||
|
plural="apoiadores encontrados"
|
||||||
|
page={state.page}
|
||||||
|
totalPages={result.totalPages}
|
||||||
|
hrefForPage={(page) => buildSupporterListHref(state, page)}
|
||||||
|
/>
|
||||||
|
) : null
|
||||||
|
|
||||||
|
const main = resolveListUnifiedEnabled() ? (
|
||||||
|
<OpsListPage
|
||||||
|
overview={overviewNode}
|
||||||
|
toolbar={toolbarNode}
|
||||||
|
table={tableNode}
|
||||||
|
empty={null}
|
||||||
|
footer={footerNode}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<CampaignListPendingBoundary>
|
||||||
|
{toolbarNode}
|
||||||
|
<CampaignListResults>
|
||||||
|
{overviewNode}
|
||||||
|
{tableNode}
|
||||||
|
{footerNode}
|
||||||
|
</CampaignListResults>
|
||||||
|
</CampaignListPendingBoundary>
|
||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -110,15 +140,7 @@ export default async function SupportersPage({ searchParams }: SupportersPagePro
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<CampaignListPendingBoundary>
|
{main}
|
||||||
<SupporterFilters
|
|
||||||
key={buildSupporterFiltersKey(state)}
|
|
||||||
state={state}
|
|
||||||
municipalityOptions={municipalityOptions}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<CampaignListResults>{listBody}</CampaignListResults>
|
|
||||||
</CampaignListPendingBoundary>
|
|
||||||
</CampaignPageShell>
|
</CampaignPageShell>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,12 @@ import {
|
||||||
} from '@/components/campaign/shared/CampaignListPending'
|
} from '@/components/campaign/shared/CampaignListPending'
|
||||||
import { CampaignSearchForm } from '@/components/campaign/shared/CampaignSearchForm'
|
import { CampaignSearchForm } from '@/components/campaign/shared/CampaignSearchForm'
|
||||||
import { CampaignTable, type CampaignTableColumn } from '@/components/campaign/shared/CampaignTable'
|
import { CampaignTable, type CampaignTableColumn } from '@/components/campaign/shared/CampaignTable'
|
||||||
|
import { OpsListPage } from '@/components/campaign/shared/OpsListPage'
|
||||||
import { CampaignPageShell } from '@/components/campaign/shell/CampaignPageShell'
|
import { CampaignPageShell } from '@/components/campaign/shell/CampaignPageShell'
|
||||||
import { Badge } from '@/components/ui/Badge'
|
import { Badge } from '@/components/ui/Badge'
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
import { organizationKindLabels } from '@/lib/schemas/organization'
|
import { organizationKindLabels } from '@/lib/schemas/organization'
|
||||||
|
import { resolveListUnifiedEnabled } from '@/lib/opsListRegistry/opsListFlag'
|
||||||
import { readCampaignColumnVisibility } from '@/utilities/campaignColumnVisibilityCookie'
|
import { readCampaignColumnVisibility } from '@/utilities/campaignColumnVisibilityCookie'
|
||||||
import { requireCampaignPageActor } from '@/utilities/campaignPageActor'
|
import { requireCampaignPageActor } from '@/utilities/campaignPageActor'
|
||||||
import {
|
import {
|
||||||
|
|
@ -72,6 +74,73 @@ export default async function OrganizationsPage({ searchParams }: OrganizationsP
|
||||||
const { rows, totalDocs, totalPages } = await loadOrganizationListPageData(payload, user, state)
|
const { rows, totalDocs, totalPages } = await loadOrganizationListPageData(payload, user, state)
|
||||||
const columnVisibility = await readCampaignColumnVisibility('organizacoes')
|
const columnVisibility = await readCampaignColumnVisibility('organizacoes')
|
||||||
|
|
||||||
|
const toolbarNode = (
|
||||||
|
<CampaignSearchForm
|
||||||
|
ariaLabel="Buscar organização por nome"
|
||||||
|
placeholder="Buscar por nome…"
|
||||||
|
initialQuery={state.q ?? ''}
|
||||||
|
basePath="/campanha/organizacoes"
|
||||||
|
// Canonical serialization of the ACTIVE filters minus q/page, so a
|
||||||
|
// search submit preserves `?kind=` instead of silently dropping it.
|
||||||
|
filterParams={buildOrganizationListHref({ ...state, q: undefined }, 1).replace(
|
||||||
|
/^\/campanha\/organizacoes\??/,
|
||||||
|
'',
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
|
||||||
|
const tableNode = (
|
||||||
|
<CampaignTable
|
||||||
|
columns={organizationColumns}
|
||||||
|
columnVisibility={columnVisibility}
|
||||||
|
rows={rows}
|
||||||
|
rowKey={(row) => row.id}
|
||||||
|
empty={
|
||||||
|
<CampaignListEmptyState
|
||||||
|
icon={SearchXIcon}
|
||||||
|
title="Nenhuma organização cadastrada"
|
||||||
|
description="Cadastre sindicatos, associações e movimentos para vincular lideranças e atividades."
|
||||||
|
>
|
||||||
|
<Button asChild className="min-h-11">
|
||||||
|
<Link href="/campanha/organizacoes/nova">
|
||||||
|
<PlusIcon data-icon="inline-start" aria-hidden="true" />
|
||||||
|
Nova organização
|
||||||
|
</Link>
|
||||||
|
</Button>
|
||||||
|
</CampaignListEmptyState>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
|
||||||
|
const footerNode = rows.length ? (
|
||||||
|
<CampaignListFooter
|
||||||
|
totalDocs={totalDocs}
|
||||||
|
singular="organização"
|
||||||
|
plural="organizações"
|
||||||
|
page={state.page}
|
||||||
|
totalPages={totalPages}
|
||||||
|
hrefForPage={(page) => buildOrganizationListHref(state, page)}
|
||||||
|
/>
|
||||||
|
) : null
|
||||||
|
|
||||||
|
const main = resolveListUnifiedEnabled() ? (
|
||||||
|
<OpsListPage
|
||||||
|
overview={null}
|
||||||
|
toolbar={toolbarNode}
|
||||||
|
table={tableNode}
|
||||||
|
empty={null}
|
||||||
|
footer={footerNode}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<CampaignListPendingBoundary>
|
||||||
|
{toolbarNode}
|
||||||
|
<CampaignListResults>
|
||||||
|
{tableNode}
|
||||||
|
{footerNode}
|
||||||
|
</CampaignListResults>
|
||||||
|
</CampaignListPendingBoundary>
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CampaignPageShell>
|
<CampaignPageShell>
|
||||||
<header className="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between">
|
<header className="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between">
|
||||||
|
|
@ -90,53 +159,7 @@ export default async function OrganizationsPage({ searchParams }: OrganizationsP
|
||||||
</Button>
|
</Button>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<CampaignListPendingBoundary>
|
{main}
|
||||||
<CampaignSearchForm
|
|
||||||
ariaLabel="Buscar organização por nome"
|
|
||||||
placeholder="Buscar por nome…"
|
|
||||||
initialQuery={state.q ?? ''}
|
|
||||||
basePath="/campanha/organizacoes"
|
|
||||||
// Canonical serialization of the ACTIVE filters minus q/page, so a
|
|
||||||
// search submit preserves `?kind=` instead of silently dropping it.
|
|
||||||
filterParams={buildOrganizationListHref({ ...state, q: undefined }, 1).replace(
|
|
||||||
/^\/campanha\/organizacoes\??/,
|
|
||||||
'',
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<CampaignListResults>
|
|
||||||
<CampaignTable
|
|
||||||
columns={organizationColumns}
|
|
||||||
columnVisibility={columnVisibility}
|
|
||||||
rows={rows}
|
|
||||||
rowKey={(row) => row.id}
|
|
||||||
empty={
|
|
||||||
<CampaignListEmptyState
|
|
||||||
icon={SearchXIcon}
|
|
||||||
title="Nenhuma organização cadastrada"
|
|
||||||
description="Cadastre sindicatos, associações e movimentos para vincular lideranças e atividades."
|
|
||||||
>
|
|
||||||
<Button asChild className="min-h-11">
|
|
||||||
<Link href="/campanha/organizacoes/nova">
|
|
||||||
<PlusIcon data-icon="inline-start" aria-hidden="true" />
|
|
||||||
Nova organização
|
|
||||||
</Link>
|
|
||||||
</Button>
|
|
||||||
</CampaignListEmptyState>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
{rows.length ? (
|
|
||||||
<CampaignListFooter
|
|
||||||
totalDocs={totalDocs}
|
|
||||||
singular="organização"
|
|
||||||
plural="organizações"
|
|
||||||
page={state.page}
|
|
||||||
totalPages={totalPages}
|
|
||||||
hrefForPage={(page) => buildOrganizationListHref(state, page)}
|
|
||||||
/>
|
|
||||||
) : null}
|
|
||||||
</CampaignListResults>
|
|
||||||
</CampaignListPendingBoundary>
|
|
||||||
</CampaignPageShell>
|
</CampaignPageShell>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,12 @@ const ROUTE_PAGES = {
|
||||||
liderancas: join(process.cwd(), 'src/app/(campaign)/campanha/(app)/liderancas/page.tsx'),
|
liderancas: join(process.cwd(), 'src/app/(campaign)/campanha/(app)/liderancas/page.tsx'),
|
||||||
dobradinhas: join(process.cwd(), 'src/app/(campaign)/campanha/(app)/dobradinhas/page.tsx'),
|
dobradinhas: join(process.cwd(), 'src/app/(campaign)/campanha/(app)/dobradinhas/page.tsx'),
|
||||||
demandas: join(process.cwd(), 'src/app/(campaign)/campanha/(app)/demandas/page.tsx'),
|
demandas: join(process.cwd(), 'src/app/(campaign)/campanha/(app)/demandas/page.tsx'),
|
||||||
|
<<<<<<< HEAD
|
||||||
assessores: join(process.cwd(), 'src/app/(campaign)/campanha/(app)/assessores/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'),
|
||||||
|
>>>>>>> dd10d3c (CL7 — Migrar apoiadores e organizações para OpsListPage)
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
const expectOpsListPageWiring = (source: string) => {
|
const expectOpsListPageWiring = (source: string) => {
|
||||||
|
|
@ -33,10 +38,20 @@ describe('OpsListPage CL4 routes', () => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
describe('OpsListPage assessores (CL5)', () => {
|
describe('OpsListPage assessores (CL5)', () => {
|
||||||
it('wires LIST_UNIFIED behind OpsListPage on the assessores route', () => {
|
it('wires LIST_UNIFIED behind OpsListPage on the assessores route', () => {
|
||||||
const source = readFileSync(ROUTE_PAGES.assessores, 'utf8')
|
const source = readFileSync(ROUTE_PAGES.assessores, 'utf8')
|
||||||
expectOpsListPageWiring(source)
|
expectOpsListPageWiring(source)
|
||||||
expect(source).toContain('resolveAdvisorListUrl')
|
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'))
|
||||||
|
},
|
||||||
|
)
|
||||||
|
>>>>>>> dd10d3c (CL7 — Migrar apoiadores e organizações para OpsListPage)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue