PageSourceSearch

https://portal.easymarine.com.br/assets/CreateContactDialog_fbb118d8.js

js easymarine.com.br collected 2026-09-24 13:46:37 UTC 4,095 bytes, 1 lines download raw bytes

1import{a6 as y,O as w,dg as d,dj as x,b2 as N,a5 as g,b3 as b,dk as E,a0 as S,L as e,aa as T,ab as z,ac as k,ad as A,a2 as s,a3 as o,d8 as v,ax as B,ay as I,az as L,aA as F,aB as M,bz as P,Z as O}from"./index_ec3ba43a.js";import{u as V,n as W,c as q,g as Q}from"./useWhatsappCheck_20b6454f.js";import{C as f}from"./company_7fdc2705.js";function Y({open:j,onOpenChange:m,companyId:c}){const _=y(),[a,t]=w.useState({nome_completo:"",telefone_fixo:"",telefone_celular:"",email:"",cargo:"",departamento:"",contact_type:"",whatsapp_lid:"",observacoes:""}),r=d(a.telefone_celular).length>0&&!x(a.telefone_celular),C=V(),p=N({mutationFn:async()=>{if(!x(a.telefone_celular))throw new Error("Celular deve ter 11 dígitos (DDD + 9 + número) ou 13 com DDI 55.");const l=W(a.email),u=await q(c,l);if(u)throw new Error(u);const D={nome_completo:a.nome_completo,telefone_fixo:d(a.telefone_fixo),telefone_celular:E(a.telefone_celular),email:l,cargo:a.cargo,departamento:a.departamento,contact_type:a.contact_type||null,whatsapp_lid:a.whatsapp_lid||null,observacoes:a.observacoes,company_id:c},{data:n,error:i}=await S.from("contacts").insert([D]).select("id").single();if(i){const h=Q(i);throw h?new Error(h):i}return n==null?void 0:n.id},onSuccess:l=>{_.invalidateQueries({queryKey:["contacts"],exact:!1}),g.success("Contato criado com sucesso"),l&&a.telefone_celular&&C.mutateAsync({phone:d(a.telefone_celular),company_id:c,target:"contact",target_id:l}),m(!1),t({nome_completo:"",telefone_fixo:"",telefone_celular:"",email:"",cargo:"",departamento:"",contact_type:"",whatsapp_lid:"",observacoes:""})},onError:l=>{g.error("Erro ao criar contato",{description:b("CreateContactDialog",l)})}});return e.jsx(T,{open:j,onOpenChange:m,children:e.jsxs(z,{className:"max-h-[90vh] overflow-y-auto",children:[e.jsx(k,{children:e.jsx(A,{children:"Novo Contato"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(s,{children:"Nome Completo *"}),e.jsx(o,{value:a.nome_completo,onChange:l=>t({...a,nome_completo:l.target.value})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(s,{children:"Telefone Fixo"}),e.jsx(o,{placeholder:"(00) 0000-0000",value:a.telefone_fixo,onChange:l=>t({...a,telefone_fixo:v(l.target.value)})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(s,{children:"Telefone Celular *"}),e.jsx(o,{placeholder:"(00) 00000-0000",value:a.telefone_celular,onChange:l=>t({...a,telefone_celular:v(l.target.value)}),"aria-invalid":r}),r&&e.jsx("p",{className:"text-xs text-destructive",children:"Celular deve ter 11 dígitos (DDD + 9 + número) ou 13 com DDI 55."})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(s,{children:"E-mail *"}),e.jsx(o,{type:"email",value:a.email,onChange:l=>t({...a,email:l.target.value})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(s,{children:"Cargo"}),e.jsx(o,{value:a.cargo,onChange:l=>t({...a,cargo:l.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(s,{children:"Departamento"}),e.jsx(o,{value:a.departamento,onChange:l=>t({...a,departamento:l.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(s,{children:"Tipo de Contato"}),e.jsxs(B,{value:a.contact_type,onValueChange:l=>t({...a,contact_type:l}),children:[e.jsx(I,{children:e.jsx(L,{placeholder:"Selecione o tipo"})}),e.jsx(F,{children:Object.keys(f).map(l=>e.jsx(M,{value:l,children:f[l]},l))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(s,{children:"ID Whatsapp (LID)"}),e.jsx(o,{value:a.whatsapp_lid,onChange:l=>t({...a,whatsapp_lid:l.target.value}),placeholder:"ID do Whatsapp"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(s,{children:"Observações"}),e.jsx(P,{value:a.observacoes,onChange:l=>t({...a,observacoes:l.target.value}),rows:3})]}),e.jsx(O,{className:"w-full",onClick:()=>p.mutate(),disabled:!a.nome_completo||!a.email||!a.telefone_celular||r||p.isPending,children:"Criar Contato"})]})]})})}export{Y as CreateContactDialog};

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.