1import{a6 as le,j as e,C as p,n as f,q as v,o as y,a_ as oe,a9 as re,N as F,U as ie,ao as $,ap as N,bE as O,bj as ce,r as G,ar as W,au as X,aL as Q,aM as m,aN as x,aO as u,_ as S,aP as h,$ as A,a0 as M,a1 as D,a2 as n,bk as z,aQ as j,I as C,T as Y,b2 as de,B as k,u as me,D as xe,h as ue,i as he,k as je,l as pe,aI as ve,b as T,M as H,P as ge,p as U,Y as fe,X as Ne,G as be,W as Z,av as ye,at as we,a3 as Ce}from"./index-xEYNsQ86.js";import{T as _e,a as Pe,b as E,c as I}from"./tabs-BS6UYBBC.js";import{S as Ve}from"./sidebar-BmFngE0M.js";import{A as Se}from"./AppSidebar-B09EVWG5.js";import{u as te,a as J,b as B,c as Ae,d as Me}from"./useVeterinariosPermissions-RG1Vt6Cb.js";import{S as _}from"./skeleton-Cyx8N-KW.js";import{a as De}from"./addDays-CinzTmrS.js";import{i as Ee}from"./isAfter-BPXtdeZ4.js";import{i as Ie}from"./isBefore-DqhbcPRD.js";import{f as L}from"./format-DibD1CwZ.js";import{t as Te,p as q}from"./pt-BR-4Gck0JTF.js";import{u as ke}from"./useLoteSystem-CqoEOjB3.js";import{P as Le}from"./plus-NyGkWfa2.js";import{C as qe}from"./circle-check-ZOh1o0aN.js";import{C as ne}from"./circle-x-7ZbeRtE5.js";import{u as Re,a as Fe,b as Oe,c as He}from"./useConvitesVeterinario-B25K2nXC.js";import{S as Be}from"./send-JR03L52m.js";import{C as ee}from"./clipboard-list-BSBCUEbL.js";import"./use-mobile-EdzfK1Ju.js";import"./separator-Cr5XKA_h.js";import"./avatar-BBc0POt5.js";import"./log-out-D-SRMAVf.js";import"./calculator-BwRLJFXG.js";import"./shopping-cart-P5A4ywIl.js";import"./paw-print-cLmsESXW.js";import"./trophy-Bw8B9P9X.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const ze=le("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);function se(a){return+Te(a)<Date.now()}function Ge(){const{data:a,isLoading:r}=te(),{data:t,isLoading:s}=J(),{permissions:b}=B();if(r||s)return e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[...Array(4)].map((o,w)=>e.jsxs(p,{children:[e.jsx(f,{children:e.jsx(_,{className:"h-4 w-32"})}),e.jsx(v,{children:e.jsx(_,{className:"h-8 w-16"})})]},w))});const i=new Date,d=De(i,7),P=(a==null?void 0:a.filter(o=>o.status_geral==="planejada"))||[],V=(a==null?void 0:a.filter(o=>{const w=new Date(o.data_visita);return Ee(w,i)&&Ie(w,d)}))||[],c=(a==null?void 0:a.filter(o=>o.requer_acao_imediata))||[],l=(t==null?void 0:t.filter(o=>o.ativo))||[],g=b.isProfissional?(a==null?void 0:a.filter(o=>o.profissional_id===b.profissionalId))||[]:[];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[e.jsxs(p,{children:[e.jsxs(f,{className:"flex flex-row items-center justify-between pb-2",children:[e.jsx(y,{className:"text-sm font-medium",children:"Visitas Pendentes"}),e.jsx(oe,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(v,{children:[e.jsx("div",{className:"text-2xl font-bold",children:P.length}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Aguardando conclusão"})]})]}),e.jsxs(p,{children:[e.jsxs(f,{className:"flex flex-row items-center justify-between pb-2",children:[e.jsx(y,{className:"text-sm font-medium",children:"Próximas Visitas"}),e.jsx(re,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(v,{children:[e.jsx("div",{className:"text-2xl font-bold",children:V.length}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Próximos 7 dias"})]})]}),e.jsxs(p,{children:[e.jsxs(f,{className:"flex flex-row items-center justify-between pb-2",children:[e.jsx(y,{className:"text-sm font-medium",children:"Ação Imediata"}),e.jsx(F,{className:"h-4 w-4 text-destructive"})]}),e.jsxs(v,{children:[e.jsx("div",{className:"text-2xl font-bold text-destructive",children:c.length}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Requerem atenção urgente"})]})]}),e.jsxs(p,{children:[e.jsxs(f,{className:"flex flex-row items-center justify-between pb-2",children:[e.jsx(y,{className:"text-sm font-medium",children:"Profissionais Ativos"}),e.jsx(ie,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(v,{children:[e.jsx("div",{className:"text-2xl font-bold",children:l.length}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"DisponÃveis para atendimento"})]})]})]}),b.isProfissional&&g.length>0&&e.jsxs(p,{children:[e.jsx(f,{children:e.jsx(y,{children:"Minhas Próximas Visitas"})}),e.jsx(v,{children:e.jsx("div",{className:"space-y-4",children:g.slice(0,5).map(o=>{var w,R;return e.jsxs("div",{className:"flex items-center justify-between border-b pb-2 last:border-0",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((w=o.lote)==null?void 0:w.nome)||`Lote ${(R=o.lote)==null?void 0:R.codigo}`}),e.jsx("p",{className:"text-sm text-muted-foreground",children:L(new Date(o.data_visita),"d 'de' MMMM 'de' yyyy",{locale:q})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[o.requer_acao_imediata&&e.jsx(F,{className:"h-4 w-4 text-destructive"}),e.jsx("span",{className:"text-sm capitalize",children:o.status_geral||"pendente"})]})]},o.id)})})})]}),c.length>0&&e.jsxs(p,{className:"border-destructive",children:[e.jsx(f,{children:e.jsx(y,{className:"text-destructive",children:"Visitas Requerendo Ação Imediata"})}),e.jsx(v,{children:e.jsx("div",{className:"space-y-4",children:c.map(o=>{var w,R,K;return e.jsxs("div",{className:"flex items-center justify-between border-b pb-2 last:border-0",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((w=o.lote)==null?void 0:w.nome)||`Lote ${(R=o.lote)==null?void 0:R.codigo}`}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Profissional: ",(K=o.profissional)==null?void 0:K.nome]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:L(new Date(o.data_visita),"d 'de' MMMM 'de' yyyy",{locale:q})})]}),e.jsx(F,{className:"h-5 w-5 text-destructive"})]},o.id)})})})]})]})}const Ue=$({profissional_id:N().min(1,"Selecione um profissional"),lote_id:N().optional(),area:O(["avicultura","bovinocultura","suinocultura","ovinocultura","equideocultura"]),data_visita:N().min(1,"Data é obrigatória"),hora_inicio:N().optional(),hora_fim:N().optional(),observacoes_gerais:N().optional(),requer_acao_imediata:ce().default(!1)});function $e({onSuccess:a}){const r=Ae(),{data:t}=J(),{useLotesWithDetails:s}=ke(),{data:b}=s(),{permissions:i}=B();G.useState(!1);
6const d=W({resolver:X(Ue),defaultValues:{area:"avicultura",data_visita:new Date().toISOString().split("T")[0],requer_acao_imediata:!1}});G.useEffect(()=>{i.profissionalId&&!d.getValues("profissional_id")&&d.setValue("profissional_id",i.profissionalId)},[i.profissionalId,d]);const P=d.watch("area"),V=l=>{r.mutate(l,{onSuccess:()=>{d.reset(),a==null||a()}})},c=(t==null?void 0:t.filter(l=>l.ativo))||[];return e.jsx(Q,{...d,children:e.jsxs("form",{onSubmit:d.handleSubmit(V),className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(m,{control:d.control,name:"profissional_id",render:({field:l})=>e.jsxs(x,{children:[e.jsx(u,{children:"Profissional *"}),e.jsxs(S,{onValueChange:l.onChange,value:l.value,disabled:!!i.profissionalId,children:[e.jsx(h,{children:e.jsx(A,{children:e.jsx(M,{placeholder:"Selecione o profissional"})})}),e.jsx(D,{children:c.map(g=>e.jsxs(n,{value:g.id,children:[g.nome," - ",g.especialidade]},g.id))})]}),i.profissionalId&&e.jsx(z,{children:"Você está registrando uma visita como profissional responsável"}),e.jsx(j,{})]})}),e.jsx(m,{control:d.control,name:"area",render:({field:l})=>e.jsxs(x,{children:[e.jsx(u,{children:"Ãrea de Atuação *"}),e.jsxs(S,{onValueChange:l.onChange,value:l.value,children:[e.jsx(h,{children:e.jsx(A,{children:e.jsx(M,{placeholder:"Selecione a área"})})}),e.jsxs(D,{children:[e.jsx(n,{value:"avicultura",children:"Avicultura"}),e.jsx(n,{value:"bovinocultura",children:"Bovinocultura"}),e.jsx(n,{value:"suinocultura",children:"Suinocultura"}),e.jsx(n,{value:"ovinocultura",children:"Ovinocultura"}),e.jsx(n,{value:"equideocultura",children:"Equideocultura"})]})]}),e.jsx(j,{})]})}),P==="avicultura"&&e.jsx(m,{control:d.control,name:"lote_id",render:({field:l})=>e.jsxs(x,{children:[e.jsx(u,{children:"Lote (Opcional)"}),e.jsxs(S,{onValueChange:l.onChange,value:l.value,children:[e.jsx(h,{children:e.jsx(A,{children:e.jsx(M,{placeholder:"Selecione o lote"})})}),e.jsx(D,{children:b==null?void 0:b.map(g=>e.jsxs(n,{value:g.id,children:[g.nome||g.codigo," - ",g.raca]},g.id))})]}),e.jsx(z,{children:"Selecione o lote de aves associado à visita, se aplicável"}),e.jsx(j,{})]})}),e.jsx(m,{control:d.control,name:"data_visita",render:({field:l})=>e.jsxs(x,{children:[e.jsx(u,{children:"Data da Visita *"}),e.jsx(h,{children:e.jsx(C,{type:"date",...l})}),e.jsx(j,{})]})}),e.jsx(m,{control:d.control,name:"hora_inicio",render:({field:l})=>e.jsxs(x,{children:[e.jsx(u,{children:"Hora InÃcio"}),e.jsx(h,{children:e.jsx(C,{type:"time",...l})}),e.jsx(j,{})]})}),e.jsx(m,{control:d.control,name:"hora_fim",render:({field:l})=>e.jsxs(x,{children:[e.jsx(u,{children:"Hora Fim"}),e.jsx(h,{children:e.jsx(C,{type:"time",...l})}),e.jsx(j,{})]})})]}),e.jsx(m,{control:d.control,name:"observacoes_gerais",render:({field:l})=>e.jsxs(x,{children:[e.jsx(u,{children:"Observações Gerais"}),e.jsx(h,{children:e.jsx(Y,{placeholder:"Descreva o motivo da visita, problemas identificados, etc.",className:"min-h-[100px]",...l})}),e.jsx(j,{})]})}),e.jsx(m,{control:d.control,name:"requer_acao_imediata",render:({field:l})=>e.jsxs(x,{className:"flex flex-row items-start space-x-3 space-y-0 rounded-md border p-4",children:[e.jsx(h,{children:e.jsx(de,{checked:l.value,onCheckedChange:l.onChange})}),e.jsxs("div",{className:"space-y-1 leading-none",children:[e.jsxs(u,{className:"flex items-center gap-2",children:[e.jsx(F,{className:"h-4 w-4 text-destructive"}),"Requer Ação Imediata"]}),e.jsx(z,{children:"Marque se a situação identificada requer atenção urgente"})]})]})}),e.jsx("div",{className:"flex justify-end gap-2",children:e.jsx(k,{type:"submit",disabled:r.isPending,children:r.isPending?"Registrando...":"Registrar Visita"})})]})})}function ae({minhasVisitas:a=!1,loteId:r}){const t=me(),{data:s,isLoading:b}=te(r),{permissions:i}=B(),[d,P]=G.useState(!1);if(b)return e.jsx("div",{className:"space-y-4",children:[...Array(3)].map((c,l)=>e.jsxs(p,{children:[e.jsx(f,{children:e.jsx(_,{className:"h-4 w-48"})}),e.jsx(v,{children:e.jsx(_,{className:"h-4 w-full"})})]},l))});let V=s||[];return a&&i.isProfissional&&(V=V.filter(c=>c.profissional_id===i.profissionalId)),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h2",{className:"text-2xl font-bold",children:a?"Minhas Visitas":"Todas as Visitas"}),i.canCreateVisitas&&e.jsxs(xe,{open:d,onOpenChange:P,children:[e.jsx(ue,{asChild:!0,children:e.jsxs(k,{children:[e.jsx(Le,{className:"h-4 w-4 mr-2"}),"Nova Visita"]})}),e.jsxs(he,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(je,{children:e.jsx(pe,{children:"Registrar Nova Visita"})}),e.jsx($e,{onSuccess:()=>P(!1)})]})]})]}),V.length===0?e.jsx(p,{children:e.jsx(v,{className:"py-8 text-center text-muted-foreground",children:"Nenhuma visita encontrada"})}):e.jsx("div",{className:"grid gap-4",children:V.map(c=>{var l,g,o;return e.jsxs(p,{className:c.requer_acao_imediata?"border-destructive":"",children:[e.jsx(f,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(y,{className:"flex items-center gap-2",children:[((l=c.lote)==null?void 0:l.nome)||`Lote ${(g=c.lote)==null?void 0:g.codigo}`,c.requer_acao_imediata&&e.jsx(F,{className:"h-5 w-5 text-destructive"})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(re,{className:"h-4 w-4"}),L(new Date(c.data_visita),"d 'de' MMMM 'de' yyyy",{locale:q})]}),e.jsxs("span",{children:["Ãrea: ",c.area]}),e.jsxs("span",{className:"capitalize",children:["Status: ",c.status_geral||"planejada"]})]})]}),e.jsxs(k,{variant:"outline",size:"sm",onClick:()=>t(`/assistencia-tecnica/visita/${c.id}`),children:[e.jsx(ve,{className:"h-4 w-4 mr-2"}),"Ver Detalhes"]})]})}),e.jsx(v,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Profissional:"}),e.jsx("span",{className:"font-medium",children:(o=c.profissional)==null?void 0:o.nome})]}),c.hora_inicio&&c.hora_fim&&e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Horário:"}),e.jsxs("span",{children:[c.hora_inicio," - ",c.hora_fim]})]}),c.observacoes_gerais&&e.jsxs("div",{className:"mt-2 text-sm",children:[e.jsx("p",{className:"text-muted-foreground mb-1",children:"Observações:"}),e.jsx("p",{className:"line-clamp-2",children:c.observacoes_gerais})]})]})})]},c.id)})})]})}function We(){const{data:a,isLoading:r}=J();return r?e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[...Array(6)].map((t,s)=>e.jsxs(p,{children:[e.jsx(f,{children:e.jsx(_,{className:"h-4 w-32"})}),e.jsx(v,{children:e.jsx(_,{className:"h-4 w-full"})})]},s))}):!a||a.length===0?e.jsx(p,{children:e.jsx(v,{className:"py-8 text-center text-muted-foreground",children:"Nenhum profissional cadastrado"})}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Profissionais Cadastrados"}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:a.map(t=>e.jsxs(p,{children:[e.jsx(f,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(y,{className:"text-lg",children:t.nome}),t.ativo?e.jsx(qe,{className:"h-5 w-5 text-green-500"}):e.jsx(ne,{className:"h-5 w-5 text-muted-foreground"})]})}),e.jsxs(v,{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{variant:"secondary",className:"mr-2",children:t.especialidade}),e.jsx(T,{variant:"outline",children:t.area_atuacao})]}),t.crmv&&e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"CRMV:"}),e.jsx("span",{className:"font-medium",children:t.crmv})]}),t.crmv_status&&e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Status CRMV:"}),e.jsx(T,{variant:t.crmv_status==="ativo"?"default":"secondary",children:t.crmv_status})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(H,{className:"h-4 w-4"}),e.jsx("span",{className:"truncate",children:t.email})]}),t.telefone&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ge,{className:"h-4 w-4"}),e.jsx("span",{children:t.telefone})]}),t.observacoes&&e.jsx("div",{className:"mt-2 pt-2 border-t",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:t.observacoes})})]})]},t.id))})]})}const Xe=$({nome:N().min(1,"Nome é obrigatório"),email:N().email("Email inválido"),telefone:N().optional(),crmv:N().optional(),crmv_status:O(["ativo","inativo","suspenso","cancelado"]).optional(),especialidade:O(["clinica_geral","nutricao","reproducao","cirurgia","diagnostico_imagem","laboratorio"]),area_atuacao:O(["avicultura","bovinocultura","suinocultura","ovinocultura","equideocultura"]),observacoes:N().optional()});
6function Qe(){const a=Me(),r=W({resolver:X(Xe),defaultValues:{nome:"",email:"",telefone:"",crmv:"",especialidade:"clinica_geral",area_atuacao:"avicultura",observacoes:""}}),t=s=>{a.mutate(s,{onSuccess:()=>{r.reset()}})};return e.jsxs(p,{children:[e.jsx(f,{children:e.jsx(y,{children:"Cadastrar Novo Profissional"})}),e.jsx(v,{children:e.jsx(Q,{...r,children:e.jsxs("form",{onSubmit:r.handleSubmit(t),className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(m,{control:r.control,name:"nome",render:({field:s})=>e.jsxs(x,{children:[e.jsx(u,{children:"Nome Completo *"}),e.jsx(h,{children:e.jsx(C,{placeholder:"Nome do profissional",...s})}),e.jsx(j,{})]})}),e.jsx(m,{control:r.control,name:"email",render:({field:s})=>e.jsxs(x,{children:[e.jsx(u,{children:"Email *"}),e.jsx(h,{children:e.jsx(C,{type:"email",placeholder:"[email protected]",...s})}),e.jsx(j,{})]})}),e.jsx(m,{control:r.control,name:"telefone",render:({field:s})=>e.jsxs(x,{children:[e.jsx(u,{children:"Telefone"}),e.jsx(h,{children:e.jsx(C,{placeholder:"(00) 00000-0000",...s})}),e.jsx(j,{})]})}),e.jsx(m,{control:r.control,name:"crmv",render:({field:s})=>e.jsxs(x,{children:[e.jsx(u,{children:"CRMV"}),e.jsx(h,{children:e.jsx(C,{placeholder:"CRMV-UF 00000",...s})}),e.jsx(j,{})]})}),e.jsx(m,{control:r.control,name:"crmv_status",render:({field:s})=>e.jsxs(x,{children:[e.jsx(u,{children:"Status CRMV"}),e.jsxs(S,{onValueChange:s.onChange,value:s.value,children:[e.jsx(h,{children:e.jsx(A,{children:e.jsx(M,{placeholder:"Selecione o status"})})}),e.jsxs(D,{children:[e.jsx(n,{value:"ativo",children:"Ativo"}),e.jsx(n,{value:"inativo",children:"Inativo"}),e.jsx(n,{value:"suspenso",children:"Suspenso"}),e.jsx(n,{value:"cancelado",children:"Cancelado"})]})]}),e.jsx(j,{})]})}),e.jsx(m,{control:r.control,name:"especialidade",render:({field:s})=>e.jsxs(x,{children:[e.jsx(u,{children:"Especialidade *"}),e.jsxs(S,{onValueChange:s.onChange,value:s.value,children:[e.jsx(h,{children:e.jsx(A,{children:e.jsx(M,{placeholder:"Selecione a especialidade"})})}),e.jsxs(D,{children:[e.jsx(n,{value:"clinica_geral",children:"ClÃnica Geral"}),e.jsx(n,{value:"nutricao",children:"Nutrição"}),e.jsx(n,{value:"reproducao",children:"Reprodução"}),e.jsx(n,{value:"cirurgia",children:"Cirurgia"}),e.jsx(n,{value:"diagnostico_imagem",children:"Diagnóstico por Imagem"}),e.jsx(n,{value:"laboratorio",children:"Laboratório"})]})]}),e.jsx(j,{})]})}),e.jsx(m,{control:r.control,name:"area_atuacao",render:({field:s})=>e.jsxs(x,{children:[e.jsx(u,{children:"Ãrea de Atuação *"}),e.jsxs(S,{onValueChange:s.onChange,value:s.value,children:[e.jsx(h,{children:e.jsx(A,{children:e.jsx(M,{placeholder:"Selecione a área"})})}),e.jsxs(D,{children:[e.jsx(n,{value:"avicultura",children:"Avicultura"}),e.jsx(n,{value:"bovinocultura",children:"Bovinocultura"}),e.jsx(n,{value:"suinocultura",children:"Suinocultura"}),e.jsx(n,{value:"ovinocultura",children:"Ovinocultura"}),e.jsx(n,{value:"equideocultura",children:"Equideocultura"})]})]}),e.jsx(j,{})]})})]}),e.jsx(m,{control:r.control,name:"observacoes",render:({field:s})=>e.jsxs(x,{children:[e.jsx(u,{children:"Observações"}),e.jsx(h,{children:e.jsx(Y,{placeholder:"Informações adicionais sobre o profissional",className:"min-h-[100px]",...s})}),e.jsx(j,{})]})}),e.jsx("div",{className:"flex justify-end",children:e.jsx(k,{type:"submit",disabled:a.isPending,children:a.isPending?"Cadastrando...":"Cadastrar Profissional"})})]})})})]})}const Ye=$({email:N().email("Email inválido"),nome_convidado:N().optional(),especialidade:N().min(1,"Especialidade é obrigatória"),area_atuacao:N().min(1,"Ãrea de atuação é obrigatória"),observacoes:N().optional()});function Je(){const a=Re(),r=W({resolver:X(Ye),defaultValues:{email:"",nome_convidado:"",especialidade:"",area_atuacao:"",observacoes:""}}),t=async s=>{const b={email:s.email||"",nome_convidado:s.nome_convidado,especialidade:s.especialidade||"",area_atuacao:s.area_atuacao||"",observacoes:s.observacoes};await a.mutateAsync(b),r.reset()};return e.jsxs(p,{children:[e.jsxs(f,{children:[e.jsxs(y,{className:"flex items-center gap-2",children:[e.jsx(Be,{className:"h-5 w-5"}),"Enviar Convite para Profissional"]}),e.jsx(U,{children:"O profissional receberá um email com link para criar conta e completar o cadastro"})]}),e.jsx(v,{children:e.jsx(Q,{...r,children:e.jsxs("form",{onSubmit:r.handleSubmit(t),className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(m,{control:r.control,name:"email",render:({field:s})=>e.jsxs(x,{children:[e.jsx(u,{children:"Email *"}),e.jsx(h,{children:e.jsx(C,{placeholder:"[email protected]",...s})}),e.jsx(j,{})]})}),e.jsx(m,{control:r.control,name:"nome_convidado",render:({field:s})=>e.jsxs(x,{children:[e.jsx(u,{children:"Nome Completo"}),e.jsx(h,{children:e.jsx(C,{placeholder:"Nome do profissional",...s})}),e.jsx(j,{})]})}),e.jsx(m,{control:r.control,name:"especialidade",render:({field:s})=>e.jsxs(x,{children:[e.jsx(u,{children:"Especialidade *"}),e.jsxs(S,{onValueChange:s.onChange,value:s.value,children:[e.jsx(h,{children:e.jsx(A,{children:e.jsx(M,{placeholder:"Selecione a especialidade"})})}),e.jsxs(D,{children:[e.jsx(n,{value:"nutricao_avicola",children:"Nutrição AvÃcola"}),e.jsx(n,{value:"sanidade_avicola",children:"Sanidade AvÃcola"}),e.jsx(n,{value:"reproducao_avicola",children:"Reprodução AvÃcola"}),e.jsx(n,{value:"clinica_geral",children:"ClÃnica Geral"}),e.jsx(n,{value:"bem_estar_animal",children:"Bem-Estar Animal"}),e.jsx(n,{value:"gestao_producao",children:"Gestão de Produção"})]})]}),e.jsx(j,{})]})}),e.jsx(m,{control:r.control,name:"area_atuacao",render:({field:s})=>e.jsxs(x,{children:[e.jsx(u,{children:"Ãrea de Atuação *"}),e.jsxs(S,{onValueChange:s.onChange,value:s.value,children:[e.jsx(h,{children:e.jsx(A,{children:e.jsx(M,{placeholder:"Selecione a área"})})}),e.jsxs(D,{children:[e.jsx(n,{value:"postura_comercial",children:"Postura Comercial"}),e.jsx(n,{value:"corte",children:"Corte"}),e.jsx(n,{value:"matrizes",children:"Matrizes"}),e.jsx(n,{value:"incubatorio",children:"Incubatório"}),e.jsx(n,{value:"producao_ovos",children:"Produção de Ovos"})]})]}),e.jsx(j,{})]})})]}),e.jsx(m,{control:r.control,name:"observacoes",render:({field:s})=>e.jsxs(x,{children:[e.jsx(u,{children:"Observações"}),e.jsx(h,{children:e.jsx(Y,{placeholder:"Informações adicionais sobre o convite...",className:"min-h-[100px]",...s})}),e.jsx(j,{})]})}),e.jsx("div",{className:"flex justify-end",children:e.jsx(k,{type:"submit",disabled:a.isPending,children:a.isPending?"Enviando...":"Enviar Convite"})})]})})})]})}function Ke(){const{data:a,isLoading:r}=Fe(),t=Oe(),s=He(),b=(i,d)=>{const P=se(new Date(d));return i==="aceito"?e.jsxs(T,{variant:"default",className:"bg-green-500",children:[e.jsx(be,{className:"h-3 w-3 mr-1"}),"Aceito"]}):i==="cancelado"?e.jsxs(T,{variant:"destructive",children:[e.jsx(ne,{className:"h-3 w-3 mr-1"}),"Cancelado"]}):i==="expirado"||i==="pendente"&&P?e.jsxs(T,{variant:"secondary",children:[e.jsx(Z,{className:"h-3 w-3 mr-1"}),"Expirado"]}):e.jsxs(T,{variant:"outline",className:"bg-yellow-500/10",children:[e.jsx(Z,{className:"h-3 w-3 mr-1"}),"Pendente"]})};return r?e.jsxs(p,{children:[e.jsxs(f,{children:[e.jsx(_,{className:"h-8 w-64"}),e.jsx(_,{className:"h-4 w-96"})]}),e.jsx(v,{className:"space-y-4",children:[1,2,3].map(i=>e.jsx(_,{className:"h-24 w-full"},i))})]}):!a||a.length===0?e.jsxs(p,{children:[e.jsxs(f,{children:[e.jsx(y,{children:"Convites Enviados"}),e.jsx(U,{children:"Gerencie os convites para profissionais veterinários"})]}),e.jsx(v,{children:e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(H,{className:"h-12 w-12 mx-auto mb-4 opacity-20"}),e.jsx("p",{children:"Nenhum convite enviado ainda"})]})})]}):e.jsxs(p,{children:[e.jsxs(f,{children:[e.jsx(y,{children:"Convites Enviados"}),e.jsxs(U,{children:[a.length," convite",a.length!==1?"s":""," enviado",a.length!==1?"s":""]})]}),e.jsx(v,{className:"space-y-4",children:a.map(i=>e.jsx(p,{className:"border-l-4 border-l-primary",children:e.jsx(v,{className:"pt-6",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold",children:i.nome_convidado||i.email}),b(i.status,i.expires_at)]}),i.nome_convidado&&e.jsx("p",{className:"text-sm text-muted-foreground",children:i.email})]}),i.status==="pendente"&&!se(new Date(i.expires_at))&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(k,{variant:"outline",size:"sm",onClick:()=>s.mutate(i),disabled:s.isPending,children:[e.jsx(fe,{className:"h-3 w-3 mr-1"}),"Reenviar"]}),e.jsxs(k,{variant:"ghost",size:"sm",onClick:()=>t.mutate(i.id),disabled:t.isPending,children:[e.jsx(Ne,{className:"h-3 w-3 mr-1"}),"Cancelar"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground",children:"Especialidade"}),e.jsx("p",{className:"font-medium",children:i.especialidade||"-"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground",children:"Ãrea de Atuação"}),e.jsx("p",{className:"font-medium",children:i.area_atuacao||"-"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground",children:"Enviado em"}),e.jsx("p",{className:"font-medium",children:L(new Date(i.created_at),"dd/MM/yyyy HH:mm",{locale:q})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground",children:"Expira em"}),e.jsx("p",{className:"font-medium",children:L(new Date(i.expires_at),"dd/MM/yyyy",{locale:q})})]})]}),i.observacoes&&e.jsxs("div",{className:"border-t pt-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"Observações"}),e.jsx("p",{className:"text-sm",children:i.observacoes})]}),i.accepted_at&&e.jsx("div",{className:"border-t pt-3",children:e.jsxs("p",{className:"text-sm text-green-600",children:["Aceito em ",L(new Date(i.accepted_at),"dd/MM/yyyy HH:mm",{locale:q})]})})]})})},i.id))})]})}function _s(){const{permissions:a}=B(),{isAdmin:r}=ye();return e.jsx(Ve,{children:e.jsxs("div",{className:"flex min-h-screen w-full",children:[e.jsx(Se,{}),e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsxs(we,{children:[e.jsx("title",{children:"Assistência Técnica Veterinária - Fazenda LÃbanus"}),e.jsx("meta",{name:"description",content:"Sistema de gestão de assistência técnica veterinária para acompanhamento de lotes e ações veterinárias"})]}),e.jsxs("main",{className:"flex-1 p-4 md:p-6 lg:p-8 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Assistência Técnica Veterinária"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"Gestão completa de visitas, ações veterinárias e acompanhamento de profissionais"})]}),e.jsxs(_e,{defaultValue:"dashboard",className:"space-y-6",children:[e.jsxs(Pe,{className:"grid w-full grid-cols-2 lg:grid-cols-6 gap-1 sm:gap-2 h-auto p-2 sm:p-3 bg-muted/50 backdrop-blur-sm border shadow-sm rounded-xl",children:[e.jsxs(E,{value:"dashboard",className:"group flex flex-col gap-1 p-2 sm:p-3 h-auto transition-all duration-200 hover:bg-muted/80 data-[state=active]:bg-primary data-[state=active]:text-primary-foreground data-[state=active]:shadow-md rounded-lg bg-muted/40",children:[e.jsx(Ce,{className:"h-4 w-4 sm:h-5 sm:w-5 transition-colors text-muted-foreground group-data-[state=active]:text-primary-foreground"}),e.jsx("span",{className:"text-[10px] sm:text-xs font-semibold text-muted-foreground group-data-[state=active]:text-primary-foreground",children:"Dashboard"})]}),a.isProfissional&&e.jsxs(E,{value:"minhas-visitas",className:"group flex flex-col gap-1 p-2 sm:p-3 h-auto transition-all duration-200 hover:bg-muted/80 data-[state=active]:bg-primary data-[state=active]:text-primary-foreground data-[state=active]:shadow-md rounded-lg bg-muted/40",children:[e.jsx(ee,{className:"h-4 w-4 sm:h-5 sm:w-5 transition-colors text-muted-foreground group-data-[state=active]:text-primary-foreground"}),e.jsx("span",{className:"text-[10px] sm:text-xs font-semibold text-muted-foreground group-data-[state=active]:text-primary-foreground",children:"Minhas Visitas"})]}),e.jsxs(E,{value:"todas-visitas",className:"group flex flex-col gap-1 p-2 sm:p-3 h-auto transition-all duration-200 hover:bg-muted/80 data-[state=active]:bg-primary data-[state=active]:text-primary-foreground data-[state=active]:shadow-md rounded-lg bg-muted/40",children:[e.jsx(ee,{className:"h-4 w-4 sm:h-5 sm:w-5 transition-colors text-muted-foreground group-data-[state=active]:text-primary-foreground"}),e.jsx("span",{className:"text-[10px] sm:text-xs font-semibold text-muted-foreground group-data-[state=active]:text-primary-foreground",children:"Todas Visitas"})]}),r&&e.jsxs(E,{value:"enviar-convite",className:"group flex flex-col gap-1 p-2 sm:p-3 h-auto transition-all duration-200 hover:bg-muted/80 data-[state=active]:bg-primary data-[state=active]:text-primary-foreground data-[state=active]:shadow-md rounded-lg bg-muted/40",children:[e.jsx(H,{className:"h-4 w-4 sm:h-5 sm:w-5 transition-colors text-muted-foreground group-data-[state=active]:text-primary-foreground"}),e.jsx("span",{className:"text-[10px] sm:text-xs font-semibold text-muted-foreground group-data-[state=active]:text-primary-foreground",children:"Enviar Convite"})]}),r&&e.jsxs(E,{value:"convites",className:"group flex flex-col gap-1 p-2 sm:p-3 h-auto transition-all duration-200 hover:bg-muted/80 data-[state=active]:bg-primary data-[state=active]:text-primary-foreground data-[state=active]:shadow-md rounded-lg bg-muted/40",children:[e.jsx(H,{className:"h-4 w-4 sm:h-5 sm:w-5 transition-colors text-muted-foreground group-data-[state=active]:text-primary-foreground"}),e.jsx("span",{className:"text-[10px] sm:text-xs font-semibold text-muted-foreground group-data-[state=active]:text-primary-foreground",children:"Convites"})]}),r&&e.jsxs(E,{value:"novo-profissional",className:"group flex flex-col gap-1 p-2 sm:p-3 h-auto transition-all duration-200 hover:bg-muted/80 data-[state=active]:bg-primary data-[state=active]:text-primary-foreground data-[state=active]:shadow-md rounded-lg bg-muted/40",children:[e.jsx(ze,{className:"h-4 w-4 sm:h-5 sm:w-5 transition-colors text-muted-foreground group-data-[state=active]:text-primary-foreground"}),e.jsx("span",{className:"text-[10px] sm:text-xs font-semibold text-muted-foreground group-data-[state=active]:text-primary-foreground",children:"Novo Prof."})]}),e.jsxs(E,{value:"profissionais",className:"group flex flex-col gap-1 p-2 sm:p-3 h-auto transition-all duration-200 hover:bg-muted/80 data-[state=active]:bg-primary data-[state=active]:text-primary-foreground data-[state=active]:shadow-md rounded-lg bg-muted/40",children:[e.jsx(ie,{className:"h-4 w-4 sm:h-5 sm:w-5 transition-colors text-muted-foreground group-data-[state=active]:text-primary-foreground"}),e.jsx("span",{className:"text-[10px] sm:text-xs font-semibold text-muted-foreground group-data-[state=active]:text-primary-foreground",children:"Profissionais"})]})]}),e.jsx(I,{value:"dashboard",className:"space-y-6",children:e.jsx(Ge,{})}),a.isProfissional&&e.jsx(I,{value:"minhas-visitas",className:"space-y-6",children:e.jsx(ae,{minhasVisitas:!0})}),e.jsx(I,{value:"todas-visitas",className:"space-y-6",children:e.jsx(ae,{minhasVisitas:!1})}),r&&e.jsx(I,{value:"enviar-convite",className:"space-y-6",children:e.jsx(Je,{})}),r&&e.jsx(I,{value:"convites",className:"space-y-6",children:e.jsx(Ke,{})}),r&&e.jsx(I,{value:"novo-profissional",className:"space-y-6",children:e.jsx(Qe,{})}),e.jsx(I,{value:"profissionais",className:"space-y-6",children:e.jsx(We,{})})]})]})]})]})})}export{_s 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.