teqo/src/lib/leaderContactsQuickActions.ts
Cursor Agent dfa080f74d
B89 — Ações rápidas em Contatos (liderança)
Wire the B79 drawer on /campanha/contatos for leader role with the B45
catalog (register-supporter, my-contacts). Actions use in-page hash anchors
instead of staff home-search; no drawer on Início (existing B79 gate).

Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com>
2026-08-01 05:27:45 +00:00

31 lines
1.2 KiB
TypeScript

import {
homeActionsForRole,
toHomeActionButtonProps,
type ResolvedCampaignHomeAction,
} from '@/lib/campaignHomeActions'
import type { CampaignQuickActionContext } from '@/lib/campaignQuickActionContext'
import type { CampaignQuickAction } from '@/lib/campaignQuickActionTypes'
import type { CampaignRole } from '@/lib/campaignRoles'
/** In-page anchors on `/campanha/contatos` — hash navigation from the B89 drawer. */
export const LEADER_CONTACT_FORM_HASH = '#leader-contact-form' as const
export const LEADER_CONTACTS_LIST_HASH = '#leader-contacts-list' as const
const toLeaderContactsQuickAction = (action: ResolvedCampaignHomeAction): CampaignQuickAction => {
if (action.id === 'register-supporter') {
return { ...action, href: LEADER_CONTACT_FORM_HASH }
}
if (action.id === 'my-contacts') {
return { ...action, href: LEADER_CONTACTS_LIST_HASH }
}
return action
}
export const resolveLeaderContactsQuickActions = (
role: CampaignRole,
_context: CampaignQuickActionContext,
): readonly CampaignQuickAction[] => {
if (role !== 'leader') return []
return toHomeActionButtonProps(homeActionsForRole('leader')).map(toLeaderContactsQuickAction)
}