ImportTab-ck4E3ASS.js raw
1 import{r as l,j as t,B as f,b as p,t as c}from"./index-DfKg850Q.js";function u(){const[s,a]=l.useState(null),[i,n]=l.useState(!1),r=l.useRef(null),m=async()=>{if(s){n(!0);try{const e=await p.importEvents(s);c.success(`Import complete: ${JSON.stringify(e)}`),a(null),r.current&&(r.current.value="")}catch(e){c.error(`Import failed: ${e instanceof Error?e.message:String(e)}`)}finally{n(!1)}}};return t.jsx("div",{className:"p-4 max-w-lg space-y-3",children:t.jsxs("div",{className:"rounded-lg bg-card p-4 space-y-4",children:[t.jsx("h3",{className:"text-lg font-semibold",children:"Import Events"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Upload a JSONL file to import events into the database."}),t.jsx("input",{ref:r,type:"file",accept:".jsonl,.txt",onChange:e=>{var o;return a(((o=e.target.files)==null?void 0:o[0])||null)},className:"block w-full text-sm file:mr-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:font-semibold file:bg-primary file:text-primary-foreground hover:file:bg-primary/80"}),t.jsx(f,{onClick:m,disabled:!s||i,children:i?"Importing...":"Import Events"})]})})}export{u as default};
2