mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-20 18:24:45 +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,
|
resolveWizardTrendNoteDestination,
|
||||||
} from '@/lib/politicalTrendWizardUi'
|
} from '@/lib/politicalTrendWizardUi'
|
||||||
import { toVoteEstimateScenarioViewModel } from '@/lib/voteEstimate'
|
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 config from '@/payload.config'
|
||||||
import { requireCampaignPageActor } from '@/utilities/campaignPageActor'
|
import { requireCampaignPageActor } from '@/utilities/campaignPageActor'
|
||||||
import { loadWizardLeadershipTiles } from '@/utilities/leadership/leadershipData'
|
import { loadWizardLeadershipTiles } from '@/utilities/leadership/leadershipData'
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,11 @@ import {
|
||||||
} from '@/lib/campaignWizardCopy'
|
} from '@/lib/campaignWizardCopy'
|
||||||
import { truncateNameAtWordBoundary } from '@/lib/leadershipNameTruncate'
|
import { truncateNameAtWordBoundary } from '@/lib/leadershipNameTruncate'
|
||||||
import { cn } from '@/lib/utils'
|
import { cn } from '@/lib/utils'
|
||||||
import { resolveWizardChainEntry, wizardChainContinueHref, wizardChainEndHref } from '@/lib/wizardActionChain'
|
import {
|
||||||
|
resolveWizardChainEntry,
|
||||||
|
wizardChainContinueHref,
|
||||||
|
wizardChainEndHref,
|
||||||
|
} from '@/lib/wizardActionChain'
|
||||||
import {
|
import {
|
||||||
resolveWizardLeadershipSkip,
|
resolveWizardLeadershipSkip,
|
||||||
type WizardLeadershipTileViewModel,
|
type WizardLeadershipTileViewModel,
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,11 @@ import { recordLastActedMunicipality } from '@/lib/campaignLastActedMunicipality
|
||||||
import { wizardFlowTitleForSlug } from '@/lib/campaignWizardCopy'
|
import { wizardFlowTitleForSlug } from '@/lib/campaignWizardCopy'
|
||||||
import type { MunicipalitySignalType } from '@/lib/schemas/municipalityUpdate'
|
import type { MunicipalitySignalType } from '@/lib/schemas/municipalityUpdate'
|
||||||
import { municipalitySignalTypeLabels } 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 {
|
import {
|
||||||
resolveWizardSignalSkip,
|
resolveWizardSignalSkip,
|
||||||
WIZARD_SIGNAL_BODY_STEP_TITLE_PREFIX,
|
WIZARD_SIGNAL_BODY_STEP_TITLE_PREFIX,
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,8 @@ import {
|
||||||
} from '@/lib/municipalitySignalTypeMeta'
|
} from '@/lib/municipalitySignalTypeMeta'
|
||||||
import type { MunicipalitySignalType } from '@/lib/schemas/municipalityUpdate'
|
import type { MunicipalitySignalType } from '@/lib/schemas/municipalityUpdate'
|
||||||
import { cn } from '@/lib/utils'
|
import { cn } from '@/lib/utils'
|
||||||
import { resolveWizardSignalSkip, WIZARD_SIGNAL_TYPE_STEP_TITLE } from '@/lib/wizardSignalUi'
|
|
||||||
import { wizardChainEndHref } from '@/lib/wizardActionChain'
|
import { wizardChainEndHref } from '@/lib/wizardActionChain'
|
||||||
|
import { resolveWizardSignalSkip, WIZARD_SIGNAL_TYPE_STEP_TITLE } from '@/lib/wizardSignalUi'
|
||||||
|
|
||||||
type WizardSignalTypeStepProps = {
|
type WizardSignalTypeStepProps = {
|
||||||
actionSlug: string
|
actionSlug: string
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,11 @@ import {
|
||||||
WIZARD_TREND_SAVE_LABEL,
|
WIZARD_TREND_SAVE_LABEL,
|
||||||
} from '@/lib/politicalTrendWizardUi'
|
} from '@/lib/politicalTrendWizardUi'
|
||||||
import type { PoliticalTrendStatusValue } from '@/lib/schemas/municipality'
|
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'
|
import { politicalTrendLabels } from '@/utilities/municipality/municipalityLabels'
|
||||||
|
|
||||||
type WizardTrendNoteStepProps = {
|
type WizardTrendNoteStepProps = {
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,11 @@ import {
|
||||||
wizardNextStepTitle,
|
wizardNextStepTitle,
|
||||||
} from '@/lib/campaignWizardCopy'
|
} from '@/lib/campaignWizardCopy'
|
||||||
import { type VoteEstimateScenario, type VoteEstimateScenarioViewModel } from '@/lib/voteEstimate'
|
import { type VoteEstimateScenario, type VoteEstimateScenarioViewModel } from '@/lib/voteEstimate'
|
||||||
import { resolveWizardChainEntry, wizardChainContinueHref, wizardChainEndHref } from '@/lib/wizardActionChain'
|
import {
|
||||||
|
resolveWizardChainEntry,
|
||||||
|
wizardChainContinueHref,
|
||||||
|
wizardChainEndHref,
|
||||||
|
} from '@/lib/wizardActionChain'
|
||||||
import {
|
import {
|
||||||
applyVoteShortcut,
|
applyVoteShortcut,
|
||||||
getWizardVoteViolation,
|
getWizardVoteViolation,
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import { CampaignWizardShell } from '@/components/campaign/shared/CampaignWizardShell'
|
import { CampaignWizardShell } from '@/components/campaign/shared/CampaignWizardShell'
|
||||||
import { wizardActionHref } from '@/lib/campaignActionRoutes'
|
import { wizardActionHref } from '@/lib/campaignActionRoutes'
|
||||||
import { wizardChainEndHref } from '@/lib/wizardActionChain'
|
|
||||||
import {
|
import {
|
||||||
wizardFlowTitleForSlug,
|
wizardFlowTitleForSlug,
|
||||||
wizardNextStepPlaceholder,
|
wizardNextStepPlaceholder,
|
||||||
wizardNextStepTitle,
|
wizardNextStepTitle,
|
||||||
} from '@/lib/campaignWizardCopy'
|
} from '@/lib/campaignWizardCopy'
|
||||||
|
import { wizardChainEndHref } from '@/lib/wizardActionChain'
|
||||||
|
|
||||||
type WizardMunicipalitySelectedStubProps = {
|
type WizardMunicipalitySelectedStubProps = {
|
||||||
actionSlug: string
|
actionSlug: string
|
||||||
|
|
|
||||||
|
|
@ -86,9 +86,7 @@ export const isWizardReturnPath = (pathname: string): boolean => {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
export const parseWizardReturnPath = (
|
export const parseWizardReturnPath = (value: string | string[] | undefined): string | undefined => {
|
||||||
value: string | string[] | undefined,
|
|
||||||
): string | undefined => {
|
|
||||||
const raw = Array.isArray(value) ? value[0] : value
|
const raw = Array.isArray(value) ? value[0] : value
|
||||||
const trimmed = raw?.trim()
|
const trimmed = raw?.trim()
|
||||||
if (!trimmed) return undefined
|
if (!trimmed) return undefined
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,9 @@ import {
|
||||||
} from 'lucide-react'
|
} from 'lucide-react'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
appendWizardReturnPath,
|
||||||
CAMPAIGN_WIZARD_ACTION_SLUGS,
|
CAMPAIGN_WIZARD_ACTION_SLUGS,
|
||||||
campaignActionEntryHref,
|
campaignActionEntryHref,
|
||||||
appendWizardReturnPath,
|
|
||||||
isCampaignWizardActionId,
|
isCampaignWizardActionId,
|
||||||
wizardActionHref,
|
wizardActionHref,
|
||||||
type CampaignWizardActionId,
|
type CampaignWizardActionId,
|
||||||
|
|
@ -173,9 +173,13 @@ export const toHomeActionButtonProps = (
|
||||||
href = resolved.uncoveredMunicipalitiesHref
|
href = resolved.uncoveredMunicipalitiesHref
|
||||||
} else if (isCampaignWizardActionId(action.id)) {
|
} else if (isCampaignWizardActionId(action.id)) {
|
||||||
if (resolved.municipalitySlug) {
|
if (resolved.municipalitySlug) {
|
||||||
href = wizardActionHref(CAMPAIGN_WIZARD_ACTION_SLUGS[action.id], resolved.municipalitySlug, {
|
href = wizardActionHref(
|
||||||
returnPath: resolved.returnPath,
|
CAMPAIGN_WIZARD_ACTION_SLUGS[action.id],
|
||||||
})
|
resolved.municipalitySlug,
|
||||||
|
{
|
||||||
|
returnPath: resolved.returnPath,
|
||||||
|
},
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
href = appendWizardReturnPath(campaignActionEntryHref(action.id), resolved.returnPath)
|
href = appendWizardReturnPath(campaignActionEntryHref(action.id), resolved.returnPath)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -99,10 +99,14 @@ export const resolveLeadershipQuickActions = (
|
||||||
|
|
||||||
const leadershipId = parseLeadershipDetailId(pathname)
|
const leadershipId = parseLeadershipDetailId(pathname)
|
||||||
if (leadershipId !== undefined) {
|
if (leadershipId !== undefined) {
|
||||||
return resolveLeadershipDetailActions(role, {
|
return resolveLeadershipDetailActions(
|
||||||
...context,
|
role,
|
||||||
leadershipId: context.leadershipId ?? leadershipId,
|
{
|
||||||
}, pathname)
|
...context,
|
||||||
|
leadershipId: context.leadershipId ?? leadershipId,
|
||||||
|
},
|
||||||
|
pathname,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return null
|
return null
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,14 @@ const wizardHrefForChainStep = (
|
||||||
case 'register-signal':
|
case 'register-signal':
|
||||||
return wizardSignalHref(actionSlug, municipalitySlug, undefined, entryAction, returnPath)
|
return wizardSignalHref(actionSlug, municipalitySlug, undefined, entryAction, returnPath)
|
||||||
case 'change-trend':
|
case 'change-trend':
|
||||||
return wizardTrendHref(actionSlug, municipalitySlug, undefined, entryAction, undefined, returnPath)
|
return wizardTrendHref(
|
||||||
|
actionSlug,
|
||||||
|
municipalitySlug,
|
||||||
|
undefined,
|
||||||
|
entryAction,
|
||||||
|
undefined,
|
||||||
|
returnPath,
|
||||||
|
)
|
||||||
default: {
|
default: {
|
||||||
const exhaustive: never = action
|
const exhaustive: never = action
|
||||||
return exhaustive
|
return exhaustive
|
||||||
|
|
|
||||||
|
|
@ -74,12 +74,12 @@ describe('wizardActionChain', () => {
|
||||||
|
|
||||||
it('honors allowlisted return path when the chain ends', () => {
|
it('honors allowlisted return path when the chain ends', () => {
|
||||||
const origin = '/campanha/municipios/cairu'
|
const origin = '/campanha/municipios/cairu'
|
||||||
expect(
|
expect(wizardChainContinueHref('change-trend', 'update-leadership', 'cairu', origin)).toBe(
|
||||||
wizardChainContinueHref('change-trend', 'update-leadership', 'cairu', origin),
|
origin,
|
||||||
).toBe(origin)
|
)
|
||||||
expect(
|
expect(wizardChainContinueHref('update-votes', 'change-trend', 'cairu', origin)).toBe(
|
||||||
wizardChainContinueHref('update-votes', 'change-trend', 'cairu', origin),
|
`${CAMPAIGN_ACTIONS_HOME}/registrar-sinal?municipio=cairu&entry=update-votes&from=${encodeURIComponent(origin)}`,
|
||||||
).toBe(`${CAMPAIGN_ACTIONS_HOME}/registrar-sinal?municipio=cairu&entry=update-votes&from=${encodeURIComponent(origin)}`)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('resolves session entry from query or current principal', () => {
|
it('resolves session entry from query or current principal', () => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue