From 2e3740ef3fa5dc283b2d8986d170c2f2eac60646 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 1 Aug 2026 20:40:04 +0000 Subject: [PATCH] Format B110 wizard return path changes --- .../(campaign)/campanha/(app)/acoes/[slug]/page.tsx | 6 +++++- .../campaign/leadership/WizardLeadershipStep.tsx | 6 +++++- .../campaign/municipality/WizardSignalBodyStep.tsx | 6 +++++- .../campaign/municipality/WizardSignalTypeStep.tsx | 2 +- .../campaign/municipality/WizardTrendNoteStep.tsx | 6 +++++- .../campaign/shared/WizardExpectedVotesStep.tsx | 6 +++++- .../shared/WizardMunicipalitySelectedStub.tsx | 2 +- src/lib/campaignActionRoutes.ts | 4 +--- src/lib/campaignHomeActions.ts | 12 ++++++++---- src/lib/campaignQuickActionLeadership.ts | 12 ++++++++---- src/lib/wizardActionChain.ts | 9 ++++++++- tests/unit/wizardActionChain.unit.spec.ts | 12 ++++++------ 12 files changed, 58 insertions(+), 25 deletions(-) diff --git a/src/app/(campaign)/campanha/(app)/acoes/[slug]/page.tsx b/src/app/(campaign)/campanha/(app)/acoes/[slug]/page.tsx index d37dc41e..b24d5cbe 100644 --- a/src/app/(campaign)/campanha/(app)/acoes/[slug]/page.tsx +++ b/src/app/(campaign)/campanha/(app)/acoes/[slug]/page.tsx @@ -39,7 +39,11 @@ import { resolveWizardTrendNoteDestination, } from '@/lib/politicalTrendWizardUi' import { toVoteEstimateScenarioViewModel } from '@/lib/voteEstimate' -import { isWizardChainActionId, wizardChainContinueHref, wizardChainEndHref } from '@/lib/wizardActionChain' +import { + isWizardChainActionId, + wizardChainContinueHref, + wizardChainEndHref, +} from '@/lib/wizardActionChain' import config from '@/payload.config' import { requireCampaignPageActor } from '@/utilities/campaignPageActor' import { loadWizardLeadershipTiles } from '@/utilities/leadership/leadershipData' diff --git a/src/components/campaign/leadership/WizardLeadershipStep.tsx b/src/components/campaign/leadership/WizardLeadershipStep.tsx index 4b609c43..41fa1216 100644 --- a/src/components/campaign/leadership/WizardLeadershipStep.tsx +++ b/src/components/campaign/leadership/WizardLeadershipStep.tsx @@ -35,7 +35,11 @@ import { } from '@/lib/campaignWizardCopy' import { truncateNameAtWordBoundary } from '@/lib/leadershipNameTruncate' import { cn } from '@/lib/utils' -import { resolveWizardChainEntry, wizardChainContinueHref, wizardChainEndHref } from '@/lib/wizardActionChain' +import { + resolveWizardChainEntry, + wizardChainContinueHref, + wizardChainEndHref, +} from '@/lib/wizardActionChain' import { resolveWizardLeadershipSkip, type WizardLeadershipTileViewModel, diff --git a/src/components/campaign/municipality/WizardSignalBodyStep.tsx b/src/components/campaign/municipality/WizardSignalBodyStep.tsx index b23e9b2d..37a042b4 100644 --- a/src/components/campaign/municipality/WizardSignalBodyStep.tsx +++ b/src/components/campaign/municipality/WizardSignalBodyStep.tsx @@ -17,7 +17,11 @@ import { recordLastActedMunicipality } from '@/lib/campaignLastActedMunicipality import { wizardFlowTitleForSlug } from '@/lib/campaignWizardCopy' import type { MunicipalitySignalType } from '@/lib/schemas/municipalityUpdate' import { municipalitySignalTypeLabels } from '@/lib/schemas/municipalityUpdate' -import { resolveWizardChainEntry, wizardChainContinueHref, wizardChainEndHref } from '@/lib/wizardActionChain' +import { + resolveWizardChainEntry, + wizardChainContinueHref, + wizardChainEndHref, +} from '@/lib/wizardActionChain' import { resolveWizardSignalSkip, WIZARD_SIGNAL_BODY_STEP_TITLE_PREFIX, diff --git a/src/components/campaign/municipality/WizardSignalTypeStep.tsx b/src/components/campaign/municipality/WizardSignalTypeStep.tsx index 61c0bf30..2ee88227 100644 --- a/src/components/campaign/municipality/WizardSignalTypeStep.tsx +++ b/src/components/campaign/municipality/WizardSignalTypeStep.tsx @@ -25,8 +25,8 @@ import { } from '@/lib/municipalitySignalTypeMeta' import type { MunicipalitySignalType } from '@/lib/schemas/municipalityUpdate' import { cn } from '@/lib/utils' -import { resolveWizardSignalSkip, WIZARD_SIGNAL_TYPE_STEP_TITLE } from '@/lib/wizardSignalUi' import { wizardChainEndHref } from '@/lib/wizardActionChain' +import { resolveWizardSignalSkip, WIZARD_SIGNAL_TYPE_STEP_TITLE } from '@/lib/wizardSignalUi' type WizardSignalTypeStepProps = { actionSlug: string diff --git a/src/components/campaign/municipality/WizardTrendNoteStep.tsx b/src/components/campaign/municipality/WizardTrendNoteStep.tsx index 40ed2a71..7d69edf9 100644 --- a/src/components/campaign/municipality/WizardTrendNoteStep.tsx +++ b/src/components/campaign/municipality/WizardTrendNoteStep.tsx @@ -21,7 +21,11 @@ import { WIZARD_TREND_SAVE_LABEL, } from '@/lib/politicalTrendWizardUi' import type { PoliticalTrendStatusValue } from '@/lib/schemas/municipality' -import { resolveWizardChainEntry, wizardChainContinueHref, wizardChainEndHref } from '@/lib/wizardActionChain' +import { + resolveWizardChainEntry, + wizardChainContinueHref, + wizardChainEndHref, +} from '@/lib/wizardActionChain' import { politicalTrendLabels } from '@/utilities/municipality/municipalityLabels' type WizardTrendNoteStepProps = { diff --git a/src/components/campaign/shared/WizardExpectedVotesStep.tsx b/src/components/campaign/shared/WizardExpectedVotesStep.tsx index f3d44ddc..34c86a71 100644 --- a/src/components/campaign/shared/WizardExpectedVotesStep.tsx +++ b/src/components/campaign/shared/WizardExpectedVotesStep.tsx @@ -27,7 +27,11 @@ import { wizardNextStepTitle, } from '@/lib/campaignWizardCopy' import { type VoteEstimateScenario, type VoteEstimateScenarioViewModel } from '@/lib/voteEstimate' -import { resolveWizardChainEntry, wizardChainContinueHref, wizardChainEndHref } from '@/lib/wizardActionChain' +import { + resolveWizardChainEntry, + wizardChainContinueHref, + wizardChainEndHref, +} from '@/lib/wizardActionChain' import { applyVoteShortcut, getWizardVoteViolation, diff --git a/src/components/campaign/shared/WizardMunicipalitySelectedStub.tsx b/src/components/campaign/shared/WizardMunicipalitySelectedStub.tsx index ac875303..4351d7b4 100644 --- a/src/components/campaign/shared/WizardMunicipalitySelectedStub.tsx +++ b/src/components/campaign/shared/WizardMunicipalitySelectedStub.tsx @@ -1,11 +1,11 @@ import { CampaignWizardShell } from '@/components/campaign/shared/CampaignWizardShell' import { wizardActionHref } from '@/lib/campaignActionRoutes' -import { wizardChainEndHref } from '@/lib/wizardActionChain' import { wizardFlowTitleForSlug, wizardNextStepPlaceholder, wizardNextStepTitle, } from '@/lib/campaignWizardCopy' +import { wizardChainEndHref } from '@/lib/wizardActionChain' type WizardMunicipalitySelectedStubProps = { actionSlug: string diff --git a/src/lib/campaignActionRoutes.ts b/src/lib/campaignActionRoutes.ts index 01854e1b..7a9fdd80 100644 --- a/src/lib/campaignActionRoutes.ts +++ b/src/lib/campaignActionRoutes.ts @@ -86,9 +86,7 @@ export const isWizardReturnPath = (pathname: string): boolean => { return true } -export const parseWizardReturnPath = ( - value: string | string[] | undefined, -): string | undefined => { +export const parseWizardReturnPath = (value: string | string[] | undefined): string | undefined => { const raw = Array.isArray(value) ? value[0] : value const trimmed = raw?.trim() if (!trimmed) return undefined diff --git a/src/lib/campaignHomeActions.ts b/src/lib/campaignHomeActions.ts index a5ff80fb..5b5d7bbf 100644 --- a/src/lib/campaignHomeActions.ts +++ b/src/lib/campaignHomeActions.ts @@ -11,9 +11,9 @@ import { } from 'lucide-react' import { + appendWizardReturnPath, CAMPAIGN_WIZARD_ACTION_SLUGS, campaignActionEntryHref, - appendWizardReturnPath, isCampaignWizardActionId, wizardActionHref, type CampaignWizardActionId, @@ -173,9 +173,13 @@ export const toHomeActionButtonProps = ( href = resolved.uncoveredMunicipalitiesHref } else if (isCampaignWizardActionId(action.id)) { if (resolved.municipalitySlug) { - href = wizardActionHref(CAMPAIGN_WIZARD_ACTION_SLUGS[action.id], resolved.municipalitySlug, { - returnPath: resolved.returnPath, - }) + href = wizardActionHref( + CAMPAIGN_WIZARD_ACTION_SLUGS[action.id], + resolved.municipalitySlug, + { + returnPath: resolved.returnPath, + }, + ) } else { href = appendWizardReturnPath(campaignActionEntryHref(action.id), resolved.returnPath) } diff --git a/src/lib/campaignQuickActionLeadership.ts b/src/lib/campaignQuickActionLeadership.ts index 851f445e..dc721b00 100644 --- a/src/lib/campaignQuickActionLeadership.ts +++ b/src/lib/campaignQuickActionLeadership.ts @@ -99,10 +99,14 @@ export const resolveLeadershipQuickActions = ( const leadershipId = parseLeadershipDetailId(pathname) if (leadershipId !== undefined) { - return resolveLeadershipDetailActions(role, { - ...context, - leadershipId: context.leadershipId ?? leadershipId, - }, pathname) + return resolveLeadershipDetailActions( + role, + { + ...context, + leadershipId: context.leadershipId ?? leadershipId, + }, + pathname, + ) } return null diff --git a/src/lib/wizardActionChain.ts b/src/lib/wizardActionChain.ts index ff4a63c7..3327c2d6 100644 --- a/src/lib/wizardActionChain.ts +++ b/src/lib/wizardActionChain.ts @@ -65,7 +65,14 @@ const wizardHrefForChainStep = ( case 'register-signal': return wizardSignalHref(actionSlug, municipalitySlug, undefined, entryAction, returnPath) case 'change-trend': - return wizardTrendHref(actionSlug, municipalitySlug, undefined, entryAction, undefined, returnPath) + return wizardTrendHref( + actionSlug, + municipalitySlug, + undefined, + entryAction, + undefined, + returnPath, + ) default: { const exhaustive: never = action return exhaustive diff --git a/tests/unit/wizardActionChain.unit.spec.ts b/tests/unit/wizardActionChain.unit.spec.ts index 2ad6d416..226fb067 100644 --- a/tests/unit/wizardActionChain.unit.spec.ts +++ b/tests/unit/wizardActionChain.unit.spec.ts @@ -74,12 +74,12 @@ describe('wizardActionChain', () => { it('honors allowlisted return path when the chain ends', () => { const origin = '/campanha/municipios/cairu' - expect( - wizardChainContinueHref('change-trend', 'update-leadership', 'cairu', origin), - ).toBe(origin) - expect( - wizardChainContinueHref('update-votes', 'change-trend', 'cairu', origin), - ).toBe(`${CAMPAIGN_ACTIONS_HOME}/registrar-sinal?municipio=cairu&entry=update-votes&from=${encodeURIComponent(origin)}`) + expect(wizardChainContinueHref('change-trend', 'update-leadership', 'cairu', origin)).toBe( + origin, + ) + expect(wizardChainContinueHref('update-votes', 'change-trend', 'cairu', origin)).toBe( + `${CAMPAIGN_ACTIONS_HOME}/registrar-sinal?municipio=cairu&entry=update-votes&from=${encodeURIComponent(origin)}`, + ) }) it('resolves session entry from query or current principal', () => {