2 lines
4.2 KiB
JavaScript
2 lines
4.2 KiB
JavaScript
import{y as B,z as M,r as v,d as V,j as U,u as H,p as N,o as b,c as $,a as e,f as S,g as T,w as A,e as j,v as q,t as w,l as y,T as E,h as F,b as z}from"./index-DA3SfkJ3.js";import{_ as K}from"./Button-BSIDh9oJ.js";const I=B("documents",()=>{const n=v(null),d=v([]),i=v(!1),u=v(null),c=v(!1),r=M();async function k(t){i.value=!0,u.value=null;try{n.value=await r.get(`/documents/${t}`)}catch(s){throw u.value=s instanceof Error?s.message:"Failed to fetch document",s}finally{i.value=!1}}async function D(t,s,o="",l=null){const f={title:s,content:o};return l&&(f.folder_id=l),await r.post(`/projects/${t}/documents`,f)}async function a(t,s,o){var C;const l={title:s};o!==void 0&&(l.folder_id=o);const f=await r.put(`/documents/${t}`,l);return((C=n.value)==null?void 0:C.id)===t&&(n.value=f),f}async function x(t,s){var o;c.value=!0;try{await r.put(`/documents/${t}/content`,{content:s}),((o=n.value)==null?void 0:o.id)===t&&(n.value.content=s)}finally{c.value=!1}}async function _(t){var s;await r.delete(`/documents/${t}`),((s=n.value)==null?void 0:s.id)===t&&(n.value=null)}async function p(){try{d.value=await r.get("/tags")}catch(t){console.error("Failed to fetch tags:",t)}}async function m(t,s){const o=await r.post("/tags",{name:t,color:s});return d.value.push(o),o}async function h(t,s){var o;await r.put(`/documents/${t}/tags`,{tag_ids:s}),((o=n.value)==null?void 0:o.id)===t&&(n.value.tags=d.value.filter(l=>s.includes(l.id)))}async function g(t,s){var o;await r.delete(`/documents/${t}/tags/${s}`),((o=n.value)==null?void 0:o.id)===t&&(n.value.tags=n.value.tags.filter(l=>l.id!==s))}return{currentDocument:n,tags:d,loading:i,error:u,saving:c,fetchDocument:k,createDocument:D,updateDocument:a,updateDocumentContent:x,deleteDocument:_,fetchTags:p,createTag:m,assignTags:h,removeTag:g}}),L={class:"header"},Q={class:"header__left"},R={class:"header__center"},G={class:"header__right"},J={class:"header__avatar"},O={class:"header__username"},P={key:0,class:"header__dropdown"},W={class:"header__dropdown-item header__dropdown-item--info"},X=V({__name:"Header",setup(n){const d=U(),i=H(),u=v(""),c=v(!1);function r(){u.value.trim()&&d.push({name:"dashboard",query:{q:u.value}})}function k(){i.logout(),d.push("/login")}return(D,a)=>{var _,p,m;const x=N("router-link");return b(),$("header",L,[e("div",Q,[S(x,{to:"/dashboard",class:"header__logo"},{default:T(()=>[...a[2]||(a[2]=[e("svg",{width:"28",height:"28",viewBox:"0 0 28 28",fill:"none"},[e("rect",{width:"28",height:"28",rx:"6",fill:"var(--accent)"}),e("path",{d:"M8 10h12M8 14h8M8 18h10",stroke:"white","stroke-width":"2","stroke-linecap":"round"})],-1),e("span",{class:"header__title"},"Claudia Docs",-1)])]),_:1})]),e("div",R,[e("form",{class:"header__search",onSubmit:A(r,["prevent"])},[a[3]||(a[3]=e("svg",{class:"header__search-icon",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e("circle",{cx:"11",cy:"11",r:"8"}),e("path",{d:"m21 21-4.35-4.35"})],-1)),j(e("input",{"onUpdate:modelValue":a[0]||(a[0]=h=>u.value=h),type:"text",placeholder:"Search documents...",class:"header__search-input"},null,512),[[q,u.value]]),a[4]||(a[4]=e("kbd",{class:"header__kbd"},"⌘K",-1))],32)]),e("div",G,[e("div",{class:"header__user",onClick:a[1]||(a[1]=h=>c.value=!c.value)},[e("div",J,w(((p=(_=y(i).user)==null?void 0:_.username)==null?void 0:p.charAt(0).toUpperCase())||"U"),1),e("span",O,w(((m=y(i).user)==null?void 0:m.username)||"User"),1),a[7]||(a[7]=e("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e("path",{d:"m6 9 6 6 6-6"})],-1)),S(E,{name:"fade"},{default:T(()=>{var h,g;return[c.value?(b(),$("div",P,[e("div",W,[e("span",null,w((h=y(i).user)==null?void 0:h.username),1),e("small",null,w((g=y(i).user)==null?void 0:g.role),1)]),a[6]||(a[6]=e("hr",{class:"header__dropdown-divider"},null,-1)),e("button",{class:"header__dropdown-item",onClick:k},[...a[5]||(a[5]=[e("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),e("polyline",{points:"16 17 21 12 16 7"}),e("line",{x1:"21",y1:"12",x2:"9",y2:"12"})],-1),F(" Logout ",-1)])])])):z("",!0)]}),_:1})])])])}}}),ee=K(X,[["__scopeId","data-v-0d1f0999"]]);export{ee as H,I as u};
|