mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-22 22:23:07 +00:00
B110 — wizard return path via allowlisted from query
Propagate return path from quick actions through the B98 wizard chain so dismiss, skip, and chain end navigate back to the originating page instead of always redirecting to Início. Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com>
This commit is contained in:
parent
5c21552621
commit
d5697bcfcb
28 changed files with 315 additions and 85 deletions
|
|
@ -15,12 +15,14 @@ import {
|
||||||
parseWizardEntryActionParam,
|
parseWizardEntryActionParam,
|
||||||
parseWizardLeadershipIdParam,
|
parseWizardLeadershipIdParam,
|
||||||
parseWizardMunicipioParam,
|
parseWizardMunicipioParam,
|
||||||
|
parseWizardReturnPath,
|
||||||
resolveWizardSignalTypeParam,
|
resolveWizardSignalTypeParam,
|
||||||
resolveWizardTrendStatusParam,
|
resolveWizardTrendStatusParam,
|
||||||
WIZARD_ENTRY_ACTION_QUERY_KEY,
|
WIZARD_ENTRY_ACTION_QUERY_KEY,
|
||||||
WIZARD_LEADERSHIP_ID_QUERY_KEY,
|
WIZARD_LEADERSHIP_ID_QUERY_KEY,
|
||||||
WIZARD_MUNICIPIO_QUERY_KEY,
|
WIZARD_MUNICIPIO_QUERY_KEY,
|
||||||
WIZARD_NOTE_PREFILL_QUERY_KEY,
|
WIZARD_NOTE_PREFILL_QUERY_KEY,
|
||||||
|
WIZARD_RETURN_PATH_QUERY_KEY,
|
||||||
WIZARD_SCENARIO_QUERY_KEY,
|
WIZARD_SCENARIO_QUERY_KEY,
|
||||||
WIZARD_SIGNAL_BODY_QUERY_KEY,
|
WIZARD_SIGNAL_BODY_QUERY_KEY,
|
||||||
WIZARD_SIGNAL_TYPE_QUERY_KEY,
|
WIZARD_SIGNAL_TYPE_QUERY_KEY,
|
||||||
|
|
@ -31,14 +33,13 @@ import {
|
||||||
wizardSignalHref,
|
wizardSignalHref,
|
||||||
wizardTrendHref,
|
wizardTrendHref,
|
||||||
} from '@/lib/campaignActionRoutes'
|
} from '@/lib/campaignActionRoutes'
|
||||||
import { CAMPAIGN_HOME } from '@/lib/campaignPaths'
|
|
||||||
import {
|
import {
|
||||||
buildPoliticalTrendNotePrefill,
|
buildPoliticalTrendNotePrefill,
|
||||||
resolvePoliticalTrendNotePrefillSource,
|
resolvePoliticalTrendNotePrefillSource,
|
||||||
resolveWizardTrendNoteDestination,
|
resolveWizardTrendNoteDestination,
|
||||||
} from '@/lib/politicalTrendWizardUi'
|
} from '@/lib/politicalTrendWizardUi'
|
||||||
import { toVoteEstimateScenarioViewModel } from '@/lib/voteEstimate'
|
import { toVoteEstimateScenarioViewModel } from '@/lib/voteEstimate'
|
||||||
import { isWizardChainActionId, wizardChainContinueHref } 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'
|
||||||
|
|
@ -83,6 +84,7 @@ export default async function CampaignActionWizardPage({
|
||||||
}: CampaignActionWizardPageProps) {
|
}: CampaignActionWizardPageProps) {
|
||||||
const { slug } = await params
|
const { slug } = await params
|
||||||
const resolvedSearchParams = await searchParams
|
const resolvedSearchParams = await searchParams
|
||||||
|
const returnPath = parseWizardReturnPath(resolvedSearchParams[WIZARD_RETURN_PATH_QUERY_KEY])
|
||||||
|
|
||||||
if (!isCampaignWizardActionSlug(slug)) {
|
if (!isCampaignWizardActionSlug(slug)) {
|
||||||
notFound()
|
notFound()
|
||||||
|
|
@ -104,7 +106,8 @@ export default async function CampaignActionWizardPage({
|
||||||
return (
|
return (
|
||||||
<WizardMunicipalitySearchStep
|
<WizardMunicipalitySearchStep
|
||||||
actionSlug={slug}
|
actionSlug={slug}
|
||||||
previousHref={CAMPAIGN_HOME}
|
previousHref={wizardChainEndHref(returnPath)}
|
||||||
|
returnPath={returnPath}
|
||||||
accessibleMunicipalities={accessibleMunicipalities}
|
accessibleMunicipalities={accessibleMunicipalities}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|
@ -142,6 +145,7 @@ export default async function CampaignActionWizardPage({
|
||||||
municipalitySlug={municipality.slug}
|
municipalitySlug={municipality.slug}
|
||||||
initialExpectedVotes={toVoteEstimateScenarioViewModel(municipality.expectedVotes)}
|
initialExpectedVotes={toVoteEstimateScenarioViewModel(municipality.expectedVotes)}
|
||||||
entryAction={entryAction}
|
entryAction={entryAction}
|
||||||
|
returnPath={returnPath}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -164,6 +168,7 @@ export default async function CampaignActionWizardPage({
|
||||||
entryAction={entryAction}
|
entryAction={entryAction}
|
||||||
initialTiles={tiles}
|
initialTiles={tiles}
|
||||||
initialLeadershipId={initialLeadershipId}
|
initialLeadershipId={initialLeadershipId}
|
||||||
|
returnPath={returnPath}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -200,9 +205,11 @@ export default async function CampaignActionWizardPage({
|
||||||
if (noteDestination === 'home') {
|
if (noteDestination === 'home') {
|
||||||
// Chained session: advance the queue (B98). Standalone stale deep-link: Início (B97).
|
// Chained session: advance the queue (B98). Standalone stale deep-link: Início (B97).
|
||||||
if (isWizardChainActionId(entryAction)) {
|
if (isWizardChainActionId(entryAction)) {
|
||||||
redirect(wizardChainContinueHref(entryAction, 'change-trend', municipalitySlug))
|
redirect(
|
||||||
|
wizardChainContinueHref(entryAction, 'change-trend', municipalitySlug, returnPath),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
redirect(CAMPAIGN_HOME)
|
redirect(wizardChainEndHref(returnPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (noteDestination === 'choice') {
|
if (noteDestination === 'choice') {
|
||||||
|
|
@ -220,6 +227,7 @@ export default async function CampaignActionWizardPage({
|
||||||
trendStatus={trendStatus}
|
trendStatus={trendStatus}
|
||||||
initialNote={initialNote}
|
initialNote={initialNote}
|
||||||
entryAction={entryAction}
|
entryAction={entryAction}
|
||||||
|
returnPath={returnPath}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -232,6 +240,7 @@ export default async function CampaignActionWizardPage({
|
||||||
currentStatus={currentStatus}
|
currentStatus={currentStatus}
|
||||||
entryAction={entryAction}
|
entryAction={entryAction}
|
||||||
prefillExtraParams={prefillExtraParams}
|
prefillExtraParams={prefillExtraParams}
|
||||||
|
returnPath={returnPath}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -257,6 +266,7 @@ export default async function CampaignActionWizardPage({
|
||||||
municipalitySlug={municipality.slug}
|
municipalitySlug={municipality.slug}
|
||||||
signalType={signalType}
|
signalType={signalType}
|
||||||
entryAction={entryAction}
|
entryAction={entryAction}
|
||||||
|
returnPath={returnPath}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -267,9 +277,16 @@ export default async function CampaignActionWizardPage({
|
||||||
municipalityName={municipality.name}
|
municipalityName={municipality.name}
|
||||||
municipalitySlug={municipality.slug}
|
municipalitySlug={municipality.slug}
|
||||||
entryAction={entryAction}
|
entryAction={entryAction}
|
||||||
|
returnPath={returnPath}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return <WizardMunicipalitySelectedStub actionSlug={slug} municipalityName={municipality.name} />
|
return (
|
||||||
|
<WizardMunicipalitySelectedStub
|
||||||
|
actionSlug={slug}
|
||||||
|
municipalityName={municipality.name}
|
||||||
|
returnPath={returnPath}
|
||||||
|
/>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import { CampaignHomeActionStrip } from '@/components/campaign/dashboard/CampaignHomeActionStrip'
|
import { CampaignHomeActionStrip } from '@/components/campaign/dashboard/CampaignHomeActionStrip'
|
||||||
import { homeActionsForRole, toHomeActionButtonProps } from '@/lib/campaignHomeActions'
|
import { homeActionsForRole, toHomeActionButtonProps } from '@/lib/campaignHomeActions'
|
||||||
|
import { CAMPAIGN_HOME } from '@/lib/campaignPaths'
|
||||||
import type { CampaignRole } from '@/lib/campaignRoles'
|
import type { CampaignRole } from '@/lib/campaignRoles'
|
||||||
|
|
||||||
export const CampaignHomeActions = ({
|
export const CampaignHomeActions = ({
|
||||||
|
|
@ -11,7 +12,10 @@ export const CampaignHomeActions = ({
|
||||||
role: CampaignRole
|
role: CampaignRole
|
||||||
uncoveredMunicipalitiesHref?: string
|
uncoveredMunicipalitiesHref?: string
|
||||||
}) => {
|
}) => {
|
||||||
const actions = toHomeActionButtonProps(homeActionsForRole(role), uncoveredMunicipalitiesHref)
|
const actions = toHomeActionButtonProps(homeActionsForRole(role), {
|
||||||
|
uncoveredMunicipalitiesHref,
|
||||||
|
returnPath: CAMPAIGN_HOME,
|
||||||
|
})
|
||||||
|
|
||||||
if (actions.length === 0) return null
|
if (actions.length === 0) return null
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/comp
|
||||||
import type { CampaignWizardActionId } from '@/lib/campaignActionRoutes'
|
import type { CampaignWizardActionId } from '@/lib/campaignActionRoutes'
|
||||||
import { wizardActionHref } from '@/lib/campaignActionRoutes'
|
import { wizardActionHref } from '@/lib/campaignActionRoutes'
|
||||||
import { recordLastActedMunicipality } from '@/lib/campaignLastActedMunicipality'
|
import { recordLastActedMunicipality } from '@/lib/campaignLastActedMunicipality'
|
||||||
import { CAMPAIGN_HOME } from '@/lib/campaignPaths'
|
|
||||||
import {
|
import {
|
||||||
WIZARD_LEADERSHIP_ADD_TILE_LABEL,
|
WIZARD_LEADERSHIP_ADD_TILE_LABEL,
|
||||||
WIZARD_LEADERSHIP_CONTINUE_LABEL,
|
WIZARD_LEADERSHIP_CONTINUE_LABEL,
|
||||||
|
|
@ -36,7 +35,7 @@ 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 } from '@/lib/wizardActionChain'
|
import { resolveWizardChainEntry, wizardChainContinueHref, wizardChainEndHref } from '@/lib/wizardActionChain'
|
||||||
import {
|
import {
|
||||||
resolveWizardLeadershipSkip,
|
resolveWizardLeadershipSkip,
|
||||||
type WizardLeadershipTileViewModel,
|
type WizardLeadershipTileViewModel,
|
||||||
|
|
@ -50,6 +49,7 @@ type WizardLeadershipStepProps = {
|
||||||
entryAction?: CampaignWizardActionId
|
entryAction?: CampaignWizardActionId
|
||||||
initialTiles: WizardLeadershipTileViewModel[]
|
initialTiles: WizardLeadershipTileViewModel[]
|
||||||
initialLeadershipId?: number
|
initialLeadershipId?: number
|
||||||
|
returnPath?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
type WizardLeadershipMode =
|
type WizardLeadershipMode =
|
||||||
|
|
@ -70,6 +70,7 @@ export const WizardLeadershipStep = ({
|
||||||
entryAction,
|
entryAction,
|
||||||
initialTiles,
|
initialTiles,
|
||||||
initialLeadershipId,
|
initialLeadershipId,
|
||||||
|
returnPath,
|
||||||
}: WizardLeadershipStepProps) => {
|
}: WizardLeadershipStepProps) => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const [isContinuing, startContinueTransition] = useTransition()
|
const [isContinuing, startContinueTransition] = useTransition()
|
||||||
|
|
@ -84,11 +85,12 @@ export const WizardLeadershipStep = ({
|
||||||
const [dirty, setDirty] = useState(false)
|
const [dirty, setDirty] = useState(false)
|
||||||
const [infoTile, setInfoTile] = useState<WizardLeadershipTileViewModel | null>(null)
|
const [infoTile, setInfoTile] = useState<WizardLeadershipTileViewModel | null>(null)
|
||||||
|
|
||||||
const skipConfig = resolveWizardLeadershipSkip(entryAction, municipalitySlug)
|
const skipConfig = resolveWizardLeadershipSkip(entryAction, municipalitySlug, returnPath)
|
||||||
const chainContinueHref = wizardChainContinueHref(
|
const chainContinueHref = wizardChainContinueHref(
|
||||||
resolveWizardChainEntry(entryAction, 'update-leadership'),
|
resolveWizardChainEntry(entryAction, 'update-leadership'),
|
||||||
'update-leadership',
|
'update-leadership',
|
||||||
municipalitySlug,
|
municipalitySlug,
|
||||||
|
returnPath,
|
||||||
)
|
)
|
||||||
|
|
||||||
const stepTitle =
|
const stepTitle =
|
||||||
|
|
@ -123,8 +125,8 @@ export const WizardLeadershipStep = ({
|
||||||
flowTitle={wizardFlowTitleForSlug(actionSlug)}
|
flowTitle={wizardFlowTitleForSlug(actionSlug)}
|
||||||
stepTitle={stepTitle}
|
stepTitle={stepTitle}
|
||||||
isEntryStep={false}
|
isEntryStep={false}
|
||||||
previousHref={wizardActionHref(actionSlug)}
|
previousHref={wizardActionHref(actionSlug, municipalitySlug, { returnPath })}
|
||||||
dismissHref={CAMPAIGN_HOME}
|
dismissHref={wizardChainEndHref(returnPath)}
|
||||||
municipalityLabel={municipalityName}
|
municipalityLabel={municipalityName}
|
||||||
skip={skipConfig}
|
skip={skipConfig}
|
||||||
trailingAction={trailingAction}
|
trailingAction={trailingAction}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ 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 } 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,
|
||||||
|
|
@ -31,6 +31,7 @@ type WizardSignalBodyStepProps = {
|
||||||
municipalitySlug: string
|
municipalitySlug: string
|
||||||
signalType: MunicipalitySignalType
|
signalType: MunicipalitySignalType
|
||||||
entryAction?: CampaignWizardActionId
|
entryAction?: CampaignWizardActionId
|
||||||
|
returnPath?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const WizardSignalBodyStep = ({
|
export const WizardSignalBodyStep = ({
|
||||||
|
|
@ -40,19 +41,22 @@ export const WizardSignalBodyStep = ({
|
||||||
municipalitySlug,
|
municipalitySlug,
|
||||||
signalType,
|
signalType,
|
||||||
entryAction,
|
entryAction,
|
||||||
|
returnPath,
|
||||||
}: WizardSignalBodyStepProps) => {
|
}: WizardSignalBodyStepProps) => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const [state, submitAction, isPending] = useActionState(
|
const [state, submitAction, isPending] = useActionState(
|
||||||
createMunicipalityListSignalFormAction,
|
createMunicipalityListSignalFormAction,
|
||||||
{},
|
{},
|
||||||
)
|
)
|
||||||
const skip = resolveWizardSignalSkip(entryAction, municipalitySlug)
|
const skip = resolveWizardSignalSkip(entryAction, municipalitySlug, returnPath)
|
||||||
const stepTitle = `${WIZARD_SIGNAL_BODY_STEP_TITLE_PREFIX}: ${municipalitySignalTypeLabels[signalType]}`
|
const stepTitle = `${WIZARD_SIGNAL_BODY_STEP_TITLE_PREFIX}: ${municipalitySignalTypeLabels[signalType]}`
|
||||||
|
|
||||||
useCampaignFormSuccessToast(state, () => {
|
useCampaignFormSuccessToast(state, () => {
|
||||||
recordLastActedMunicipality(municipalitySlug)
|
recordLastActedMunicipality(municipalitySlug)
|
||||||
const sessionEntry = resolveWizardChainEntry(entryAction, 'register-signal')
|
const sessionEntry = resolveWizardChainEntry(entryAction, 'register-signal')
|
||||||
router.replace(wizardChainContinueHref(sessionEntry, 'register-signal', municipalitySlug))
|
router.replace(
|
||||||
|
wizardChainContinueHref(sessionEntry, 'register-signal', municipalitySlug, returnPath),
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -60,7 +64,14 @@ export const WizardSignalBodyStep = ({
|
||||||
flowTitle={wizardFlowTitleForSlug(actionSlug)}
|
flowTitle={wizardFlowTitleForSlug(actionSlug)}
|
||||||
isEntryStep={false}
|
isEntryStep={false}
|
||||||
stepTitle={stepTitle}
|
stepTitle={stepTitle}
|
||||||
previousHref={wizardSignalHref(actionSlug, municipalitySlug, undefined, entryAction)}
|
previousHref={wizardSignalHref(
|
||||||
|
actionSlug,
|
||||||
|
municipalitySlug,
|
||||||
|
undefined,
|
||||||
|
entryAction,
|
||||||
|
returnPath,
|
||||||
|
)}
|
||||||
|
dismissHref={wizardChainEndHref(returnPath)}
|
||||||
municipalityLabel={municipalityName}
|
municipalityLabel={municipalityName}
|
||||||
skip={skip}
|
skip={skip}
|
||||||
trailingAction={skip ? <WizardSignalSkipTrailing skip={skip} /> : undefined}
|
trailingAction={skip ? <WizardSignalSkipTrailing skip={skip} /> : undefined}
|
||||||
|
|
|
||||||
|
|
@ -26,12 +26,14 @@ import {
|
||||||
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 { resolveWizardSignalSkip, WIZARD_SIGNAL_TYPE_STEP_TITLE } from '@/lib/wizardSignalUi'
|
||||||
|
import { wizardChainEndHref } from '@/lib/wizardActionChain'
|
||||||
|
|
||||||
type WizardSignalTypeStepProps = {
|
type WizardSignalTypeStepProps = {
|
||||||
actionSlug: string
|
actionSlug: string
|
||||||
municipalityName: string
|
municipalityName: string
|
||||||
municipalitySlug: string
|
municipalitySlug: string
|
||||||
entryAction?: CampaignWizardActionId
|
entryAction?: CampaignWizardActionId
|
||||||
|
returnPath?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const WizardSignalTypeStep = ({
|
export const WizardSignalTypeStep = ({
|
||||||
|
|
@ -39,10 +41,11 @@ export const WizardSignalTypeStep = ({
|
||||||
municipalityName,
|
municipalityName,
|
||||||
municipalitySlug,
|
municipalitySlug,
|
||||||
entryAction,
|
entryAction,
|
||||||
|
returnPath,
|
||||||
}: WizardSignalTypeStepProps) => {
|
}: WizardSignalTypeStepProps) => {
|
||||||
const [infoType, setInfoType] = useState<MunicipalitySignalType | null>(null)
|
const [infoType, setInfoType] = useState<MunicipalitySignalType | null>(null)
|
||||||
const infoEntry = infoType ? municipalitySignalTypeMetaByType[infoType] : null
|
const infoEntry = infoType ? municipalitySignalTypeMetaByType[infoType] : null
|
||||||
const skip = resolveWizardSignalSkip(entryAction, municipalitySlug)
|
const skip = resolveWizardSignalSkip(entryAction, municipalitySlug, returnPath)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
@ -50,7 +53,8 @@ export const WizardSignalTypeStep = ({
|
||||||
flowTitle={wizardFlowTitleForSlug(actionSlug)}
|
flowTitle={wizardFlowTitleForSlug(actionSlug)}
|
||||||
isEntryStep={false}
|
isEntryStep={false}
|
||||||
stepTitle={WIZARD_SIGNAL_TYPE_STEP_TITLE}
|
stepTitle={WIZARD_SIGNAL_TYPE_STEP_TITLE}
|
||||||
previousHref={wizardActionHref(actionSlug)}
|
previousHref={wizardActionHref(actionSlug, municipalitySlug, { returnPath })}
|
||||||
|
dismissHref={wizardChainEndHref(returnPath)}
|
||||||
municipalityLabel={municipalityName}
|
municipalityLabel={municipalityName}
|
||||||
contentAlign="end"
|
contentAlign="end"
|
||||||
skip={skip}
|
skip={skip}
|
||||||
|
|
@ -62,7 +66,13 @@ export const WizardSignalTypeStep = ({
|
||||||
return (
|
return (
|
||||||
<li key={entry.type} className="relative">
|
<li key={entry.type} className="relative">
|
||||||
<CampaignWizardNavLink
|
<CampaignWizardNavLink
|
||||||
href={wizardSignalHref(actionSlug, municipalitySlug, entry.type, entryAction)}
|
href={wizardSignalHref(
|
||||||
|
actionSlug,
|
||||||
|
municipalitySlug,
|
||||||
|
entry.type,
|
||||||
|
entryAction,
|
||||||
|
returnPath,
|
||||||
|
)}
|
||||||
className={cn(
|
className={cn(
|
||||||
'flex aspect-square w-full flex-col justify-between rounded-lg border border-border bg-transparent p-3 pr-10 text-left',
|
'flex aspect-square w-full flex-col justify-between rounded-lg border border-border bg-transparent p-3 pr-10 text-left',
|
||||||
'transition-colors hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
|
'transition-colors hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import {
|
||||||
} from '@/lib/politicalTrendWizardUi'
|
} from '@/lib/politicalTrendWizardUi'
|
||||||
import type { PoliticalTrendStatusValue } from '@/lib/schemas/municipality'
|
import type { PoliticalTrendStatusValue } from '@/lib/schemas/municipality'
|
||||||
import { cn } from '@/lib/utils'
|
import { cn } from '@/lib/utils'
|
||||||
|
import { wizardChainEndHref } from '@/lib/wizardActionChain'
|
||||||
|
|
||||||
type WizardTrendChoiceStepProps = {
|
type WizardTrendChoiceStepProps = {
|
||||||
actionSlug: string
|
actionSlug: string
|
||||||
|
|
@ -38,6 +39,7 @@ type WizardTrendChoiceStepProps = {
|
||||||
currentStatus: PoliticalTrendStatusValue | null
|
currentStatus: PoliticalTrendStatusValue | null
|
||||||
entryAction?: CampaignWizardActionId
|
entryAction?: CampaignWizardActionId
|
||||||
prefillExtraParams?: Record<string, string>
|
prefillExtraParams?: Record<string, string>
|
||||||
|
returnPath?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const WizardTrendChoiceStep = ({
|
export const WizardTrendChoiceStep = ({
|
||||||
|
|
@ -47,9 +49,10 @@ export const WizardTrendChoiceStep = ({
|
||||||
currentStatus,
|
currentStatus,
|
||||||
entryAction,
|
entryAction,
|
||||||
prefillExtraParams,
|
prefillExtraParams,
|
||||||
|
returnPath,
|
||||||
}: WizardTrendChoiceStepProps) => {
|
}: WizardTrendChoiceStepProps) => {
|
||||||
const [infoEntry, setInfoEntry] = useState<PoliticalTrendWizardMetaEntry | null>(null)
|
const [infoEntry, setInfoEntry] = useState<PoliticalTrendWizardMetaEntry | null>(null)
|
||||||
const skip = resolveWizardTrendSkip(entryAction, municipalitySlug)
|
const skip = resolveWizardTrendSkip(entryAction, municipalitySlug, returnPath)
|
||||||
const options = selectablePoliticalTrendStatuses(currentStatus)
|
const options = selectablePoliticalTrendStatuses(currentStatus)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -58,7 +61,8 @@ export const WizardTrendChoiceStep = ({
|
||||||
flowTitle={wizardFlowTitleForSlug(actionSlug)}
|
flowTitle={wizardFlowTitleForSlug(actionSlug)}
|
||||||
isEntryStep={false}
|
isEntryStep={false}
|
||||||
stepTitle={wizardTrendChoiceStepTitle(currentStatus)}
|
stepTitle={wizardTrendChoiceStepTitle(currentStatus)}
|
||||||
previousHref={wizardActionHref(actionSlug, municipalitySlug, { entryAction })}
|
previousHref={wizardActionHref(actionSlug, municipalitySlug, { entryAction, returnPath })}
|
||||||
|
dismissHref={wizardChainEndHref(returnPath)}
|
||||||
municipalityLabel={municipalityName}
|
municipalityLabel={municipalityName}
|
||||||
skip={skip}
|
skip={skip}
|
||||||
trailingAction={skip ? <WizardTrendSkipTrailing skip={skip} /> : undefined}
|
trailingAction={skip ? <WizardTrendSkipTrailing skip={skip} /> : undefined}
|
||||||
|
|
@ -76,6 +80,7 @@ export const WizardTrendChoiceStep = ({
|
||||||
status,
|
status,
|
||||||
entryAction,
|
entryAction,
|
||||||
prefillExtraParams,
|
prefillExtraParams,
|
||||||
|
returnPath,
|
||||||
)}
|
)}
|
||||||
className={cn(
|
className={cn(
|
||||||
'flex aspect-square w-full flex-col justify-between rounded-lg border bg-background p-3 pr-10 text-left',
|
'flex aspect-square w-full flex-col justify-between rounded-lg border bg-background p-3 pr-10 text-left',
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ 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 } 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 = {
|
||||||
|
|
@ -32,6 +32,7 @@ type WizardTrendNoteStepProps = {
|
||||||
trendStatus: PoliticalTrendStatusValue
|
trendStatus: PoliticalTrendStatusValue
|
||||||
initialNote: string
|
initialNote: string
|
||||||
entryAction?: CampaignWizardActionId
|
entryAction?: CampaignWizardActionId
|
||||||
|
returnPath?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const WizardTrendNoteStep = ({
|
export const WizardTrendNoteStep = ({
|
||||||
|
|
@ -42,6 +43,7 @@ export const WizardTrendNoteStep = ({
|
||||||
trendStatus,
|
trendStatus,
|
||||||
initialNote,
|
initialNote,
|
||||||
entryAction,
|
entryAction,
|
||||||
|
returnPath,
|
||||||
}: WizardTrendNoteStepProps) => {
|
}: WizardTrendNoteStepProps) => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const [note, setNote] = useState(initialNote)
|
const [note, setNote] = useState(initialNote)
|
||||||
|
|
@ -49,13 +51,15 @@ export const WizardTrendNoteStep = ({
|
||||||
setMunicipalityPoliticalTrendFormAction,
|
setMunicipalityPoliticalTrendFormAction,
|
||||||
{},
|
{},
|
||||||
)
|
)
|
||||||
const skip = resolveWizardTrendSkip(entryAction, municipalitySlug)
|
const skip = resolveWizardTrendSkip(entryAction, municipalitySlug, returnPath)
|
||||||
const stepTitle = `Mudar tendência para ${politicalTrendLabels[trendStatus]}`
|
const stepTitle = `Mudar tendência para ${politicalTrendLabels[trendStatus]}`
|
||||||
|
|
||||||
useCampaignFormSuccessToast(state, () => {
|
useCampaignFormSuccessToast(state, () => {
|
||||||
recordLastActedMunicipality(municipalitySlug)
|
recordLastActedMunicipality(municipalitySlug)
|
||||||
const sessionEntry = resolveWizardChainEntry(entryAction, 'change-trend')
|
const sessionEntry = resolveWizardChainEntry(entryAction, 'change-trend')
|
||||||
router.replace(wizardChainContinueHref(sessionEntry, 'change-trend', municipalitySlug))
|
router.replace(
|
||||||
|
wizardChainContinueHref(sessionEntry, 'change-trend', municipalitySlug, returnPath),
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -63,7 +67,15 @@ export const WizardTrendNoteStep = ({
|
||||||
flowTitle={wizardFlowTitleForSlug(actionSlug)}
|
flowTitle={wizardFlowTitleForSlug(actionSlug)}
|
||||||
isEntryStep={false}
|
isEntryStep={false}
|
||||||
stepTitle={stepTitle}
|
stepTitle={stepTitle}
|
||||||
previousHref={wizardTrendHref(actionSlug, municipalitySlug, undefined, entryAction)}
|
previousHref={wizardTrendHref(
|
||||||
|
actionSlug,
|
||||||
|
municipalitySlug,
|
||||||
|
undefined,
|
||||||
|
entryAction,
|
||||||
|
undefined,
|
||||||
|
returnPath,
|
||||||
|
)}
|
||||||
|
dismissHref={wizardChainEndHref(returnPath)}
|
||||||
municipalityLabel={municipalityName}
|
municipalityLabel={municipalityName}
|
||||||
skip={skip}
|
skip={skip}
|
||||||
trailingAction={skip ? <WizardTrendSkipTrailing skip={skip} /> : undefined}
|
trailingAction={skip ? <WizardTrendSkipTrailing skip={skip} /> : undefined}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ import type { CampaignWizardActionId } from '@/lib/campaignActionRoutes'
|
||||||
import { wizardActionHref } from '@/lib/campaignActionRoutes'
|
import { wizardActionHref } from '@/lib/campaignActionRoutes'
|
||||||
import { postCampaignJson } from '@/lib/campaignJsonRequest'
|
import { postCampaignJson } from '@/lib/campaignJsonRequest'
|
||||||
import { recordLastActedMunicipality } from '@/lib/campaignLastActedMunicipality'
|
import { recordLastActedMunicipality } from '@/lib/campaignLastActedMunicipality'
|
||||||
import { CAMPAIGN_HOME } from '@/lib/campaignPaths'
|
|
||||||
import {
|
import {
|
||||||
resolveWizardVotesSkip,
|
resolveWizardVotesSkip,
|
||||||
WIZARD_VOTES_FINAL_CTA_LABEL,
|
WIZARD_VOTES_FINAL_CTA_LABEL,
|
||||||
|
|
@ -28,7 +27,7 @@ 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 } from '@/lib/wizardActionChain'
|
import { resolveWizardChainEntry, wizardChainContinueHref, wizardChainEndHref } from '@/lib/wizardActionChain'
|
||||||
import {
|
import {
|
||||||
applyVoteShortcut,
|
applyVoteShortcut,
|
||||||
getWizardVoteViolation,
|
getWizardVoteViolation,
|
||||||
|
|
@ -45,6 +44,7 @@ type WizardExpectedVotesStepProps = {
|
||||||
municipalitySlug: string
|
municipalitySlug: string
|
||||||
initialExpectedVotes: VoteEstimateScenarioViewModel
|
initialExpectedVotes: VoteEstimateScenarioViewModel
|
||||||
entryAction?: CampaignWizardActionId
|
entryAction?: CampaignWizardActionId
|
||||||
|
returnPath?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const WizardExpectedVotesStep = ({
|
export const WizardExpectedVotesStep = ({
|
||||||
|
|
@ -54,6 +54,7 @@ export const WizardExpectedVotesStep = ({
|
||||||
municipalitySlug,
|
municipalitySlug,
|
||||||
initialExpectedVotes,
|
initialExpectedVotes,
|
||||||
entryAction,
|
entryAction,
|
||||||
|
returnPath,
|
||||||
}: WizardExpectedVotesStepProps) => {
|
}: WizardExpectedVotesStepProps) => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const [isPending, startTransition] = useTransition()
|
const [isPending, startTransition] = useTransition()
|
||||||
|
|
@ -61,7 +62,7 @@ export const WizardExpectedVotesStep = ({
|
||||||
const [focusedScenario, setFocusedScenario] = useState<VoteEstimateScenario>('central')
|
const [focusedScenario, setFocusedScenario] = useState<VoteEstimateScenario>('central')
|
||||||
const [violation, setViolation] = useState<WizardVoteViolation | null>(null)
|
const [violation, setViolation] = useState<WizardVoteViolation | null>(null)
|
||||||
const [saveError, setSaveError] = useState<string | null>(null)
|
const [saveError, setSaveError] = useState<string | null>(null)
|
||||||
const skip = resolveWizardVotesSkip(entryAction, municipalitySlug)
|
const skip = resolveWizardVotesSkip(entryAction, municipalitySlug, returnPath)
|
||||||
|
|
||||||
const clearViolationState = () => {
|
const clearViolationState = () => {
|
||||||
if (violation) setViolation(null)
|
if (violation) setViolation(null)
|
||||||
|
|
@ -80,7 +81,9 @@ export const WizardExpectedVotesStep = ({
|
||||||
|
|
||||||
const continueAfterVotes = () => {
|
const continueAfterVotes = () => {
|
||||||
const sessionEntry = resolveWizardChainEntry(entryAction, 'update-votes')
|
const sessionEntry = resolveWizardChainEntry(entryAction, 'update-votes')
|
||||||
router.replace(wizardChainContinueHref(sessionEntry, 'update-votes', municipalitySlug))
|
router.replace(
|
||||||
|
wizardChainContinueHref(sessionEntry, 'update-votes', municipalitySlug, returnPath),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleConfirm = () => {
|
const handleConfirm = () => {
|
||||||
|
|
@ -131,8 +134,8 @@ export const WizardExpectedVotesStep = ({
|
||||||
flowTitle={wizardFlowTitleForSlug(actionSlug)}
|
flowTitle={wizardFlowTitleForSlug(actionSlug)}
|
||||||
stepTitle={wizardNextStepTitle(actionSlug)}
|
stepTitle={wizardNextStepTitle(actionSlug)}
|
||||||
isEntryStep={false}
|
isEntryStep={false}
|
||||||
previousHref={wizardActionHref(actionSlug)}
|
previousHref={wizardActionHref(actionSlug, municipalitySlug, { returnPath })}
|
||||||
dismissHref={CAMPAIGN_HOME}
|
dismissHref={wizardChainEndHref(returnPath)}
|
||||||
municipalityLabel={municipalityName}
|
municipalityLabel={municipalityName}
|
||||||
skip={skip}
|
skip={skip}
|
||||||
trailingAction={trailingAction}
|
trailingAction={trailingAction}
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ type WizardSearchResultsState =
|
||||||
type WizardMunicipalitySearchStepProps = {
|
type WizardMunicipalitySearchStepProps = {
|
||||||
actionSlug: string
|
actionSlug: string
|
||||||
previousHref: string
|
previousHref: string
|
||||||
|
returnPath?: string
|
||||||
accessibleMunicipalities: AccessibleMunicipality[]
|
accessibleMunicipalities: AccessibleMunicipality[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -72,6 +73,7 @@ const buildSuggestSuccessState = (
|
||||||
export const WizardMunicipalitySearchStep = ({
|
export const WizardMunicipalitySearchStep = ({
|
||||||
actionSlug,
|
actionSlug,
|
||||||
previousHref,
|
previousHref,
|
||||||
|
returnPath,
|
||||||
accessibleMunicipalities,
|
accessibleMunicipalities,
|
||||||
}: WizardMunicipalitySearchStepProps) => {
|
}: WizardMunicipalitySearchStepProps) => {
|
||||||
const { query, setRaw, isDebouncing } = useHomeSearchQuery()
|
const { query, setRaw, isDebouncing } = useHomeSearchQuery()
|
||||||
|
|
@ -216,7 +218,7 @@ export const WizardMunicipalitySearchStep = ({
|
||||||
{displayRows.map(({ hit, continuityReason }) => (
|
{displayRows.map(({ hit, continuityReason }) => (
|
||||||
<li key={hit.slug}>
|
<li key={hit.slug}>
|
||||||
<HomeSearchHitRow
|
<HomeSearchHitRow
|
||||||
href={wizardActionHref(actionSlug, hit.slug)}
|
href={wizardActionHref(actionSlug, hit.slug, { returnPath })}
|
||||||
primary={hit.name}
|
primary={hit.name}
|
||||||
secondary={continuityReason ?? hit.region}
|
secondary={continuityReason ?? hit.region}
|
||||||
showPriority={hit.priority === 'alta'}
|
showPriority={hit.priority === 'alta'}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
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 { CAMPAIGN_HOME } from '@/lib/campaignPaths'
|
import { wizardChainEndHref } from '@/lib/wizardActionChain'
|
||||||
import {
|
import {
|
||||||
wizardFlowTitleForSlug,
|
wizardFlowTitleForSlug,
|
||||||
wizardNextStepPlaceholder,
|
wizardNextStepPlaceholder,
|
||||||
|
|
@ -10,18 +10,20 @@ import {
|
||||||
type WizardMunicipalitySelectedStubProps = {
|
type WizardMunicipalitySelectedStubProps = {
|
||||||
actionSlug: string
|
actionSlug: string
|
||||||
municipalityName: string
|
municipalityName: string
|
||||||
|
returnPath?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const WizardMunicipalitySelectedStub = ({
|
export const WizardMunicipalitySelectedStub = ({
|
||||||
actionSlug,
|
actionSlug,
|
||||||
municipalityName,
|
municipalityName,
|
||||||
|
returnPath,
|
||||||
}: WizardMunicipalitySelectedStubProps) => (
|
}: WizardMunicipalitySelectedStubProps) => (
|
||||||
<CampaignWizardShell
|
<CampaignWizardShell
|
||||||
flowTitle={wizardFlowTitleForSlug(actionSlug)}
|
flowTitle={wizardFlowTitleForSlug(actionSlug)}
|
||||||
stepTitle={wizardNextStepTitle(actionSlug)}
|
stepTitle={wizardNextStepTitle(actionSlug)}
|
||||||
isEntryStep={false}
|
isEntryStep={false}
|
||||||
previousHref={wizardActionHref(actionSlug)}
|
previousHref={wizardActionHref(actionSlug, undefined, { returnPath })}
|
||||||
dismissHref={CAMPAIGN_HOME}
|
dismissHref={wizardChainEndHref(returnPath)}
|
||||||
municipalityLabel={municipalityName}
|
municipalityLabel={municipalityName}
|
||||||
>
|
>
|
||||||
<p className="text-sm text-muted-foreground">{wizardNextStepPlaceholder(actionSlug)}</p>
|
<p className="text-sm text-muted-foreground">{wizardNextStepPlaceholder(actionSlug)}</p>
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ const listQuickActions = (): readonly CampaignQuickAction[] => [
|
||||||
const wizardActionsWithMunicipalityPrefill = (
|
const wizardActionsWithMunicipalityPrefill = (
|
||||||
role: CampaignRole,
|
role: CampaignRole,
|
||||||
municipalitySlug: string,
|
municipalitySlug: string,
|
||||||
|
returnPath: string,
|
||||||
): readonly CampaignQuickAction[] => {
|
): readonly CampaignQuickAction[] => {
|
||||||
const homeActions = homeActionsForRole(role).filter((action) =>
|
const homeActions = homeActionsForRole(role).filter((action) =>
|
||||||
WIZARD_ACTION_IDS.includes(action.id as CampaignWizardActionId),
|
WIZARD_ACTION_IDS.includes(action.id as CampaignWizardActionId),
|
||||||
|
|
@ -55,7 +56,9 @@ const wizardActionsWithMunicipalityPrefill = (
|
||||||
label: action.label,
|
label: action.label,
|
||||||
icon: action.icon,
|
icon: action.icon,
|
||||||
description: action.description,
|
description: action.description,
|
||||||
href: wizardActionHref(CAMPAIGN_WIZARD_ACTION_SLUGS[wizardId], municipalitySlug),
|
href: wizardActionHref(CAMPAIGN_WIZARD_ACTION_SLUGS[wizardId], municipalitySlug, {
|
||||||
|
returnPath,
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -93,6 +96,7 @@ export const resolveActivityQuickActions = (
|
||||||
surface: ActivityQuickActionSurface,
|
surface: ActivityQuickActionSurface,
|
||||||
role: CampaignRole,
|
role: CampaignRole,
|
||||||
context: CampaignQuickActionContext,
|
context: CampaignQuickActionContext,
|
||||||
|
pathname?: string,
|
||||||
): readonly CampaignQuickAction[] => {
|
): readonly CampaignQuickAction[] => {
|
||||||
if (!isStaffCampaignRole(role)) return []
|
if (!isStaffCampaignRole(role)) return []
|
||||||
|
|
||||||
|
|
@ -102,6 +106,7 @@ export const resolveActivityQuickActions = (
|
||||||
|
|
||||||
const activitySlug = context.activitySlug ?? surface.activitySlug
|
const activitySlug = context.activitySlug ?? surface.activitySlug
|
||||||
const municipalitySlug = context.municipalitySlug
|
const municipalitySlug = context.municipalitySlug
|
||||||
|
const returnPath = pathname ?? `/campanha/atividades/${activitySlug}`
|
||||||
|
|
||||||
const detailActions = detailVerticalQuickActions(activitySlug)
|
const detailActions = detailVerticalQuickActions(activitySlug)
|
||||||
|
|
||||||
|
|
@ -109,5 +114,8 @@ export const resolveActivityQuickActions = (
|
||||||
return detailActions
|
return detailActions
|
||||||
}
|
}
|
||||||
|
|
||||||
return [...wizardActionsWithMunicipalityPrefill(role, municipalitySlug), ...detailActions]
|
return [
|
||||||
|
...wizardActionsWithMunicipalityPrefill(role, municipalitySlug, returnPath),
|
||||||
|
...detailActions,
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -67,9 +67,50 @@ export const WIZARD_VOTE_TO_QUERY_KEY = 'voteTo' as const
|
||||||
|
|
||||||
export const WIZARD_LEADERSHIP_ID_QUERY_KEY = 'leadershipId' as const
|
export const WIZARD_LEADERSHIP_ID_QUERY_KEY = 'leadershipId' as const
|
||||||
|
|
||||||
|
export const WIZARD_RETURN_PATH_QUERY_KEY = 'from' as const
|
||||||
|
|
||||||
|
const WIZARD_RETURN_PATH_AUTH_PREFIXES = [
|
||||||
|
'/campanha/login',
|
||||||
|
'/campanha/convite',
|
||||||
|
'/campanha/redefinir-senha',
|
||||||
|
'/campanha/webauthn',
|
||||||
|
] as const
|
||||||
|
|
||||||
|
/** Allowlisted internal return paths for wizard dismiss / chain end (B110). */
|
||||||
|
export const isWizardReturnPath = (pathname: string): boolean => {
|
||||||
|
if (!pathname.startsWith('/campanha')) return false
|
||||||
|
if (pathname.startsWith('/campanha/acoes')) return false
|
||||||
|
for (const prefix of WIZARD_RETURN_PATH_AUTH_PREFIXES) {
|
||||||
|
if (pathname === prefix || pathname.startsWith(`${prefix}/`)) return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
if (trimmed.includes('://') || trimmed.startsWith('//')) return undefined
|
||||||
|
const path = trimmed.startsWith('/') ? trimmed : `/${trimmed}`
|
||||||
|
if (path.includes('?') || path.includes('#')) return undefined
|
||||||
|
return isWizardReturnPath(path) ? path : undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
export const appendWizardReturnPath = (href: string, returnPath?: string): string => {
|
||||||
|
if (!returnPath || !isWizardReturnPath(returnPath)) return href
|
||||||
|
const queryIndex = href.indexOf('?')
|
||||||
|
const base = queryIndex === -1 ? href : href.slice(0, queryIndex)
|
||||||
|
const params = new URLSearchParams(queryIndex === -1 ? '' : href.slice(queryIndex + 1))
|
||||||
|
params.set(WIZARD_RETURN_PATH_QUERY_KEY, returnPath)
|
||||||
|
return `${base}?${params.toString()}`
|
||||||
|
}
|
||||||
|
|
||||||
export type WizardActionHrefOptions = {
|
export type WizardActionHrefOptions = {
|
||||||
entryAction?: CampaignWizardActionId
|
entryAction?: CampaignWizardActionId
|
||||||
leadershipId?: number
|
leadershipId?: number
|
||||||
|
returnPath?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const wizardActionHref = (
|
export const wizardActionHref = (
|
||||||
|
|
@ -79,7 +120,7 @@ export const wizardActionHref = (
|
||||||
): string => {
|
): string => {
|
||||||
const base = `${CAMPAIGN_ACTIONS_HOME}/${actionSlug}`
|
const base = `${CAMPAIGN_ACTIONS_HOME}/${actionSlug}`
|
||||||
if (!municipalitySlug && !options?.leadershipId && !options?.entryAction) {
|
if (!municipalitySlug && !options?.leadershipId && !options?.entryAction) {
|
||||||
return base
|
return appendWizardReturnPath(base, options?.returnPath)
|
||||||
}
|
}
|
||||||
const params = new URLSearchParams()
|
const params = new URLSearchParams()
|
||||||
if (municipalitySlug) {
|
if (municipalitySlug) {
|
||||||
|
|
@ -91,7 +132,8 @@ export const wizardActionHref = (
|
||||||
if (options?.leadershipId !== undefined) {
|
if (options?.leadershipId !== undefined) {
|
||||||
params.set(WIZARD_LEADERSHIP_ID_QUERY_KEY, String(options.leadershipId))
|
params.set(WIZARD_LEADERSHIP_ID_QUERY_KEY, String(options.leadershipId))
|
||||||
}
|
}
|
||||||
return `${base}?${params.toString()}`
|
const href = params.size > 0 ? `${base}?${params.toString()}` : base
|
||||||
|
return appendWizardReturnPath(href, options?.returnPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const parseWizardMunicipioParam = (
|
export const parseWizardMunicipioParam = (
|
||||||
|
|
@ -132,10 +174,11 @@ export const wizardSignalHref = (
|
||||||
municipalitySlug?: string,
|
municipalitySlug?: string,
|
||||||
signalType?: MunicipalitySignalType,
|
signalType?: MunicipalitySignalType,
|
||||||
entryAction?: CampaignWizardActionId,
|
entryAction?: CampaignWizardActionId,
|
||||||
|
returnPath?: string,
|
||||||
): string => {
|
): string => {
|
||||||
const base = `${CAMPAIGN_ACTIONS_HOME}/${actionSlug}`
|
const base = `${CAMPAIGN_ACTIONS_HOME}/${actionSlug}`
|
||||||
if (!municipalitySlug) {
|
if (!municipalitySlug) {
|
||||||
return base
|
return appendWizardReturnPath(base, returnPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
const params = new URLSearchParams({ [WIZARD_MUNICIPIO_QUERY_KEY]: municipalitySlug })
|
const params = new URLSearchParams({ [WIZARD_MUNICIPIO_QUERY_KEY]: municipalitySlug })
|
||||||
|
|
@ -145,7 +188,7 @@ export const wizardSignalHref = (
|
||||||
if (entryAction) {
|
if (entryAction) {
|
||||||
params.set(WIZARD_ENTRY_ACTION_QUERY_KEY, entryAction)
|
params.set(WIZARD_ENTRY_ACTION_QUERY_KEY, entryAction)
|
||||||
}
|
}
|
||||||
return `${base}?${params.toString()}`
|
return appendWizardReturnPath(`${base}?${params.toString()}`, returnPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const resolveWizardSignalTypeParam = (
|
export const resolveWizardSignalTypeParam = (
|
||||||
|
|
@ -171,10 +214,11 @@ export const wizardTrendHref = (
|
||||||
trendStatus?: PoliticalTrendStatusValue,
|
trendStatus?: PoliticalTrendStatusValue,
|
||||||
entryAction?: CampaignWizardActionId,
|
entryAction?: CampaignWizardActionId,
|
||||||
extraParams?: Record<string, string>,
|
extraParams?: Record<string, string>,
|
||||||
|
returnPath?: string,
|
||||||
): string => {
|
): string => {
|
||||||
const base = `${CAMPAIGN_ACTIONS_HOME}/${actionSlug}`
|
const base = `${CAMPAIGN_ACTIONS_HOME}/${actionSlug}`
|
||||||
if (!municipalitySlug) {
|
if (!municipalitySlug) {
|
||||||
return base
|
return appendWizardReturnPath(base, returnPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
const params = new URLSearchParams({ [WIZARD_MUNICIPIO_QUERY_KEY]: municipalitySlug })
|
const params = new URLSearchParams({ [WIZARD_MUNICIPIO_QUERY_KEY]: municipalitySlug })
|
||||||
|
|
@ -189,7 +233,7 @@ export const wizardTrendHref = (
|
||||||
if (value) params.set(key, value)
|
if (value) params.set(key, value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return `${base}?${params.toString()}`
|
return appendWizardReturnPath(`${base}?${params.toString()}`, returnPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const resolveWizardTrendStatusParam = (
|
export const resolveWizardTrendStatusParam = (
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import {
|
||||||
import {
|
import {
|
||||||
CAMPAIGN_WIZARD_ACTION_SLUGS,
|
CAMPAIGN_WIZARD_ACTION_SLUGS,
|
||||||
campaignActionEntryHref,
|
campaignActionEntryHref,
|
||||||
|
appendWizardReturnPath,
|
||||||
isCampaignWizardActionId,
|
isCampaignWizardActionId,
|
||||||
wizardActionHref,
|
wizardActionHref,
|
||||||
type CampaignWizardActionId,
|
type CampaignWizardActionId,
|
||||||
|
|
@ -132,6 +133,7 @@ export const UNCOVERED_MUNICIPALITIES_LIST_HREF =
|
||||||
export type HomeActionButtonPropsOptions = {
|
export type HomeActionButtonPropsOptions = {
|
||||||
uncoveredMunicipalitiesHref?: string
|
uncoveredMunicipalitiesHref?: string
|
||||||
municipalitySlug?: string
|
municipalitySlug?: string
|
||||||
|
returnPath?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Staff Início catalog with hrefs — shared by quick-action registries (B80+). */
|
/** Staff Início catalog with hrefs — shared by quick-action registries (B80+). */
|
||||||
|
|
@ -139,14 +141,20 @@ const staffHomeQuickActionsByRole = new Map<CampaignRole, readonly ResolvedCampa
|
||||||
|
|
||||||
export const resolveStaffHomeQuickActions = (
|
export const resolveStaffHomeQuickActions = (
|
||||||
role: CampaignRole,
|
role: CampaignRole,
|
||||||
|
returnPath?: string,
|
||||||
): readonly ResolvedCampaignHomeAction[] => {
|
): readonly ResolvedCampaignHomeAction[] => {
|
||||||
if (!isStaffCampaignRole(role)) return []
|
if (!isStaffCampaignRole(role)) return []
|
||||||
const cached = staffHomeQuickActionsByRole.get(role)
|
if (!returnPath) {
|
||||||
if (cached) return cached
|
const cached = staffHomeQuickActionsByRole.get(role)
|
||||||
|
if (cached) return cached
|
||||||
|
}
|
||||||
const actions = toHomeActionButtonProps(homeActionsForRole(role), {
|
const actions = toHomeActionButtonProps(homeActionsForRole(role), {
|
||||||
uncoveredMunicipalitiesHref: UNCOVERED_MUNICIPALITIES_LIST_HREF,
|
uncoveredMunicipalitiesHref: UNCOVERED_MUNICIPALITIES_LIST_HREF,
|
||||||
|
returnPath,
|
||||||
})
|
})
|
||||||
staffHomeQuickActionsByRole.set(role, actions)
|
if (!returnPath) {
|
||||||
|
staffHomeQuickActionsByRole.set(role, actions)
|
||||||
|
}
|
||||||
return actions
|
return actions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -164,9 +172,13 @@ export const toHomeActionButtonProps = (
|
||||||
} else if (action.id === 'uncovered-municipalities') {
|
} else if (action.id === 'uncovered-municipalities') {
|
||||||
href = resolved.uncoveredMunicipalitiesHref
|
href = resolved.uncoveredMunicipalitiesHref
|
||||||
} else if (isCampaignWizardActionId(action.id)) {
|
} else if (isCampaignWizardActionId(action.id)) {
|
||||||
href = resolved.municipalitySlug
|
if (resolved.municipalitySlug) {
|
||||||
? wizardActionHref(CAMPAIGN_WIZARD_ACTION_SLUGS[action.id], resolved.municipalitySlug)
|
href = wizardActionHref(CAMPAIGN_WIZARD_ACTION_SLUGS[action.id], resolved.municipalitySlug, {
|
||||||
: campaignActionEntryHref(action.id)
|
returnPath: resolved.returnPath,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
href = appendWizardReturnPath(campaignActionEntryHref(action.id), resolved.returnPath)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
...action,
|
...action,
|
||||||
|
|
|
||||||
|
|
@ -22,18 +22,20 @@ export const parseMunicipalityDetailSlug = (pathname: string): string | undefine
|
||||||
|
|
||||||
export const resolveMunicipalityListQuickActions = (
|
export const resolveMunicipalityListQuickActions = (
|
||||||
role: CampaignRole,
|
role: CampaignRole,
|
||||||
): readonly ResolvedCampaignHomeAction[] => resolveStaffHomeQuickActions(role)
|
returnPath?: string,
|
||||||
|
): readonly ResolvedCampaignHomeAction[] => resolveStaffHomeQuickActions(role, returnPath)
|
||||||
|
|
||||||
export const resolveMunicipalityDetailQuickActions = (
|
export const resolveMunicipalityDetailQuickActions = (
|
||||||
role: CampaignRole,
|
role: CampaignRole,
|
||||||
municipalitySlug: string,
|
municipalitySlug: string,
|
||||||
|
returnPath?: string,
|
||||||
): readonly ResolvedCampaignHomeAction[] => {
|
): readonly ResolvedCampaignHomeAction[] => {
|
||||||
if (!isStaffCampaignRole(role)) return []
|
if (!isStaffCampaignRole(role)) return []
|
||||||
|
|
||||||
const actions = homeActionsForRole(role).filter(
|
const actions = homeActionsForRole(role).filter(
|
||||||
(action) => action.id !== 'uncovered-municipalities',
|
(action) => action.id !== 'uncovered-municipalities',
|
||||||
)
|
)
|
||||||
return toHomeActionButtonProps(actions, { municipalitySlug })
|
return toHomeActionButtonProps(actions, { municipalitySlug, returnPath })
|
||||||
}
|
}
|
||||||
|
|
||||||
export const resolveMunicipalityQuickActionsForPath = (
|
export const resolveMunicipalityQuickActionsForPath = (
|
||||||
|
|
@ -42,12 +44,12 @@ export const resolveMunicipalityQuickActionsForPath = (
|
||||||
context: CampaignQuickActionContext,
|
context: CampaignQuickActionContext,
|
||||||
): readonly ResolvedCampaignHomeAction[] => {
|
): readonly ResolvedCampaignHomeAction[] => {
|
||||||
if (isMunicipalitiesListPath(pathname)) {
|
if (isMunicipalitiesListPath(pathname)) {
|
||||||
return resolveMunicipalityListQuickActions(role)
|
return resolveMunicipalityListQuickActions(role, pathname)
|
||||||
}
|
}
|
||||||
|
|
||||||
const slug = context.municipalitySlug ?? parseMunicipalityDetailSlug(pathname)
|
const slug = context.municipalitySlug ?? parseMunicipalityDetailSlug(pathname)
|
||||||
if (slug) {
|
if (slug) {
|
||||||
return resolveMunicipalityDetailQuickActions(role, slug)
|
return resolveMunicipalityDetailQuickActions(role, slug, pathname)
|
||||||
}
|
}
|
||||||
|
|
||||||
return []
|
return []
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ export const resolveDemandsListQuickActions = (
|
||||||
export const resolveDemandDetailQuickActions = (
|
export const resolveDemandDetailQuickActions = (
|
||||||
role: CampaignRole,
|
role: CampaignRole,
|
||||||
context: CampaignQuickActionContext,
|
context: CampaignQuickActionContext,
|
||||||
|
returnPath: string,
|
||||||
): readonly CampaignQuickAction[] => {
|
): readonly CampaignQuickAction[] => {
|
||||||
if (!isStaffCampaignRole(role)) {
|
if (!isStaffCampaignRole(role)) {
|
||||||
return []
|
return []
|
||||||
|
|
@ -93,7 +94,9 @@ export const resolveDemandDetailQuickActions = (
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
...action,
|
...action,
|
||||||
href: wizardActionHref(CAMPAIGN_WIZARD_ACTION_SLUGS[id], municipalitySlug),
|
href: wizardActionHref(CAMPAIGN_WIZARD_ACTION_SLUGS[id], municipalitySlug, {
|
||||||
|
returnPath,
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ export const resolveDobradinhasQuickActions = (
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
const staffActions = resolveStaffHomeQuickActions(role)
|
const staffActions = resolveStaffHomeQuickActions(role, pathname)
|
||||||
|
|
||||||
if (isStateDeputyListPath(pathname)) {
|
if (isStateDeputyListPath(pathname)) {
|
||||||
return [newStateDeputyAction(), ...staffActions]
|
return [newStateDeputyAction(), ...staffActions]
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import {
|
import {
|
||||||
CAMPAIGN_WIZARD_ACTION_SLUGS,
|
CAMPAIGN_WIZARD_ACTION_SLUGS,
|
||||||
|
appendWizardReturnPath,
|
||||||
campaignActionEntryHref,
|
campaignActionEntryHref,
|
||||||
wizardActionHref,
|
wizardActionHref,
|
||||||
type CampaignWizardActionId,
|
type CampaignWizardActionId,
|
||||||
|
|
@ -34,40 +35,46 @@ const parseLeadershipDetailId = (pathname: string): number | undefined => {
|
||||||
|
|
||||||
const resolveLeadershipListActions = (
|
const resolveLeadershipListActions = (
|
||||||
role: CampaignRole,
|
role: CampaignRole,
|
||||||
|
returnPath: string,
|
||||||
): readonly ResolvedCampaignHomeAction[] => {
|
): readonly ResolvedCampaignHomeAction[] => {
|
||||||
const actions = homeActionsForRole(role).filter((action) => action.id === 'update-leadership')
|
const actions = homeActionsForRole(role).filter((action) => action.id === 'update-leadership')
|
||||||
return actions.map((action) => ({
|
return actions.map((action) => ({
|
||||||
...action,
|
...action,
|
||||||
href: campaignActionEntryHref('update-leadership'),
|
href: appendWizardReturnPath(campaignActionEntryHref('update-leadership'), returnPath),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
const hrefForLeadershipDetailAction = (
|
const hrefForLeadershipDetailAction = (
|
||||||
action: CampaignHomeAction,
|
action: CampaignHomeAction,
|
||||||
context: CampaignQuickActionContext,
|
context: CampaignQuickActionContext,
|
||||||
|
returnPath: string,
|
||||||
): string => {
|
): string => {
|
||||||
const wizardSlug = CAMPAIGN_WIZARD_ACTION_SLUGS[action.id as CampaignWizardActionId]
|
const wizardSlug = CAMPAIGN_WIZARD_ACTION_SLUGS[action.id as CampaignWizardActionId]
|
||||||
const { municipalitySlug, leadershipId } = context
|
const { municipalitySlug, leadershipId } = context
|
||||||
|
|
||||||
if (action.id === 'update-leadership') {
|
if (action.id === 'update-leadership') {
|
||||||
if (municipalitySlug && leadershipId !== undefined) {
|
if (municipalitySlug && leadershipId !== undefined) {
|
||||||
return wizardActionHref(wizardSlug, municipalitySlug, { leadershipId })
|
return wizardActionHref(wizardSlug, municipalitySlug, { leadershipId, returnPath })
|
||||||
}
|
}
|
||||||
if (leadershipId !== undefined) {
|
if (leadershipId !== undefined) {
|
||||||
return `${LEADERSHIP_LIST_PATH}/${leadershipId}`
|
return `${LEADERSHIP_LIST_PATH}/${leadershipId}`
|
||||||
}
|
}
|
||||||
return campaignActionEntryHref('update-leadership')
|
return appendWizardReturnPath(campaignActionEntryHref('update-leadership'), returnPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (municipalitySlug) {
|
if (municipalitySlug) {
|
||||||
return wizardActionHref(wizardSlug, municipalitySlug)
|
return wizardActionHref(wizardSlug, municipalitySlug, { returnPath })
|
||||||
}
|
}
|
||||||
return campaignActionEntryHref(action.id as CampaignWizardActionId)
|
return appendWizardReturnPath(
|
||||||
|
campaignActionEntryHref(action.id as CampaignWizardActionId),
|
||||||
|
returnPath,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const resolveLeadershipDetailActions = (
|
const resolveLeadershipDetailActions = (
|
||||||
role: CampaignRole,
|
role: CampaignRole,
|
||||||
context: CampaignQuickActionContext,
|
context: CampaignQuickActionContext,
|
||||||
|
returnPath: string,
|
||||||
): readonly ResolvedCampaignHomeAction[] => {
|
): readonly ResolvedCampaignHomeAction[] => {
|
||||||
const actions = homeActionsForRole(role).filter((action) =>
|
const actions = homeActionsForRole(role).filter((action) =>
|
||||||
LEADERSHIP_DETAIL_WIZARD_IDS.includes(action.id as CampaignWizardActionId),
|
LEADERSHIP_DETAIL_WIZARD_IDS.includes(action.id as CampaignWizardActionId),
|
||||||
|
|
@ -75,7 +82,7 @@ const resolveLeadershipDetailActions = (
|
||||||
|
|
||||||
return actions.map((action) => ({
|
return actions.map((action) => ({
|
||||||
...action,
|
...action,
|
||||||
href: hrefForLeadershipDetailAction(action, context),
|
href: hrefForLeadershipDetailAction(action, context, returnPath),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -87,7 +94,7 @@ export const resolveLeadershipQuickActions = (
|
||||||
if (!isStaffCampaignRole(role)) return null
|
if (!isStaffCampaignRole(role)) return null
|
||||||
|
|
||||||
if (isLeadershipListPath(pathname)) {
|
if (isLeadershipListPath(pathname)) {
|
||||||
return resolveLeadershipListActions(role)
|
return resolveLeadershipListActions(role, pathname)
|
||||||
}
|
}
|
||||||
|
|
||||||
const leadershipId = parseLeadershipDetailId(pathname)
|
const leadershipId = parseLeadershipDetailId(pathname)
|
||||||
|
|
@ -95,7 +102,7 @@ export const resolveLeadershipQuickActions = (
|
||||||
return resolveLeadershipDetailActions(role, {
|
return resolveLeadershipDetailActions(role, {
|
||||||
...context,
|
...context,
|
||||||
leadershipId: context.leadershipId ?? leadershipId,
|
leadershipId: context.leadershipId ?? leadershipId,
|
||||||
})
|
}, pathname)
|
||||||
}
|
}
|
||||||
|
|
||||||
return null
|
return null
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ export const resolveQuickActionsForPath = (
|
||||||
|
|
||||||
const activitySurface = parseActivityQuickActionSurface(pathname)
|
const activitySurface = parseActivityQuickActionSurface(pathname)
|
||||||
if (activitySurface) {
|
if (activitySurface) {
|
||||||
return resolveActivityQuickActions(activitySurface, role, context)
|
return resolveActivityQuickActions(activitySurface, role, context, pathname)
|
||||||
}
|
}
|
||||||
|
|
||||||
const organizationSurface = parseOrganizationQuickActionSurface(pathname)
|
const organizationSurface = parseOrganizationQuickActionSurface(pathname)
|
||||||
|
|
@ -60,7 +60,7 @@ export const resolveQuickActionsForPath = (
|
||||||
return resolveDemandsListQuickActions(role)
|
return resolveDemandsListQuickActions(role)
|
||||||
}
|
}
|
||||||
if (isDemandDetailPath(pathname)) {
|
if (isDemandDetailPath(pathname)) {
|
||||||
return resolveDemandDetailQuickActions(role, context)
|
return resolveDemandDetailQuickActions(role, context, pathname)
|
||||||
}
|
}
|
||||||
|
|
||||||
const municipalityActions = resolveMunicipalityQuickActionsForPath(pathname, role, context)
|
const municipalityActions = resolveMunicipalityQuickActionsForPath(pathname, role, context)
|
||||||
|
|
@ -79,7 +79,7 @@ export const resolveQuickActionsForPath = (
|
||||||
if (advisorActions.length > 0) return advisorActions
|
if (advisorActions.length > 0) return advisorActions
|
||||||
|
|
||||||
if (isTerritoriesListPath(pathname)) {
|
if (isTerritoriesListPath(pathname)) {
|
||||||
return resolveStaffHomeQuickActions(role)
|
return resolveStaffHomeQuickActions(role, pathname)
|
||||||
}
|
}
|
||||||
|
|
||||||
const referenceActions = resolveReferenceQuickActionsForPath(pathname, role, context)
|
const referenceActions = resolveReferenceQuickActionsForPath(pathname, role, context)
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ const shouldShowWizardVotesSkip = (entryAction: CampaignWizardActionId | undefin
|
||||||
export const resolveWizardVotesSkip = (
|
export const resolveWizardVotesSkip = (
|
||||||
entryAction: CampaignWizardActionId | undefined,
|
entryAction: CampaignWizardActionId | undefined,
|
||||||
municipalitySlug: string,
|
municipalitySlug: string,
|
||||||
|
returnPath?: string,
|
||||||
): WizardVotesSkipAction | undefined =>
|
): WizardVotesSkipAction | undefined =>
|
||||||
shouldShowWizardVotesSkip(entryAction)
|
shouldShowWizardVotesSkip(entryAction)
|
||||||
? {
|
? {
|
||||||
|
|
@ -57,6 +58,7 @@ export const resolveWizardVotesSkip = (
|
||||||
resolveWizardChainEntry(entryAction, 'update-votes'),
|
resolveWizardChainEntry(entryAction, 'update-votes'),
|
||||||
'update-votes',
|
'update-votes',
|
||||||
municipalitySlug,
|
municipalitySlug,
|
||||||
|
returnPath,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
: undefined
|
: undefined
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ export const shouldShowWizardTrendSkip = (
|
||||||
export const resolveWizardTrendSkip = (
|
export const resolveWizardTrendSkip = (
|
||||||
entryAction: CampaignWizardActionId | undefined,
|
entryAction: CampaignWizardActionId | undefined,
|
||||||
municipalitySlug: string,
|
municipalitySlug: string,
|
||||||
|
returnPath?: string,
|
||||||
): WizardTrendSkipAction | undefined =>
|
): WizardTrendSkipAction | undefined =>
|
||||||
shouldShowWizardTrendSkip(entryAction)
|
shouldShowWizardTrendSkip(entryAction)
|
||||||
? {
|
? {
|
||||||
|
|
@ -77,6 +78,7 @@ export const resolveWizardTrendSkip = (
|
||||||
resolveWizardChainEntry(entryAction, 'change-trend'),
|
resolveWizardChainEntry(entryAction, 'change-trend'),
|
||||||
'change-trend',
|
'change-trend',
|
||||||
municipalitySlug,
|
municipalitySlug,
|
||||||
|
returnPath,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
: undefined
|
: undefined
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
import {
|
import {
|
||||||
CAMPAIGN_WIZARD_ACTION_SLUGS,
|
CAMPAIGN_WIZARD_ACTION_SLUGS,
|
||||||
type CampaignWizardActionId,
|
type CampaignWizardActionId,
|
||||||
|
isWizardReturnPath,
|
||||||
wizardActionHref,
|
wizardActionHref,
|
||||||
wizardSignalHref,
|
wizardSignalHref,
|
||||||
wizardTrendHref,
|
wizardTrendHref,
|
||||||
|
|
@ -54,16 +55,17 @@ const wizardHrefForChainStep = (
|
||||||
action: WizardChainActionId,
|
action: WizardChainActionId,
|
||||||
municipalitySlug: string,
|
municipalitySlug: string,
|
||||||
entryAction: WizardChainActionId,
|
entryAction: WizardChainActionId,
|
||||||
|
returnPath?: string,
|
||||||
): string => {
|
): string => {
|
||||||
const actionSlug = CAMPAIGN_WIZARD_ACTION_SLUGS[action]
|
const actionSlug = CAMPAIGN_WIZARD_ACTION_SLUGS[action]
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case 'update-votes':
|
case 'update-votes':
|
||||||
case 'update-leadership':
|
case 'update-leadership':
|
||||||
return wizardActionHref(actionSlug, municipalitySlug, { entryAction })
|
return wizardActionHref(actionSlug, municipalitySlug, { entryAction, returnPath })
|
||||||
case 'register-signal':
|
case 'register-signal':
|
||||||
return wizardSignalHref(actionSlug, municipalitySlug, undefined, entryAction)
|
return wizardSignalHref(actionSlug, municipalitySlug, undefined, entryAction, returnPath)
|
||||||
case 'change-trend':
|
case 'change-trend':
|
||||||
return wizardTrendHref(actionSlug, municipalitySlug, undefined, entryAction)
|
return wizardTrendHref(actionSlug, municipalitySlug, undefined, entryAction, undefined, returnPath)
|
||||||
default: {
|
default: {
|
||||||
const exhaustive: never = action
|
const exhaustive: never = action
|
||||||
return exhaustive
|
return exhaustive
|
||||||
|
|
@ -71,23 +73,28 @@ const wizardHrefForChainStep = (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Chain end or dismiss target: allowlisted `from`, else Início (B110). */
|
||||||
|
export const wizardChainEndHref = (returnPath?: string): string =>
|
||||||
|
returnPath && isWizardReturnPath(returnPath) ? returnPath : CAMPAIGN_HOME
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Href for the next chained wizard after completing/skipping `completedAction`,
|
* Href for the next chained wizard after completing/skipping `completedAction`,
|
||||||
* or Início when the queue is empty / entry is not chainable.
|
* or the return path (default Início) when the queue is empty / entry is not chainable.
|
||||||
*/
|
*/
|
||||||
export const wizardChainContinueHref = (
|
export const wizardChainContinueHref = (
|
||||||
entryAction: CampaignWizardActionId,
|
entryAction: CampaignWizardActionId,
|
||||||
completedAction: WizardChainActionId,
|
completedAction: WizardChainActionId,
|
||||||
municipalitySlug: string,
|
municipalitySlug: string,
|
||||||
|
returnPath?: string,
|
||||||
): string => {
|
): string => {
|
||||||
if (!isWizardChainActionId(entryAction)) {
|
if (!isWizardChainActionId(entryAction)) {
|
||||||
return CAMPAIGN_HOME
|
return wizardChainEndHref(returnPath)
|
||||||
}
|
}
|
||||||
const next = nextWizardChainStep(entryAction, completedAction)
|
const next = nextWizardChainStep(entryAction, completedAction)
|
||||||
if (!next) {
|
if (!next) {
|
||||||
return CAMPAIGN_HOME
|
return wizardChainEndHref(returnPath)
|
||||||
}
|
}
|
||||||
return wizardHrefForChainStep(next, municipalitySlug, entryAction)
|
return wizardHrefForChainStep(next, municipalitySlug, entryAction, returnPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Session owner for navigation: explicit `entry` query, else the current principal. */
|
/** Session owner for navigation: explicit `entry` query, else the current principal. */
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ export const showLeadershipWizardSkip = (entryAction?: CampaignWizardActionId):
|
||||||
export const resolveWizardLeadershipSkip = (
|
export const resolveWizardLeadershipSkip = (
|
||||||
entryAction: CampaignWizardActionId | undefined,
|
entryAction: CampaignWizardActionId | undefined,
|
||||||
municipalitySlug: string,
|
municipalitySlug: string,
|
||||||
|
returnPath?: string,
|
||||||
): WizardLeadershipSkipAction | undefined =>
|
): WizardLeadershipSkipAction | undefined =>
|
||||||
showLeadershipWizardSkip(entryAction)
|
showLeadershipWizardSkip(entryAction)
|
||||||
? {
|
? {
|
||||||
|
|
@ -35,6 +36,7 @@ export const resolveWizardLeadershipSkip = (
|
||||||
resolveWizardChainEntry(entryAction, 'update-leadership'),
|
resolveWizardChainEntry(entryAction, 'update-leadership'),
|
||||||
'update-leadership',
|
'update-leadership',
|
||||||
municipalitySlug,
|
municipalitySlug,
|
||||||
|
returnPath,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
: undefined
|
: undefined
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ export const shouldShowWizardSignalSkip = (
|
||||||
export const resolveWizardSignalSkip = (
|
export const resolveWizardSignalSkip = (
|
||||||
entryAction: CampaignWizardActionId | undefined,
|
entryAction: CampaignWizardActionId | undefined,
|
||||||
municipalitySlug: string,
|
municipalitySlug: string,
|
||||||
|
returnPath?: string,
|
||||||
): WizardSignalSkipAction | undefined =>
|
): WizardSignalSkipAction | undefined =>
|
||||||
shouldShowWizardSignalSkip(entryAction)
|
shouldShowWizardSignalSkip(entryAction)
|
||||||
? {
|
? {
|
||||||
|
|
@ -30,6 +31,7 @@ export const resolveWizardSignalSkip = (
|
||||||
resolveWizardChainEntry(entryAction, 'register-signal'),
|
resolveWizardChainEntry(entryAction, 'register-signal'),
|
||||||
'register-signal',
|
'register-signal',
|
||||||
municipalitySlug,
|
municipalitySlug,
|
||||||
|
returnPath,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
: undefined
|
: undefined
|
||||||
|
|
|
||||||
|
|
@ -218,7 +218,7 @@ describe('campaignQuickActionDobradinhas (B83)', () => {
|
||||||
expect(actions.map((action) => action.id)).toEqual(['new-state-deputy', ...staffActionIds])
|
expect(actions.map((action) => action.id)).toEqual(['new-state-deputy', ...staffActionIds])
|
||||||
expect(actions[0]?.href).toBe('/campanha/dobradinhas/nova')
|
expect(actions[0]?.href).toBe('/campanha/dobradinhas/nova')
|
||||||
expect(actions.find((action) => action.id === 'update-votes')?.href).toBe(
|
expect(actions.find((action) => action.id === 'update-votes')?.href).toBe(
|
||||||
'/campanha/acoes/atualizar-votos',
|
'/campanha/acoes/atualizar-votos?from=%2Fcampanha%2Fdobradinhas',
|
||||||
)
|
)
|
||||||
expect(actions.find((action) => action.id === 'uncovered-municipalities')?.href).toBe(
|
expect(actions.find((action) => action.id === 'uncovered-municipalities')?.href).toBe(
|
||||||
UNCOVERED_MUNICIPALITIES_LIST_HREF,
|
UNCOVERED_MUNICIPALITIES_LIST_HREF,
|
||||||
|
|
@ -279,7 +279,7 @@ describe('campaignQuickActionRegistry', () => {
|
||||||
})
|
})
|
||||||
expect(detail).toHaveLength(5)
|
expect(detail).toHaveLength(5)
|
||||||
expect(detail.find((action) => action.id === 'update-votes')?.href).toBe(
|
expect(detail.find((action) => action.id === 'update-votes')?.href).toBe(
|
||||||
'/campanha/acoes/atualizar-votos?municipio=foo',
|
'/campanha/acoes/atualizar-votos?municipio=foo&from=%2Fcampanha%2Fmunicipios%2Ffoo',
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -303,7 +303,7 @@ describe('campaignQuickActionRegistry', () => {
|
||||||
)
|
)
|
||||||
const registerSignal = actions.find((action) => action.id === 'register-signal')
|
const registerSignal = actions.find((action) => action.id === 'register-signal')
|
||||||
expect(registerSignal?.href).toBe(
|
expect(registerSignal?.href).toBe(
|
||||||
`/campanha/acoes/${CAMPAIGN_WIZARD_ACTION_SLUGS['register-signal']}?municipio=salvador-ze-01`,
|
`/campanha/acoes/${CAMPAIGN_WIZARD_ACTION_SLUGS['register-signal']}?municipio=salvador-ze-01&from=%2Fcampanha%2Fatividades%2Fevento-zona-1`,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -311,7 +311,7 @@ describe('campaignQuickActionRegistry', () => {
|
||||||
const actions = resolveQuickActionsForPath('/campanha/territorios', 'coordinator', {})
|
const actions = resolveQuickActionsForPath('/campanha/territorios', 'coordinator', {})
|
||||||
expect(actions.map((action) => action.id)).toEqual(staffActionIds)
|
expect(actions.map((action) => action.id)).toEqual(staffActionIds)
|
||||||
expect(actions.find((action) => action.id === 'update-votes')?.href).toBe(
|
expect(actions.find((action) => action.id === 'update-votes')?.href).toBe(
|
||||||
'/campanha/acoes/atualizar-votos',
|
'/campanha/acoes/atualizar-votos?from=%2Fcampanha%2Fterritorios',
|
||||||
)
|
)
|
||||||
expect(actions.find((action) => action.id === 'uncovered-municipalities')?.href).toBe(
|
expect(actions.find((action) => action.id === 'uncovered-municipalities')?.href).toBe(
|
||||||
UNCOVERED_MUNICIPALITIES_LIST_HREF,
|
UNCOVERED_MUNICIPALITIES_LIST_HREF,
|
||||||
|
|
@ -346,7 +346,7 @@ describe('campaignQuickActionRegistry', () => {
|
||||||
'register-demand',
|
'register-demand',
|
||||||
])
|
])
|
||||||
expect(actions.find((action) => action.id === 'update-votes')?.href).toBe(
|
expect(actions.find((action) => action.id === 'update-votes')?.href).toBe(
|
||||||
'/campanha/acoes/atualizar-votos?municipio=cairu',
|
'/campanha/acoes/atualizar-votos?municipio=cairu&from=%2Fcampanha%2Fdemandas%2Fpedido-cairu',
|
||||||
)
|
)
|
||||||
expect(actions.find((action) => action.id === 'register-demand')?.href).toBe(
|
expect(actions.find((action) => action.id === 'register-demand')?.href).toBe(
|
||||||
demandCreateHref(42),
|
demandCreateHref(42),
|
||||||
|
|
@ -389,7 +389,11 @@ describe('campaignQuickActionDemands resolvers', () => {
|
||||||
it('returns empty catalog for leader lockdown', () => {
|
it('returns empty catalog for leader lockdown', () => {
|
||||||
expect(resolveDemandsListQuickActions('leader')).toEqual([])
|
expect(resolveDemandsListQuickActions('leader')).toEqual([])
|
||||||
expect(
|
expect(
|
||||||
resolveDemandDetailQuickActions('leader', { municipalitySlug: 'cairu', municipalityId: 1 }),
|
resolveDemandDetailQuickActions(
|
||||||
|
'leader',
|
||||||
|
{ municipalitySlug: 'cairu', municipalityId: 1 },
|
||||||
|
'/campanha/demandas/foo',
|
||||||
|
),
|
||||||
).toEqual([])
|
).toEqual([])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,9 @@ describe('resolveLeadershipQuickActions', () => {
|
||||||
const actions = resolveLeadershipQuickActions('/campanha/liderancas', 'coordinator', {})
|
const actions = resolveLeadershipQuickActions('/campanha/liderancas', 'coordinator', {})
|
||||||
expect(actions).toHaveLength(1)
|
expect(actions).toHaveLength(1)
|
||||||
expect(actions?.[0]?.id).toBe('update-leadership')
|
expect(actions?.[0]?.id).toBe('update-leadership')
|
||||||
expect(actions?.[0]?.href).toBe(`${CAMPAIGN_ACTIONS_HOME}/atualizar-lideranca`)
|
expect(actions?.[0]?.href).toBe(
|
||||||
|
`${CAMPAIGN_ACTIONS_HOME}/atualizar-lideranca?from=%2Fcampanha%2Fliderancas`,
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns five wizard actions on detail with municipality prefill when N=1', () => {
|
it('returns five wizard actions on detail with municipality prefill when N=1', () => {
|
||||||
|
|
@ -24,10 +26,10 @@ describe('resolveLeadershipQuickActions', () => {
|
||||||
'register-demand',
|
'register-demand',
|
||||||
])
|
])
|
||||||
expect(actions?.find((action) => action.id === 'update-votes')?.href).toBe(
|
expect(actions?.find((action) => action.id === 'update-votes')?.href).toBe(
|
||||||
`${CAMPAIGN_ACTIONS_HOME}/atualizar-votos?municipio=cairu`,
|
`${CAMPAIGN_ACTIONS_HOME}/atualizar-votos?municipio=cairu&from=%2Fcampanha%2Fliderancas%2F42`,
|
||||||
)
|
)
|
||||||
expect(actions?.find((action) => action.id === 'update-leadership')?.href).toBe(
|
expect(actions?.find((action) => action.id === 'update-leadership')?.href).toBe(
|
||||||
`${CAMPAIGN_ACTIONS_HOME}/atualizar-lideranca?municipio=cairu&leadershipId=42`,
|
`${CAMPAIGN_ACTIONS_HOME}/atualizar-lideranca?municipio=cairu&leadershipId=42&from=%2Fcampanha%2Fliderancas%2F42`,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -39,7 +41,7 @@ describe('resolveLeadershipQuickActions', () => {
|
||||||
'/campanha/liderancas/7',
|
'/campanha/liderancas/7',
|
||||||
)
|
)
|
||||||
expect(actions?.find((action) => action.id === 'update-votes')?.href).toBe(
|
expect(actions?.find((action) => action.id === 'update-votes')?.href).toBe(
|
||||||
`${CAMPAIGN_ACTIONS_HOME}/atualizar-votos`,
|
`${CAMPAIGN_ACTIONS_HOME}/atualizar-votos?from=%2Fcampanha%2Fliderancas%2F7`,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,16 @@ describe('wizardActionChain', () => {
|
||||||
expect(wizardChainContinueHref('register-demand', 'update-votes', 'cairu')).toBe(CAMPAIGN_HOME)
|
expect(wizardChainContinueHref('register-demand', 'update-votes', 'cairu')).toBe(CAMPAIGN_HOME)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
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)}`)
|
||||||
|
})
|
||||||
|
|
||||||
it('resolves session entry from query or current principal', () => {
|
it('resolves session entry from query or current principal', () => {
|
||||||
expect(resolveWizardChainEntry(undefined, 'update-votes')).toBe('update-votes')
|
expect(resolveWizardChainEntry(undefined, 'update-votes')).toBe('update-votes')
|
||||||
expect(resolveWizardChainEntry('register-signal', 'update-votes')).toBe('register-signal')
|
expect(resolveWizardChainEntry('register-signal', 'update-votes')).toBe('register-signal')
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,12 @@ describe('resolveWizardLeadershipSkip', () => {
|
||||||
expect(resolveWizardLeadershipSkip('update-leadership', 'cairu')).toBeUndefined()
|
expect(resolveWizardLeadershipSkip('update-leadership', 'cairu')).toBeUndefined()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('points skip to Início when leadership is the last chained step', () => {
|
it('points skip to origin when from is set, else Início at chain end', () => {
|
||||||
// In the v1 matrix, leadership is always the final chained elo.
|
const origin = '/campanha/liderancas/7'
|
||||||
|
expect(resolveWizardLeadershipSkip('update-votes', 'cairu', origin)).toEqual({
|
||||||
|
label: WIZARD_CHAIN_SKIP_LABEL,
|
||||||
|
href: origin,
|
||||||
|
})
|
||||||
expect(resolveWizardLeadershipSkip('update-votes', 'cairu')).toEqual({
|
expect(resolveWizardLeadershipSkip('update-votes', 'cairu')).toEqual({
|
||||||
label: WIZARD_CHAIN_SKIP_LABEL,
|
label: WIZARD_CHAIN_SKIP_LABEL,
|
||||||
href: CAMPAIGN_HOME,
|
href: CAMPAIGN_HOME,
|
||||||
|
|
|
||||||
51
tests/unit/wizardReturnPath.unit.spec.ts
Normal file
51
tests/unit/wizardReturnPath.unit.spec.ts
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
import { describe, expect, it } from 'vitest'
|
||||||
|
|
||||||
|
import {
|
||||||
|
appendWizardReturnPath,
|
||||||
|
isWizardReturnPath,
|
||||||
|
parseWizardReturnPath,
|
||||||
|
WIZARD_RETURN_PATH_QUERY_KEY,
|
||||||
|
} from '@/lib/campaignActionRoutes'
|
||||||
|
import { CAMPAIGN_HOME } from '@/lib/campaignPaths'
|
||||||
|
|
||||||
|
describe('wizard return path (B110)', () => {
|
||||||
|
it('allowlists internal /campanha paths outside acoes and auth', () => {
|
||||||
|
expect(isWizardReturnPath('/campanha')).toBe(true)
|
||||||
|
expect(isWizardReturnPath('/campanha/municipios/cairu')).toBe(true)
|
||||||
|
expect(isWizardReturnPath('/campanha/liderancas/42')).toBe(true)
|
||||||
|
expect(isWizardReturnPath('/campanha/acoes/mudar-tendencia')).toBe(false)
|
||||||
|
expect(isWizardReturnPath('/campanha/login')).toBe(false)
|
||||||
|
expect(isWizardReturnPath('/campanha/convite/token')).toBe(false)
|
||||||
|
expect(isWizardReturnPath('https://evil.test/phish')).toBe(false)
|
||||||
|
expect(isWizardReturnPath('/public')).toBe(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('parseWizardReturnPath fails closed on invalid values', () => {
|
||||||
|
expect(parseWizardReturnPath(undefined)).toBeUndefined()
|
||||||
|
expect(parseWizardReturnPath('/campanha/municipios/foo')).toBe('/campanha/municipios/foo')
|
||||||
|
expect(parseWizardReturnPath('/campanha/acoes/foo')).toBeUndefined()
|
||||||
|
expect(parseWizardReturnPath('//evil.test')).toBeUndefined()
|
||||||
|
expect(parseWizardReturnPath('/campanha/foo?x=1')).toBeUndefined()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('appendWizardReturnPath adds the from query key', () => {
|
||||||
|
const href = appendWizardReturnPath(
|
||||||
|
'/campanha/acoes/mudar-tendencia?municipio=cairu',
|
||||||
|
'/campanha/municipios/cairu',
|
||||||
|
)
|
||||||
|
expect(href).toContain(`${WIZARD_RETURN_PATH_QUERY_KEY}=`)
|
||||||
|
expect(href).toContain(
|
||||||
|
`${WIZARD_RETURN_PATH_QUERY_KEY}=${encodeURIComponent('/campanha/municipios/cairu')}`,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('appendWizardReturnPath ignores invalid return paths', () => {
|
||||||
|
expect(appendWizardReturnPath('/campanha/acoes/foo', '/campanha/acoes/bar')).toBe(
|
||||||
|
'/campanha/acoes/foo',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('CAMPAIGN_HOME is a valid return path', () => {
|
||||||
|
expect(parseWizardReturnPath(CAMPAIGN_HOME)).toBe(CAMPAIGN_HOME)
|
||||||
|
})
|
||||||
|
})
|
||||||
Loading…
Reference in a new issue