mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-23 16:13:04 +00:00
fix(miss-52): one shared Drawer for the chip-relation lists too
The B42 fix reached the municípios mobile cards, but the three chip-relation surfaces still mounted a Drawer root per OPENED cell on coarse pointers (lideranças 50 cells, dobradinhas 50, assessores 25): the exact hundreds-of-hidden-instances class that tripped React #130 in prod. Each now wraps its table in CampaignListSheetProvider — cell bodies portal into the single host Drawer, fine-pointer popover path untouched (behavior delta: after opening N cells sequentially on touch, N drawer roots -> 1).
This commit is contained in:
parent
bfbb0ec713
commit
6f42bc3bf3
3 changed files with 276 additions and 259 deletions
|
|
@ -10,6 +10,7 @@ import {
|
||||||
CampaignListResults,
|
CampaignListResults,
|
||||||
CampaignTransitionAnchor,
|
CampaignTransitionAnchor,
|
||||||
} from '@/components/campaign/shared/CampaignListPending'
|
} from '@/components/campaign/shared/CampaignListPending'
|
||||||
|
import { CampaignListSheetProvider } from '@/components/campaign/shared/CampaignListSheetHost'
|
||||||
import {
|
import {
|
||||||
CampaignTable,
|
CampaignTable,
|
||||||
CampaignTableHead,
|
CampaignTableHead,
|
||||||
|
|
@ -249,14 +250,18 @@ export default async function StateDeputiesPage({ searchParams }: StateDeputiesP
|
||||||
<p className="text-sm text-muted-foreground" aria-live="polite">
|
<p className="text-sm text-muted-foreground" aria-live="polite">
|
||||||
{sortSummary}
|
{sortSummary}
|
||||||
</p>
|
</p>
|
||||||
<CampaignTable
|
{/* One shared Drawer for every chip-cell sheet on coarse pointers
|
||||||
caption={`${sortSummary}. Deputados estaduais com quem a campanha dobra.`}
|
(miss #52 — never a Drawer root per opened cell). */}
|
||||||
columns={columns}
|
<CampaignListSheetProvider>
|
||||||
columnVisibility={columnVisibility}
|
<CampaignTable
|
||||||
rows={rows}
|
caption={`${sortSummary}. Deputados estaduais com quem a campanha dobra.`}
|
||||||
rowKey={(row) => row.id}
|
columns={columns}
|
||||||
empty={<StateDeputyListEmptyState state={state} />}
|
columnVisibility={columnVisibility}
|
||||||
/>
|
rows={rows}
|
||||||
|
rowKey={(row) => row.id}
|
||||||
|
empty={<StateDeputyListEmptyState state={state} />}
|
||||||
|
/>
|
||||||
|
</CampaignListSheetProvider>
|
||||||
{rows.length ? (
|
{rows.length ? (
|
||||||
<CampaignListFooter
|
<CampaignListFooter
|
||||||
totalDocs={totalDocs}
|
totalDocs={totalDocs}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ import {
|
||||||
CampaignListResults,
|
CampaignListResults,
|
||||||
CampaignTransitionAnchor,
|
CampaignTransitionAnchor,
|
||||||
} from '@/components/campaign/shared/CampaignListPending'
|
} from '@/components/campaign/shared/CampaignListPending'
|
||||||
|
import { CampaignListSheetProvider } from '@/components/campaign/shared/CampaignListSheetHost'
|
||||||
import {
|
import {
|
||||||
CampaignTable,
|
CampaignTable,
|
||||||
CampaignTableHead,
|
CampaignTableHead,
|
||||||
|
|
@ -402,14 +403,18 @@ export default async function LeadershipsPage({ searchParams }: LeadershipsPageP
|
||||||
<p className="text-sm text-muted-foreground" aria-live="polite">
|
<p className="text-sm text-muted-foreground" aria-live="polite">
|
||||||
{sortSummary}
|
{sortSummary}
|
||||||
</p>
|
</p>
|
||||||
<CampaignTable
|
{/* One shared Drawer for every chip-cell sheet on coarse pointers
|
||||||
caption={`${sortSummary}. Uma ficha por pessoa — cada liderança pode atuar em vários municípios e organizações.`}
|
(miss #52 — never a Drawer root per opened cell). */}
|
||||||
columns={columns}
|
<CampaignListSheetProvider>
|
||||||
columnVisibility={columnVisibility}
|
<CampaignTable
|
||||||
rows={rows}
|
caption={`${sortSummary}. Uma ficha por pessoa — cada liderança pode atuar em vários municípios e organizações.`}
|
||||||
rowKey={(row) => row.id}
|
columns={columns}
|
||||||
empty={<LeadershipListEmptyState state={state} />}
|
columnVisibility={columnVisibility}
|
||||||
/>
|
rows={rows}
|
||||||
|
rowKey={(row) => row.id}
|
||||||
|
empty={<LeadershipListEmptyState state={state} />}
|
||||||
|
/>
|
||||||
|
</CampaignListSheetProvider>
|
||||||
{rows.length ? (
|
{rows.length ? (
|
||||||
<CampaignListFooter
|
<CampaignListFooter
|
||||||
totalDocs={totalDocs}
|
totalDocs={totalDocs}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import {
|
||||||
campaignReadCellClassName,
|
campaignReadCellClassName,
|
||||||
} from '@/components/campaign/shared/CampaignCopyableCell'
|
} from '@/components/campaign/shared/CampaignCopyableCell'
|
||||||
import { CampaignListEmptyState } from '@/components/campaign/shared/CampaignListEmptyState'
|
import { CampaignListEmptyState } from '@/components/campaign/shared/CampaignListEmptyState'
|
||||||
|
import { CampaignListSheetProvider } from '@/components/campaign/shared/CampaignListSheetHost'
|
||||||
import { MunicipalityPortfolioCell } from '@/components/campaign/shared/MunicipalityPortfolioCell'
|
import { MunicipalityPortfolioCell } from '@/components/campaign/shared/MunicipalityPortfolioCell'
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
import { Input } from '@/components/ui/input'
|
import { Input } from '@/components/ui/input'
|
||||||
|
|
@ -155,223 +156,120 @@ export const AdvisorsTable = ({
|
||||||
const showEmpty = rows.length === 0 && !draft
|
const showEmpty = rows.length === 0 && !draft
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-4">
|
// One shared Drawer for the portfolio chip cells on coarse pointers
|
||||||
<div className="flex flex-wrap justify-end gap-2">
|
// (miss #52 — never a Drawer root per opened cell).
|
||||||
{editing ? (
|
<CampaignListSheetProvider>
|
||||||
<Button type="button" variant="outline" className="min-h-11" onClick={leaveEditing}>
|
<div className="flex flex-col gap-4">
|
||||||
Concluir edição
|
<div className="flex flex-wrap justify-end gap-2">
|
||||||
</Button>
|
{editing ? (
|
||||||
) : (
|
<Button type="button" variant="outline" className="min-h-11" onClick={leaveEditing}>
|
||||||
<Button
|
Concluir edição
|
||||||
type="button"
|
|
||||||
variant="outline"
|
|
||||||
className="min-h-11"
|
|
||||||
onClick={() => setEditing(true)}
|
|
||||||
>
|
|
||||||
<PencilIcon data-icon="inline-start" aria-hidden="true" />
|
|
||||||
Editar nome e contato
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
<Button type="button" className="min-h-11" onClick={startDraft} disabled={Boolean(draft)}>
|
|
||||||
<PlusIcon data-icon="inline-start" aria-hidden="true" />
|
|
||||||
Novo assessor
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{showEmpty ? (
|
|
||||||
<CampaignListEmptyState
|
|
||||||
icon={hasQuery ? SearchXIcon : UserCogIcon}
|
|
||||||
title={hasQuery ? 'Nenhum assessor encontrado' : 'Nenhum assessor cadastrado'}
|
|
||||||
description={
|
|
||||||
hasQuery
|
|
||||||
? 'Ajuste a busca ou limpe o filtro para ver todos.'
|
|
||||||
: 'Ative a edição e crie a conta na tabela.'
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{!hasQuery ? (
|
|
||||||
<Button type="button" className="min-h-11" onClick={startDraft}>
|
|
||||||
<PlusIcon data-icon="inline-start" aria-hidden="true" />
|
|
||||||
Novo assessor
|
|
||||||
</Button>
|
</Button>
|
||||||
) : null}
|
) : (
|
||||||
</CampaignListEmptyState>
|
<Button
|
||||||
) : (
|
type="button"
|
||||||
<div className="overflow-x-auto rounded-xl border">
|
variant="outline"
|
||||||
<Table className="min-w-[56rem] table-fixed">
|
className="min-h-11"
|
||||||
<TableHeader>
|
onClick={() => setEditing(true)}
|
||||||
<TableRow>
|
>
|
||||||
<TableHead className="w-[20%]">Nome</TableHead>
|
<PencilIcon data-icon="inline-start" aria-hidden="true" />
|
||||||
<TableHead className="w-[24%]">E-mail</TableHead>
|
Editar nome e contato
|
||||||
<TableHead className="w-[14%]">Celular</TableHead>
|
</Button>
|
||||||
<TableHead>Municípios</TableHead>
|
)}
|
||||||
<TableHead className="w-28 text-right">
|
<Button type="button" className="min-h-11" onClick={startDraft} disabled={Boolean(draft)}>
|
||||||
<span className="sr-only">Ações</span>
|
<PlusIcon data-icon="inline-start" aria-hidden="true" />
|
||||||
</TableHead>
|
Novo assessor
|
||||||
</TableRow>
|
</Button>
|
||||||
</TableHeader>
|
</div>
|
||||||
<TableBody>
|
|
||||||
{draft ? (
|
{showEmpty ? (
|
||||||
<TableRow className="bg-muted/20">
|
<CampaignListEmptyState
|
||||||
<TableCell>
|
icon={hasQuery ? SearchXIcon : UserCogIcon}
|
||||||
<Input
|
title={hasQuery ? 'Nenhum assessor encontrado' : 'Nenhum assessor cadastrado'}
|
||||||
value={draft.name}
|
description={
|
||||||
onChange={(event) => {
|
hasQuery
|
||||||
const name = event.currentTarget.value
|
? 'Ajuste a busca ou limpe o filtro para ver todos.'
|
||||||
setDraft((current) => (current ? { ...current, name } : current))
|
: 'Ative a edição e crie a conta na tabela.'
|
||||||
}}
|
}
|
||||||
placeholder="Nome"
|
>
|
||||||
aria-label="Nome do novo assessor"
|
{!hasQuery ? (
|
||||||
className={campaignInlineInputClassName}
|
<Button type="button" className="min-h-11" onClick={startDraft}>
|
||||||
autoFocus
|
<PlusIcon data-icon="inline-start" aria-hidden="true" />
|
||||||
/>
|
Novo assessor
|
||||||
</TableCell>
|
</Button>
|
||||||
<TableCell>
|
) : null}
|
||||||
<Input
|
</CampaignListEmptyState>
|
||||||
type="email"
|
) : (
|
||||||
value={draft.email}
|
<div className="overflow-x-auto rounded-xl border">
|
||||||
onChange={(event) => {
|
<Table className="min-w-[56rem] table-fixed">
|
||||||
const email = event.currentTarget.value
|
<TableHeader>
|
||||||
setDraft((current) => (current ? { ...current, email } : current))
|
<TableRow>
|
||||||
}}
|
<TableHead className="w-[20%]">Nome</TableHead>
|
||||||
placeholder="E-mail"
|
<TableHead className="w-[24%]">E-mail</TableHead>
|
||||||
aria-label="E-mail do novo assessor"
|
<TableHead className="w-[14%]">Celular</TableHead>
|
||||||
className={campaignInlineInputClassName}
|
<TableHead>Municípios</TableHead>
|
||||||
/>
|
<TableHead className="w-28 text-right">
|
||||||
</TableCell>
|
<span className="sr-only">Ações</span>
|
||||||
<TableCell>
|
</TableHead>
|
||||||
<Input
|
|
||||||
type="tel"
|
|
||||||
inputMode="numeric"
|
|
||||||
value={draft.phone}
|
|
||||||
onChange={(event) => {
|
|
||||||
const phone = formatBrazilianPhoneInput(
|
|
||||||
sanitizeBrazilianPhoneInput(event.currentTarget.value),
|
|
||||||
)
|
|
||||||
setDraft((current) => (current ? { ...current, phone } : current))
|
|
||||||
}}
|
|
||||||
placeholder="Celular"
|
|
||||||
aria-label="Celular do novo assessor"
|
|
||||||
className={campaignInlineInputClassName}
|
|
||||||
/>
|
|
||||||
</TableCell>
|
|
||||||
<TableCell>
|
|
||||||
<MunicipalityPortfolioCell
|
|
||||||
ownerId={null}
|
|
||||||
ownerName={draft.name.trim() || 'um novo assessor'}
|
|
||||||
municipalityIds={draft.municipalityIds}
|
|
||||||
municipalityIndex={municipalityIndex}
|
|
||||||
draft
|
|
||||||
onDraftChange={(municipalityIds) =>
|
|
||||||
setDraft((current) => (current ? { ...current, municipalityIds } : current))
|
|
||||||
}
|
|
||||||
commitAction={municipalitiesAction}
|
|
||||||
drawerTitle="Carteira do assessor"
|
|
||||||
updateErrorMessage="Não foi possível atualizar a carteira."
|
|
||||||
/>
|
|
||||||
</TableCell>
|
|
||||||
<TableCell className="text-right">
|
|
||||||
<div className="flex justify-end gap-1">
|
|
||||||
<Button
|
|
||||||
type="button"
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
className="size-10"
|
|
||||||
aria-label="Cancelar novo assessor"
|
|
||||||
disabled={isCreating}
|
|
||||||
onClick={cancelDraft}
|
|
||||||
>
|
|
||||||
<XIcon className="size-4" aria-hidden="true" />
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
type="button"
|
|
||||||
size="icon"
|
|
||||||
className="size-10"
|
|
||||||
aria-label="Salvar novo assessor"
|
|
||||||
disabled={isCreating}
|
|
||||||
onClick={saveDraft}
|
|
||||||
>
|
|
||||||
{isCreating ? (
|
|
||||||
<Spinner className="size-4" aria-hidden="true" />
|
|
||||||
) : (
|
|
||||||
<SaveIcon className="size-4" aria-hidden="true" />
|
|
||||||
)}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</TableCell>
|
|
||||||
</TableRow>
|
</TableRow>
|
||||||
) : null}
|
</TableHeader>
|
||||||
|
<TableBody>
|
||||||
{rows.map((row) => {
|
{draft ? (
|
||||||
const whatsAppHref = whatsAppHrefForPhone(row.phone)
|
<TableRow className="bg-muted/20">
|
||||||
const emailShown = displayEmail(row.email)
|
|
||||||
|
|
||||||
return (
|
|
||||||
<TableRow key={row.id}>
|
|
||||||
<TableCell>
|
<TableCell>
|
||||||
{editing ? (
|
<Input
|
||||||
<AdvisorDebouncedTextCell
|
value={draft.name}
|
||||||
advisorId={row.id}
|
onChange={(event) => {
|
||||||
field="name"
|
const name = event.currentTarget.value
|
||||||
defaultValue={row.name}
|
setDraft((current) => (current ? { ...current, name } : current))
|
||||||
ariaLabel={`Nome de ${row.name}`}
|
}}
|
||||||
formAction={updateProfileAction}
|
placeholder="Nome"
|
||||||
/>
|
aria-label="Nome do novo assessor"
|
||||||
) : (
|
className={campaignInlineInputClassName}
|
||||||
<Link
|
autoFocus
|
||||||
href={`/campanha/assessores/${row.id}`}
|
/>
|
||||||
className={cn(
|
|
||||||
campaignReadCellClassName,
|
|
||||||
'font-medium text-primary underline-offset-4 hover:underline',
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<span className="truncate">{row.name}</span>
|
|
||||||
</Link>
|
|
||||||
)}
|
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
{editing ? (
|
<Input
|
||||||
<AdvisorDebouncedTextCell
|
type="email"
|
||||||
advisorId={row.id}
|
value={draft.email}
|
||||||
field="email"
|
onChange={(event) => {
|
||||||
type="email"
|
const email = event.currentTarget.value
|
||||||
defaultValue={row.email ?? ''}
|
setDraft((current) => (current ? { ...current, email } : current))
|
||||||
placeholder="E-mail"
|
}}
|
||||||
ariaLabel={`E-mail de ${row.name}`}
|
placeholder="E-mail"
|
||||||
placeholderEmailFallback={row.email}
|
aria-label="E-mail do novo assessor"
|
||||||
formAction={updateProfileAction}
|
className={campaignInlineInputClassName}
|
||||||
/>
|
/>
|
||||||
) : (
|
|
||||||
<CampaignCopyableCell value={emailShown} label="E-mail" />
|
|
||||||
)}
|
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
{editing ? (
|
<Input
|
||||||
<AdvisorDebouncedTextCell
|
type="tel"
|
||||||
advisorId={row.id}
|
inputMode="numeric"
|
||||||
field="phone"
|
value={draft.phone}
|
||||||
type="tel"
|
onChange={(event) => {
|
||||||
defaultValue={row.phone ? formatBrazilianPhoneInput(row.phone) : ''}
|
const phone = formatBrazilianPhoneInput(
|
||||||
placeholder="Celular"
|
sanitizeBrazilianPhoneInput(event.currentTarget.value),
|
||||||
ariaLabel={`Celular de ${row.name}`}
|
)
|
||||||
formAction={updateProfileAction}
|
setDraft((current) => (current ? { ...current, phone } : current))
|
||||||
/>
|
}}
|
||||||
) : (
|
placeholder="Celular"
|
||||||
<CampaignCopyableCell
|
aria-label="Celular do novo assessor"
|
||||||
value={row.phone}
|
className={campaignInlineInputClassName}
|
||||||
label="Celular"
|
/>
|
||||||
displayValue={
|
|
||||||
row.phone ? formatBrazilianPhoneInput(row.phone) : undefined
|
|
||||||
}
|
|
||||||
className="tabular-nums"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<MunicipalityPortfolioCell
|
<MunicipalityPortfolioCell
|
||||||
ownerId={row.id}
|
ownerId={null}
|
||||||
ownerName={row.name}
|
ownerName={draft.name.trim() || 'um novo assessor'}
|
||||||
municipalityIds={municipalityIdsByAdvisor.get(row.id) ?? []}
|
municipalityIds={draft.municipalityIds}
|
||||||
municipalityIndex={municipalityIndex}
|
municipalityIndex={municipalityIndex}
|
||||||
|
draft
|
||||||
|
onDraftChange={(municipalityIds) =>
|
||||||
|
setDraft((current) =>
|
||||||
|
current ? { ...current, municipalityIds } : current,
|
||||||
|
)
|
||||||
|
}
|
||||||
commitAction={municipalitiesAction}
|
commitAction={municipalitiesAction}
|
||||||
drawerTitle="Carteira do assessor"
|
drawerTitle="Carteira do assessor"
|
||||||
updateErrorMessage="Não foi possível atualizar a carteira."
|
updateErrorMessage="Não foi possível atualizar a carteira."
|
||||||
|
|
@ -379,45 +277,154 @@ export const AdvisorsTable = ({
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className="text-right">
|
<TableCell className="text-right">
|
||||||
<div className="flex justify-end gap-1">
|
<div className="flex justify-end gap-1">
|
||||||
{whatsAppHref ? (
|
<Button
|
||||||
<Button asChild variant="ghost" size="icon" className="size-10">
|
type="button"
|
||||||
<a
|
variant="ghost"
|
||||||
href={whatsAppHref}
|
size="icon"
|
||||||
target="_blank"
|
className="size-10"
|
||||||
rel="noopener noreferrer"
|
aria-label="Cancelar novo assessor"
|
||||||
aria-label={`Enviar WhatsApp para ${row.name}`}
|
disabled={isCreating}
|
||||||
>
|
onClick={cancelDraft}
|
||||||
<MessageCircleIcon className="size-4" aria-hidden="true" />
|
>
|
||||||
</a>
|
<XIcon className="size-4" aria-hidden="true" />
|
||||||
</Button>
|
</Button>
|
||||||
) : (
|
<Button
|
||||||
<Button
|
type="button"
|
||||||
type="button"
|
size="icon"
|
||||||
variant="ghost"
|
className="size-10"
|
||||||
size="icon"
|
aria-label="Salvar novo assessor"
|
||||||
className="size-10"
|
disabled={isCreating}
|
||||||
disabled
|
onClick={saveDraft}
|
||||||
aria-label={`WhatsApp indisponível — ${row.name} sem celular`}
|
>
|
||||||
>
|
{isCreating ? (
|
||||||
<MessageCircleIcon className="size-4" aria-hidden="true" />
|
<Spinner className="size-4" aria-hidden="true" />
|
||||||
</Button>
|
) : (
|
||||||
)}
|
<SaveIcon className="size-4" aria-hidden="true" />
|
||||||
<AdvisorPasswordResetButton
|
)}
|
||||||
advisorId={row.id}
|
</Button>
|
||||||
disabled={!emailShown}
|
|
||||||
layout="icon"
|
|
||||||
accessibleName={`Enviar link de senha para ${row.name}`}
|
|
||||||
formAction={passwordResetAction}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
)
|
) : null}
|
||||||
})}
|
|
||||||
</TableBody>
|
{rows.map((row) => {
|
||||||
</Table>
|
const whatsAppHref = whatsAppHrefForPhone(row.phone)
|
||||||
</div>
|
const emailShown = displayEmail(row.email)
|
||||||
)}
|
|
||||||
</div>
|
return (
|
||||||
|
<TableRow key={row.id}>
|
||||||
|
<TableCell>
|
||||||
|
{editing ? (
|
||||||
|
<AdvisorDebouncedTextCell
|
||||||
|
advisorId={row.id}
|
||||||
|
field="name"
|
||||||
|
defaultValue={row.name}
|
||||||
|
ariaLabel={`Nome de ${row.name}`}
|
||||||
|
formAction={updateProfileAction}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<Link
|
||||||
|
href={`/campanha/assessores/${row.id}`}
|
||||||
|
className={cn(
|
||||||
|
campaignReadCellClassName,
|
||||||
|
'font-medium text-primary underline-offset-4 hover:underline',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<span className="truncate">{row.name}</span>
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
{editing ? (
|
||||||
|
<AdvisorDebouncedTextCell
|
||||||
|
advisorId={row.id}
|
||||||
|
field="email"
|
||||||
|
type="email"
|
||||||
|
defaultValue={row.email ?? ''}
|
||||||
|
placeholder="E-mail"
|
||||||
|
ariaLabel={`E-mail de ${row.name}`}
|
||||||
|
placeholderEmailFallback={row.email}
|
||||||
|
formAction={updateProfileAction}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<CampaignCopyableCell value={emailShown} label="E-mail" />
|
||||||
|
)}
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
{editing ? (
|
||||||
|
<AdvisorDebouncedTextCell
|
||||||
|
advisorId={row.id}
|
||||||
|
field="phone"
|
||||||
|
type="tel"
|
||||||
|
defaultValue={row.phone ? formatBrazilianPhoneInput(row.phone) : ''}
|
||||||
|
placeholder="Celular"
|
||||||
|
ariaLabel={`Celular de ${row.name}`}
|
||||||
|
formAction={updateProfileAction}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<CampaignCopyableCell
|
||||||
|
value={row.phone}
|
||||||
|
label="Celular"
|
||||||
|
displayValue={
|
||||||
|
row.phone ? formatBrazilianPhoneInput(row.phone) : undefined
|
||||||
|
}
|
||||||
|
className="tabular-nums"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<MunicipalityPortfolioCell
|
||||||
|
ownerId={row.id}
|
||||||
|
ownerName={row.name}
|
||||||
|
municipalityIds={municipalityIdsByAdvisor.get(row.id) ?? []}
|
||||||
|
municipalityIndex={municipalityIndex}
|
||||||
|
commitAction={municipalitiesAction}
|
||||||
|
drawerTitle="Carteira do assessor"
|
||||||
|
updateErrorMessage="Não foi possível atualizar a carteira."
|
||||||
|
/>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell className="text-right">
|
||||||
|
<div className="flex justify-end gap-1">
|
||||||
|
{whatsAppHref ? (
|
||||||
|
<Button asChild variant="ghost" size="icon" className="size-10">
|
||||||
|
<a
|
||||||
|
href={whatsAppHref}
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
aria-label={`Enviar WhatsApp para ${row.name}`}
|
||||||
|
>
|
||||||
|
<MessageCircleIcon className="size-4" aria-hidden="true" />
|
||||||
|
</a>
|
||||||
|
</Button>
|
||||||
|
) : (
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="ghost"
|
||||||
|
size="icon"
|
||||||
|
className="size-10"
|
||||||
|
disabled
|
||||||
|
aria-label={`WhatsApp indisponível — ${row.name} sem celular`}
|
||||||
|
>
|
||||||
|
<MessageCircleIcon className="size-4" aria-hidden="true" />
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
<AdvisorPasswordResetButton
|
||||||
|
advisorId={row.id}
|
||||||
|
disabled={!emailShown}
|
||||||
|
layout="icon"
|
||||||
|
accessibleName={`Enviar link de senha para ${row.name}`}
|
||||||
|
formAction={passwordResetAction}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</CampaignListSheetProvider>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue