mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-26 21:53:06 +00:00
OH12: simplify Local lists — shared offline copy + boundary hook
Reuse opsListLocalCopy for saved-filter gates, drive OfflineBoundary from useBrowserOffline, drop dead registry null-check and unused exports, and tighten municipality Local sorting/casts. Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com>
This commit is contained in:
parent
63cd15eef5
commit
c04c1a4c36
9 changed files with 55 additions and 107 deletions
|
|
@ -4,6 +4,8 @@ Conteúdo movido do `AGENTS.md` em 2026-07-30 (fatiamento do paradigma de agente
|
|||
|
||||
---
|
||||
|
||||
**Recently resolved (2026-08-02):** **OH12** (Issue #174) — `OpsListLocal` read-only via registry + mirror: `OfflineBoundary` nas 8 rotas de lista; Local com `CampaignTable` + parsers canónicos sobre o mirror (municípios/lideranças/dobradinhas/orgs/demandas); assessores/territórios/apoiadores com estado honesto; saved filters create/delete disabled offline; e2e lista `?q=`. Plano: [`oh12-ops-list-local.md`](docs/plans/oh12-ops-list-local.md).
|
||||
|
||||
**Recently resolved (2026-08-02):** **OH11** (Issue #173) — SW cache-first para `/_next/static/` (chunks hashed, prefixo `campanha-<buildId>`); logout limpa campaignOps na ordem abort sync → outbox → persistence → Cache API (`clearCampaignOpsStorage` + `clearCampaignPwaCaches`); e2e `campaignOpsOffline` com jornada write→reload→online→sync (`OPS_HYBRID=1`). Plano: [`oh11-sw-e2e-docs.md`](docs/plans/oh11-sw-e2e-docs.md).
|
||||
|
||||
**Recently resolved (2026-08-02):** **B120** (Issue #207) — municípios mobile: combobox multi-filtro (chips + typeahead) no lugar da pilha NativeSelect; overview KPI + aviso de sort só em `md+`; cards densificados (cobertura/nível + controles compactos). URL B18 intacta. Plano: [`municipios-mobile-filtro-combobox-densificar.md`](docs/plans/municipios-mobile-filtro-combobox-densificar.md).
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ flowchart LR
|
|||
Bound -->|online| Factory[OpsListPage RSC]
|
||||
Bound -->|offline + flag| Local[OpsListLocal slug]
|
||||
Local --> Parse[parser URL domínio]
|
||||
Local --> Q[useLiveQuery mirror]
|
||||
Local --> Q[subscribeChanges mirror]
|
||||
Q --> Table[CampaignTable + shells]
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { BookmarkPlusIcon } from 'lucide-react'
|
|||
import { useId, useState, type FormEvent } from 'react'
|
||||
import { toast } from 'sonner'
|
||||
|
||||
import { OPS_LIST_ONLINE_ONLY_MESSAGE } from '@/components/campaign/opsSync/opsListLocalCopy'
|
||||
import { useBrowserOffline } from '@/components/campaign/opsSync/useBrowserOffline'
|
||||
import { useMunicipalitySavedFilters } from '@/components/campaign/shared/useMunicipalitySavedFilters'
|
||||
import { Alert, AlertDescription } from '@/components/ui/Alert'
|
||||
|
|
@ -22,8 +23,6 @@ import {
|
|||
saveMunicipalitySavedFilter,
|
||||
} from '@/utilities/municipality/municipalitySavedFilters'
|
||||
|
||||
const ONLINE_ONLY_SAVED_FILTER_MESSAGE = 'Disponível quando estiveres online.'
|
||||
|
||||
type SaveMunicipalityFilterControlProps = {
|
||||
/** The APPLIED state — a search still inside the debounce window is not in the URL yet. */
|
||||
state: MunicipalityListState
|
||||
|
|
@ -94,8 +93,8 @@ export const SaveMunicipalityFilterControl = ({ state }: SaveMunicipalityFilterC
|
|||
variant="ghost"
|
||||
className="min-h-11 shrink-0 md:self-end"
|
||||
disabled
|
||||
title={ONLINE_ONLY_SAVED_FILTER_MESSAGE}
|
||||
aria-label={`${existing ? 'Renomear' : 'Salvar'} filtro — ${ONLINE_ONLY_SAVED_FILTER_MESSAGE}`}
|
||||
title={OPS_LIST_ONLINE_ONLY_MESSAGE}
|
||||
aria-label={`${existing ? 'Renomear' : 'Salvar'} filtro — ${OPS_LIST_ONLINE_ONLY_MESSAGE}`}
|
||||
>
|
||||
<BookmarkPlusIcon aria-hidden="true" />
|
||||
{existing ? 'Renomear' : 'Salvar filtro'}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import { useEffect, useState, type ReactNode } from 'react'
|
||||
|
||||
import { useBrowserOffline } from '@/components/campaign/opsSync/useBrowserOffline'
|
||||
import { resolveOpsHybridEnabled } from '@/lib/campaignOps/opsHybridFlag'
|
||||
|
||||
/**
|
||||
|
|
@ -24,20 +25,10 @@ export const OfflineBoundary = ({
|
|||
}) => {
|
||||
const hybrid = resolveOpsHybridEnabled()
|
||||
const [mounted, setMounted] = useState(false)
|
||||
const [browserOffline, setBrowserOffline] = useState(false)
|
||||
const browserOffline = useBrowserOffline()
|
||||
|
||||
useEffect(() => {
|
||||
setMounted(true)
|
||||
setBrowserOffline(typeof navigator !== 'undefined' ? !navigator.onLine : false)
|
||||
|
||||
const onOnline = () => setBrowserOffline(false)
|
||||
const onOffline = () => setBrowserOffline(true)
|
||||
window.addEventListener('online', onOnline)
|
||||
window.addEventListener('offline', onOffline)
|
||||
return () => {
|
||||
window.removeEventListener('online', onOnline)
|
||||
window.removeEventListener('offline', onOffline)
|
||||
}
|
||||
}, [])
|
||||
|
||||
return <div className="contents">{mounted && hybrid && browserOffline ? fallback : children}</div>
|
||||
|
|
|
|||
|
|
@ -25,11 +25,7 @@ import {
|
|||
} from '@/components/campaign/opsSync/opsMirrorClient'
|
||||
import { CampaignListFooter } from '@/components/campaign/shared/CampaignListFooter'
|
||||
import { CampaignSearchInput } from '@/components/campaign/shared/CampaignSearchInput'
|
||||
import {
|
||||
CampaignTable,
|
||||
CampaignTableHead,
|
||||
type CampaignTableColumn,
|
||||
} from '@/components/campaign/shared/CampaignTable'
|
||||
import { CampaignTable, type CampaignTableColumn } from '@/components/campaign/shared/CampaignTable'
|
||||
import { OpsListView } from '@/components/campaign/shared/OpsListView'
|
||||
import { useCampaignListFilterNavigation } from '@/components/campaign/shared/useCampaignListFilterNavigation'
|
||||
import { Button } from '@/components/ui/button'
|
||||
|
|
@ -42,6 +38,16 @@ import type {
|
|||
OpsOrganization,
|
||||
OpsStateDeputy,
|
||||
} from '@/lib/campaignOps/opsContract'
|
||||
import { formatElectionNumber } from '@/lib/electionFormat'
|
||||
import {
|
||||
EMPTY_ENGAGEMENT_LEVEL_LABEL,
|
||||
formatEngagementLevelLabel,
|
||||
isEngagementLevel,
|
||||
} from '@/lib/engagementLevel'
|
||||
import type { OpsListDomainId } from '@/lib/opsListRegistry/opsListRegistry'
|
||||
import { campaignDemandKindLabels, campaignDemandStatusLabels } from '@/lib/schemas/campaignDemand'
|
||||
import { organizationKindLabels } from '@/lib/schemas/organization'
|
||||
import { DEFAULT_VOTE_ESTIMATE_SCENARIO, getVoteEstimateForScenario } from '@/lib/voteEstimate'
|
||||
import {
|
||||
filterSortPageOpsDemands,
|
||||
filterSortPageOpsLeaderships,
|
||||
|
|
@ -49,26 +55,13 @@ import {
|
|||
filterSortPageOpsStateDeputies,
|
||||
} from '@/utilities/campaignOps/opsEntityListLocal'
|
||||
import { filterSortPageOpsMunicipalities } from '@/utilities/campaignOps/opsMunicipalityListLocal'
|
||||
import { formatElectionNumber } from '@/lib/electionFormat'
|
||||
import {
|
||||
EMPTY_ENGAGEMENT_LEVEL_LABEL,
|
||||
formatEngagementLevelLabel,
|
||||
isEngagementLevel,
|
||||
} from '@/lib/engagementLevel'
|
||||
import { getOpsListDomain, type OpsListDomainId } from '@/lib/opsListRegistry/opsListRegistry'
|
||||
import { campaignDemandKindLabels, campaignDemandStatusLabels } from '@/lib/schemas/campaignDemand'
|
||||
import { organizationKindLabels } from '@/lib/schemas/organization'
|
||||
import { DEFAULT_VOTE_ESTIMATE_SCENARIO, getVoteEstimateForScenario } from '@/lib/voteEstimate'
|
||||
import { buildDemandListHref, parseDemandListParams } from '@/utilities/demand/demandListUrl'
|
||||
import { supportStatusLabels } from '@/utilities/leadership/leadershipLabels'
|
||||
import {
|
||||
buildLeadershipListHref,
|
||||
parseLeadershipListParams,
|
||||
} from '@/utilities/leadership/leadershipListUrl'
|
||||
import {
|
||||
politicalTrendLabels,
|
||||
type PoliticalTrendStatus,
|
||||
} from '@/utilities/municipality/municipalityLabels'
|
||||
import { politicalTrendLabels } from '@/utilities/municipality/municipalityLabels'
|
||||
import {
|
||||
buildMunicipalityFilterHref,
|
||||
clearMunicipalityListFilters,
|
||||
|
|
@ -154,11 +147,15 @@ const OpsListLocalShell = ({
|
|||
)
|
||||
|
||||
const OpsListDomainUnavailable = ({ title }: { title: string }) => (
|
||||
<OpsListLocalShell title={title} description={OPS_LIST_DOMAIN_UNAVAILABLE_MESSAGE}>
|
||||
<div className="flex flex-col gap-6">
|
||||
<header className="flex flex-col gap-2">
|
||||
<h1 className="text-2xl font-semibold tracking-tight">{title}</h1>
|
||||
<p className="text-muted-foreground">{OPS_LIST_DOMAIN_UNAVAILABLE_MESSAGE}</p>
|
||||
</header>
|
||||
<section aria-label="Lista indisponível offline" className="rounded-xl border px-4 py-6">
|
||||
<OpsListLocalNotice>{OPS_LIST_ONLINE_ONLY_MESSAGE}</OpsListLocalNotice>
|
||||
</section>
|
||||
</OpsListLocalShell>
|
||||
</div>
|
||||
)
|
||||
|
||||
/* ——— Municipios ——— */
|
||||
|
|
@ -231,12 +228,11 @@ const MunicipalityLocalFilters = ({ state }: { state: MunicipalityListState }) =
|
|||
)
|
||||
}
|
||||
|
||||
const municipalityLocalColumns = (): Array<CampaignTableColumn<OpsMunicipality>> => [
|
||||
const MUNICIPALITY_LOCAL_COLUMNS: Array<CampaignTableColumn<OpsMunicipality>> = [
|
||||
{
|
||||
id: 'name',
|
||||
label: 'Município',
|
||||
mandatory: true,
|
||||
head: <CampaignTableHead>Município</CampaignTableHead>,
|
||||
cell: (row) => (
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<Link
|
||||
|
|
@ -252,23 +248,20 @@ const municipalityLocalColumns = (): Array<CampaignTableColumn<OpsMunicipality>>
|
|||
{
|
||||
id: 'region',
|
||||
label: 'Território',
|
||||
head: <CampaignTableHead>Território</CampaignTableHead>,
|
||||
cellClassName: 'text-muted-foreground',
|
||||
cell: (row) => row.region,
|
||||
},
|
||||
{
|
||||
id: 'trend',
|
||||
label: 'Tendência',
|
||||
head: <CampaignTableHead>Tendência</CampaignTableHead>,
|
||||
cell: (row) => {
|
||||
const status = row.politicalTrend?.status as PoliticalTrendStatus | null | undefined
|
||||
const status = row.politicalTrend?.status
|
||||
return status ? politicalTrendLabels[status] : '—'
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'level',
|
||||
label: 'Nível',
|
||||
head: <CampaignTableHead>Nível</CampaignTableHead>,
|
||||
cell: (row) =>
|
||||
isEngagementLevel(row.engagementLevel)
|
||||
? formatEngagementLevelLabel(row.engagementLevel)
|
||||
|
|
@ -277,7 +270,6 @@ const municipalityLocalColumns = (): Array<CampaignTableColumn<OpsMunicipality>>
|
|||
{
|
||||
id: 'expectedVotes',
|
||||
label: 'Votos estimados',
|
||||
head: <CampaignTableHead>Votos estimados</CampaignTableHead>,
|
||||
cellClassName: 'text-right',
|
||||
cell: (row) => {
|
||||
const votes = getVoteEstimateForScenario(row.expectedVotes, DEFAULT_VOTE_ESTIMATE_SCENARIO)
|
||||
|
|
@ -287,7 +279,6 @@ const municipalityLocalColumns = (): Array<CampaignTableColumn<OpsMunicipality>>
|
|||
{
|
||||
id: 'advisors',
|
||||
label: 'Assessores',
|
||||
head: <CampaignTableHead>Assessores</CampaignTableHead>,
|
||||
cellClassName: 'text-right',
|
||||
cell: (row) => String(row.advisors?.length ?? 0),
|
||||
},
|
||||
|
|
@ -310,7 +301,7 @@ const OpsMunicipalityListLocal = () => {
|
|||
)
|
||||
}
|
||||
|
||||
const columns = municipalityLocalColumns()
|
||||
const columns = MUNICIPALITY_LOCAL_COLUMNS
|
||||
const overview = (
|
||||
<div className="rounded-xl border px-4 py-3">
|
||||
<OpsListLocalNotice>{OPS_LIST_KPI_UNAVAILABLE_MESSAGE}</OpsListLocalNotice>
|
||||
|
|
@ -362,12 +353,11 @@ const OpsMunicipalityListLocal = () => {
|
|||
|
||||
/* ——— Leaderships ——— */
|
||||
|
||||
const leadershipLocalColumns = (): Array<CampaignTableColumn<OpsLeadership>> => [
|
||||
const LEADERSHIP_LOCAL_COLUMNS: Array<CampaignTableColumn<OpsLeadership>> = [
|
||||
{
|
||||
id: 'name',
|
||||
label: 'Nome',
|
||||
mandatory: true,
|
||||
head: <CampaignTableHead>Nome</CampaignTableHead>,
|
||||
cell: (row) => (
|
||||
<Link
|
||||
href={`/campanha/liderancas/${row.id}`}
|
||||
|
|
@ -380,13 +370,11 @@ const leadershipLocalColumns = (): Array<CampaignTableColumn<OpsLeadership>> =>
|
|||
{
|
||||
id: 'supportStatus',
|
||||
label: 'Status',
|
||||
head: <CampaignTableHead>Status</CampaignTableHead>,
|
||||
cell: (row) => supportStatusLabels[row.supportStatus],
|
||||
},
|
||||
{
|
||||
id: 'municipalities',
|
||||
label: 'Municípios',
|
||||
head: <CampaignTableHead>Municípios</CampaignTableHead>,
|
||||
cellClassName: 'text-right',
|
||||
cell: (row) => String(row.municipalities.length),
|
||||
},
|
||||
|
|
@ -423,7 +411,7 @@ const OpsLeadershipListLocal = () => {
|
|||
}
|
||||
table={
|
||||
<CampaignTable
|
||||
columns={leadershipLocalColumns()}
|
||||
columns={LEADERSHIP_LOCAL_COLUMNS}
|
||||
rows={pageResult.rows}
|
||||
rowKey={(row) => row.id}
|
||||
caption="Lideranças (offline)"
|
||||
|
|
@ -471,7 +459,6 @@ const OpsStateDeputyListLocal = () => {
|
|||
id: 'name',
|
||||
label: 'Nome',
|
||||
mandatory: true,
|
||||
head: <CampaignTableHead>Nome</CampaignTableHead>,
|
||||
cell: (row) => (
|
||||
<Link
|
||||
href={`/campanha/dobradinhas/${row.slug}`}
|
||||
|
|
@ -484,7 +471,6 @@ const OpsStateDeputyListLocal = () => {
|
|||
{
|
||||
id: 'party',
|
||||
label: 'Partido',
|
||||
head: <CampaignTableHead>Partido</CampaignTableHead>,
|
||||
cell: (row) => row.party?.trim() || '—',
|
||||
},
|
||||
]
|
||||
|
|
@ -539,7 +525,6 @@ const OpsOrganizationListLocal = () => {
|
|||
id: 'name',
|
||||
label: 'Nome',
|
||||
mandatory: true,
|
||||
head: <CampaignTableHead>Nome</CampaignTableHead>,
|
||||
cell: (row) => (
|
||||
<Link
|
||||
href={`/campanha/organizacoes/${row.slug}`}
|
||||
|
|
@ -552,7 +537,6 @@ const OpsOrganizationListLocal = () => {
|
|||
{
|
||||
id: 'kind',
|
||||
label: 'Tipo',
|
||||
head: <CampaignTableHead>Tipo</CampaignTableHead>,
|
||||
cell: (row) => organizationKindLabels[row.kind],
|
||||
},
|
||||
]
|
||||
|
|
@ -607,7 +591,6 @@ const OpsDemandListLocal = () => {
|
|||
id: 'title',
|
||||
label: 'Título',
|
||||
mandatory: true,
|
||||
head: <CampaignTableHead>Título</CampaignTableHead>,
|
||||
cell: (row) => (
|
||||
<Link
|
||||
href={`/campanha/demandas/${row.slug}`}
|
||||
|
|
@ -620,13 +603,11 @@ const OpsDemandListLocal = () => {
|
|||
{
|
||||
id: 'kind',
|
||||
label: 'Tipo',
|
||||
head: <CampaignTableHead>Tipo</CampaignTableHead>,
|
||||
cell: (row) => campaignDemandKindLabels[row.kind],
|
||||
},
|
||||
{
|
||||
id: 'status',
|
||||
label: 'Status',
|
||||
head: <CampaignTableHead>Status</CampaignTableHead>,
|
||||
cell: (row) => campaignDemandStatusLabels[row.status],
|
||||
},
|
||||
]
|
||||
|
|
@ -682,11 +663,6 @@ const DOMAIN_TITLES: Record<OpsListDomainId, string> = {
|
|||
* via `subscribeChanges` (same coalesce as MunicipalityDetailLocal).
|
||||
*/
|
||||
export const OpsListLocal = ({ slug }: { slug: OpsListDomainId }) => {
|
||||
const meta = getOpsListDomain(slug)
|
||||
if (!meta) {
|
||||
return <OpsListDomainUnavailable title={slug} />
|
||||
}
|
||||
|
||||
switch (slug) {
|
||||
case 'municipios':
|
||||
return <OpsMunicipalityListLocal />
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import { usePathname, useSearchParams } from 'next/navigation'
|
|||
import { useEffect, useId, useRef, useState } from 'react'
|
||||
import { toast } from 'sonner'
|
||||
|
||||
import { OPS_LIST_ONLINE_ONLY_MESSAGE } from '@/components/campaign/opsSync/opsListLocalCopy'
|
||||
import { useBrowserOffline } from '@/components/campaign/opsSync/useBrowserOffline'
|
||||
import { useMunicipalitySavedFilters } from '@/components/campaign/shared/useMunicipalitySavedFilters'
|
||||
import {
|
||||
|
|
@ -143,12 +144,10 @@ export const MunicipalityNavSavedFilters = ({ onNavigate }: { onNavigate: () =>
|
|||
handleRemove(entry)
|
||||
}}
|
||||
disabled={browserOffline}
|
||||
title={
|
||||
browserOffline ? 'Apagar filtro disponível quando estiveres online.' : undefined
|
||||
}
|
||||
title={browserOffline ? OPS_LIST_ONLINE_ONLY_MESSAGE : undefined}
|
||||
aria-label={
|
||||
browserOffline
|
||||
? `Apagar o filtro salvo ${entry.name} — disponível quando estiveres online.`
|
||||
? `Apagar o filtro salvo ${entry.name} — ${OPS_LIST_ONLINE_ONLY_MESSAGE}`
|
||||
: `Apagar o filtro salvo ${entry.name}`
|
||||
}
|
||||
className="top-1 group-focus-within/menu-sub-item:opacity-100 group-hover/menu-sub-item:opacity-100 md:opacity-0"
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import {
|
|||
type StateDeputyListState,
|
||||
} from '@/utilities/stateDeputyListUrl'
|
||||
|
||||
export type OpsPagedResult<T> = {
|
||||
type OpsPagedResult<T> = {
|
||||
rows: T[]
|
||||
totalDocs: number
|
||||
totalPages: number
|
||||
|
|
|
|||
|
|
@ -4,12 +4,8 @@
|
|||
* not invent server-only aggregates (classe / déficit / votos 2022).
|
||||
*/
|
||||
import type { OpsMunicipality } from '@/lib/campaignOps/opsContract'
|
||||
import { engagementLevelRank, type EngagementLevel } from '@/lib/engagementLevel'
|
||||
import {
|
||||
DEFAULT_VOTE_ESTIMATE_SCENARIO,
|
||||
getVoteEstimateForScenario,
|
||||
type VoteEstimateScenario,
|
||||
} from '@/lib/voteEstimate'
|
||||
import { engagementLevelRank, isEngagementLevel } from '@/lib/engagementLevel'
|
||||
import { DEFAULT_VOTE_ESTIMATE_SCENARIO, getVoteEstimateForScenario } from '@/lib/voteEstimate'
|
||||
import { strictDecimalInteger } from '@/utilities/campaignListUrl'
|
||||
import {
|
||||
municipalityPageSize,
|
||||
|
|
@ -25,8 +21,7 @@ const TREND_SORT_RANK: Record<string, number> = {
|
|||
desfavoravel: 0,
|
||||
}
|
||||
|
||||
/** Sort keys that need TSE / goal-coverage data absent from the mirror. */
|
||||
export const OPS_MUNICIPALITY_OFFLINE_UNAVAILABLE_SORTS = new Set<MunicipalityListSortKey>([
|
||||
const OPS_MUNICIPALITY_OFFLINE_UNAVAILABLE_SORTS = new Set<MunicipalityListSortKey>([
|
||||
'votos',
|
||||
'deficit',
|
||||
'frescor',
|
||||
|
|
@ -58,10 +53,7 @@ const matchesMunicipalityFilters = (
|
|||
state: MunicipalityListState,
|
||||
): boolean => {
|
||||
if (state.q && !matchesQuery(row, state.q)) return false
|
||||
if (
|
||||
state.regions?.length &&
|
||||
!state.regions.includes(row.region as (typeof state.regions)[number])
|
||||
) {
|
||||
if (state.regions?.length && !state.regions.some((region) => region === row.region)) {
|
||||
return false
|
||||
}
|
||||
if (state.slugs?.length && !state.slugs.includes(row.slug)) return false
|
||||
|
|
@ -93,7 +85,6 @@ const sortMunicipalityRows = (
|
|||
rows: OpsMunicipality[],
|
||||
sort: MunicipalityListSortKey,
|
||||
dir: 'asc' | 'desc',
|
||||
scenario: VoteEstimateScenario,
|
||||
): OpsMunicipality[] => {
|
||||
const factor = dir === 'asc' ? 1 : -1
|
||||
return [...rows].sort((left, right) => {
|
||||
|
|
@ -118,8 +109,10 @@ const sortMunicipalityRows = (
|
|||
break
|
||||
}
|
||||
case 'expectedVotes': {
|
||||
const leftVotes = getVoteEstimateForScenario(left.expectedVotes, scenario) ?? -1
|
||||
const rightVotes = getVoteEstimateForScenario(right.expectedVotes, scenario) ?? -1
|
||||
const leftVotes =
|
||||
getVoteEstimateForScenario(left.expectedVotes, DEFAULT_VOTE_ESTIMATE_SCENARIO) ?? -1
|
||||
const rightVotes =
|
||||
getVoteEstimateForScenario(right.expectedVotes, DEFAULT_VOTE_ESTIMATE_SCENARIO) ?? -1
|
||||
cmp = leftVotes - rightVotes
|
||||
break
|
||||
}
|
||||
|
|
@ -130,10 +123,12 @@ const sortMunicipalityRows = (
|
|||
cmp = (left.advisors?.length ?? 0) - (right.advisors?.length ?? 0)
|
||||
break
|
||||
case 'nivel': {
|
||||
const leftLevel = left.engagementLevel as EngagementLevel | null | undefined
|
||||
const rightLevel = right.engagementLevel as EngagementLevel | null | undefined
|
||||
const leftRank = leftLevel ? engagementLevelRank[leftLevel] : -1
|
||||
const rightRank = rightLevel ? engagementLevelRank[rightLevel] : -1
|
||||
const leftRank = isEngagementLevel(left.engagementLevel)
|
||||
? engagementLevelRank[left.engagementLevel]
|
||||
: -1
|
||||
const rightRank = isEngagementLevel(right.engagementLevel)
|
||||
? engagementLevelRank[right.engagementLevel]
|
||||
: -1
|
||||
cmp = leftRank - rightRank
|
||||
break
|
||||
}
|
||||
|
|
@ -145,9 +140,7 @@ const sortMunicipalityRows = (
|
|||
break
|
||||
default: {
|
||||
const _exhaustive: never = sort
|
||||
void _exhaustive
|
||||
cmp = left.name.localeCompare(right.name, 'pt-BR')
|
||||
break
|
||||
return _exhaustive
|
||||
}
|
||||
}
|
||||
if (cmp !== 0) return cmp * factor
|
||||
|
|
@ -158,7 +151,6 @@ const sortMunicipalityRows = (
|
|||
export const filterSortPageOpsMunicipalities = (
|
||||
rows: ReadonlyArray<OpsMunicipality>,
|
||||
state: MunicipalityListState,
|
||||
options: { scenario?: VoteEstimateScenario } = {},
|
||||
): OpsMunicipalityListLocalResult => {
|
||||
const classFilterUnavailable = Boolean(state.classes?.length)
|
||||
const filtered = rows.filter((row) => matchesMunicipalityFilters(row, state))
|
||||
|
|
@ -166,12 +158,7 @@ export const filterSortPageOpsMunicipalities = (
|
|||
const sortDegraded = OPS_MUNICIPALITY_OFFLINE_UNAVAILABLE_SORTS.has(resolved.sort)
|
||||
const effectiveSort: MunicipalityListSortKey = sortDegraded ? 'name' : resolved.sort
|
||||
const effectiveDir = sortDegraded ? 'asc' : resolved.dir
|
||||
const sorted = sortMunicipalityRows(
|
||||
filtered,
|
||||
effectiveSort,
|
||||
effectiveDir,
|
||||
options.scenario ?? DEFAULT_VOTE_ESTIMATE_SCENARIO,
|
||||
)
|
||||
const sorted = sortMunicipalityRows(filtered, effectiveSort, effectiveDir)
|
||||
const totalDocs = sorted.length
|
||||
const totalPages = Math.max(1, Math.ceil(totalDocs / municipalityPageSize))
|
||||
const page = Math.min(Math.max(1, state.page), totalPages)
|
||||
|
|
|
|||
|
|
@ -1,16 +1,10 @@
|
|||
import { expect, test } from './fixtures/campaignE2EFixtures.js'
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
* OH9/OH11 — dual-path municipality detail + full offline journey. Requires
|
||||
* `OPS_HYBRID=1` on the Playwright webServer (compile-time). Default CI keeps
|
||||
* the flag off so characterization / municipalities specs continue to pin the
|
||||
* RSC path.
|
||||
=======
|
||||
* OH9 / OH12 — dual-path municipality detail + list. Requires `OPS_HYBRID=1` on
|
||||
* the Playwright webServer (compile-time). Default CI keeps the flag off so
|
||||
* characterization / municipalities specs continue to pin the RSC path.
|
||||
>>>>>>> c9e3e84f (OH12: OpsListLocal read-only via registry + OfflineBoundary on lists)
|
||||
* OH9/OH11/OH12 — dual-path municipality detail + offline journey + list Local.
|
||||
* Requires `OPS_HYBRID=1` on the Playwright webServer (compile-time). Default CI
|
||||
* keeps the flag off so characterization / municipalities specs continue to pin
|
||||
* the RSC path.
|
||||
*/
|
||||
const opsHybridEnabled =
|
||||
process.env.OPS_HYBRID === '1' || process.env.OPS_HYBRID?.toLowerCase() === 'true'
|
||||
|
|
|
|||
Loading…
Reference in a new issue