B96 — Header wizard: X na tendência standalone, Pular só encadeada

resolveWizardTrendSkip(entryAction) espelha resolveWizardSignalSkip:
skip só quando entryAction presente e diferente de change-trend.
WizardTrendChoiceStep e WizardTrendNoteStep condicionam skip/trailingAction.

Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com>
This commit is contained in:
Cursor Agent 2026-08-01 10:54:34 +00:00
parent 317935b128
commit 5181116d84
No known key found for this signature in database
4 changed files with 26 additions and 11 deletions

View file

@ -27,7 +27,6 @@ import {
resolveWizardTrendSkip,
selectablePoliticalTrendStatuses,
wizardTrendChoiceStepTitle,
type WizardTrendSkipAction,
} from '@/lib/politicalTrendWizardUi'
import type { PoliticalTrendStatusValue } from '@/lib/schemas/municipality'
import { cn } from '@/lib/utils'
@ -50,7 +49,7 @@ export const WizardTrendChoiceStep = ({
prefillExtraParams,
}: WizardTrendChoiceStepProps) => {
const [infoEntry, setInfoEntry] = useState<PoliticalTrendWizardMetaEntry | null>(null)
const skip: WizardTrendSkipAction = resolveWizardTrendSkip()
const skip = resolveWizardTrendSkip(entryAction)
const options = selectablePoliticalTrendStatuses(currentStatus)
return (
@ -62,7 +61,7 @@ export const WizardTrendChoiceStep = ({
previousHref={wizardActionHref(actionSlug, municipalitySlug, { entryAction })}
municipalityLabel={municipalityName}
skip={skip}
trailingAction={<WizardTrendSkipTrailing skip={skip} />}
trailingAction={skip ? <WizardTrendSkipTrailing skip={skip} /> : undefined}
>
<ul className="grid list-none grid-cols-2 gap-3 md:grid-cols-3">
{options.map((status) => {

View file

@ -49,7 +49,7 @@ export const WizardTrendNoteStep = ({
setMunicipalityPoliticalTrendFormAction,
{},
)
const skip = resolveWizardTrendSkip()
const skip = resolveWizardTrendSkip(entryAction)
const stepTitle = `Mudar tendência para ${politicalTrendLabels[trendStatus]}`
useCampaignFormSuccessToast(state, () => {
@ -65,7 +65,7 @@ export const WizardTrendNoteStep = ({
previousHref={wizardTrendHref(actionSlug, municipalitySlug, undefined, entryAction)}
municipalityLabel={municipalityName}
skip={skip}
trailingAction={<WizardTrendSkipTrailing skip={skip} />}
trailingAction={skip ? <WizardTrendSkipTrailing skip={skip} /> : undefined}
>
<form
action={submitAction}

View file

@ -63,10 +63,16 @@ export const resolveWizardTrendNoteDestination = (
return 'note'
}
export const resolveWizardTrendSkip = (): WizardTrendSkipAction => ({
label: WIZARD_TREND_SKIP_LABEL,
href: CAMPAIGN_HOME,
})
export const shouldShowWizardTrendSkip = (
entryAction: CampaignWizardActionId | undefined,
): boolean => entryAction != null && entryAction !== 'change-trend'
export const resolveWizardTrendSkip = (
entryAction: CampaignWizardActionId | undefined,
): WizardTrendSkipAction | undefined =>
shouldShowWizardTrendSkip(entryAction)
? { label: WIZARD_TREND_SKIP_LABEL, href: CAMPAIGN_HOME }
: undefined
export type PoliticalTrendNotePrefillSource =
| { kind: 'none' }

View file

@ -11,6 +11,7 @@ import {
resolveWizardTrendNoteDestination,
resolveWizardTrendSkip,
selectablePoliticalTrendStatuses,
shouldShowWizardTrendSkip,
WIZARD_TREND_SKIP_LABEL,
WIZARD_TREND_UNREGISTERED_TITLE,
wizardTrendChoiceStepTitle,
@ -35,8 +36,17 @@ describe('politicalTrendWizardUi', () => {
expect(resolveWizardTrendNoteDestination('favoravel', null)).toBe('note')
})
it('always exposes skip to abandon the trend change', () => {
expect(resolveWizardTrendSkip()).toEqual({
it('hides skip for standalone change-trend entry', () => {
expect(shouldShowWizardTrendSkip(undefined)).toBe(false)
expect(shouldShowWizardTrendSkip('change-trend')).toBe(false)
expect(resolveWizardTrendSkip(undefined)).toBeUndefined()
expect(resolveWizardTrendSkip('change-trend')).toBeUndefined()
})
it('shows skip when embedded from another wizard action', () => {
expect(shouldShowWizardTrendSkip('update-votes')).toBe(true)
expect(shouldShowWizardTrendSkip('register-signal')).toBe(true)
expect(resolveWizardTrendSkip('update-votes')).toEqual({
label: WIZARD_TREND_SKIP_LABEL,
href: CAMPAIGN_HOME,
})