PageSourceSearch

https://bitacora.ai/assets/ImportarBulkPaste-IhHPDPbt.js

js bitacora.ai collected 2026-10-05 15:28:19 UTC 8,775 bytes, 1 lines download raw bytes

1import{aL as w,s as T,u as A,aF as D,r as b,j as e,L as O,z as p,e as g}from"./index-BiVk33Bn.js";import{A as R}from"./arrow-left-CmSIiUGN.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};t.SENTRY_RELEASE={id:"daca8474617e38beb40596519f5b410a89e15552"};var n=new t.Error().stack;n&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[n]="3cfd7546-7da9-4cb1-8758-372f14570607",t._sentryDebugIdIdentifier="sentry-dbid-3cfd7546-7da9-4cb1-8758-372f14570607")}catch{}})();const y="https://api.bitacora.ai";async function _(){var r;const{data:t}=await T.auth.getSession(),n=(r=t.session)==null?void 0:r.access_token;if(!n)throw new Error("No hay sesión activa. Vuelve a ingresar.");return{Authorization:`Bearer ${n}`,"Content-Type":"application/json"}}async function B(t){const n=await _(),r=await fetch(`${y}/import/bulk-paste/detect`,{method:"POST",headers:n,body:JSON.stringify({raw:t})});if(!r.ok)throw new Error(w(await r.text().catch(()=>""),r.status));return await r.json()}async function F(t){const n=await _(),r=await fetch(`${y}/import/bulk-paste/preview`,{method:"POST",headers:n,body:JSON.stringify({rows:t})});if(!r.ok)throw new Error(w(await r.text().catch(()=>""),r.status));return await r.json()}async function I(t){const n=await _(),r=await fetch(`${y}/import/bulk-paste/confirm`,{method:"POST",headers:n,body:JSON.stringify({rows:t})});if(!r.ok)throw new Error(w(await r.text().catch(()=>""),r.status));return await r.json()}const z=["ignore","patient_name","date_text","time_text","duration_minutes"],$={ignore:"bulkPaste.roleIgnore",patient_name:"bulkPaste.rolePatient",date_text:"bulkPaste.roleDate",time_text:"bulkPaste.roleTime",duration_minutes:"bulkPaste.roleDuration"},J={tab:"bulkPaste.sepTab",comma:"bulkPaste.sepComma",pipe:"bulkPaste.sepPipe",whitespace:"bulkPaste.sepWhitespace"};function K(){const{t}=A("pacientes"),n=D(),[r,x]=b.useState("paste"),[h,N]=b.useState(""),[o,P]=b.useState(null),[k,j]=b.useState([]),[u,E]=b.useState([]),[c,d]=b.useState(!1);async function S(){if(!h.trim()){p.error(t("bulkPaste.pasteFirst"));return}d(!0);try{const a=await B(h);P(a);const s=new Array(a.columns).fill("ignore");a.columns>=1&&(s[0]="patient_name"),a.columns>=2&&(s[1]="date_text"),a.columns>=3&&(s[2]="time_text"),a.columns>=4&&(s[3]="duration_minutes"),j(s),x("mapping")}catch(a){p.error(g(a,t("bulkPaste.detectError")))}finally{d(!1)}}function v(){return o?o.rows.map(a=>{const s={patient_name:""};return k.forEach((i,l)=>{const m=a[l];if(!(!m||i==="ignore")){if(i==="patient_name")s.patient_name=m;else if(i==="date_text")s.date_text=m;else if(i==="time_text")s.time_text=m;else if(i==="duration_minutes"){const f=Number(m.replace(/[^\d]/g,""));Number.isFinite(f)&&f>0&&(s.duration_minutes=f)}}}),s}):[]}async function C(){d(!0);try{const a=v(),s=await F(a);E(s),x("preview")}catch(a){p.error(g(a,t("bulkPaste.previewError")))}finally{d(!1)}}async function L(){d(!0);try{const a=v(),s=await I(a);p.success(t("bulkPaste.importedToast",{count:s.sessions_created})),n("/dashboard/agenda")}catch(a){p.error(g(a,t("bulkPaste.confirmError")))}finally{d(!1)}}return e.jsx(e.Fragment,{children:e.jsxs("div",{className:"px-5 py-8 lg:px-12 lg:py-16 max-w-4xl",children:[e.jsxs(O,{to:"/dashboard/configuracion?tab=integraciones",className:"inline-flex items-center gap-2 text-small text-bark-muted hover:text-bark mb-8",children:[e.jsx(R,{size:16}),t("importCalendar.integrations")]}),e.jsx("p",{className:"text-tiny uppercase tracking-widest text-terracotta mb-6",children:t("bulkPaste.marker")}),e.jsx("h1",{className:"text-h1 font-sans text-bark mb-4",children:t("bulkPaste.title")}),e.jsx("p",{className:"text-body text-bark-muted mb-10 leading-relaxed",children:t("bulkPaste.description")}),r==="paste"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx("textarea",{value:h,onChange:a=>N(a.target.value),placeholder:t("bulkPaste.pastePlaceholder"),rows:12,className:"w-full border border-bark/20 rounded-md p-4 font-mono text-small bg-linen text-bark",maxLength:1e4}),e.jsx("p",{className:"text-tiny text-bark-muted",children:t("bulkPaste.pasteHint")}),e.jsx("button",{type:"button",onClick:()=>void S(),disabled:c||!h.trim(),className:"border border-terracotta text-terracotta uppercase tracking-widest text-tiny rounded-full px-8 py-2.5 hover:bg-terracotta hover:text-linen transition-colors disabled:opacity-40",children:t(c?"bulkPaste.detecting":"bulkPaste.detectColumns")})]}),r==="mapping"&&o&&e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-tiny uppercase tracking-widest text-bark-muted mb-2",children:t("bulkPaste.separatorDetected")}),e.jsx("p",{className:"text-small text-bark",children:t(J[o.separator])})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-tiny uppercase tracking-widest text-bark-muted mb-4",children:t("bulkPaste.assignColumns")}),e.jsx("div",{className:"border border-bark/10 rounded-md overflow-x-auto",children:e.jsxs("table",{className:"w-full text-small",children:[e.jsx("thead",{className:"bg-bone",children:e.jsx("tr",{children:Array.from({length:o.columns}).map((a,s)=>e.jsx("th",{className:"text-left p-3 border-b border-bark/10",children:e.jsx("select",{value:k[s]??"ignore",onCh
1ange:i=>{const l=[...k];l[s]=i.target.value,j(l)},className:"border border-bark/20 rounded-md px-2 py-1 bg-linen text-bark text-small",children:z.map(i=>e.jsx("option",{value:i,children:t($[i])},i))})},s))})}),e.jsx("tbody",{children:o.rows.slice(0,5).map((a,s)=>e.jsx("tr",{children:Array.from({length:o.columns}).map((i,l)=>e.jsx("td",{className:"p-3 border-b border-bark/10 text-bark",children:a[l]??""},l))},s))})]})}),o.rows.length>5&&e.jsx("p",{className:"text-tiny text-bark-muted mt-2",children:t("bulkPaste.showingFirst5",{total:o.total_rows})})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{type:"button",onClick:()=>x("paste"),className:"border border-bark/30 text-bark uppercase tracking-widest text-tiny rounded-full px-6 py-2.5 hover:border-bark transition-colors",children:t("common:acciones.volver")}),e.jsx("button",{type:"button",onClick:()=>void C(),disabled:c||!k.includes("patient_name"),className:"border border-terracotta text-terracotta uppercase tracking-widest text-tiny rounded-full px-8 py-2.5 hover:bg-terracotta hover:text-linen transition-colors disabled:opacity-40",children:t(c?"common:estados.procesando":"bulkPaste.preview")})]})]}),r==="preview"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx("p",{className:"text-small text-bark",children:t("bulkPaste.previewSummary",{ready:u.filter(a=>a.match_patient_id).length,ignored:u.filter(a=>!a.match_patient_id).length})}),e.jsx("div",{className:"border border-bark/10 rounded-md overflow-x-auto lg:overflow-hidden",children:e.jsxs("table",{className:"w-full text-small",children:[e.jsx("thead",{className:"bg-bone text-bark-muted",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left p-3 border-b border-bark/10",children:t("bulkPaste.colPatient")}),e.jsx("th",{className:"text-left p-3 border-b border-bark/10",children:t("bulkPaste.colDateTime")}),e.jsx("th",{className:"text-left p-3 border-b border-bark/10",children:t("bulkPaste.colDuration")}),e.jsx("th",{className:"text-left p-3 border-b border-bark/10",children:t("bulkPaste.colStatus")})]})}),e.jsx("tbody",{children:u.map(a=>e.jsxs("tr",{className:a.match_patient_id?"":"opacity-50",children:[e.jsx("td",{className:"p-3 border-b border-bark/10 text-bark",children:a.match_patient_name??a.patient_name}),e.jsx("td",{className:"p-3 border-b border-bark/10 text-bark",children:a.scheduled_start?new Date(a.scheduled_start).toLocaleString("es"):"—"}),e.jsxs("td",{className:"p-3 border-b border-bark/10 text-bark",children:[a.duration_minutes??"—"," min"]}),e.jsx("td",{className:"p-3 border-b border-bark/10 text-bark-muted text-tiny uppercase tracking-widest",children:a.match_patient_id?t("bulkPaste.statusReady"):a.reason_skip??t("bulkPaste.statusNotFound")})]},a.raw_index))})]})}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{type:"button",onClick:()=>x("mapping"),className:"border border-bark/30 text-bark uppercase tracking-widest text-tiny rounded-full px-6 py-2.5 hover:border-bark transition-colors",children:t("common:acciones.volver")}),e.jsx("button",{type:"button",onClick:()=>void L(),disabled:c||u.filter(a=>a.match_patient_id).length===0,className:"border border-terracotta text-terracotta uppercase tracking-widest text-tiny rounded-full px-8 py-2.5 hover:bg-terracotta hover:text-linen transition-colors disabled:opacity-40",children:c?t("bulkPaste.importing"):t("bulkPaste.confirmCount",{count:u.filter(a=>a.match_patient_id).length})})]})]})]})})}export{K 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.