mirror of
https://github.com/fsolla/teqo.git
synced 2026-12-06 18:53:05 +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,11 +47,20 @@ 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
|
||||||
|
|
||||||
|
const toolbarNode = (
|
||||||
|
<SupporterFilters
|
||||||
|
key={buildSupporterFiltersKey(state)}
|
||||||
|
state={state}
|
||||||
|
municipalityOptions={municipalityOptions}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
|
||||||
|
const tableNode = (
|
||||||
<SupporterList
|
<SupporterList
|
||||||
supporters={result.docs.map((supporter) => toSupporterListItemViewModel(supporter))}
|
supporters={result.docs.map((supporter) => toSupporterListItemViewModel(supporter))}
|
||||||
columnVisibility={columnVisibility}
|
columnVisibility={columnVisibility}
|
||||||
|
|
@ -65,7 +76,9 @@ export default async function SupportersPage({ searchParams }: SupportersPagePro
|
||||||
</CampaignListEmptyState>
|
</CampaignListEmptyState>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
{result.docs.length > 0 ? (
|
)
|
||||||
|
|
||||||
|
const footerNode = result.docs.length > 0 ? (
|
||||||
<CampaignListFooter
|
<CampaignListFooter
|
||||||
totalDocs={result.totalDocs}
|
totalDocs={result.totalDocs}
|
||||||
singular="apoiador encontrado"
|
singular="apoiador encontrado"
|
||||||
|
|
@ -74,8 +87,25 @@ export default async function SupportersPage({ searchParams }: SupportersPagePro
|
||||||
totalPages={result.totalPages}
|
totalPages={result.totalPages}
|
||||||
hrefForPage={(page) => buildSupporterListHref(state, page)}
|
hrefForPage={(page) => buildSupporterListHref(state, page)}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : 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,25 +74,7 @@ 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')
|
||||||
|
|
||||||
return (
|
const toolbarNode = (
|
||||||
<CampaignPageShell>
|
|
||||||
<header className="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between">
|
|
||||||
<div className="flex flex-col gap-2">
|
|
||||||
<h1 className="text-2xl font-semibold tracking-tight">Organizações</h1>
|
|
||||||
<p className="text-muted-foreground">
|
|
||||||
Sindicatos, associações e movimentos que apoiam a campanha — com suas lideranças e
|
|
||||||
atividades.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<Button asChild className="min-h-11">
|
|
||||||
<Link href="/campanha/organizacoes/nova">
|
|
||||||
<PlusIcon data-icon="inline-start" aria-hidden="true" />
|
|
||||||
Nova organização
|
|
||||||
</Link>
|
|
||||||
</Button>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<CampaignListPendingBoundary>
|
|
||||||
<CampaignSearchForm
|
<CampaignSearchForm
|
||||||
ariaLabel="Buscar organização por nome"
|
ariaLabel="Buscar organização por nome"
|
||||||
placeholder="Buscar por nome…"
|
placeholder="Buscar por nome…"
|
||||||
|
|
@ -103,8 +87,9 @@ export default async function OrganizationsPage({ searchParams }: OrganizationsP
|
||||||
'',
|
'',
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
)
|
||||||
|
|
||||||
<CampaignListResults>
|
const tableNode = (
|
||||||
<CampaignTable
|
<CampaignTable
|
||||||
columns={organizationColumns}
|
columns={organizationColumns}
|
||||||
columnVisibility={columnVisibility}
|
columnVisibility={columnVisibility}
|
||||||
|
|
@ -125,7 +110,9 @@ export default async function OrganizationsPage({ searchParams }: OrganizationsP
|
||||||
</CampaignListEmptyState>
|
</CampaignListEmptyState>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
{rows.length ? (
|
)
|
||||||
|
|
||||||
|
const footerNode = rows.length ? (
|
||||||
<CampaignListFooter
|
<CampaignListFooter
|
||||||
totalDocs={totalDocs}
|
totalDocs={totalDocs}
|
||||||
singular="organização"
|
singular="organização"
|
||||||
|
|
@ -134,9 +121,45 @@ export default async function OrganizationsPage({ searchParams }: OrganizationsP
|
||||||
totalPages={totalPages}
|
totalPages={totalPages}
|
||||||
hrefForPage={(page) => buildOrganizationListHref(state, page)}
|
hrefForPage={(page) => buildOrganizationListHref(state, page)}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null
|
||||||
|
|
||||||
|
const main = resolveListUnifiedEnabled() ? (
|
||||||
|
<OpsListPage
|
||||||
|
overview={null}
|
||||||
|
toolbar={toolbarNode}
|
||||||
|
table={tableNode}
|
||||||
|
empty={null}
|
||||||
|
footer={footerNode}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<CampaignListPendingBoundary>
|
||||||
|
{toolbarNode}
|
||||||
|
<CampaignListResults>
|
||||||
|
{tableNode}
|
||||||
|
{footerNode}
|
||||||
</CampaignListResults>
|
</CampaignListResults>
|
||||||
</CampaignListPendingBoundary>
|
</CampaignListPendingBoundary>
|
||||||
|
)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<CampaignPageShell>
|
||||||
|
<header className="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between">
|
||||||
|
<div className="flex flex-col gap-2">
|
||||||
|
<h1 className="text-2xl font-semibold tracking-tight">Organizações</h1>
|
||||||
|
<p className="text-muted-foreground">
|
||||||
|
Sindicatos, associações e movimentos que apoiam a campanha — com suas lideranças e
|
||||||
|
atividades.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<Button asChild className="min-h-11">
|
||||||
|
<Link href="/campanha/organizacoes/nova">
|
||||||
|
<PlusIcon data-icon="inline-start" aria-hidden="true" />
|
||||||
|
Nova organização
|
||||||
|
</Link>
|
||||||
|
</Button>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
{main}
|
||||||
</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