Fix: Use fresh authStore reference for each request to avoid stale token
This commit is contained in:
@@ -1 +1 @@
|
||||
import{d as l,c as n,q as c,b as i,E as r,o}from"./index-DA3SfkJ3.js";const u=["type","disabled"],f={key:0,class:"btn__spinner"},b=l({__name:"Button",props:{variant:{default:"primary"},size:{default:"md"},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},type:{default:"button"}},setup(e){return(t,a)=>(o(),n("button",{type:e.type,disabled:e.disabled||e.loading,class:c(["btn",`btn--${e.variant}`,`btn--${e.size}`])},[e.loading?(o(),n("span",f)):i("",!0),r(t.$slots,"default",{},void 0)],10,u))}}),m=(e,t)=>{const a=e.__vccOpts||e;for(const[s,d]of t)a[s]=d;return a},y=m(b,[["__scopeId","data-v-a1ef9cca"]]);export{y as B,m as _};
|
||||
import{d as l,c as n,q as c,b as i,E as r,o}from"./index-DRjWNyfe.js";const u=["type","disabled"],f={key:0,class:"btn__spinner"},b=l({__name:"Button",props:{variant:{default:"primary"},size:{default:"md"},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},type:{default:"button"}},setup(e){return(t,a)=>(o(),n("button",{type:e.type,disabled:e.disabled||e.loading,class:c(["btn",`btn--${e.variant}`,`btn--${e.size}`])},[e.loading?(o(),n("span",f)):i("",!0),r(t.$slots,"default",{},void 0)],10,u))}}),m=(e,t)=>{const a=e.__vccOpts||e;for(const[s,d]of t)a[s]=d;return a},y=m(b,[["__scopeId","data-v-a1ef9cca"]]);export{y as B,m as _};
|
||||
@@ -1 +1 @@
|
||||
import{d as b,k as x,c as a,a as t,t as u,l as c,f as p,g as i,F as P,m as B,r as f,o as n,h as m,e as y,v as g,w as N,j as D,b as M}from"./index-DA3SfkJ3.js";import{u as V}from"./projects-gD83Kd3J.js";import{B as _,_ as S}from"./Button-BSIDh9oJ.js";import{M as $}from"./Modal-CeHY9Rct.js";const F={class:"dashboard"},U={class:"dashboard__header"},z={class:"dashboard__subtitle"},L={key:0,class:"dashboard__loading"},H={key:1,class:"dashboard__empty"},R={key:2,class:"dashboard__grid"},T=["onClick"],E={class:"project-card__content"},I={class:"project-card__name"},Y={key:0,class:"project-card__desc"},q={class:"project-card__date"},A={class:"form__field"},G={class:"form__field"},J=b({__name:"Dashboard",setup(K){const k=D(),s=V(),l=f(!1),d=f(""),v=f(""),j=f(!1);x(async()=>{await s.fetchProjects()});function h(r){k.push(`/projects/${r}`)}async function w(){if(d.value.trim()){j.value=!0;try{const r=await s.createProject(d.value.trim(),v.value.trim());l.value=!1,d.value="",v.value="",h(r.id)}catch(r){console.error("Failed to create project:",r)}finally{j.value=!1}}}function C(r){return new Date(r).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}return(r,e)=>(n(),a("div",F,[t("div",U,[t("div",null,[e[6]||(e[6]=t("h1",{class:"dashboard__title"},"Your Projects",-1)),t("p",z,u(c(s).projects.length)+" project"+u(c(s).projects.length!==1?"s":""),1)]),p(_,{variant:"primary",onClick:e[0]||(e[0]=o=>l.value=!0)},{default:i(()=>[...e[7]||(e[7]=[t("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[t("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),t("line",{x1:"5",y1:"12",x2:"19",y2:"12"})],-1),m(" New Project ",-1)])]),_:1})]),c(s).loading?(n(),a("div",L,[...e[8]||(e[8]=[t("div",{class:"dashboard__spinner"},null,-1),t("p",null,"Loading projects...",-1)])])):c(s).projects.length===0?(n(),a("div",H,[e[10]||(e[10]=t("svg",{width:"64",height:"64",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[t("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})],-1)),e[11]||(e[11]=t("h2",null,"No projects yet",-1)),e[12]||(e[12]=t("p",null,"Create your first project to start organizing your documents",-1)),p(_,{variant:"primary",onClick:e[1]||(e[1]=o=>l.value=!0)},{default:i(()=>[...e[9]||(e[9]=[m(" Create First Project ",-1)])]),_:1})])):(n(),a("div",R,[(n(!0),a(P,null,B(c(s).projects,o=>(n(),a("article",{key:o.id,class:"project-card",onClick:O=>h(o.id)},[e[13]||(e[13]=t("div",{class:"project-card__icon"},[t("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[t("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})])],-1)),t("div",E,[t("h3",I,u(o.name),1),o.description?(n(),a("p",Y,u(o.description),1)):M("",!0),t("p",q," Updated "+u(C(o.updated_at)),1)]),e[14]||(e[14]=t("svg",{class:"project-card__arrow",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[t("path",{d:"m9 18 6-6-6-6"})],-1))],8,T))),128))])),p($,{show:l.value,title:"Create New Project",onClose:e[5]||(e[5]=o=>l.value=!1)},{footer:i(()=>[p(_,{variant:"secondary",onClick:e[4]||(e[4]=o=>l.value=!1)},{default:i(()=>[...e[17]||(e[17]=[m("Cancel",-1)])]),_:1}),p(_,{variant:"primary",loading:j.value,onClick:w},{default:i(()=>[...e[18]||(e[18]=[m("Create Project",-1)])]),_:1},8,["loading"])]),default:i(()=>[t("form",{onSubmit:N(w,["prevent"])},[t("div",A,[e[15]||(e[15]=t("label",{for:"project-name",class:"form__label"},"Project Name",-1)),y(t("input",{id:"project-name","onUpdate:modelValue":e[2]||(e[2]=o=>d.value=o),type:"text",class:"form__input",placeholder:"My Research Project",autofocus:""},null,512),[[g,d.value]])]),t("div",G,[e[16]||(e[16]=t("label",{for:"project-desc",class:"form__label"},"Description (optional)",-1)),y(t("textarea",{id:"project-desc","onUpdate:modelValue":e[3]||(e[3]=o=>v.value=o),class:"form__textarea",placeholder:"Brief description of your project...",rows:"3"},null,512),[[g,v.value]])])],32)]),_:1},8,["show"])]))}}),ee=S(J,[["__scopeId","data-v-a5d62dba"]]);export{ee as default};
|
||||
import{d as b,k as x,c as a,a as t,t as u,l as c,f as p,g as i,F as P,m as B,r as f,o as n,h as m,e as y,v as g,w as N,j as D,b as M}from"./index-DRjWNyfe.js";import{u as V}from"./projects-Qx3ewdzw.js";import{B as _,_ as S}from"./Button-C94ALd0N.js";import{M as $}from"./Modal-4l4K46VH.js";const F={class:"dashboard"},U={class:"dashboard__header"},z={class:"dashboard__subtitle"},L={key:0,class:"dashboard__loading"},H={key:1,class:"dashboard__empty"},R={key:2,class:"dashboard__grid"},T=["onClick"],E={class:"project-card__content"},I={class:"project-card__name"},Y={key:0,class:"project-card__desc"},q={class:"project-card__date"},A={class:"form__field"},G={class:"form__field"},J=b({__name:"Dashboard",setup(K){const k=D(),s=V(),l=f(!1),d=f(""),v=f(""),j=f(!1);x(async()=>{await s.fetchProjects()});function h(r){k.push(`/projects/${r}`)}async function w(){if(d.value.trim()){j.value=!0;try{const r=await s.createProject(d.value.trim(),v.value.trim());l.value=!1,d.value="",v.value="",h(r.id)}catch(r){console.error("Failed to create project:",r)}finally{j.value=!1}}}function C(r){return new Date(r).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}return(r,e)=>(n(),a("div",F,[t("div",U,[t("div",null,[e[6]||(e[6]=t("h1",{class:"dashboard__title"},"Your Projects",-1)),t("p",z,u(c(s).projects.length)+" project"+u(c(s).projects.length!==1?"s":""),1)]),p(_,{variant:"primary",onClick:e[0]||(e[0]=o=>l.value=!0)},{default:i(()=>[...e[7]||(e[7]=[t("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[t("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),t("line",{x1:"5",y1:"12",x2:"19",y2:"12"})],-1),m(" New Project ",-1)])]),_:1})]),c(s).loading?(n(),a("div",L,[...e[8]||(e[8]=[t("div",{class:"dashboard__spinner"},null,-1),t("p",null,"Loading projects...",-1)])])):c(s).projects.length===0?(n(),a("div",H,[e[10]||(e[10]=t("svg",{width:"64",height:"64",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[t("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})],-1)),e[11]||(e[11]=t("h2",null,"No projects yet",-1)),e[12]||(e[12]=t("p",null,"Create your first project to start organizing your documents",-1)),p(_,{variant:"primary",onClick:e[1]||(e[1]=o=>l.value=!0)},{default:i(()=>[...e[9]||(e[9]=[m(" Create First Project ",-1)])]),_:1})])):(n(),a("div",R,[(n(!0),a(P,null,B(c(s).projects,o=>(n(),a("article",{key:o.id,class:"project-card",onClick:O=>h(o.id)},[e[13]||(e[13]=t("div",{class:"project-card__icon"},[t("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[t("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})])],-1)),t("div",E,[t("h3",I,u(o.name),1),o.description?(n(),a("p",Y,u(o.description),1)):M("",!0),t("p",q," Updated "+u(C(o.updated_at)),1)]),e[14]||(e[14]=t("svg",{class:"project-card__arrow",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[t("path",{d:"m9 18 6-6-6-6"})],-1))],8,T))),128))])),p($,{show:l.value,title:"Create New Project",onClose:e[5]||(e[5]=o=>l.value=!1)},{footer:i(()=>[p(_,{variant:"secondary",onClick:e[4]||(e[4]=o=>l.value=!1)},{default:i(()=>[...e[17]||(e[17]=[m("Cancel",-1)])]),_:1}),p(_,{variant:"primary",loading:j.value,onClick:w},{default:i(()=>[...e[18]||(e[18]=[m("Create Project",-1)])]),_:1},8,["loading"])]),default:i(()=>[t("form",{onSubmit:N(w,["prevent"])},[t("div",A,[e[15]||(e[15]=t("label",{for:"project-name",class:"form__label"},"Project Name",-1)),y(t("input",{id:"project-name","onUpdate:modelValue":e[2]||(e[2]=o=>d.value=o),type:"text",class:"form__input",placeholder:"My Research Project",autofocus:""},null,512),[[g,d.value]])]),t("div",G,[e[16]||(e[16]=t("label",{for:"project-desc",class:"form__label"},"Description (optional)",-1)),y(t("textarea",{id:"project-desc","onUpdate:modelValue":e[3]||(e[3]=o=>v.value=o),class:"form__textarea",placeholder:"Brief description of your project...",rows:"3"},null,512),[[g,v.value]])])],32)]),_:1},8,["show"])]))}}),ee=S(J,[["__scopeId","data-v-a5d62dba"]]);export{ee as default};
|
||||
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
||||
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};
|
||||
import{y as B,r as v,z as M,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-DRjWNyfe.js";import{_ as K}from"./Button-C94ALd0N.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};
|
||||
@@ -1 +1 @@
|
||||
import{d as C,u as k,c as _,a as e,t as n,w as S,b as A,e as v,v as g,f as B,g as M,h as p,r as i,i as m,j as V,o as f}from"./index-DA3SfkJ3.js";import{B as D,_ as E}from"./Button-BSIDh9oJ.js";const N={class:"login"},I={class:"login__card"},L={class:"login__header"},T={class:"login__title"},U={class:"login__subtitle"},P={key:0,class:"login__error"},R={class:"login__field"},j={class:"login__field"},z={class:"login__toggle"},W=C({__name:"Login",setup(q){const h=V(),r=k(),o=i(""),s=i(""),a=i(!1),u=i(!1),l=i(""),w=m(()=>a.value?"Create Account":"Welcome Back"),y=m(()=>a.value?"Create Account":"Sign In");async function b(){if(!o.value||!s.value){l.value="Please fill in all fields";return}u.value=!0,l.value="";try{a.value?(await r.register(o.value,s.value),await r.login(o.value,s.value)):await r.login(o.value,s.value),h.push("/dashboard")}catch(d){l.value=d instanceof Error?d.message:"Authentication failed"}finally{u.value=!1}}function x(){a.value=!a.value,l.value=""}return(d,t)=>(f(),_("div",N,[e("div",I,[e("div",L,[t[2]||(t[2]=e("svg",{width:"40",height:"40",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("h1",T,n(w.value),1),e("p",U,n(a.value?"Create your account to get started":"Sign in to access your documents"),1)]),e("form",{class:"login__form",onSubmit:S(b,["prevent"])},[l.value?(f(),_("div",P,n(l.value),1)):A("",!0),e("div",R,[t[3]||(t[3]=e("label",{for:"username",class:"login__label"},"Username",-1)),v(e("input",{id:"username","onUpdate:modelValue":t[0]||(t[0]=c=>o.value=c),type:"text",class:"login__input",placeholder:"Enter your username",autocomplete:"username"},null,512),[[g,o.value]])]),e("div",j,[t[4]||(t[4]=e("label",{for:"password",class:"login__label"},"Password",-1)),v(e("input",{id:"password","onUpdate:modelValue":t[1]||(t[1]=c=>s.value=c),type:"password",class:"login__input",placeholder:"Enter your password",autocomplete:"current-password"},null,512),[[g,s.value]])]),B(D,{type:"submit",variant:"primary",size:"lg",loading:u.value,style:{width:"100%"}},{default:M(()=>[p(n(y.value),1)]),_:1},8,["loading"]),e("p",z,[p(n(a.value?"Already have an account?":"Don't have an account?")+" ",1),e("button",{type:"button",class:"login__toggle-btn",onClick:x},n(a.value?"Sign in":"Create one"),1)])],32)]),t[5]||(t[5]=e("p",{class:"login__footer"}," Claudia Docs — Document Management for AI Agents ",-1))]))}}),H=E(W,[["__scopeId","data-v-d1a9e623"]]);export{H as default};
|
||||
import{d as C,u as k,c as _,a as e,t as n,w as S,b as A,e as v,v as g,f as B,g as M,h as p,r as i,i as m,j as V,o as f}from"./index-DRjWNyfe.js";import{B as D,_ as E}from"./Button-C94ALd0N.js";const N={class:"login"},I={class:"login__card"},L={class:"login__header"},T={class:"login__title"},U={class:"login__subtitle"},P={key:0,class:"login__error"},R={class:"login__field"},j={class:"login__field"},z={class:"login__toggle"},W=C({__name:"Login",setup(q){const h=V(),r=k(),o=i(""),s=i(""),a=i(!1),u=i(!1),l=i(""),w=m(()=>a.value?"Create Account":"Welcome Back"),y=m(()=>a.value?"Create Account":"Sign In");async function b(){if(!o.value||!s.value){l.value="Please fill in all fields";return}u.value=!0,l.value="";try{a.value?(await r.register(o.value,s.value),await r.login(o.value,s.value)):await r.login(o.value,s.value),h.push("/dashboard")}catch(d){l.value=d instanceof Error?d.message:"Authentication failed"}finally{u.value=!1}}function x(){a.value=!a.value,l.value=""}return(d,t)=>(f(),_("div",N,[e("div",I,[e("div",L,[t[2]||(t[2]=e("svg",{width:"40",height:"40",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("h1",T,n(w.value),1),e("p",U,n(a.value?"Create your account to get started":"Sign in to access your documents"),1)]),e("form",{class:"login__form",onSubmit:S(b,["prevent"])},[l.value?(f(),_("div",P,n(l.value),1)):A("",!0),e("div",R,[t[3]||(t[3]=e("label",{for:"username",class:"login__label"},"Username",-1)),v(e("input",{id:"username","onUpdate:modelValue":t[0]||(t[0]=c=>o.value=c),type:"text",class:"login__input",placeholder:"Enter your username",autocomplete:"username"},null,512),[[g,o.value]])]),e("div",j,[t[4]||(t[4]=e("label",{for:"password",class:"login__label"},"Password",-1)),v(e("input",{id:"password","onUpdate:modelValue":t[1]||(t[1]=c=>s.value=c),type:"password",class:"login__input",placeholder:"Enter your password",autocomplete:"current-password"},null,512),[[g,s.value]])]),B(D,{type:"submit",variant:"primary",size:"lg",loading:u.value,style:{width:"100%"}},{default:M(()=>[p(n(y.value),1)]),_:1},8,["loading"]),e("p",z,[p(n(a.value?"Already have an account?":"Don't have an account?")+" ",1),e("button",{type:"button",class:"login__toggle-btn",onClick:x},n(a.value?"Sign in":"Create one"),1)])],32)]),t[5]||(t[5]=e("p",{class:"login__footer"}," Claudia Docs — Document Management for AI Agents ",-1))]))}}),H=E(W,[["__scopeId","data-v-d1a9e623"]]);export{H as default};
|
||||
@@ -1 +1 @@
|
||||
import{d as _,n as f,C as u,s as k,f as h,T as v,g as p,D as y,o as s,c as l,a,t as C,b as n,E as i,q as B}from"./index-DA3SfkJ3.js";import{_ as w}from"./Button-BSIDh9oJ.js";const E={key:0,class:"modal__header"},$={class:"modal__title"},b={class:"modal__body"},g={key:1,class:"modal__footer"},z=_({__name:"Modal",props:{show:{type:Boolean},title:{},size:{default:"md"}},emits:["close"],setup(o,{emit:c}){const t=c;function r(e){e.target.classList.contains("modal")&&t("close")}function m(e){e.key==="Escape"&&t("close")}return f(()=>t,()=>{},{immediate:!0}),u(()=>{document.removeEventListener("keydown",m)}),(e,d)=>(s(),k(y,{to:"body"},[h(v,{name:"modal"},{default:p(()=>[o.show?(s(),l("div",{key:0,class:"modal",onClick:r},[a("div",{class:B(["modal__content",`modal__content--${o.size}`])},[o.title?(s(),l("div",E,[a("h2",$,C(o.title),1),a("button",{class:"modal__close",onClick:d[0]||(d[0]=M=>t("close"))},"×")])):n("",!0),a("div",b,[i(e.$slots,"default",{},void 0,!0)]),e.$slots.footer?(s(),l("div",g,[i(e.$slots,"footer",{},void 0,!0)])):n("",!0)],2)])):n("",!0)]),_:3})]))}}),V=w(z,[["__scopeId","data-v-f5a1757e"]]);export{V as M};
|
||||
import{d as _,n as f,C as u,s as k,f as h,T as v,g as p,D as y,o as s,c as l,a,t as C,b as n,E as i,q as B}from"./index-DRjWNyfe.js";import{_ as w}from"./Button-C94ALd0N.js";const E={key:0,class:"modal__header"},$={class:"modal__title"},b={class:"modal__body"},g={key:1,class:"modal__footer"},z=_({__name:"Modal",props:{show:{type:Boolean},title:{},size:{default:"md"}},emits:["close"],setup(o,{emit:c}){const t=c;function r(e){e.target.classList.contains("modal")&&t("close")}function m(e){e.key==="Escape"&&t("close")}return f(()=>t,()=>{},{immediate:!0}),u(()=>{document.removeEventListener("keydown",m)}),(e,d)=>(s(),k(y,{to:"body"},[h(v,{name:"modal"},{default:p(()=>[o.show?(s(),l("div",{key:0,class:"modal",onClick:r},[a("div",{class:B(["modal__content",`modal__content--${o.size}`])},[o.title?(s(),l("div",E,[a("h2",$,C(o.title),1),a("button",{class:"modal__close",onClick:d[0]||(d[0]=M=>t("close"))},"×")])):n("",!0),a("div",b,[i(e.$slots,"default",{},void 0,!0)]),e.$slots.footer?(s(),l("div",g,[i(e.$slots,"footer",{},void 0,!0)])):n("",!0)],2)])):n("",!0)]),_:3})]))}}),V=w(z,[["__scopeId","data-v-f5a1757e"]]);export{V as M};
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
||||
import{y as x,z as E,r as s}from"./index-DA3SfkJ3.js";const M=x("projects",()=>{const c=s([]),a=s(null),u=s([]),d=s([]),p=s([]),i=s(!1),l=s(null),r=E();async function j(){i.value=!0,l.value=null;try{const e=await r.get("/projects");c.value=e.projects}catch(e){throw l.value=e instanceof Error?e.message:"Failed to fetch projects",e}finally{i.value=!1}}async function y(e){i.value=!0,l.value=null;try{a.value=await r.get(`/projects/${e}`),await f(e)}catch(o){throw l.value=o instanceof Error?o.message:"Failed to fetch project",o}finally{i.value=!1}}async function f(e){try{const[o,t]=await Promise.all([r.get(`/projects/${e}/folders`),r.get(`/projects/${e}/documents`)]);u.value=o.folders,d.value=t.documents,m()}catch(o){throw l.value=o instanceof Error?o.message:"Failed to fetch project tree",o}}function m(){const e=new Map,o=[];for(const t of u.value){const n={id:t.id,name:t.name,type:"folder",children:[],parent_id:t.parent_id};e.set(t.id,n)}for(const t of d.value)if(!t.folder_id){const n={id:t.id,name:t.title,type:"document",parent_id:null};e.set(t.id,n)}for(const t of d.value)if(t.folder_id){const n=e.get(t.folder_id);n&&n.children&&n.children.push({id:t.id,name:t.title,type:"document",parent_id:t.folder_id})}for(const t of e.values())if(t.parent_id===null)o.push(t);else{const n=e.get(t.parent_id);n&&n.children&&n.children.push(t)}p.value=o}async function w(e,o){const t=await r.post("/projects",{name:e,description:o});return c.value.push(t),t}async function _(e,o,t){var h;const n=await r.put(`/projects/${e}`,{name:o,description:t}),v=c.value.findIndex(F=>F.id===e);return v!==-1&&(c.value[v]=n),((h=a.value)==null?void 0:h.id)===e&&(a.value=n),n}async function g(e){var o;await r.delete(`/projects/${e}`),c.value=c.value.filter(t=>t.id!==e),((o=a.value)==null?void 0:o.id)===e&&(a.value=null)}async function P(e,o,t=null){const n=await r.post(`/projects/${e}/folders`,{name:o,parent_id:t});return u.value.push(n),await f(e),n}async function $(e){await r.delete(`/folders/${e}`),a.value&&await f(a.value.id)}return{projects:c,currentProject:a,folders:u,documents:d,treeNodes:p,loading:i,error:l,fetchProjects:j,fetchProject:y,fetchProjectTree:f,createProject:w,updateProject:_,deleteProject:g,createFolder:P,deleteFolder:$}});export{M as u};
|
||||
import{y as x,r as s,z as E}from"./index-DRjWNyfe.js";const M=x("projects",()=>{const c=s([]),a=s(null),u=s([]),d=s([]),p=s([]),i=s(!1),l=s(null),r=E();async function j(){i.value=!0,l.value=null;try{const e=await r.get("/projects");c.value=e.projects}catch(e){throw l.value=e instanceof Error?e.message:"Failed to fetch projects",e}finally{i.value=!1}}async function y(e){i.value=!0,l.value=null;try{a.value=await r.get(`/projects/${e}`),await f(e)}catch(o){throw l.value=o instanceof Error?o.message:"Failed to fetch project",o}finally{i.value=!1}}async function f(e){try{const[o,t]=await Promise.all([r.get(`/projects/${e}/folders`),r.get(`/projects/${e}/documents`)]);u.value=o.folders,d.value=t.documents,m()}catch(o){throw l.value=o instanceof Error?o.message:"Failed to fetch project tree",o}}function m(){const e=new Map,o=[];for(const t of u.value){const n={id:t.id,name:t.name,type:"folder",children:[],parent_id:t.parent_id};e.set(t.id,n)}for(const t of d.value)if(!t.folder_id){const n={id:t.id,name:t.title,type:"document",parent_id:null};e.set(t.id,n)}for(const t of d.value)if(t.folder_id){const n=e.get(t.folder_id);n&&n.children&&n.children.push({id:t.id,name:t.title,type:"document",parent_id:t.folder_id})}for(const t of e.values())if(t.parent_id===null)o.push(t);else{const n=e.get(t.parent_id);n&&n.children&&n.children.push(t)}p.value=o}async function w(e,o){const t=await r.post("/projects",{name:e,description:o});return c.value.push(t),t}async function _(e,o,t){var h;const n=await r.put(`/projects/${e}`,{name:o,description:t}),v=c.value.findIndex(F=>F.id===e);return v!==-1&&(c.value[v]=n),((h=a.value)==null?void 0:h.id)===e&&(a.value=n),n}async function g(e){var o;await r.delete(`/projects/${e}`),c.value=c.value.filter(t=>t.id!==e),((o=a.value)==null?void 0:o.id)===e&&(a.value=null)}async function P(e,o,t=null){const n=await r.post(`/projects/${e}/folders`,{name:o,parent_id:t});return u.value.push(n),await f(e),n}async function $(e){await r.delete(`/folders/${e}`),a.value&&await f(a.value.id)}return{projects:c,currentProject:a,folders:u,documents:d,treeNodes:p,loading:i,error:l,fetchProjects:j,fetchProject:y,fetchProjectTree:f,createProject:w,updateProject:_,deleteProject:g,createFolder:P,deleteFolder:$}});export{M as u};
|
||||
2
dist/index.html
vendored
2
dist/index.html
vendored
@@ -5,7 +5,7 @@
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Claudia Docs</title>
|
||||
<script type="module" crossorigin src="/assets/index-DA3SfkJ3.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-DRjWNyfe.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-BG6SLZYI.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -3,9 +3,22 @@ import router from '@/router'
|
||||
|
||||
const BASE_URL = import.meta.env.VITE_API_BASE_URL || 'http://localhost:8000/api/v1'
|
||||
|
||||
export function useApi() {
|
||||
// Helper to get token - always accesses the store freshly to avoid stale closures
|
||||
function getToken(): string | null {
|
||||
try {
|
||||
const authStore = useAuthStore()
|
||||
// In Pinia setup stores, refs are auto-unwrapped on store access
|
||||
// But be defensive: handle both unwrapped string and raw ref
|
||||
const token = authStore.token
|
||||
if (!token) return null
|
||||
// If token is a ref (rare case), access .value
|
||||
return (token as unknown as { value?: string }).value ?? token
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
export function useApi() {
|
||||
async function refreshAccessToken(): Promise<string | null> {
|
||||
try {
|
||||
const response = await fetch(`${BASE_URL}/auth/refresh`, {
|
||||
@@ -14,6 +27,7 @@ export function useApi() {
|
||||
})
|
||||
if (response.ok) {
|
||||
const data = await response.json()
|
||||
const authStore = useAuthStore()
|
||||
authStore.token = data.access_token
|
||||
localStorage.setItem('access_token', data.access_token)
|
||||
return data.access_token
|
||||
@@ -24,22 +38,27 @@ export function useApi() {
|
||||
return null
|
||||
}
|
||||
|
||||
async function request<T>(endpoint: string, options: RequestInit = {}, retryCount = 0): Promise<T> {
|
||||
async function request<T>(method: string, endpoint: string, body?: unknown, retryCount = 0): Promise<T> {
|
||||
const headers: Record<string, string> = {
|
||||
'Content-Type': 'application/json',
|
||||
...(options.headers as Record<string, string> || {})
|
||||
}
|
||||
|
||||
const token = getToken()
|
||||
console.log(`[useApi] ${method} ${endpoint} - token: ${token ? 'present' : 'null'}`)
|
||||
|
||||
// Only add Authorization header for non-auth endpoints
|
||||
// Auth endpoints (login, register, refresh) should NOT receive the old token
|
||||
if (authStore.token && !endpoint.includes('/auth/')) {
|
||||
headers['Authorization'] = `Bearer ${authStore.token}`
|
||||
if (token && !endpoint.includes('/auth/')) {
|
||||
headers['Authorization'] = `Bearer ${token}`
|
||||
console.log(`[useApi] Added Authorization header: Bearer ${token.substring(0, 10)}...`)
|
||||
} else {
|
||||
console.log(`[useApi] NO Authorization header - token=${token}, isAuthEndpoint=${endpoint.includes('/auth/')}`)
|
||||
}
|
||||
|
||||
const response = await fetch(`${BASE_URL}${endpoint}`, {
|
||||
...options,
|
||||
method,
|
||||
headers,
|
||||
body: options.body ? JSON.stringify(options.body) : undefined
|
||||
body: body ? JSON.stringify(body) : undefined,
|
||||
credentials: 'include'
|
||||
})
|
||||
|
||||
if (response.status === 401) {
|
||||
@@ -50,10 +69,10 @@ export function useApi() {
|
||||
// Retry original request with new token
|
||||
headers['Authorization'] = `Bearer ${newToken}`
|
||||
const retryResponse = await fetch(`${BASE_URL}${endpoint}`, {
|
||||
...options,
|
||||
method,
|
||||
headers,
|
||||
credentials: 'include', // Include cookies for auth
|
||||
body: options.body ? JSON.stringify(options.body) : undefined
|
||||
credentials: 'include',
|
||||
body: body ? JSON.stringify(body) : undefined
|
||||
})
|
||||
if (retryResponse.ok) {
|
||||
if (retryResponse.status === 204) {
|
||||
@@ -63,6 +82,7 @@ export function useApi() {
|
||||
}
|
||||
}
|
||||
}
|
||||
const authStore = useAuthStore()
|
||||
authStore.logout()
|
||||
router.push('/login')
|
||||
throw new Error('Unauthorized')
|
||||
@@ -81,11 +101,11 @@ export function useApi() {
|
||||
}
|
||||
|
||||
return {
|
||||
get: <T>(endpoint: string) => request<T>(endpoint, { method: 'GET' }),
|
||||
get: <T>(endpoint: string) => request<T>('GET', endpoint),
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
post: <T>(endpoint: string, body?: any) => request<T>(endpoint, { method: 'POST', body }),
|
||||
post: <T>(endpoint: string, body?: any) => request<T>('POST', endpoint, body),
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
put: <T>(endpoint: string, body?: any) => request<T>(endpoint, { method: 'PUT', body }),
|
||||
delete: <T>(endpoint: string) => request<T>(endpoint, { method: 'DELETE' })
|
||||
put: <T>(endpoint: string, body?: any) => request<T>('PUT', endpoint, body),
|
||||
delete: <T>(endpoint: string) => request<T>('DELETE', endpoint)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user