PageSourceSearch

https://ortomagic-dashboard.vercel.app/_next/static/chunks/190.8553940b262f514d.js

js ortomagic-dashboard.vercel.app collected 2026-10-03 07:27:08 UTC 14,789 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[190],{2190:function(e,o,a){a.r(o),a.d(o,{default:function(){return g}});var r=a(7437),n=a(3589),t=a(2265),s=a(2369),i=a(407),l=a(525),d=a(7885),c=a(7618);let p=["Instagram","Google","Indicacao","Facebook","Site","WhatsApp","Outros"],u=["Ortodontia","Botox","Harmoniza\xe7\xe3o","Implante","Clareamento","Gengivoplastia","Outros"];function g(e){let{onClose:o,onSuccess:a}=e,{theme:g}=(0,d.F)(),x=(0,c.d)(),h=new Date().getFullYear(),m="R"===(localStorage.getItem("orto-tenant")||"R"),[b,y]=(0,t.useState)("ficha"),[f,j]=t.useState({nome:"",numero:"",ano:String(h),valor:"",obs2:m?"N\xe3o precisa":"REC - Declara",obs3:""}),[v,C]=(0,t.useState)({cpf:"",data_nascimento:"",sexo:"",email:"",telefone_whatsapp:"",instagram:"",cep:"",logradouro:"",numero_endereco:"",complemento:"",bairro:"",cidade:"",uf:"RS",origem_lead:"",interesses:[],observacoes_crm:""}),[S,k]=t.useState(null),[_,R]=t.useState(""),[z,w]=t.useState([]);(0,t.useEffect)(()=>{(0,n.S)("/api/nova-ficha").then(e=>e.json()).then(e=>{e.sugerido&&N("numero",e.sugerido)}).catch(()=>{}),(0,n.S)("/api/agenda/profissionais").then(e=>e.json()).then(e=>{if(e.success&&e.profissionais){let o=e.profissionais.filter(e=>"doutor"===e.tipo);w(o),1===o.length&&N("obs3",o[0].nome)}}).catch(()=>{})},[]);let N=(e,o)=>j(a=>({...a,[e]:o})),T=(e,o)=>C(a=>({...a,[e]:o})),F=e=>C(o=>({...o,interesses:o.interesses.includes(e)?o.interesses.filter(o=>o!==e):[...o.interesses,e]})),P=async e=>{if(e.preventDefault(),!f.nome.trim()){k("error"),R("O nome n\xe3o pode ser vazio.");return}if(!f.numero.trim()){k("error"),R("O n\xfamero da ficha n\xe3o pode ser vazio.");return}if(!f.obs3.trim()){k("error"),R("Selecione o Dr. Respons\xe1vel.");return}k("loading"),R(""),0===z.length&&f.obs3.trim()&&(0,n.S)("/api/agenda/profissionais",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({nome:f.obs3.trim(),tipo:"doutor"})}).then(e=>e.json()).then(e=>{e.success&&w([{id:e.id,nome:f.obs3.trim(),tipo:"doutor"}])}).catch(()=>{});try{let e=await (0,n.S)("/api/nova-ficha",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...f,nome:f.nome.trim()+" "+f.ano})}),o=await e.json();if(409===e.status){k("warning"),R(o.warning||o.error||"Ficha j\xe1 existe.");return}if(!e.ok||!o.success){k("error"),R(o.error||"Erro ao criar ficha.");return}let r=v.cpf||v.telefone_whatsapp||v.origem_lead||v.interesses.length>0;if(r){let e=f.nome.trim();await (0,n.S)("/api/ficha-geral",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({...v,nome_completo:e,numero_prontuario:f.numero,status_atual:"Lead"})}).catch(console.error)}k("success");let t=[];o.fichaFinanceiraCriada&&t.push("Ficha Financeira criada com sucesso!"),o.fichaClinicaCriada&&t.push("Ficha Cl\xednica criada com sucesso!"),r&&t.push("Dados CRM salvos!"),R(t.join(" ")),a&&a(o)}catch(e){console.error(e),k("error"),R("Erro de rede. Imposs\xedvel conectar \xe0 AWS no momento.")}},B={background:g.bgSurface,borderRadius:16,border:"1px solid ".concat(g.border),padding:x?20:32,width:"100%",maxWidth:600,maxHeight:"92vh",overflowY:"auto",position:"relative",color:g.textPrimary,fontFamily:"system-ui, sans-serif",boxSizing:"border-box"},D={width:"100%",boxSizing:"border-box",padding:"10px 12px",background:g.inputBg,border:"1px solid ".concat(g.border),color:g.textPrimary,borderRadius:8,fontSize:14},I={display:"block",color:g.textSecondary,fontSize:13,marginBottom:6,marginTop:18},O={display:"flex",flexDirection:"column",gap:6,marginTop:6},W={display:"flex",alignItems:"center",gap:8,fontSize:14,color:g.textSecondary,cursor:"pointer"},A=(e,o,a)=>{let n=b===e;return(0,r.jsxs)("button",{type:"button",onClick:()=>y(e),style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:6,padding:"8px 12px",borderRadius:8,border:"none",cursor:"pointer",fontSize:12,fontWeight:n?700:400,background:n?g.accentBg:"transparent",color:n?g.accent:g.textSecondary,transition:"0.2s"},children:[a," ",o]})};return(0,r.jsx)("div",{style:{position:"fixed",inset:0,backgroundColor:"rgba(0,0,0,0.75)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:20},onClick:e=>{e.target===e.currentTarget&&o()},children:(0,r.jsxs)("div",{style:B,children:[(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16,borderBottom:"1px solid ".concat(g.border),paddingBottom:16},children:[(0,r.jsxs)("h2",{style:{margin:0,fontSize:20,color:g.accent,display:"flex",alignItems:"center",gap:10},children:[(0,r.jsx)(s.Z,{size:20})," Nova Ficha de Paciente"]}),(0,r.jsx)("button",{onClick:o,style:{background:"none",border:"none",color:g.textSecondary,cursor:"pointer",fontSize:20,lineHeight:1},children:"✕"})]}),(0,r.jsxs)("div",{style:{display:"flex",gap:4,padding:4,background:g.bgSurfaceAlt,borderRadius:10,border:"1px solid ".concat(g.border),marginBottom:20}
1,children:[A("ficha","Ficha Principal",(0,r.jsx)(s.Z,{size:13})),A("pessoal","Dados Pessoais",(0,r.jsx)(i.Z,{size:13})),A("crm","CRM / Origem",(0,r.jsx)(l.Z,{size:13}))]}),"error"===S&&(0,r.jsx)("div",{style:{background:"rgba(248,113,113,0.12)",border:"1px solid rgba(248,113,113,0.4)",color:g.accentRed,padding:"12px 16px",borderRadius:8,marginBottom:16,fontSize:14},children:_}),"warning"===S&&(0,r.jsx)("div",{style:{background:"rgba(250,204,21,0.1)",border:"1px solid rgba(250,204,21,0.4)",color:g.accentYellow,padding:"12px 16px",borderRadius:8,marginBottom:16,fontSize:14},children:_}),"success"===S&&(0,r.jsxs)("div",{style:{background:"rgba(74,222,128,0.12)",border:"1px solid rgba(74,222,128,0.4)",color:g.accentGreen,padding:"16px",borderRadius:8,marginBottom:16,fontSize:14},children:["✅ ",_,(0,r.jsxs)("div",{style:{marginTop:12,display:"flex",gap:10},children:[(0,r.jsx)("button",{onClick:o,style:{flex:1,padding:"10px",background:g.accent,color:g.bgBase,border:"none",borderRadius:8,fontWeight:"bold",cursor:"pointer"},children:"Fechar"}),(0,r.jsx)("button",{onClick:()=>{k(null),R(""),j({nome:"",numero:"",ano:String(h),valor:"",obs2:m?"
1N\xe3o precisa":"REC - Declara",obs3:1===z.length?z[0].nome:""}),C({cpf:"",data_nascimento:"",sexo:"",email:"",telefone_whatsapp:"",instagram:"",cep:"",logradouro:"",numero_endereco:"",complemento:"",bairro:"",cidade:"",uf:"RS",origem_lead:"",interesses:[],observacoes_crm:""}),y("ficha")},style:{flex:1,padding:"10px",background:g.bgSurfaceAlt,color:g.textPrimary,border:"1px solid ".concat(g.bgSurfaceAlt),borderRadius:8,fontWeight:"bold",cursor:"pointer"},children:"+ Nova"})]})]}),"success"!==S&&(0,r.jsxs)("form",{onSubmit:P,children:["ficha"===b&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{style:I,children:"Nome completo*"}),(0,r.jsx)("input",{style:D,type:"text",placeholder:"ex: Sandra de S\xe1",value:f.nome,onChange:e=>N("nome",e.target.value)}),(0,r.jsx)("label",{style:I,children:"N\xfamero do caso (at\xe9 6 d\xedgitos)*"}),(0,r.jsx)("input",{style:D,type:"text",maxLength:6,placeholder:"ex: 000245",value:f.numero,onChange:e=>N("numero",e.target.value)}),(0,r.jsx)("label",{style:I,children:"Ano do controle"}),(0,r.jsx)("input",{style:{...D,width:100},type:"text",maxLength:4,value:f.ano,onChange:e=>N("ano",e.target.value)}),(0,r.jsx)("label",{style:I,children:"Dr. Respons\xe1vel*"}),z.length>0?(0,r.jsx)("div",{style:O,children:z.map(e=>(0,r.jsxs)("label",{style:W,children:[(0,r.jsx)("input",{type:"radio",name:"obs3",value:e.nome,checked:f.obs3===e.nome,onChange:()=>N("obs3",e.nome)}),e.nome]},e.id))}):(0,r.jsxs)("div",{children:[(0,r.jsx)("input",{style:D,type:"text",placeholder:"Nome do Dr. (ser\xe1 cadastrado automaticamente)",value:f.obs3,onChange:e=>N("obs3",e.target.value)}),(0,r.jsx)("div",{style:{fontSize:11,color:g.textMuted,marginTop:3},children:"Nenhum profissional cadastrado ainda — este Dr. ser\xe1 registrado ao salvar."})]}),(0,r.jsx)("label",{style:I,children:"Valor mensal inicial (se houver)"}),(0,r.jsx)("input",{style:D,type:"text",placeholder:"ex: 140, 160, sob consulta...",value:f.valor,onChange:e=>N("valor",e.target.value)}),m&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("label",{style:I,children:"Modo de emiss\xe3o de Nota Fiscal"}),(0,r.jsxs)("div",{style:O,children:[(0,r.jsxs)("label",{style:W,children:[(0,r.jsx)("input",{type:"radio",name:"obs2",value:"REC - Declara",checked:"REC - Declara"===f.obs2,onChange:()=>N("obs2","REC - Declara")}),(0,r.jsx)("span",{style:{color:"rgba(250,204,21,0.9)",fontWeight:600},children:"Imediata"})," — imprime e entrega na hora do pagamento"]}),(0,r.jsxs)("label",{style:W,children:[(0,r.jsx)("input",{type:"radio",name:"obs2",value:"N\xe3o precisa",checked:"N\xe3o precisa"===f.obs2,onChange:()=>N("obs2","N\xe3o precisa")}),(0,r.jsx)("span",{style:{color:"rgba(34,211,238,0.9)",fontWeight:600},children:"Anual"})," — pega ao final do ano"]})]})]})]}),"pessoal"===b&&(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{style:{margin:"0 0 4px",fontSize:12,color:g.textMuted},children:"Campos com * s\xe3o obrigat\xf3rios."}),(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:x?"1fr":"1fr 1fr",gap:"0 16px"},children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{style:I,children:"CPF"}),(0,r.jsx)("input",{style:D,placeholder:"000.000.000-00",value:v.cpf,onChange:e=>T("cpf",e.target.value)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{style:I,children:"Data de Nascimento *"}),(0,r.jsx)("input",{style:D,type:"date",value:v.data_nascimento,onChange:e=>T("data_nascimento",e.target.value)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{style:I,children:"Sexo *"}),(0,r.jsxs)("select",{style:D,value:v.sexo,onChange:e=>T("sexo",e.target.value),children:[(0,r.jsx)("option",{value:"",children:"—"}),(0,r.jsx)("option",{value:"M",children:"Masculino"}),(0,r.jsx)("option",{value:"F",children:"Feminino"}),(0,r.jsx)("option",{value:"Outro",children:"Outro"})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{style:I,children:"WhatsApp *"}),(0,r.jsx)("input",{style:D,placeholder:"(47) 99999-9999",value:v.telefone_whatsapp,onChange:e=>T("telefone_whatsapp",e.target.value)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{style:I,children:"E-mail"}),(0,r.jsx)("input",{style:D,type:"email",value:v.email,onChange:e=>T("email",e.target.value)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{style:I,children:"Instagram"}),(0,r.jsx)("input",{style:D,placeholder:"@usuario",value:v.instagram,onChange:e=>T("instagram",e.target.value)})]})]}),(0,r.jsx)("label",{style:{...I,marginTop:20},children:"CEP"}),(0,r.jsx)("input",{style:{...D,width:x?"100%":160},placeholder:"00000-000",value:v.cep,onChange:e=>T("cep",e.target.value)}),(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:x?"1fr":"2fr 1fr",gap:"0 16px"},children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{style:I,children:"Logradouro"}),(0,r.jsx)("input",{style:D,value:v.logradouro,onChange:e=>T("logradouro",e.target.value)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{style:I,children:"N\xfamero"}),(0,r.jsx)("input",{style:D,value:v.numero_endereco,onChange:e=>T("numero_endereco",e.target.value)})]})]}),(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:x?"1fr 1fr":"1fr 1fr 1fr 70px",gap:"0 16px"},children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{style:I,children:"Complemento"}),(0,r.jsx)("input",{style:D,value:v.complemento,onChange:e=>T("complemento",e.target.value)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{style:I,children:"Bairro"}),(0,r.jsx)("input",{style:D,value:v.bairro,onChange:e=>T("bairro",e.target.value)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{style:I,children:"Cidade"}),(0,r.jsx)("input",{style:D,value:v.cidade,onChange:e=>T("cidade",e.target.value)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{style:I,children:"UF"}),(0,r.jsx)("input",{style:{...D,textTransform:"uppercase"},maxLength:2,value:v.uf,onChange:e=>T("uf",e.target.value.toUpperCase())})]})]})]}),"crm"===b&&(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{style:{margin:"0 0 4px",fontSize:12,color:g.textMuted},children:"Dados comerciais para o funil de relacionamento."}),(0,r.jsx)("label",{style:I,children:"Como conheceu a cl\xednica? (Origem do Lead)"}),(0,r.jsxs)("select",{style:D,value:v.origem_lead,onChange:e=>T("origem_lead",e.target.value),children:[(0,r.jsx)("option",{value:"",children:"— Selecione —"}),p.map(e=>(0,r.jsx)("option",{value:e,children:e},e))]}),(0,r.jsx)("label",{style:I,children:"Interesses / Procedimentos de interesse"}),(0,r.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:10,marginTop:6},children:u.map(e=>(0,r.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:7,fontSize:13,color:g.textSecondary,cursor:"pointer",padding:"6px 12px",background:v.interesses.includes(e)?g.accentBg:g.bgSurfaceAlt,border:"1px solid ".concat(v.interesses.includes(e)?g.accentBorder:g.border),borderRadius:20},children:[(0,r.jsx)("input",{type:"checkbox",style:{display:"none"},checked:v.interesses.includes(e),onChange:()=>F(e)}),(0,r.jsx)("span",{style:{color:v.interesses.includes(e)?g.accent:g.textSecondary,fontWeight:v.interesses.includes(e)?700:400},children:e})]},e))}),(0,r.jsx)("label",{style:I,children:"Observa\xe7\xf5es CRM"}),(0,r.jsx)("textarea",{style:{...D,resize:"vertical",minHeight:70},placeholder:"Primeira impress\xe3o, notas de abordagem...",value:v.observacoes_crm,onChange:e=>T("observacoes_crm",e.target.value)})]}),(0,r.jsxs)("div",{style:{display:"flex",gap:12,marginTop:28,paddingTop:20,borderTop:"1px solid ".concat(g.border)},children:[(0,r.jsx)("button",{type:"button",onClick:o,style:{flex:1,padding:"12px",background:g.bgSurfaceAlt,color:g.textPrimary,border:"1px solid ".concat(g.border),borderRadius:8,fontWeight:"bold",cursor:"pointer"},children:"Cancelar"}),"crm"!==b&&(0,r.jsxs)("button",{type:"button",onClick:()=>
1{if("pessoal"===b){if(!v.data_nascimento){k("error"),R("Preencha a Data de Nascimento.");return}if(!v.sexo){k("error"),R("Selecione o Sexo.");return}if(!v.telefone_whatsapp.trim()){k("error"),R("Preencha o WhatsApp.");return}k(null),R("")}y("ficha"===b?"pessoal":"crm")},style:{flex:1,padding:"12px",background:g.bgSurfaceAlt,color:g.accent,border:"1px solid ".concat(g.accentBorder),borderRadius:8,fontWeight:"bold",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:["Pr\xf3ximo ",(0,r.jsx)(i.Z,{size:16})]}),"crm"===b&&(0,r.jsx)("button",{type:"submit",disabled:"loading"===S,style:{flex:2,padding:"12px",background:"loading"===S?g.bgSurfaceAlt:"linear-gradient(135deg,".concat(g.accent,",").concat(g.accentPurple,")"),color:g.bgBase,border:"none",borderRadius:8,fontWeight:"bold",cursor:"loading"===S?"wait":"pointer",fontSize:15},children:"loading"===S?"Gravando...":"Gravar Nova Ficha"})]})]})]})})}}}]);

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.