mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-16 20:13:04 +00:00
Ações de ajuste (votos, tendência, atualização, liderança) agora retornam à origem ao salvar (toast + from allowlist B110 / Início), sem avançar sozinhas para outro wizard. Removidos fila de encadeamento (wizardActionChain.ts), param entry, skip/Pular (chrome mobile sempre X) e prefill de nota sem produtor. Liderança: botão pós-save 'Continuar' → 'Concluir' (origem). Sem migration.
51 lines
1.7 KiB
TypeScript
51 lines
1.7 KiB
TypeScript
import { politicalTrendStatuses, type PoliticalTrendStatusValue } from '@/lib/schemas/municipality'
|
|
|
|
const politicalTrendDisplayLabels: Record<PoliticalTrendStatusValue, string> = {
|
|
favoravel: 'Favorável',
|
|
neutra: 'Neutra',
|
|
desfavoravel: 'Desfavorável',
|
|
}
|
|
|
|
export const WIZARD_TREND_SAVE_LABEL = 'Salvar' as const
|
|
|
|
export const WIZARD_TREND_CLEAR_LABEL = 'Limpar' as const
|
|
|
|
export const WIZARD_TREND_SAVED_MESSAGE = 'Tendência política registrada.' as const
|
|
|
|
export const WIZARD_TREND_UNREGISTERED_TITLE = 'Tendência não registrada' as const
|
|
|
|
export const wizardTrendChoiceStepTitle = (
|
|
currentStatus: PoliticalTrendStatusValue | null,
|
|
): string =>
|
|
currentStatus
|
|
? `Tendência ${politicalTrendDisplayLabels[currentStatus]}`
|
|
: WIZARD_TREND_UNREGISTERED_TITLE
|
|
|
|
export const selectablePoliticalTrendStatuses = (
|
|
currentStatus: PoliticalTrendStatusValue | null,
|
|
): PoliticalTrendStatusValue[] =>
|
|
currentStatus
|
|
? politicalTrendStatuses.filter((status) => status !== currentStatus)
|
|
: [...politicalTrendStatuses]
|
|
|
|
/** Where the change-trend wizard should land when `tendencia=` is present. */
|
|
export type WizardTrendNoteDestination = 'note' | 'choice' | 'home'
|
|
|
|
/**
|
|
* `home` when the query trend already matches the persisted status — covers
|
|
* post-save RSC refresh (B97) and stale deep-links; never loops back to choice.
|
|
*/
|
|
export const resolveWizardTrendNoteDestination = (
|
|
trendStatus: PoliticalTrendStatusValue,
|
|
currentStatus: PoliticalTrendStatusValue | null,
|
|
): WizardTrendNoteDestination => {
|
|
if (trendStatus === currentStatus) {
|
|
return 'home'
|
|
}
|
|
|
|
if (!selectablePoliticalTrendStatuses(currentStatus).includes(trendStatus)) {
|
|
return 'choice'
|
|
}
|
|
|
|
return 'note'
|
|
}
|