feat: Administração > Configurações, remover usuário do tenant, Discador > Callbacks
Fecha os últimos gaps do módulo Administração (agente.md secao 169): tela de Configurações self-service do próprio tenant (GET/PATCH /tenant-settings, nunca aceita tenantId arbitrário — só user.tenantId das claims), e DELETE /users/:id pra remover alguém do tenant, com duas proteções que não existiam antes (não deixa remover a si mesmo, não deixa remover/rebaixar o último Tenant Admin). Corrige um bug real achado testando a remoção: o delete de TenantMembership (FORCE RLS) rodava dentro de um prisma.$transaction([...]) em forma de array, que nunca seta app.current_tenant_id — Prisma devolvia P2025 "not found" com a linha existindo (500 pro cliente). Mesma classe de bug já corrigida antes em TenantsController.create; corrigido com $transaction(async (tx) => ...) + set_config explícito. Adiciona Discador > Callbacks (GET/PATCH /leads/callbacks, tenant-wide): reagendar, tentar de novo sem esperar, ou desistir de um lead que pediu retorno em outro horário. Remove "Importações" do menu — decisão já registrada na PHASE 39 de não duplicar uma tela pro que já existe (CSV em lote no wizard/detalhe da campanha). Testado ponta a ponta via curl e Puppeteer contra o tenant Acme real: tenant-settings GET/PATCH, proteção de último-admin nos dois endpoints que a usam, convite+remoção de um admin temporário, e o fluxo completo de callback (lead forçado pra CALLBACK via SQL, reagendar rejeitado pro passado/aceito pro futuro, requeue confirmado). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BFaBaBSQGhyXGEgtTYZGV8
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
"use server";
|
||||
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { requireSession } from "@/lib/session";
|
||||
import { apiFetch, ApiError } from "@/lib/api";
|
||||
import type { TenantSettings } from "@/lib/admin-types";
|
||||
|
||||
function extractErrorMessage(err: unknown): string {
|
||||
if (err instanceof ApiError) {
|
||||
try {
|
||||
const parsed = JSON.parse(err.message);
|
||||
if (Array.isArray(parsed.message)) return parsed.message.join(" ");
|
||||
if (typeof parsed.message === "string") return parsed.message;
|
||||
} catch {
|
||||
// corpo não era JSON
|
||||
}
|
||||
return err.message || "Falha inesperada na API.";
|
||||
}
|
||||
return "Falha inesperada. Tente novamente.";
|
||||
}
|
||||
|
||||
export interface UpdateTenantSettingsInput {
|
||||
tradeName: string;
|
||||
taxId: string;
|
||||
timezone: string;
|
||||
locale: string;
|
||||
aiPrivacyLevel: string;
|
||||
}
|
||||
|
||||
export async function updateTenantSettings(
|
||||
input: UpdateTenantSettingsInput,
|
||||
): Promise<{ ok: true; settings: TenantSettings } | { ok: false; error: string }> {
|
||||
const session = await requireSession();
|
||||
try {
|
||||
const settings = await apiFetch<TenantSettings>("/tenant-settings", session.accessToken, {
|
||||
method: "PATCH",
|
||||
body: JSON.stringify(input),
|
||||
});
|
||||
revalidatePath("/app/administracao/configuracoes");
|
||||
return { ok: true, settings };
|
||||
} catch (err) {
|
||||
return { ok: false, error: extractErrorMessage(err) };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useTransition } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { Check } from "lucide-react";
|
||||
import { Panel, PanelHeader } from "@/components/ui/panel";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input, Select, FieldLabel } from "@/components/ui/input";
|
||||
import { Pill } from "@/components/ui/pill";
|
||||
import { AI_PRIVACY_LEVEL_LABELS, type TenantSettings } from "@/lib/admin-types";
|
||||
|
||||
type AiPrivacyLevel = TenantSettings["aiPrivacyLevel"];
|
||||
import { TENANT_STATUS_LABELS } from "@/lib/platform-types";
|
||||
import { formatDate } from "@/lib/format";
|
||||
import { updateTenantSettings } from "./actions";
|
||||
|
||||
export function ConfiguracoesView({ settings }: { settings: TenantSettings }) {
|
||||
const router = useRouter();
|
||||
const [tradeName, setTradeName] = useState(settings.tradeName ?? "");
|
||||
const [taxId, setTaxId] = useState(settings.taxId ?? "");
|
||||
const [timezone, setTimezone] = useState(settings.timezone);
|
||||
const [locale, setLocale] = useState(settings.locale);
|
||||
const [aiPrivacyLevel, setAiPrivacyLevel] = useState(settings.aiPrivacyLevel);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [saved, setSaved] = useState(false);
|
||||
const [pending, startTransition] = useTransition();
|
||||
|
||||
function onSubmit(e: React.FormEvent) {
|
||||
e.preventDefault();
|
||||
setError(null);
|
||||
setSaved(false);
|
||||
startTransition(async () => {
|
||||
const result = await updateTenantSettings({ tradeName: tradeName.trim(), taxId: taxId.trim(), timezone, locale, aiPrivacyLevel });
|
||||
if (!result.ok) {
|
||||
setError(result.error);
|
||||
return;
|
||||
}
|
||||
setSaved(true);
|
||||
router.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-5">
|
||||
<div>
|
||||
<h1 className="text-lg font-semibold text-foreground">Configurações</h1>
|
||||
<p className="mt-1 max-w-2xl text-sm text-muted-foreground">
|
||||
Dados do próprio tenant (agente.md secao 169). Razão social, código, plano e status são controlados pela
|
||||
plataforma — fale com o suporte pra mudar algum desses.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Panel className="p-5">
|
||||
<PanelHeader title="Identificação" description="Somente leitura — controlado pela plataforma" />
|
||||
<div className="mt-4 grid grid-cols-1 gap-4 sm:grid-cols-3">
|
||||
<ReadOnlyField label="Razão social" value={settings.legalName} />
|
||||
<ReadOnlyField label="Código" value={settings.code} mono />
|
||||
<div>
|
||||
<FieldLabel>Status</FieldLabel>
|
||||
<div className="pt-1.5">
|
||||
<Pill tone={settings.status === "ACTIVE" ? "accent" : "neutral"}>{TENANT_STATUS_LABELS[settings.status]}</Pill>
|
||||
</div>
|
||||
</div>
|
||||
<ReadOnlyField label="Plano" value={settings.plan.name} />
|
||||
<ReadOnlyField label="Moeda de faturamento" value={settings.billingCurrency} />
|
||||
<ReadOnlyField label="Domínio de telefonia" value={settings.telephonyDomain ?? "—"} mono />
|
||||
<ReadOnlyField label="Cliente desde" value={formatDate(settings.createdAt)} />
|
||||
</div>
|
||||
</Panel>
|
||||
|
||||
<Panel className="p-5">
|
||||
<form onSubmit={onSubmit} className="space-y-4">
|
||||
<PanelHeader title="Editável" description="Só um Tenant Admin pode alterar" />
|
||||
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
|
||||
<div>
|
||||
<FieldLabel htmlFor="cf-tradename">Nome fantasia</FieldLabel>
|
||||
<Input id="cf-tradename" value={tradeName} onChange={(e) => setTradeName(e.target.value)} disabled={pending} />
|
||||
</div>
|
||||
<div>
|
||||
<FieldLabel htmlFor="cf-taxid">CNPJ/CPF</FieldLabel>
|
||||
<Input id="cf-taxid" value={taxId} onChange={(e) => setTaxId(e.target.value)} disabled={pending} className="font-mono" />
|
||||
</div>
|
||||
<div>
|
||||
<FieldLabel htmlFor="cf-timezone">Fuso horário</FieldLabel>
|
||||
<Input id="cf-timezone" value={timezone} onChange={(e) => setTimezone(e.target.value)} disabled={pending} className="font-mono" />
|
||||
</div>
|
||||
<div>
|
||||
<FieldLabel htmlFor="cf-locale">Idioma</FieldLabel>
|
||||
<Input id="cf-locale" value={locale} onChange={(e) => setLocale(e.target.value)} disabled={pending} className="font-mono" />
|
||||
</div>
|
||||
<div className="sm:col-span-2">
|
||||
<FieldLabel htmlFor="cf-ai">Privacidade de IA</FieldLabel>
|
||||
<Select id="cf-ai" value={aiPrivacyLevel} onChange={(e) => setAiPrivacyLevel(e.target.value as AiPrivacyLevel)} disabled={pending}>
|
||||
{Object.entries(AI_PRIVACY_LEVEL_LABELS).map(([key, label]) => (
|
||||
<option key={key} value={key}>
|
||||
{label}
|
||||
</option>
|
||||
))}
|
||||
</Select>
|
||||
<p className="mt-1.5 text-xs text-muted-foreground">
|
||||
Nível padrão deste tenant — campanha e fila podem sobrescrever com um nível mais restrito, nunca mais
|
||||
permissivo.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{error && (
|
||||
<p role="alert" className="rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive">
|
||||
{error}
|
||||
</p>
|
||||
)}
|
||||
<div className="flex items-center justify-end gap-3">
|
||||
{saved && !pending && (
|
||||
<span className="flex items-center gap-1.5 text-sm text-status-green">
|
||||
<Check className="h-4 w-4" aria-hidden /> Salvo
|
||||
</span>
|
||||
)}
|
||||
<Button type="submit" disabled={pending}>
|
||||
{pending ? "Salvando…" : "Salvar alterações"}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
</Panel>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ReadOnlyField({ label, value, mono }: { label: string; value: string; mono?: boolean }) {
|
||||
return (
|
||||
<div>
|
||||
<FieldLabel>{label}</FieldLabel>
|
||||
<p className={`pt-1.5 text-sm text-foreground ${mono ? "font-mono" : ""}`}>{value}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { requireSession } from "@/lib/session";
|
||||
import { apiFetch } from "@/lib/api";
|
||||
import type { TenantSettings } from "@/lib/admin-types";
|
||||
import { ConfiguracoesView } from "./configuracoes-view";
|
||||
|
||||
export default async function ConfiguracoesPage() {
|
||||
const session = await requireSession();
|
||||
const settings = await apiFetch<TenantSettings>("/tenant-settings", session.accessToken);
|
||||
return <ConfiguracoesView settings={settings} />;
|
||||
}
|
||||
@@ -50,3 +50,14 @@ export async function updateUserRole(id: string, roleKey: string): Promise<{ ok:
|
||||
return { ok: false, error: extractErrorMessage(err) };
|
||||
}
|
||||
}
|
||||
|
||||
export async function removeUser(id: string): Promise<{ ok: true } | { ok: false; error: string }> {
|
||||
const session = await requireSession();
|
||||
try {
|
||||
await apiFetch<void>(`/users/${id}`, session.accessToken, { method: "DELETE" });
|
||||
revalidatePath("/app/administracao/usuarios");
|
||||
return { ok: true };
|
||||
} catch (err) {
|
||||
return { ok: false, error: extractErrorMessage(err) };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { useState, useTransition } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { Check, Plus, User as UserIcon, X } from "lucide-react";
|
||||
import { Check, Plus, Trash2, User as UserIcon, X } from "lucide-react";
|
||||
import { Panel, PanelHeader } from "@/components/ui/panel";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input, Select, FieldLabel } from "@/components/ui/input";
|
||||
@@ -10,7 +10,7 @@ import { Pill } from "@/components/ui/pill";
|
||||
import { SecretReveal } from "@/components/ui/secret-reveal";
|
||||
import { TBody, TD, TH, THead, TR, Table } from "@/components/ui/table";
|
||||
import { TENANT_ROLE_OPTIONS, type TenantMember } from "@/lib/admin-types";
|
||||
import { inviteUser, updateUserRole } from "./actions";
|
||||
import { inviteUser, removeUser, updateUserRole } from "./actions";
|
||||
|
||||
export function UsuariosView({ members, currentUserId }: { members: TenantMember[]; currentUserId: string }) {
|
||||
const [showForm, setShowForm] = useState(false);
|
||||
@@ -152,6 +152,7 @@ function MemberRow({ member, isSelf }: { member: TenantMember; isSelf: boolean }
|
||||
const [editing, setEditing] = useState(false);
|
||||
const [roleKey, setRoleKey] = useState(member.role?.key ?? TENANT_ROLE_OPTIONS[2].key);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [confirmingRemove, setConfirmingRemove] = useState(false);
|
||||
const [pending, startTransition] = useTransition();
|
||||
|
||||
function onSave() {
|
||||
@@ -167,6 +168,23 @@ function MemberRow({ member, isSelf }: { member: TenantMember; isSelf: boolean }
|
||||
});
|
||||
}
|
||||
|
||||
function onRemove() {
|
||||
if (!confirmingRemove) {
|
||||
setConfirmingRemove(true);
|
||||
return;
|
||||
}
|
||||
setError(null);
|
||||
startTransition(async () => {
|
||||
const result = await removeUser(member.id);
|
||||
if (!result.ok) {
|
||||
setError(result.error);
|
||||
setConfirmingRemove(false);
|
||||
return;
|
||||
}
|
||||
router.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<TR>
|
||||
<TD>
|
||||
@@ -201,10 +219,24 @@ function MemberRow({ member, isSelf }: { member: TenantMember; isSelf: boolean }
|
||||
<div className="flex items-center gap-2">
|
||||
<Pill>{member.role?.name ?? "sem papel"}</Pill>
|
||||
{!isSelf && (
|
||||
<Button type="button" variant="ghost" size="sm" onClick={() => setEditing(true)}>
|
||||
Trocar
|
||||
</Button>
|
||||
<>
|
||||
<Button type="button" variant="ghost" size="sm" onClick={() => setEditing(true)} disabled={pending}>
|
||||
Trocar
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
variant={confirmingRemove ? "destructive" : "ghost"}
|
||||
size="sm"
|
||||
onClick={onRemove}
|
||||
disabled={pending}
|
||||
aria-label={confirmingRemove ? `Confirmar remoção de ${member.name}` : `Remover ${member.name} do tenant`}
|
||||
>
|
||||
<Trash2 className="h-3.5 w-3.5" aria-hidden />
|
||||
{confirmingRemove ? "Confirmar" : ""}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
{error && <span className="text-xs text-destructive">{error}</span>}
|
||||
</div>
|
||||
)}
|
||||
</TD>
|
||||
|
||||
42
apps/frontend/src/app/app/discador/callbacks/actions.ts
Normal file
42
apps/frontend/src/app/app/discador/callbacks/actions.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
"use server";
|
||||
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { requireSession } from "@/lib/session";
|
||||
import { apiFetch, ApiError } from "@/lib/api";
|
||||
|
||||
function extractErrorMessage(err: unknown): string {
|
||||
if (err instanceof ApiError) {
|
||||
try {
|
||||
const parsed = JSON.parse(err.message);
|
||||
if (Array.isArray(parsed.message)) return parsed.message.join(" ");
|
||||
if (typeof parsed.message === "string") return parsed.message;
|
||||
} catch {
|
||||
// corpo não era JSON
|
||||
}
|
||||
return err.message || "Falha inesperada na API.";
|
||||
}
|
||||
return "Falha inesperada. Tente novamente.";
|
||||
}
|
||||
|
||||
async function updateCallback(id: string, body: { action: "RESCHEDULE" | "REQUEUE" | "CANCEL"; nextAttemptAt?: string }) {
|
||||
const session = await requireSession();
|
||||
try {
|
||||
await apiFetch<void>(`/leads/callbacks/${id}`, session.accessToken, { method: "PATCH", body: JSON.stringify(body) });
|
||||
revalidatePath("/app/discador/callbacks");
|
||||
return { ok: true as const };
|
||||
} catch (err) {
|
||||
return { ok: false as const, error: extractErrorMessage(err) };
|
||||
}
|
||||
}
|
||||
|
||||
export async function rescheduleCallback(id: string, nextAttemptAt: string) {
|
||||
return updateCallback(id, { action: "RESCHEDULE", nextAttemptAt });
|
||||
}
|
||||
|
||||
export async function requeueCallback(id: string) {
|
||||
return updateCallback(id, { action: "REQUEUE" });
|
||||
}
|
||||
|
||||
export async function cancelCallback(id: string) {
|
||||
return updateCallback(id, { action: "CANCEL" });
|
||||
}
|
||||
170
apps/frontend/src/app/app/discador/callbacks/callbacks-view.tsx
Normal file
170
apps/frontend/src/app/app/discador/callbacks/callbacks-view.tsx
Normal file
@@ -0,0 +1,170 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useTransition } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { CalendarClock, PhoneForwarded, Trash2 } from "lucide-react";
|
||||
import { Panel, PanelHeader } from "@/components/ui/panel";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Pill } from "@/components/ui/pill";
|
||||
import { EmptyState, TBody, TD, TH, THead, TR, Table } from "@/components/ui/table";
|
||||
import { formatDateTime } from "@/lib/format";
|
||||
import type { CallbackLead } from "@/lib/campaign-types";
|
||||
import { cancelCallback, rescheduleCallback, requeueCallback } from "./actions";
|
||||
|
||||
export function CallbacksView({ callbacks }: { callbacks: CallbackLead[] }) {
|
||||
return (
|
||||
<div className="space-y-5">
|
||||
<div>
|
||||
<h1 className="text-lg font-semibold text-foreground">Callbacks</h1>
|
||||
<p className="mt-1 max-w-2xl text-sm text-muted-foreground">
|
||||
Leads que pediram pra ser chamados de volta em outro horário (agente.md secao 78-79, todas as campanhas
|
||||
deste tenant). O discador preditivo respeita "Remarcado para" sozinho — não precisa fazer nada aqui a
|
||||
menos que queira adiantar, adiar ou desistir de um contato.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Panel>
|
||||
<PanelHeader title="Callbacks pendentes" description={`${callbacks.length} lead(s) aguardando retorno`} />
|
||||
{callbacks.length === 0 ? (
|
||||
<EmptyState
|
||||
title="Nenhum callback pendente"
|
||||
description="Quando um agente marcar um lead pra ligar de volta depois, ele aparece aqui."
|
||||
/>
|
||||
) : (
|
||||
<Table>
|
||||
<THead>
|
||||
<TR>
|
||||
<TH>Campanha</TH>
|
||||
<TH>Nome</TH>
|
||||
<TH>Telefone</TH>
|
||||
<TH>Tentativas</TH>
|
||||
<TH>Remarcado para</TH>
|
||||
<TH>
|
||||
<span className="sr-only">Ações</span>
|
||||
</TH>
|
||||
</TR>
|
||||
</THead>
|
||||
<TBody>
|
||||
{callbacks.map((lead) => (
|
||||
<CallbackRow key={lead.id} lead={lead} />
|
||||
))}
|
||||
</TBody>
|
||||
</Table>
|
||||
)}
|
||||
</Panel>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function toLocalInputValue(iso: string | null): string {
|
||||
if (!iso) return "";
|
||||
const d = new Date(iso);
|
||||
const pad = (n: number) => String(n).padStart(2, "0");
|
||||
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
||||
}
|
||||
|
||||
function CallbackRow({ lead }: { lead: CallbackLead }) {
|
||||
const router = useRouter();
|
||||
const [rescheduling, setRescheduling] = useState(false);
|
||||
const [when, setWhen] = useState(toLocalInputValue(lead.nextAttemptAt));
|
||||
const [confirmingCancel, setConfirmingCancel] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [pending, startTransition] = useTransition();
|
||||
|
||||
function onReschedule() {
|
||||
if (!rescheduling) {
|
||||
setRescheduling(true);
|
||||
return;
|
||||
}
|
||||
setError(null);
|
||||
if (!when) {
|
||||
setError("Escolha uma data/hora.");
|
||||
return;
|
||||
}
|
||||
startTransition(async () => {
|
||||
const result = await rescheduleCallback(lead.id, new Date(when).toISOString());
|
||||
if (!result.ok) {
|
||||
setError(result.error);
|
||||
return;
|
||||
}
|
||||
setRescheduling(false);
|
||||
router.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
function onRequeue() {
|
||||
setError(null);
|
||||
startTransition(async () => {
|
||||
const result = await requeueCallback(lead.id);
|
||||
if (!result.ok) {
|
||||
setError(result.error);
|
||||
return;
|
||||
}
|
||||
router.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
function onCancel() {
|
||||
if (!confirmingCancel) {
|
||||
setConfirmingCancel(true);
|
||||
return;
|
||||
}
|
||||
setError(null);
|
||||
startTransition(async () => {
|
||||
const result = await cancelCallback(lead.id);
|
||||
if (!result.ok) {
|
||||
setError(result.error);
|
||||
setConfirmingCancel(false);
|
||||
return;
|
||||
}
|
||||
router.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<TR>
|
||||
<TD>
|
||||
<Pill>{lead.campaign.name}</Pill>
|
||||
</TD>
|
||||
<TD className="text-foreground">{lead.name ?? "—"}</TD>
|
||||
<TD className="font-mono text-muted-foreground">{lead.phoneNormalized}</TD>
|
||||
<TD className="font-mono tabular-nums text-muted-foreground">{lead.attemptCount}</TD>
|
||||
<TD>
|
||||
{rescheduling ? (
|
||||
<Input type="datetime-local" value={when} onChange={(e) => setWhen(e.target.value)} disabled={pending} className="h-8 w-52" />
|
||||
) : (
|
||||
<span className="text-muted-foreground">{lead.nextAttemptAt ? formatDateTime(lead.nextAttemptAt) : "—"}</span>
|
||||
)}
|
||||
</TD>
|
||||
<TD>
|
||||
<div className="flex items-center justify-end gap-2">
|
||||
{error && <span className="text-xs text-destructive">{error}</span>}
|
||||
<Button type="button" variant="ghost" size="sm" onClick={onReschedule} disabled={pending}>
|
||||
<CalendarClock className="h-3.5 w-3.5" aria-hidden />
|
||||
{rescheduling ? "Confirmar" : "Remarcar"}
|
||||
</Button>
|
||||
{!rescheduling && (
|
||||
<Button type="button" variant="ghost" size="sm" onClick={onRequeue} disabled={pending} title="Tentar de novo agora, sem esperar a data">
|
||||
<PhoneForwarded className="h-3.5 w-3.5" aria-hidden />
|
||||
Tentar agora
|
||||
</Button>
|
||||
)}
|
||||
{!rescheduling && (
|
||||
<Button
|
||||
type="button"
|
||||
variant={confirmingCancel ? "destructive" : "ghost"}
|
||||
size="sm"
|
||||
onClick={onCancel}
|
||||
disabled={pending}
|
||||
aria-label={confirmingCancel ? `Confirmar cancelamento do callback de ${lead.phoneNormalized}` : `Cancelar callback de ${lead.phoneNormalized}`}
|
||||
>
|
||||
<Trash2 className="h-3.5 w-3.5" aria-hidden />
|
||||
{confirmingCancel ? "Confirmar" : ""}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</TD>
|
||||
</TR>
|
||||
);
|
||||
}
|
||||
10
apps/frontend/src/app/app/discador/callbacks/page.tsx
Normal file
10
apps/frontend/src/app/app/discador/callbacks/page.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import { requireSession } from "@/lib/session";
|
||||
import { apiFetch } from "@/lib/api";
|
||||
import type { CallbackLead } from "@/lib/campaign-types";
|
||||
import { CallbacksView } from "./callbacks-view";
|
||||
|
||||
export default async function CallbacksPage() {
|
||||
const session = await requireSession();
|
||||
const callbacks = await apiFetch<CallbackLead[]>("/leads/callbacks", session.accessToken);
|
||||
return <CallbacksView callbacks={callbacks} />;
|
||||
}
|
||||
@@ -42,8 +42,11 @@ export const TENANT_NAV: NavSection[] = [
|
||||
href: "/app/discador/leads",
|
||||
description: "Leads de uma campanha — buscar, adicionar, remover",
|
||||
},
|
||||
{ label: "Importações" },
|
||||
{ label: "Callbacks" },
|
||||
{
|
||||
label: "Callbacks",
|
||||
href: "/app/discador/callbacks",
|
||||
description: "Leads que pediram retorno em outro horário — remarcar, tentar agora ou cancelar",
|
||||
},
|
||||
{
|
||||
label: "Lista de Bloqueio",
|
||||
href: "/app/discador/bloqueio",
|
||||
@@ -177,7 +180,11 @@ export const TENANT_NAV: NavSection[] = [
|
||||
href: "/app/administracao/perfis",
|
||||
description: "O que cada papel pode fazer neste tenant",
|
||||
},
|
||||
{ label: "Configurações" },
|
||||
{
|
||||
label: "Configurações",
|
||||
href: "/app/administracao/configuracoes",
|
||||
description: "Dados do tenant — nome fantasia, fuso, idioma, privacidade de IA",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
@@ -16,3 +16,25 @@ export const TENANT_ROLE_OPTIONS: { key: string; name: string }[] = [
|
||||
{ key: "supervisor", name: "Supervisor" },
|
||||
{ key: "agent", name: "Agente" },
|
||||
];
|
||||
|
||||
export interface TenantSettings {
|
||||
id: string;
|
||||
code: string;
|
||||
legalName: string;
|
||||
tradeName: string | null;
|
||||
taxId: string | null;
|
||||
status: "TRIAL" | "ACTIVE" | "SUSPENDED" | "PAST_DUE" | "CANCELLED";
|
||||
timezone: string;
|
||||
locale: string;
|
||||
billingCurrency: string;
|
||||
telephonyDomain: string | null;
|
||||
aiPrivacyLevel: "AI_OFF" | "TRANSCRIPTION_ONLY" | "TRANSCRIPTION_AND_ANALYSIS";
|
||||
plan: { key: string; name: string };
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export const AI_PRIVACY_LEVEL_LABELS: Record<string, string> = {
|
||||
AI_OFF: "Desligada — nenhum áudio/transcrição sai deste tenant",
|
||||
TRANSCRIPTION_ONLY: "Só transcrição — sem análise por IA",
|
||||
TRANSCRIPTION_AND_ANALYSIS: "Transcrição e análise por IA",
|
||||
};
|
||||
|
||||
@@ -88,6 +88,10 @@ export interface Lead {
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface CallbackLead extends Lead {
|
||||
campaign: { id: string; name: string };
|
||||
}
|
||||
|
||||
export const LEAD_STATUS_LABELS: Record<string, string> = {
|
||||
NEW: "Novo",
|
||||
READY: "Pronto",
|
||||
|
||||
Reference in New Issue
Block a user