PageSourceSearch

https://agentoai.dk/assets/ClientOwnKnowledge-dX1fsaiZ.js

js agentoai.dk collected 2026-10-02 01:53:19 UTC 7,965 bytes, 1 lines download raw bytes

1import{r as c,j as e}from"./framer-motion-CQxuJa5n.js";import{a as H,b as M,s as d,x as N,B as a,j as o,I as m,C as k,i as b,f as G,g as J,h as Q}from"./index-CSx7K-7R.js";import{T as y}from"./textarea-BFuIyuCd.js";import{D as C,f as W,a as _,b as T,c as D,d as F,e as S}from"./dialog-RiETlj4q.js";import{T as X,a as Y,b as K,c as V}from"./tabs-sn5fbWIA.js";import{C as Z}from"./ClientKnowledgeShareManager-9MLt53qH.js";import{F as f}from"./file-text-CQNieni0.js";import{S as $}from"./share-2-oHd1C7_0.js";import{P as E}from"./plus-t8RS0EeL.js";import{L as ee}from"./link-PqJR2IMo.js";import{S as te}from"./square-pen-BvxvHUSl.js";import{T as se}from"./trash-2-DxlklYFw.js";import"./recharts-CFjfazL9.js";import"./index-CVOcPLpq.js";import"./index-CwKDC_mg.js";import"./table-DcItj2h-.js";import"./badge-Yar_qzGV.js";import"./eye-C7uXpcGF.js";import"./copy-B5YKNs8h.js";import"./toggle-right-D0Z7-kik.js";import"./toggle-left-CB4QYrfM.js";function ye(){const{user:x}=H(),{toast:r}=M(),[i,L]=c.useState(null),[g,I]=c.useState([]),[B,O]=c.useState(!0),[q,u]=c.useState(!1),[j,p]=c.useState(null),[s,n]=c.useState({title:"",content:"",source_url:""});c.useEffect(()=>{x&&A()},[x]);const A=async()=>{try{const{data:t,error:l}=await d.from("clients").select("id, name, chatbot_id").eq("user_id",x?.id).single();if(l)throw l;L(t),t&&h(t.id)}catch{r({title:"Fejl",description:"Kunne ikke hente dine data",variant:"destructive"})}finally{O(!1)}},h=async t=>{try{const{data:l,error:w}=await d.from("client_knowledge").select("*").eq("client_id",t).order("created_at",{ascending:!1});if(w)throw w;I(l||[])}catch{r({title:"Fejl",description:"Kunne ikke hente videnbase",variant:"destructive"})}},R=async()=>{if(!s.title||!i){r({title:"Fejl",description:"Titel er påkrævet",variant:"destructive"});return}try{const{error:t}=await d.from("client_knowledge").insert({client_id:i.id,chatbot_id:i.chatbot_id,title:s.title,content:s.content||null,source_url:s.source_url||null});if(t)throw t;r({title:"Succes",description:"Viden tilføjet"}),u(!1),n({title:"",content:"",source_url:""}),h(i.id)}catch(t){r({title:"Fejl",description:t.message||"Kunne ikke tilføje viden",variant:"destructive"})}},P=async()=>{if(!j||!s.title||!i){r({title:"Fejl",description:"Titel er påkrævet",variant:"destructive"});return}try{const{error:t}=await d.from("client_knowledge").update({title:s.title,content:s.content||null,source_url:s.source_url||null}).eq("id",j.id);if(t)throw t;r({title:"Succes",description:"Viden opdateret"}),p(null),n({title:"",content:"",source_url:""}),h(i.id)}catch(t){r({title:"Fejl",description:t.message||"Kunne ikke opdatere viden",variant:"destructive"})}},U=async t=>{if(confirm("Er du sikker på at du vil slette denne viden?"))try{const{error:l}=await d.from("client_knowledge").delete().eq("id",t);if(l)throw l;r({title:"Succes",description:"Viden slettet"}),i&&h(i.id)}catch(l){r({title:"Fejl",description:l.message||"Kunne ikke slette viden",variant:"destructive"})}},z=t=>{p(t),n({title:t.title,content:t.content||"",source_url:t.source_url||""})},v=()=>{p(null),n({title:"",content:"",source_url:""})};return B?e.jsx(N,{children:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary"})})}):e.jsx(N,{children:e.jsxs("div",{className:"container mx-auto py-8 px-4 max-w-6xl",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-3xl font-bold text-foreground",children:"Min Videnbase"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Administrer din personlige information som din bot kan bruge"})]}),e.jsxs(X,{defaultValue:"knowledge",className:"space-y-6",children:[e.jsxs(Y,{children:[e.jsxs(K,{value:"knowledge",children:[e.jsx(f,{className:"w-4 h-4 mr-2"}),"Viden"]}),e.jsxs(K,{value:"sharing",children:[e.jsx($,{className:"w-4 h-4 mr-2"}),"Deling"]})]}),e.jsxs(V,{value:"knowledge",className:"space-y-6",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(C,{open:q,onOpenChange:u,children:[e.jsx(W,{asChild:!0,children:e.jsxs(a,{children:[e.jsx(E,{className:"w-4 h-4 mr-2"}),"Tilføj Viden"]})}),e.jsxs(_,{className:"max-w-2xl",children:[e.jsxs(T,{children:[e.jsx(D,{children:"Tilføj Ny Viden"}),e.jsx(F,{children:"Tilføj personlig information til din videnbase"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"title",children:"Titel *"}),e.jsx(m,{id:"title",value:s.title,onChange:t=>n({...s,title:t.target.value}),placeholder:"Eks: Næste lektion, Status, Betalinger..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"content",children:"Indhold"}),e.jsx(y,{id:"content",value:s.content,onChange:t=>n({...s,content:t.target.value}),placeholder:"Beskriv den information som botten skal bruge...",rows:6})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"source_url",children:"Kilde URL (valgfrit)"}),e.jsx(m,{id:"source_url",value:s.source_url,onChange:t=>n({...s,source_url:t.target.value}),placeholder:"https://example.com"})]})]}),e.jsxs(S,{children:[e.jsx(a,{variant:"outline",onClick:()=>u(!1),children:"Annuller"}),e.jsx(a,{onClick:R,children:"Tilføj Viden"})]})]})]})}),g.length===0?e.jsx(k,{children:e.jsxs(b,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(f,{className:"w-12 h-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Ingen videnbase endnu"}),e.jsx("p",{className:"text-muted-foreground text-center mb-4",children:"Tilføj personlig information til din videnbase"}),e.jsxs(a,{onClick:()=>u(!0),children:[e.jsx(E,{className:"w-4 h-4 mr-2"}),"Tilføj Viden"]})]})}):e.jsx("div",{className:"grid gap-4",children:g.map(t=>e.jsxs(k,{children:[e.jsx(G,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs(J,{className:"flex items-center gap-2",children:[e.jsx(f,{className:"w-5 h-5"}),t.title]}),t.source_url&&e.jsxs(Q,{className:"flex items-center gap-1 mt-2",children:[e.jsx(ee,{className:"w-3 h-3"}),e.jsx("a",{href:t.source_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:t.source_url})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(a,{variant:"ghost",size:"sm",onClick:()=>z(t),children:e.jsx(te,{className:"w-4 h-4"})}),e.jsx(a,{variant:"ghost",size:"sm",onClick:()=>U(t.id),children:e.jsx(se,{className:"w-4 h-4 text-destructive"})})]})]})}),t.content&&e.jsx(b,{children:e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:t.content})})]},t.id))}),e.jsx(C,{open:!!j,onOpenChange:t=>!t&&v(),children:e.jsxs(_,{className:"max-w-2xl",children:[e.jsxs(T,{children:[e.jsx(D,{children:"Rediger Viden"}),e.jsx(F,{children:"Opdater videnbase information"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"edit-title",children:"Titel *"}),e.jsx(m,{id:"edit-title",value:s.title,onChange:t=>n({...s,title:t.target.value}),placeholder:"Eks: Næste lektion, Status, Betalinger..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"edit-content",children:"Indhold"}),e.jsx(y,{id:"edit-content",value:s.content,onChange:t=>n({...s,content:t.target.value}),placeholder:"Beskriv den information som botten skal bruge...",rows:6})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"edit-source_url",children:"Kilde URL (valgfrit)"}),e.jsx(m,{id:"edit-source_url",value:s.source_url,onChange:t=>n({...s,source_url:t.target.value}),placeholder:"https://example.com"})]})]}),e.jsxs(S,{children:[e.jsx(a,{variant:"outline",onClick:v,children:"Annuller"}),e.jsx(a,{onClick:P,children:"Gem Ændringer"})]})]})})]}),e.jsx(V,{value:"sharing",children:i&&e.jsx(Z,{clientId:i.id,clientName:i.name})})]})]})})}export{ye 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.