mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-26 21:53:06 +00:00
Merge pull request #218 from fsolla/cursor/pool-i205-4d8c38ce-14ae
B118 — Listas mobile — ocultar título, subtítulo e chip de escopo
This commit is contained in:
commit
492d0c77b8
12 changed files with 207 additions and 116 deletions
|
|
@ -83,6 +83,7 @@ export const E2E_AFFECTED_MANIFEST = [
|
|||
{
|
||||
prefixes: [
|
||||
'src/components/campaign/shell',
|
||||
'src/components/campaign/shared/CampaignListPageHeader',
|
||||
'src/components/ui/Drawer',
|
||||
`${CAMPAIGN_APP}/layout.tsx`,
|
||||
'src/utilities/campaignPwa',
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import { getPayload } from 'payload'
|
|||
|
||||
import { CampaignListEmptyState } from '@/components/campaign/shared/CampaignListEmptyState'
|
||||
import { CampaignListFooter } from '@/components/campaign/shared/CampaignListFooter'
|
||||
import { CampaignListPageHeader } from '@/components/campaign/shared/CampaignListPageHeader'
|
||||
import {
|
||||
CampaignListPendingBoundary,
|
||||
CampaignListResults,
|
||||
|
|
@ -109,35 +110,35 @@ export default async function SupportersPage({ searchParams }: SupportersPagePro
|
|||
|
||||
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">Apoiadores</h1>
|
||||
<p className="text-muted-foreground">
|
||||
Base nominal de apoio com intenção de voto e vínculo opcional a municípios.
|
||||
</p>
|
||||
<CampaignListPageHeader
|
||||
title="Apoiadores"
|
||||
description="Base nominal de apoio com intenção de voto e vínculo opcional a municípios."
|
||||
scope={
|
||||
<CampaignScopeBadge>
|
||||
{isCampaignUnrestricted(user)
|
||||
? `${campaignRoleLabels[user.role]} · todos os apoiadores`
|
||||
: getSupporterScopeLabel(result.totalDocs)}
|
||||
</CampaignScopeBadge>
|
||||
</div>
|
||||
<div className="flex flex-col gap-2 sm:flex-row">
|
||||
{isCampaignCoordinator(user) ? (
|
||||
<Button asChild variant="outline" className="min-h-11">
|
||||
<Link href="/campanha/apoiadores/importar">
|
||||
<FileUpIcon data-icon="inline-start" aria-hidden="true" />
|
||||
Importar CSV
|
||||
}
|
||||
actions={
|
||||
<div className="flex flex-col gap-2 sm:flex-row">
|
||||
{isCampaignCoordinator(user) ? (
|
||||
<Button asChild variant="outline" className="min-h-11">
|
||||
<Link href="/campanha/apoiadores/importar">
|
||||
<FileUpIcon data-icon="inline-start" aria-hidden="true" />
|
||||
Importar CSV
|
||||
</Link>
|
||||
</Button>
|
||||
) : null}
|
||||
<Button asChild className="min-h-11">
|
||||
<Link href="/campanha/apoiadores/novo">
|
||||
<PlusIcon data-icon="inline-start" aria-hidden="true" />
|
||||
Novo
|
||||
</Link>
|
||||
</Button>
|
||||
) : null}
|
||||
<Button asChild className="min-h-11">
|
||||
<Link href="/campanha/apoiadores/novo">
|
||||
<PlusIcon data-icon="inline-start" aria-hidden="true" />
|
||||
Novo
|
||||
</Link>
|
||||
</Button>
|
||||
</div>
|
||||
</header>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
|
||||
{main}
|
||||
</CampaignPageShell>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import type { ReactNode } from 'react'
|
|||
|
||||
import { AdvisorsTable } from '@/components/campaign/advisor/AdvisorsTable'
|
||||
import { CampaignListFooter } from '@/components/campaign/shared/CampaignListFooter'
|
||||
import { CampaignListPageHeader } from '@/components/campaign/shared/CampaignListPageHeader'
|
||||
import {
|
||||
CampaignListPendingBoundary,
|
||||
CampaignListResults,
|
||||
|
|
@ -105,13 +106,10 @@ export default async function AdvisorsPage({ searchParams }: AdvisorsPageProps)
|
|||
|
||||
return (
|
||||
<CampaignPageShell>
|
||||
<header className="flex flex-col gap-2">
|
||||
<h1 className="text-2xl font-semibold tracking-tight">Assessores</h1>
|
||||
<p className="text-muted-foreground">
|
||||
Consulte na tabela; ative Editar para alterar campos e carteira. Nome abre a ficha;
|
||||
e-mail/celular copiam; município abre o município.
|
||||
</p>
|
||||
</header>
|
||||
<CampaignListPageHeader
|
||||
title="Assessores"
|
||||
description="Consulte na tabela; ative Editar para alterar campos e carteira. Nome abre a ficha; e-mail/celular copiam; município abre o município."
|
||||
/>
|
||||
|
||||
{main}
|
||||
</CampaignPageShell>
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import { ActivityFilters } from '@/components/campaign/activity/ActivityFilters'
|
|||
import { ActivityList } from '@/components/campaign/activity/ActivityList'
|
||||
import { CampaignListEmptyState } from '@/components/campaign/shared/CampaignListEmptyState'
|
||||
import { CampaignListFooter } from '@/components/campaign/shared/CampaignListFooter'
|
||||
import { CampaignListPageHeader } from '@/components/campaign/shared/CampaignListPageHeader'
|
||||
import { CampaignPageShell } from '@/components/campaign/shell/CampaignPageShell'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import type { Activity } from '@/payload-types'
|
||||
|
|
@ -53,32 +54,30 @@ export default async function ActivityListPage({ searchParams }: ActivityListPag
|
|||
|
||||
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">Atividades</h1>
|
||||
<p className="text-muted-foreground">
|
||||
Organize caminhadas, comícios, panfletagens e demais ações de campanha.
|
||||
</p>
|
||||
</div>
|
||||
{canCreate ? (
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{/* E13: the planner generates several drafts at once, so it sits next
|
||||
to "Nova atividade" rather than replacing it. */}
|
||||
<Button asChild variant="outline" className="min-h-11">
|
||||
<Link href={TOUR_COMPOSER_PATH}>
|
||||
<MapPinnedIcon data-icon="inline-start" aria-hidden="true" />
|
||||
Planejar giro
|
||||
</Link>
|
||||
</Button>
|
||||
<Button asChild className="min-h-11">
|
||||
<Link href="/campanha/atividades/nova">
|
||||
<PlusIcon data-icon="inline-start" aria-hidden="true" />
|
||||
Nova atividade
|
||||
</Link>
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
</header>
|
||||
<CampaignListPageHeader
|
||||
title="Atividades"
|
||||
description="Organize caminhadas, comícios, panfletagens e demais ações de campanha."
|
||||
actions={
|
||||
canCreate ? (
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{/* E13: the planner generates several drafts at once, so it sits next
|
||||
to "Nova atividade" rather than replacing it. */}
|
||||
<Button asChild variant="outline" className="min-h-11">
|
||||
<Link href={TOUR_COMPOSER_PATH}>
|
||||
<MapPinnedIcon data-icon="inline-start" aria-hidden="true" />
|
||||
Planejar giro
|
||||
</Link>
|
||||
</Button>
|
||||
<Button asChild className="min-h-11">
|
||||
<Link href="/campanha/atividades/nova">
|
||||
<PlusIcon data-icon="inline-start" aria-hidden="true" />
|
||||
Nova atividade
|
||||
</Link>
|
||||
</Button>
|
||||
</div>
|
||||
) : null
|
||||
}
|
||||
/>
|
||||
|
||||
<CampaignListPendingBoundary>
|
||||
<ActivityFilters
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import { getPayload } from 'payload'
|
|||
import { CampaignFilterChips } from '@/components/campaign/shared/CampaignFilterChips'
|
||||
import { CampaignListEmptyState } from '@/components/campaign/shared/CampaignListEmptyState'
|
||||
import { CampaignListFooter } from '@/components/campaign/shared/CampaignListFooter'
|
||||
import { CampaignListPageHeader } from '@/components/campaign/shared/CampaignListPageHeader'
|
||||
import {
|
||||
CampaignListPendingBoundary,
|
||||
CampaignListResults,
|
||||
|
|
@ -186,24 +187,23 @@ export default async function DemandsPage({ searchParams }: DemandsPageProps) {
|
|||
|
||||
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">Demandas</h1>
|
||||
<p className="text-muted-foreground">
|
||||
Necessidades da campanha abertas pelas lideranças, revisadas pela assessoria e — quando
|
||||
preciso — decididas pelo Coordenador Geral.
|
||||
</p>
|
||||
<CampaignListPageHeader
|
||||
title="Demandas"
|
||||
description="Necessidades da campanha abertas pelas lideranças, revisadas pela assessoria e — quando preciso — decididas pelo Coordenador Geral."
|
||||
scope={
|
||||
<Badge variant="estimate-pending" className="w-fit">
|
||||
{openCount} {openCount === 1 ? 'demanda em aberto' : 'demandas em aberto'}
|
||||
</Badge>
|
||||
</div>
|
||||
<Button asChild className="min-h-11">
|
||||
<Link href="/campanha/demandas/nova">
|
||||
<PlusIcon data-icon="inline-start" aria-hidden="true" />
|
||||
Nova demanda
|
||||
</Link>
|
||||
</Button>
|
||||
</header>
|
||||
}
|
||||
actions={
|
||||
<Button asChild className="min-h-11">
|
||||
<Link href="/campanha/demandas/nova">
|
||||
<PlusIcon data-icon="inline-start" aria-hidden="true" />
|
||||
Nova demanda
|
||||
</Link>
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
|
||||
{main}
|
||||
</CampaignPageShell>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { redirect } from 'next/navigation'
|
|||
import { getPayload } from 'payload'
|
||||
|
||||
import { CampaignListFooter } from '@/components/campaign/shared/CampaignListFooter'
|
||||
import { CampaignListPageHeader } from '@/components/campaign/shared/CampaignListPageHeader'
|
||||
import {
|
||||
CampaignListPendingBoundary,
|
||||
CampaignListResults,
|
||||
|
|
@ -282,21 +283,18 @@ export default async function StateDeputiesPage({ searchParams }: StateDeputiesP
|
|||
|
||||
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">Dobradinhas</h1>
|
||||
<p className="text-muted-foreground">
|
||||
Deputados estaduais com quem a campanha dobra — vincule lideranças e municípios direto
|
||||
na lista.
|
||||
</p>
|
||||
</div>
|
||||
<Button asChild className="min-h-11">
|
||||
<Link href="/campanha/dobradinhas/nova">
|
||||
<PlusIcon data-icon="inline-start" aria-hidden="true" />
|
||||
Nova dobradinha
|
||||
</Link>
|
||||
</Button>
|
||||
</header>
|
||||
<CampaignListPageHeader
|
||||
title="Dobradinhas"
|
||||
description="Deputados estaduais com quem a campanha dobra — vincule lideranças e municípios direto na lista."
|
||||
actions={
|
||||
<Button asChild className="min-h-11">
|
||||
<Link href="/campanha/dobradinhas/nova">
|
||||
<PlusIcon data-icon="inline-start" aria-hidden="true" />
|
||||
Nova dobradinha
|
||||
</Link>
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
|
||||
{main}
|
||||
</CampaignPageShell>
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import {
|
|||
} from '@/components/campaign/leadership/LeadershipSortableHead'
|
||||
import { CampaignCopyableCell } from '@/components/campaign/shared/CampaignCopyableCell'
|
||||
import { CampaignListFooter } from '@/components/campaign/shared/CampaignListFooter'
|
||||
import { CampaignListPageHeader } from '@/components/campaign/shared/CampaignListPageHeader'
|
||||
import {
|
||||
CampaignListPendingBoundary,
|
||||
CampaignListResults,
|
||||
|
|
@ -436,20 +437,18 @@ export default async function LeadershipsPage({ searchParams }: LeadershipsPageP
|
|||
|
||||
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">Lideranças</h1>
|
||||
<p className="text-muted-foreground">
|
||||
Uma ficha por pessoa — cada liderança pode atuar em vários municípios e organizações.
|
||||
</p>
|
||||
</div>
|
||||
<Button asChild className="min-h-11">
|
||||
<Link href="/campanha/liderancas/nova">
|
||||
<PlusIcon data-icon="inline-start" aria-hidden="true" />
|
||||
Nova liderança
|
||||
</Link>
|
||||
</Button>
|
||||
</header>
|
||||
<CampaignListPageHeader
|
||||
title="Lideranças"
|
||||
description="Uma ficha por pessoa — cada liderança pode atuar em vários municípios e organizações."
|
||||
actions={
|
||||
<Button asChild className="min-h-11">
|
||||
<Link href="/campanha/liderancas/nova">
|
||||
<PlusIcon data-icon="inline-start" aria-hidden="true" />
|
||||
Nova liderança
|
||||
</Link>
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
|
||||
{main}
|
||||
</CampaignPageShell>
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import { MunicipalityFilters } from '@/components/campaign/municipality/Municipa
|
|||
import { MunicipalityList } from '@/components/campaign/municipality/MunicipalityList'
|
||||
import { MunicipalityListOverview } from '@/components/campaign/municipality/MunicipalityListOverview'
|
||||
import { CampaignListFooter } from '@/components/campaign/shared/CampaignListFooter'
|
||||
import { CampaignListPageHeader } from '@/components/campaign/shared/CampaignListPageHeader'
|
||||
import { CampaignScopeBadge } from '@/components/campaign/shared/CampaignScopeBadge'
|
||||
import { OpsListPage } from '@/components/campaign/shared/OpsListPage'
|
||||
import { CampaignPageShell } from '@/components/campaign/shell/CampaignPageShell'
|
||||
|
|
@ -185,14 +186,13 @@ export default async function MunicipalitiesPage({ searchParams }: Municipalitie
|
|||
|
||||
return (
|
||||
<CampaignPageShell>
|
||||
<header className="flex flex-col gap-2">
|
||||
<h1 className="text-2xl font-semibold tracking-tight">Municípios</h1>
|
||||
<p className="text-muted-foreground">
|
||||
Os 435 municípios da campanha: um por município da Bahia — em Salvador, uma zona eleitoral
|
||||
cada.
|
||||
</p>
|
||||
<CampaignScopeBadge>{getCampaignScopeLabel(user.role, scopeTotal)}</CampaignScopeBadge>
|
||||
</header>
|
||||
<CampaignListPageHeader
|
||||
title="Municípios"
|
||||
description="Os 435 municípios da campanha: um por município da Bahia — em Salvador, uma zona eleitoral cada."
|
||||
scope={
|
||||
<CampaignScopeBadge>{getCampaignScopeLabel(user.role, scopeTotal)}</CampaignScopeBadge>
|
||||
}
|
||||
/>
|
||||
|
||||
{main}
|
||||
{listVisitLabel ? (
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { getPayload } from 'payload'
|
|||
import { TerritoryFilters } from '@/components/campaign/municipality/TerritoryFilters'
|
||||
import { TerritoryList } from '@/components/campaign/municipality/TerritoryList'
|
||||
import { CampaignListFooter } from '@/components/campaign/shared/CampaignListFooter'
|
||||
import { CampaignListPageHeader } from '@/components/campaign/shared/CampaignListPageHeader'
|
||||
import {
|
||||
CampaignListPendingBoundary,
|
||||
CampaignListResults,
|
||||
|
|
@ -81,15 +82,13 @@ export default async function TerritoriesPage({ searchParams }: TerritoriesPageP
|
|||
|
||||
return (
|
||||
<CampaignPageShell>
|
||||
<header className="flex max-w-prose flex-col gap-2">
|
||||
<h1 className="text-2xl font-semibold tracking-tight text-balance">
|
||||
Territórios de Identidade
|
||||
</h1>
|
||||
<p className="text-muted-foreground text-pretty">
|
||||
Compare a concentração histórica e a cobertura de assessoria das regiões da Bahia. Abra um
|
||||
território para ver seus municípios.
|
||||
</p>
|
||||
</header>
|
||||
<CampaignListPageHeader
|
||||
className="max-w-prose"
|
||||
title="Territórios de Identidade"
|
||||
titleClassName="text-balance"
|
||||
description="Compare a concentração histórica e a cobertura de assessoria das regiões da Bahia. Abra um território para ver seus municípios."
|
||||
descriptionClassName="text-pretty"
|
||||
/>
|
||||
{main}
|
||||
</CampaignPageShell>
|
||||
)
|
||||
|
|
|
|||
47
src/components/campaign/shared/CampaignListPageHeader.tsx
Normal file
47
src/components/campaign/shared/CampaignListPageHeader.tsx
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
import type { ReactNode } from 'react'
|
||||
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
type CampaignListPageHeaderProps = {
|
||||
title: string
|
||||
description: string
|
||||
scope?: ReactNode
|
||||
actions?: ReactNode
|
||||
className?: string
|
||||
titleClassName?: string
|
||||
descriptionClassName?: string
|
||||
}
|
||||
|
||||
export const CampaignListPageHeader = ({
|
||||
title,
|
||||
description,
|
||||
scope,
|
||||
actions,
|
||||
className,
|
||||
titleClassName,
|
||||
descriptionClassName,
|
||||
}: CampaignListPageHeaderProps) => (
|
||||
<header
|
||||
className={cn(
|
||||
'flex flex-col gap-2',
|
||||
actions && 'gap-4 sm:flex-row sm:items-start sm:justify-between',
|
||||
className,
|
||||
)}
|
||||
>
|
||||
<div className="flex flex-col gap-2">
|
||||
<h1
|
||||
className={cn(
|
||||
'sr-only text-2xl font-semibold tracking-tight md:not-sr-only',
|
||||
titleClassName,
|
||||
)}
|
||||
>
|
||||
{title}
|
||||
</h1>
|
||||
<p className={cn('hidden text-muted-foreground md:block', descriptionClassName)}>
|
||||
{description}
|
||||
</p>
|
||||
{scope ? <div className="hidden md:contents">{scope}</div> : null}
|
||||
</div>
|
||||
{actions}
|
||||
</header>
|
||||
)
|
||||
|
|
@ -39,6 +39,28 @@ test.describe('Municípios — shell (OH8)', () => {
|
|||
})
|
||||
})
|
||||
|
||||
test.describe('Municípios — list header mobile (B118)', () => {
|
||||
test.use({ viewport: { width: 390, height: 844 } })
|
||||
|
||||
test('hides page title chrome on mobile but keeps list tools', async ({ campaign, page }) => {
|
||||
const { fixtures } = campaign
|
||||
const coordinator = await fixtures.createCampaignUser('coordinator', {
|
||||
name: fixtures.value('Coordenador Mobile Header'),
|
||||
})
|
||||
|
||||
await campaign.login(page, coordinator.email!, coordinator.password)
|
||||
await page.goto(`${campaign.baseURL}/campanha/municipios`)
|
||||
const heading = page.getByRole('heading', { name: 'Municípios', exact: true })
|
||||
await expect(heading).toHaveClass(/sr-only/)
|
||||
const headingBox = await heading.boundingBox()
|
||||
expect(headingBox?.height ?? 0).toBeLessThanOrEqual(2)
|
||||
await expect(page.locator('header p')).toBeHidden()
|
||||
await expect(page.locator('[data-scope="campaign"]')).toBeHidden()
|
||||
await expect(page.getByLabel('Buscar município')).toBeVisible()
|
||||
await expect(page.getByText(/\d+ municípios encontrados/)).toBeVisible()
|
||||
})
|
||||
})
|
||||
|
||||
test.describe('Municípios — jornadas por papel', () => {
|
||||
test('coordinator opens the municipalities list, edits strategy and assigns an advisor', async ({
|
||||
campaign,
|
||||
|
|
|
|||
27
tests/unit/campaignListPageHeader.unit.spec.ts
Normal file
27
tests/unit/campaignListPageHeader.unit.spec.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import { createElement } from 'react'
|
||||
import { renderToStaticMarkup } from 'react-dom/server'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { CampaignListPageHeader } from '@/components/campaign/shared/CampaignListPageHeader'
|
||||
import { CampaignScopeBadge } from '@/components/campaign/shared/CampaignScopeBadge'
|
||||
|
||||
describe('CampaignListPageHeader (B118)', () => {
|
||||
it('keeps h1 in the DOM with sr-only on mobile and hides subtitle and scope chip below md', () => {
|
||||
const html = renderToStaticMarkup(
|
||||
createElement(CampaignListPageHeader, {
|
||||
title: 'Municípios',
|
||||
description: 'Os 435 municípios da campanha.',
|
||||
scope: createElement(CampaignScopeBadge, null, '435 municípios'),
|
||||
}),
|
||||
)
|
||||
|
||||
expect(html).toContain('<h1')
|
||||
expect(html).toContain('sr-only')
|
||||
expect(html).toContain('md:not-sr-only')
|
||||
expect(html).toContain('hidden')
|
||||
expect(html).toContain('md:block')
|
||||
expect(html).toContain('md:contents')
|
||||
expect(html).toContain('Municípios')
|
||||
expect(html).toContain('Os 435 municípios da campanha.')
|
||||
})
|
||||
})
|
||||
Loading…
Reference in a new issue