mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-26 21:53:06 +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
|
||||
|
||||
Status: rascunho
|
||||
Status: entregue
|
||||
Atualizado em: 2026-08-01
|
||||
Issue: #161
|
||||
Priority: P1
|
||||
|
|
|
|||
|
|
@ -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,65 @@ export default async function SupportersPage({ searchParams }: SupportersPagePro
|
|||
if (redirectHref) redirect(redirectHref)
|
||||
const columnVisibility = await readCampaignColumnVisibility('apoiadores')
|
||||
|
||||
const listBody = (
|
||||
<>
|
||||
{result.docs.length > 0 && overview ? (
|
||||
<SupporterListOverview view={overview} now={now} />
|
||||
) : null}
|
||||
<SupporterList
|
||||
supporters={result.docs.map((supporter) => toSupporterListItemViewModel(supporter))}
|
||||
columnVisibility={columnVisibility}
|
||||
empty={
|
||||
<CampaignListEmptyState
|
||||
icon={SearchXIcon}
|
||||
title="Nenhum apoiador encontrado"
|
||||
description="Ajuste a busca ou os filtros. Você só vê apoiadores dentro do seu escopo."
|
||||
>
|
||||
<Button asChild variant="outline" className="min-h-11">
|
||||
<Link href="/campanha/apoiadores">Limpar busca e filtros</Link>
|
||||
</Button>
|
||||
</CampaignListEmptyState>
|
||||
}
|
||||
/>
|
||||
{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 overviewNode =
|
||||
result.docs.length > 0 && overview ? (
|
||||
<SupporterListOverview view={overview} now={now} />
|
||||
) : null
|
||||
|
||||
const toolbarNode = (
|
||||
<SupporterFilters
|
||||
key={buildSupporterFiltersKey(state)}
|
||||
state={state}
|
||||
municipalityOptions={municipalityOptions}
|
||||
/>
|
||||
)
|
||||
|
||||
const tableNode = (
|
||||
<SupporterList
|
||||
supporters={result.docs.map((supporter) => toSupporterListItemViewModel(supporter))}
|
||||
columnVisibility={columnVisibility}
|
||||
empty={
|
||||
<CampaignListEmptyState
|
||||
icon={SearchXIcon}
|
||||
title="Nenhum apoiador encontrado"
|
||||
description="Ajuste a busca ou os filtros. Você só vê apoiadores dentro do seu escopo."
|
||||
>
|
||||
<Button asChild variant="outline" className="min-h-11">
|
||||
<Link href="/campanha/apoiadores">Limpar busca e filtros</Link>
|
||||
</Button>
|
||||
</CampaignListEmptyState>
|
||||
}
|
||||
/>
|
||||
)
|
||||
|
||||
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 (
|
||||
|
|
@ -110,15 +140,7 @@ export default async function SupportersPage({ searchParams }: SupportersPagePro
|
|||
</div>
|
||||
</header>
|
||||
|
||||
<CampaignListPendingBoundary>
|
||||
<SupporterFilters
|
||||
key={buildSupporterFiltersKey(state)}
|
||||
state={state}
|
||||
municipalityOptions={municipalityOptions}
|
||||
/>
|
||||
|
||||
<CampaignListResults>{listBody}</CampaignListResults>
|
||||
</CampaignListPendingBoundary>
|
||||
{main}
|
||||
</CampaignPageShell>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,10 +11,12 @@ 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 { organizationKindLabels } from '@/lib/schemas/organization'
|
||||
import { resolveListUnifiedEnabled } from '@/lib/opsListRegistry/opsListFlag'
|
||||
import { readCampaignColumnVisibility } from '@/utilities/campaignColumnVisibilityCookie'
|
||||
import { requireCampaignPageActor } from '@/utilities/campaignPageActor'
|
||||
import {
|
||||
|
|
@ -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 = (
|
||||
<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 (
|
||||
<CampaignPageShell>
|
||||
<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>
|
||||
</header>
|
||||
|
||||
<CampaignListPendingBoundary>
|
||||
<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>
|
||||
{main}
|
||||
</CampaignPageShell>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,12 @@ const ROUTE_PAGES = {
|
|||
liderancas: join(process.cwd(), 'src/app/(campaign)/campanha/(app)/liderancas/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'),
|
||||
<<<<<<< HEAD
|
||||
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
|
||||
|
||||
const expectOpsListPageWiring = (source: string) => {
|
||||
|
|
@ -33,10 +38,20 @@ describe('OpsListPage CL4 routes', () => {
|
|||
)
|
||||
})
|
||||
|
||||
<<<<<<< HEAD
|
||||
describe('OpsListPage assessores (CL5)', () => {
|
||||
it('wires LIST_UNIFIED behind OpsListPage on the assessores route', () => {
|
||||
const source = readFileSync(ROUTE_PAGES.assessores, 'utf8')
|
||||
expectOpsListPageWiring(source)
|
||||
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