mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-13 06:43:06 +00:00
Format B110 wizard return path changes
This commit is contained in:
parent
d5697bcfcb
commit
2e3740ef3f
12 changed files with 58 additions and 25 deletions
|
|
@ -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'
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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', () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue