mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-26 21:53:06 +00:00
B96 — Header wizard: X na tendência standalone, Pular só encadeada
resolveWizardTrendSkip(entryAction) espelha resolveWizardSignalSkip: skip só quando entryAction presente e diferente de change-trend. WizardTrendChoiceStep e WizardTrendNoteStep condicionam skip/trailingAction. Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com>
This commit is contained in:
parent
317935b128
commit
5181116d84
4 changed files with 26 additions and 11 deletions
|
|
@ -27,7 +27,6 @@ import {
|
||||||
resolveWizardTrendSkip,
|
resolveWizardTrendSkip,
|
||||||
selectablePoliticalTrendStatuses,
|
selectablePoliticalTrendStatuses,
|
||||||
wizardTrendChoiceStepTitle,
|
wizardTrendChoiceStepTitle,
|
||||||
type WizardTrendSkipAction,
|
|
||||||
} 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'
|
||||||
|
|
@ -50,7 +49,7 @@ export const WizardTrendChoiceStep = ({
|
||||||
prefillExtraParams,
|
prefillExtraParams,
|
||||||
}: WizardTrendChoiceStepProps) => {
|
}: WizardTrendChoiceStepProps) => {
|
||||||
const [infoEntry, setInfoEntry] = useState<PoliticalTrendWizardMetaEntry | null>(null)
|
const [infoEntry, setInfoEntry] = useState<PoliticalTrendWizardMetaEntry | null>(null)
|
||||||
const skip: WizardTrendSkipAction = resolveWizardTrendSkip()
|
const skip = resolveWizardTrendSkip(entryAction)
|
||||||
const options = selectablePoliticalTrendStatuses(currentStatus)
|
const options = selectablePoliticalTrendStatuses(currentStatus)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -62,7 +61,7 @@ export const WizardTrendChoiceStep = ({
|
||||||
previousHref={wizardActionHref(actionSlug, municipalitySlug, { entryAction })}
|
previousHref={wizardActionHref(actionSlug, municipalitySlug, { entryAction })}
|
||||||
municipalityLabel={municipalityName}
|
municipalityLabel={municipalityName}
|
||||||
skip={skip}
|
skip={skip}
|
||||||
trailingAction={<WizardTrendSkipTrailing skip={skip} />}
|
trailingAction={skip ? <WizardTrendSkipTrailing skip={skip} /> : undefined}
|
||||||
>
|
>
|
||||||
<ul className="grid list-none grid-cols-2 gap-3 md:grid-cols-3">
|
<ul className="grid list-none grid-cols-2 gap-3 md:grid-cols-3">
|
||||||
{options.map((status) => {
|
{options.map((status) => {
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ export const WizardTrendNoteStep = ({
|
||||||
setMunicipalityPoliticalTrendFormAction,
|
setMunicipalityPoliticalTrendFormAction,
|
||||||
{},
|
{},
|
||||||
)
|
)
|
||||||
const skip = resolveWizardTrendSkip()
|
const skip = resolveWizardTrendSkip(entryAction)
|
||||||
const stepTitle = `Mudar tendência para ${politicalTrendLabels[trendStatus]}`
|
const stepTitle = `Mudar tendência para ${politicalTrendLabels[trendStatus]}`
|
||||||
|
|
||||||
useCampaignFormSuccessToast(state, () => {
|
useCampaignFormSuccessToast(state, () => {
|
||||||
|
|
@ -65,7 +65,7 @@ export const WizardTrendNoteStep = ({
|
||||||
previousHref={wizardTrendHref(actionSlug, municipalitySlug, undefined, entryAction)}
|
previousHref={wizardTrendHref(actionSlug, municipalitySlug, undefined, entryAction)}
|
||||||
municipalityLabel={municipalityName}
|
municipalityLabel={municipalityName}
|
||||||
skip={skip}
|
skip={skip}
|
||||||
trailingAction={<WizardTrendSkipTrailing skip={skip} />}
|
trailingAction={skip ? <WizardTrendSkipTrailing skip={skip} /> : undefined}
|
||||||
>
|
>
|
||||||
<form
|
<form
|
||||||
action={submitAction}
|
action={submitAction}
|
||||||
|
|
|
||||||
|
|
@ -63,10 +63,16 @@ export const resolveWizardTrendNoteDestination = (
|
||||||
return 'note'
|
return 'note'
|
||||||
}
|
}
|
||||||
|
|
||||||
export const resolveWizardTrendSkip = (): WizardTrendSkipAction => ({
|
export const shouldShowWizardTrendSkip = (
|
||||||
label: WIZARD_TREND_SKIP_LABEL,
|
entryAction: CampaignWizardActionId | undefined,
|
||||||
href: CAMPAIGN_HOME,
|
): boolean => entryAction != null && entryAction !== 'change-trend'
|
||||||
})
|
|
||||||
|
export const resolveWizardTrendSkip = (
|
||||||
|
entryAction: CampaignWizardActionId | undefined,
|
||||||
|
): WizardTrendSkipAction | undefined =>
|
||||||
|
shouldShowWizardTrendSkip(entryAction)
|
||||||
|
? { label: WIZARD_TREND_SKIP_LABEL, href: CAMPAIGN_HOME }
|
||||||
|
: undefined
|
||||||
|
|
||||||
export type PoliticalTrendNotePrefillSource =
|
export type PoliticalTrendNotePrefillSource =
|
||||||
| { kind: 'none' }
|
| { kind: 'none' }
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import {
|
||||||
resolveWizardTrendNoteDestination,
|
resolveWizardTrendNoteDestination,
|
||||||
resolveWizardTrendSkip,
|
resolveWizardTrendSkip,
|
||||||
selectablePoliticalTrendStatuses,
|
selectablePoliticalTrendStatuses,
|
||||||
|
shouldShowWizardTrendSkip,
|
||||||
WIZARD_TREND_SKIP_LABEL,
|
WIZARD_TREND_SKIP_LABEL,
|
||||||
WIZARD_TREND_UNREGISTERED_TITLE,
|
WIZARD_TREND_UNREGISTERED_TITLE,
|
||||||
wizardTrendChoiceStepTitle,
|
wizardTrendChoiceStepTitle,
|
||||||
|
|
@ -35,8 +36,17 @@ describe('politicalTrendWizardUi', () => {
|
||||||
expect(resolveWizardTrendNoteDestination('favoravel', null)).toBe('note')
|
expect(resolveWizardTrendNoteDestination('favoravel', null)).toBe('note')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('always exposes skip to abandon the trend change', () => {
|
it('hides skip for standalone change-trend entry', () => {
|
||||||
expect(resolveWizardTrendSkip()).toEqual({
|
expect(shouldShowWizardTrendSkip(undefined)).toBe(false)
|
||||||
|
expect(shouldShowWizardTrendSkip('change-trend')).toBe(false)
|
||||||
|
expect(resolveWizardTrendSkip(undefined)).toBeUndefined()
|
||||||
|
expect(resolveWizardTrendSkip('change-trend')).toBeUndefined()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('shows skip when embedded from another wizard action', () => {
|
||||||
|
expect(shouldShowWizardTrendSkip('update-votes')).toBe(true)
|
||||||
|
expect(shouldShowWizardTrendSkip('register-signal')).toBe(true)
|
||||||
|
expect(resolveWizardTrendSkip('update-votes')).toEqual({
|
||||||
label: WIZARD_TREND_SKIP_LABEL,
|
label: WIZARD_TREND_SKIP_LABEL,
|
||||||
href: CAMPAIGN_HOME,
|
href: CAMPAIGN_HOME,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue