PageSourceSearch

https://plataforma.sabioadv.com.br/assets/Tarefas-CT9o20-B.js

js sabioadv.com.br collected 2026-10-04 12:23:55 UTC 7,290 bytes, 1 lines download raw bytes

1import{r as h,j as t}from"./index-SGT5r0KW.js";import{u as T,P as j}from"./useTeamPermissions-CgKgY9cb.js";import{u as B}from"./useRequirePermission-DomfweaO.js";import{o as M,r as y,a6 as E,I as R,a as P,aA as F,aB as A,J as N}from"./bootstrapApp-DqY-bpl_.js";import{s as x}from"./client-B7OYBDmk.js";import{T as K}from"./TopBar-CdbYr14u.js";import{B as H}from"./BackNavigation-CZ4l_ZAa.js";import{a as p}from"./utils-DpIXgyu3.js";import{C as Q}from"./checkbox-CZVcGrGh.js";import{u as $}from"./index-O3ZtSVup.js";import{L as z}from"./list-todo-ExEiCo5F.js";import{C as G}from"./x-B6pAtZ9Q.js";import{a as J}from"./sparkles-CxgsQTxW.js";import{E as O}from"./video-CTLl-Mi6.js";import"./index-Ce6r6pTY.js";import"./users-DqDjcKnn.js";import"./trending-up-Ci-j66HZ.js";import"./arrow-up-right-DnCWP4HN.js";import"./sortable.esm-1-wN07lt.js";import"./scale-DeMStf9Q.js";import"./logo-sabio-adv-UxKYOloV.js";import"./user-check-DJg8cfUw.js";import"./pen-CE_IEw1K.js";import"./user-plus-LbKG0wXe.js";import"./useHasFacebookToken-CBrW3Nym.js";const v=[{id:"atrasadas",titulo:"Atrasadas",tom:"text-red-400"},{id:"hoje",titulo:"Hoje",tom:"text-emerald-400"},{id:"semana",titulo:"Próximos 7 dias",tom:"text-white/80"},{id:"futuras",titulo:"Futuras",tom:"text-white/60"},{id:"sem_data",titulo:"Sem data",tom:"text-white/40"},{id:"concluidas",titulo:"Concluídas",tom:"text-white/40"}],Y=i=>new Date(i.getFullYear(),i.getMonth(),i.getDate()),U=(i,n=new Date)=>{if(i.completed)return"concluidas";if(!i.due_date)return"sem_data";const d=new Date(i.due_date),c=Y(n),l=new Date(c);l.setDate(l.getDate()+1);const m=new Date(c);return m.setDate(m.getDate()+8),d<c?"atrasadas":d<l?"hoje":d<m?"semana":"futuras"},V=i=>{if(!i)return"sem data";const n=new Date(i),d=n.getHours()!==0||n.getMinutes()!==0;return n.toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric",...d?{hour:"2-digit",minute:"2-digit"}:{}})};function Ne(){B(j.tarefasAcessar);const{can:i}=T(),n=i(j.tarefasEditar),d=$(),c=M(),[l,m]=h.useState(""),[f,C]=h.useState(!1),[S,_]=h.useState(new Set(["concluidas"])),{data:o}=y({queryKey:["tarefas-contexto"],queryFn:async()=>{var r;const{data:{session:e}}=await x.auth.getSession(),a=(r=e==null?void 0:e.user)==null?void 0:r.id;if(!a)return null;const{data:s}=await x.from("profiles").select("company_id").eq("id",a).maybeSingle();return{userId:a,companyId:(s==null?void 0:s.company_id)??null}}}),{data:w=[],isLoading:g}=y({queryKey:["tarefas-lista",o==null?void 0:o.companyId],enabled:!!(o!=null&&o.companyId),queryFn:async()=>{const{data:e,error:a}=await x.from("tasks").select("id, name, description, due_date, completed, created_by, lead_id, lead:leads(nome)").eq("company_id",o.companyId).order("due_date",{ascending:!0,nullsFirst:!1}).limit(2e3);if(a)throw a;return e||[]}}),u=h.useMemo(()=>{const e=l.trim().toLowerCase();return w.filter(a=>{var s;return f&&a.created_by!==(o==null?void 0:o.userId)?!1:e?(a.name||"").toLowerCase().includes(e)||(a.description||"").toLowerCase().includes(e)||(((s=a.lead)==null?void 0:s.nome)||"").toLowerCase().includes(e):!0})},[w,l,f,o==null?void 0:o.userId]),D=h.useMemo(()=>{const e=new Map;for(const a of v)e.set(a.id,[]);for(const a of u)e.get(U(a)).push(a);return e},[u]),k=async e=>{const a=!e.completed,{error:s}=await x.from("tasks").update({completed:a}).eq("id",e.id);if(s){console.error("[Tarefas] concluir:",s),N.error("Não foi possível atualizar a tarefa");return}N.success(a?"Tarefa concluída":"Tarefa reaberta"),c.invalidateQueries({queryKey:["tarefas-lista"]})},q=e=>{e.lead_id&&d(`/leads?lead=${e.lead_id}&tab=tasks`)},I=e=>{_(a=>{const s=new Set(a);return s.has(e)?s.delete(e):s.add(e),s})},L=u.filter(e=>!e.completed).length;return t.jsxs("div",{className:"min-h-screen analytics-dashboard",children:[t.jsx(K,{}),t.jsx(H,{className:"!bg-[#0f1419] border-emerald-500/20",buttonClassName:"!text-white hover:!text-emerald-300 hover:bg-emerald-500/10"}),t.jsxs("main",{className:"container mx-auto px-6 py-8 max-w-5xl space-y-5",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"p-2.5 rounded-xl bg-emerald-500/10 border border-emerald-500/20",children:t.jsx(z,{className:"w-6 h-6 text-emerald-400"})}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-semibold text-white",children:"Tarefas"}),t.jsx("p",{className:"text-sm text-white/50",children:g?"Carregando...":`${L} em aberto · ${u.length} no total`})]})]}),t.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[t.jsxs("div",{className:"relative flex-1",children:[t.jsx(E,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-white/40"}
1),t.jsx(R,{value:l,onChange:e=>m(e.target.value),placeholder:"Buscar por tarefa, descrição ou lead...",className:"pl-9 h-11 bg-white/[0.03] border-white/[0.06] text-white placeholder:text-white/30 focus:border-white/20 focus:ring-0 rounded-xl"})]}),t.jsx(P,{variant:"outline",onClick:()=>C(e=>!e),className:p("h-11 rounded-xl border-white/[0.06] bg-white/[0.03] text-white/70 hover:bg-white/[0.06] hover:text-white",f&&"bg-emerald-500/15 border-emerald-500/30 text-emerald-400 hover:bg-emerald-500/25 hover:text-emerald-300"),children:"Só as minhas"})]}),g?t.jsx("div",{className:"flex items-center justify-center py-16",children:t.jsx(F,{className:"w-6 h-6 animate-spin text-emerald-400"})}):u.length===0?t.jsx("div",{className:"text-center py-16 text-white/40 text-sm",children:w.length===0?"Nenhuma tarefa cadastrada ainda. Crie tarefas pelo card do lead, no CRM.":"Nenhuma tarefa encontrada com esses filtros."}):t.jsx("div",{className:"space-y-4",children:v.map(e=>{const a=D.get(e.id)??[];if(a.length===0)return null;const s=S.has(e.id);return t.jsxs("section",{className:"rounded-2xl border border-white/[0.06] bg-[#0d1117]",children:[t.jsxs("button",{type:"button",onClick:()=>I(e.id),className:"w-full flex items-center gap-2 px-4 py-3 text-left",children:[s?t.jsx(G,{className:"w-4 h-4 text-white/40"}):t.jsx(J,{className:"w-4 h-4 text-white/40"}),t.jsx("span",{className:p("text-sm font-semibold",e.tom),children:e.titulo}),t.jsx(A,{variant:"secondary",className:"ml-1 bg-white/[0.06] text-white/60 border-white/[0.06]",children:a.length})]}),!s&&t.jsx("ul",{className:"divide-y divide-white/[0.06]",children:a.map(r=>{var b;return t.jsxs("li",{className:"flex items-start gap-3 px-4 py-3",children:[t.jsx(Q,{checked:!!r.completed,disabled:!n,onCheckedChange:()=>k(r),className:"mt-0.5 data-[state=checked]:bg-emerald-500 data-[state=checked]:border-emerald-500"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:p("text-sm text-white/90",r.completed&&"line-through text-white/40"),children:r.name}),r.description&&t.jsx("p",{className:"text-xs text-white/40 mt-0.5 line-clamp-2",children:r.description}),t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 mt-1.5 text-xs text-white/40",children:[t.jsx("span",{className:p(e.id==="atrasadas"&&"text-red-400"),children:V(r.due_date)}),((b=r.lead)==null?void 0:b.nome)&&t.jsxs("button",{type:"button",onClick:()=>q(r),className:"inline-flex items-center gap-1 text-emerald-400 hover:text-emerald-300",children:[r.lead.nome,t.jsx(O,{className:"w-3 h-3"})]})]})]})]},r.id)})})]},e.id)})})]})]})}export{U as classificarTarefa,Ne as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.