mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-26 21:53:06 +00:00
Merge pull request #187 from fsolla/cursor/pool-i158-2c584dfa-c233
CL4 — Migrar lideranças, dobradinhas, demandas para a factory
This commit is contained in:
commit
f69855eac1
4 changed files with 208 additions and 118 deletions
|
|
@ -11,9 +11,11 @@ import {
|
|||
CampaignListResults,
|
||||
} from '@/components/campaign/shared/CampaignListPending'
|
||||
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 {
|
||||
campaignDemandKindLabels,
|
||||
campaignDemandStatusLabels,
|
||||
|
|
@ -110,6 +112,72 @@ export default async function DemandsPage({ searchParams }: DemandsPageProps) {
|
|||
const hrefForStatus = (status?: CampaignDemandStatus) =>
|
||||
buildDemandListHref({ ...state, status }, 1)
|
||||
|
||||
const statusChips = (
|
||||
<CampaignFilterChips
|
||||
ariaLabel="Filtrar por status"
|
||||
chips={[
|
||||
{ href: hrefForStatus(undefined), label: 'Todas', active: state.status === undefined },
|
||||
...campaignDemandStatuses.map((status) => ({
|
||||
href: hrefForStatus(status),
|
||||
label: campaignDemandStatusLabels[status],
|
||||
active: state.status === status,
|
||||
})),
|
||||
]}
|
||||
/>
|
||||
)
|
||||
|
||||
const tableNode = (
|
||||
<CampaignTable
|
||||
columns={demandColumns}
|
||||
columnVisibility={columnVisibility}
|
||||
rows={rows}
|
||||
rowKey={(row) => row.id}
|
||||
empty={
|
||||
<CampaignListEmptyState
|
||||
icon={InboxIcon}
|
||||
title="Nenhuma demanda por aqui"
|
||||
description="Abra uma demanda quando precisar de material, transporte, espaço ou apoio para uma ação."
|
||||
>
|
||||
<Button asChild className="min-h-11">
|
||||
<Link href="/campanha/demandas/nova">
|
||||
<PlusIcon data-icon="inline-start" aria-hidden="true" />
|
||||
Nova demanda
|
||||
</Link>
|
||||
</Button>
|
||||
</CampaignListEmptyState>
|
||||
}
|
||||
/>
|
||||
)
|
||||
|
||||
const footerNode = rows.length ? (
|
||||
<CampaignListFooter
|
||||
totalDocs={totalDocs}
|
||||
singular="demanda"
|
||||
plural="demandas"
|
||||
page={state.page}
|
||||
totalPages={totalPages}
|
||||
hrefForPage={(page) => buildDemandListHref(state, page)}
|
||||
/>
|
||||
) : null
|
||||
|
||||
const main = resolveListUnifiedEnabled() ? (
|
||||
<OpsListPage
|
||||
overview={null}
|
||||
toolbar={statusChips}
|
||||
table={tableNode}
|
||||
empty={null}
|
||||
footer={footerNode}
|
||||
/>
|
||||
) : (
|
||||
<CampaignListPendingBoundary>
|
||||
{statusChips}
|
||||
<CampaignListResults>
|
||||
{tableNode}
|
||||
{footerNode}
|
||||
</CampaignListResults>
|
||||
</CampaignListPendingBoundary>
|
||||
)
|
||||
|
||||
return (
|
||||
<CampaignPageShell>
|
||||
<header className="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between">
|
||||
|
|
@ -131,52 +199,7 @@ export default async function DemandsPage({ searchParams }: DemandsPageProps) {
|
|||
</Button>
|
||||
</header>
|
||||
|
||||
<CampaignListPendingBoundary>
|
||||
<CampaignFilterChips
|
||||
ariaLabel="Filtrar por status"
|
||||
chips={[
|
||||
{ href: hrefForStatus(undefined), label: 'Todas', active: state.status === undefined },
|
||||
...campaignDemandStatuses.map((status) => ({
|
||||
href: hrefForStatus(status),
|
||||
label: campaignDemandStatusLabels[status],
|
||||
active: state.status === status,
|
||||
})),
|
||||
]}
|
||||
/>
|
||||
|
||||
<CampaignListResults>
|
||||
<CampaignTable
|
||||
columns={demandColumns}
|
||||
columnVisibility={columnVisibility}
|
||||
rows={rows}
|
||||
rowKey={(row) => row.id}
|
||||
empty={
|
||||
<CampaignListEmptyState
|
||||
icon={InboxIcon}
|
||||
title="Nenhuma demanda por aqui"
|
||||
description="Abra uma demanda quando precisar de material, transporte, espaço ou apoio para uma ação."
|
||||
>
|
||||
<Button asChild className="min-h-11">
|
||||
<Link href="/campanha/demandas/nova">
|
||||
<PlusIcon data-icon="inline-start" aria-hidden="true" />
|
||||
Nova demanda
|
||||
</Link>
|
||||
</Button>
|
||||
</CampaignListEmptyState>
|
||||
}
|
||||
/>
|
||||
{rows.length ? (
|
||||
<CampaignListFooter
|
||||
totalDocs={totalDocs}
|
||||
singular="demanda"
|
||||
plural="demandas"
|
||||
page={state.page}
|
||||
totalPages={totalPages}
|
||||
hrefForPage={(page) => buildDemandListHref(state, page)}
|
||||
/>
|
||||
) : null}
|
||||
</CampaignListResults>
|
||||
</CampaignListPendingBoundary>
|
||||
{main}
|
||||
</CampaignPageShell>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import {
|
|||
type RelationCellOption,
|
||||
} from '@/components/campaign/shared/LeadershipStateDeputyRelationCell'
|
||||
import { MunicipalityPortfolioCell } from '@/components/campaign/shared/MunicipalityPortfolioCell'
|
||||
import { OpsListPage } from '@/components/campaign/shared/OpsListPage'
|
||||
import { CampaignPageShell } from '@/components/campaign/shell/CampaignPageShell'
|
||||
import { StateDeputyFilters } from '@/components/campaign/stateDeputy/StateDeputyFilters'
|
||||
import { StateDeputySortableHead } from '@/components/campaign/stateDeputy/StateDeputySortableHead'
|
||||
|
|
@ -35,6 +36,7 @@ import {
|
|||
} from '@/components/ui/Empty'
|
||||
import { resolveVisibleColumns } from '@/lib/campaignColumnVisibility'
|
||||
import type { MunicipalityPortfolioIndexEntry } from '@/lib/municipalityPortfolio'
|
||||
import { resolveListUnifiedEnabled } from '@/lib/opsListRegistry/opsListFlag'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { getAdvisorMunicipalityIds } from '@/utilities/campaignAccess'
|
||||
import { readCampaignColumnVisibility } from '@/utilities/campaignColumnVisibilityCookie'
|
||||
|
|
@ -221,6 +223,63 @@ export default async function StateDeputiesPage({ searchParams }: StateDeputiesP
|
|||
administeredIds ? new Set(administeredIds) : undefined,
|
||||
)
|
||||
|
||||
const filters = (
|
||||
<StateDeputyFilters
|
||||
state={state}
|
||||
partyOptions={partyFilterOptions}
|
||||
hasNoParty={filterFacets.hasNoParty}
|
||||
/>
|
||||
)
|
||||
|
||||
const sortSummaryNode = (
|
||||
<p className="text-sm text-muted-foreground" aria-live="polite">
|
||||
{sortSummary}
|
||||
</p>
|
||||
)
|
||||
|
||||
const tableNode = (
|
||||
<CampaignListSheetProvider>
|
||||
<CampaignTable
|
||||
caption={`${sortSummary}. Deputados estaduais com quem a campanha dobra.`}
|
||||
columns={columns}
|
||||
columnVisibility={columnVisibility}
|
||||
rows={rows}
|
||||
rowKey={(row) => row.id}
|
||||
empty={<StateDeputyListEmptyState state={state} />}
|
||||
/>
|
||||
</CampaignListSheetProvider>
|
||||
)
|
||||
|
||||
const footerNode = rows.length ? (
|
||||
<CampaignListFooter
|
||||
totalDocs={totalDocs}
|
||||
singular="dobradinha"
|
||||
plural="dobradinhas"
|
||||
page={state.page}
|
||||
totalPages={totalPages}
|
||||
hrefForPage={(page) => buildStateDeputyListHref(state, page)}
|
||||
/>
|
||||
) : null
|
||||
|
||||
const main = resolveListUnifiedEnabled() ? (
|
||||
<OpsListPage
|
||||
overview={sortSummaryNode}
|
||||
toolbar={filters}
|
||||
table={tableNode}
|
||||
empty={null}
|
||||
footer={footerNode}
|
||||
/>
|
||||
) : (
|
||||
<CampaignListPendingBoundary>
|
||||
{filters}
|
||||
<CampaignListResults>
|
||||
{sortSummaryNode}
|
||||
{tableNode}
|
||||
{footerNode}
|
||||
</CampaignListResults>
|
||||
</CampaignListPendingBoundary>
|
||||
)
|
||||
|
||||
return (
|
||||
<CampaignPageShell>
|
||||
<header className="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between">
|
||||
|
|
@ -239,41 +298,7 @@ export default async function StateDeputiesPage({ searchParams }: StateDeputiesP
|
|||
</Button>
|
||||
</header>
|
||||
|
||||
<CampaignListPendingBoundary>
|
||||
<StateDeputyFilters
|
||||
state={state}
|
||||
partyOptions={partyFilterOptions}
|
||||
hasNoParty={filterFacets.hasNoParty}
|
||||
/>
|
||||
|
||||
<CampaignListResults>
|
||||
<p className="text-sm text-muted-foreground" aria-live="polite">
|
||||
{sortSummary}
|
||||
</p>
|
||||
{/* One shared Drawer for every chip-cell sheet on coarse pointers
|
||||
(miss #52 — never a Drawer root per opened cell). */}
|
||||
<CampaignListSheetProvider>
|
||||
<CampaignTable
|
||||
caption={`${sortSummary}. Deputados estaduais com quem a campanha dobra.`}
|
||||
columns={columns}
|
||||
columnVisibility={columnVisibility}
|
||||
rows={rows}
|
||||
rowKey={(row) => row.id}
|
||||
empty={<StateDeputyListEmptyState state={state} />}
|
||||
/>
|
||||
</CampaignListSheetProvider>
|
||||
{rows.length ? (
|
||||
<CampaignListFooter
|
||||
totalDocs={totalDocs}
|
||||
singular="dobradinha"
|
||||
plural="dobradinhas"
|
||||
page={state.page}
|
||||
totalPages={totalPages}
|
||||
hrefForPage={(page) => buildStateDeputyListHref(state, page)}
|
||||
/>
|
||||
) : null}
|
||||
</CampaignListResults>
|
||||
</CampaignListPendingBoundary>
|
||||
{main}
|
||||
</CampaignPageShell>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import {
|
|||
type RelationCellOption,
|
||||
} from '@/components/campaign/shared/LeadershipStateDeputyRelationCell'
|
||||
import { MunicipalityPortfolioCell } from '@/components/campaign/shared/MunicipalityPortfolioCell'
|
||||
import { OpsListPage } from '@/components/campaign/shared/OpsListPage'
|
||||
import { CampaignPageShell } from '@/components/campaign/shell/CampaignPageShell'
|
||||
import { Badge } from '@/components/ui/Badge'
|
||||
import { Button, buttonVariants } from '@/components/ui/button'
|
||||
|
|
@ -46,6 +47,7 @@ import {
|
|||
resolvedPortfolioEntriesById,
|
||||
type MunicipalityPortfolioIndexEntry,
|
||||
} from '@/lib/municipalityPortfolio'
|
||||
import { resolveListUnifiedEnabled } from '@/lib/opsListRegistry/opsListFlag'
|
||||
import { formatBrazilianPhoneInput, whatsAppHrefForPhone } from '@/lib/phone'
|
||||
import { MAX_LEADERSHIP_MUNICIPALITIES } from '@/lib/schemas/leadership'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
|
@ -379,6 +381,59 @@ export default async function LeadershipsPage({ searchParams }: LeadershipsPageP
|
|||
nowMs: Date.now(),
|
||||
})
|
||||
|
||||
const filters = (
|
||||
<LeadershipFilters state={state} municipalityLabelsById={municipalityLabelsById} />
|
||||
)
|
||||
|
||||
const sortSummaryNode = (
|
||||
<p className="text-sm text-muted-foreground" aria-live="polite">
|
||||
{sortSummary}
|
||||
</p>
|
||||
)
|
||||
|
||||
const tableNode = (
|
||||
<CampaignListSheetProvider>
|
||||
<CampaignTable
|
||||
caption={`${sortSummary}. Uma ficha por pessoa — cada liderança pode atuar em vários municípios e organizações.`}
|
||||
columns={columns}
|
||||
columnVisibility={columnVisibility}
|
||||
rows={rows}
|
||||
rowKey={(row) => row.id}
|
||||
empty={<LeadershipListEmptyState state={state} />}
|
||||
/>
|
||||
</CampaignListSheetProvider>
|
||||
)
|
||||
|
||||
const footerNode = rows.length ? (
|
||||
<CampaignListFooter
|
||||
totalDocs={totalDocs}
|
||||
singular="liderança"
|
||||
plural="lideranças"
|
||||
page={state.page}
|
||||
totalPages={totalPages}
|
||||
hrefForPage={(page) => buildLeadershipListHref(state, page)}
|
||||
/>
|
||||
) : null
|
||||
|
||||
const main = resolveListUnifiedEnabled() ? (
|
||||
<OpsListPage
|
||||
overview={sortSummaryNode}
|
||||
toolbar={filters}
|
||||
table={tableNode}
|
||||
empty={null}
|
||||
footer={footerNode}
|
||||
/>
|
||||
) : (
|
||||
<CampaignListPendingBoundary>
|
||||
{filters}
|
||||
<CampaignListResults>
|
||||
{sortSummaryNode}
|
||||
{tableNode}
|
||||
{footerNode}
|
||||
</CampaignListResults>
|
||||
</CampaignListPendingBoundary>
|
||||
)
|
||||
|
||||
return (
|
||||
<CampaignPageShell>
|
||||
<header className="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between">
|
||||
|
|
@ -396,37 +451,7 @@ export default async function LeadershipsPage({ searchParams }: LeadershipsPageP
|
|||
</Button>
|
||||
</header>
|
||||
|
||||
<CampaignListPendingBoundary>
|
||||
<LeadershipFilters state={state} municipalityLabelsById={municipalityLabelsById} />
|
||||
|
||||
<CampaignListResults>
|
||||
<p className="text-sm text-muted-foreground" aria-live="polite">
|
||||
{sortSummary}
|
||||
</p>
|
||||
{/* One shared Drawer for every chip-cell sheet on coarse pointers
|
||||
(miss #52 — never a Drawer root per opened cell). */}
|
||||
<CampaignListSheetProvider>
|
||||
<CampaignTable
|
||||
caption={`${sortSummary}. Uma ficha por pessoa — cada liderança pode atuar em vários municípios e organizações.`}
|
||||
columns={columns}
|
||||
columnVisibility={columnVisibility}
|
||||
rows={rows}
|
||||
rowKey={(row) => row.id}
|
||||
empty={<LeadershipListEmptyState state={state} />}
|
||||
/>
|
||||
</CampaignListSheetProvider>
|
||||
{rows.length ? (
|
||||
<CampaignListFooter
|
||||
totalDocs={totalDocs}
|
||||
singular="liderança"
|
||||
plural="lideranças"
|
||||
page={state.page}
|
||||
totalPages={totalPages}
|
||||
hrefForPage={(page) => buildLeadershipListHref(state, page)}
|
||||
/>
|
||||
) : null}
|
||||
</CampaignListResults>
|
||||
</CampaignListPendingBoundary>
|
||||
{main}
|
||||
</CampaignPageShell>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,14 +3,31 @@ import { join } from 'node:path'
|
|||
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
const MUNICIPIOS_PAGE = join(process.cwd(), 'src/app/(campaign)/campanha/(app)/municipios/page.tsx')
|
||||
const ROUTE_PAGES = {
|
||||
municipios: join(process.cwd(), 'src/app/(campaign)/campanha/(app)/municipios/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'),
|
||||
demandas: join(process.cwd(), 'src/app/(campaign)/campanha/(app)/demandas/page.tsx'),
|
||||
} as const
|
||||
|
||||
const expectOpsListPageWiring = (source: string) => {
|
||||
expect(source).toContain('resolveListUnifiedEnabled')
|
||||
expect(source).toContain('OpsListPage')
|
||||
expect(source).toContain("from '@/components/campaign/shared/OpsListPage'")
|
||||
expect(source).toContain("from '@/lib/opsListRegistry/opsListFlag'")
|
||||
}
|
||||
|
||||
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'")
|
||||
expectOpsListPageWiring(readFileSync(ROUTE_PAGES.municipios, 'utf8'))
|
||||
})
|
||||
})
|
||||
|
||||
describe('OpsListPage CL4 routes', () => {
|
||||
it.each(['liderancas', 'dobradinhas', 'demandas'] as const)(
|
||||
'wires LIST_UNIFIED behind OpsListPage on the %s route',
|
||||
(route) => {
|
||||
expectOpsListPageWiring(readFileSync(ROUTE_PAGES[route], 'utf8'))
|
||||
},
|
||||
)
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue