PageSourceSearch

https://criticdb.com/_nuxt/BdRpid80.js

js criticdb.com collected 2026-09-25 06:11:06 UTC 11,724 bytes, 1 lines download raw bytes

1import{_ as se}from"./DBcJK9cq.js";import{I as S,o as F,k as ae,D as le,c as r,b as o,d as l,F as k,a as t,f as O,l as c,m as n,J as oe,s as i,r as b,p as ie,v as re,t as g,h as ne,_ as de,g as m}from"./DVPCUeIP.js";import{_ as ue}from"./cAa4lX3s.js";import{_ as ce}from"./DlsM4xyN.js";import{_ as ve}from"./Cx_oi8VI.js";import{u as ge}from"./GPdVP3It.js";import"./DNd9cadU.js";import"./eyC4mF6J.js";import"./Cme3_O54.js";import"./CKn5O6Ku.js";import"./BQhWxLM2.js";import"./WlG_yBXe.js";const ye={class:"max-w-5xl mx-auto"},fe={key:0,class:"space-y-8"},me={class:"p-6 space-y-6"},pe={class:"divide-y divide-gray-100 dark:divide-gray-800"},he={class:"p-6"},ke={class:"divide-y divide-gray-100 dark:divide-gray-800"},_e={class:"p-6"},be={class:"divide-y divide-gray-100 dark:divide-gray-800"},we={key:0,class:"space-y-8"},xe={class:"mb-8"},Ae={class:"space-y-4"},Ie={key:0,class:"divide-y dark:divide-gray-700"},Se={class:"font-medium text-gray-900 dark:text-white"},Ve={class:"mb-8"},Ee={key:0,class:"p-4 text-center text-gray-500"},Ce={key:1,class:"divide-y dark:divide-gray-700"},Le={class:"font-medium text-gray-900 dark:text-white"},$e={class:"text-sm text-gray-500"},qe={class:"flex gap-2"},je={key:0,class:"mb-8"},Pe={class:"p-6"},Ue={key:0,class:"py-4"},Fe={key:1,class:"text-gray-500"},Oe={key:2,class:"divide-y divide-gray-100 dark:divide-gray-800"},Te={class:"space-y-1"},Be={class:"font-medium"},De={class:"text-sm text-gray-500"},Re={class:"text-xs text-gray-400"},Ne={key:1},Me={class:"flex items-center justify-between"},We={class:"text-base font-semibold"},Je={class:"space-y-4"},Qe={class:"flex justify-end gap-3"},ze={class:"space-y-4"},Ge={class:"flex justify-end gap-3"},dt={__name:"authors",setup(He){const w=n(""),x=n([]),L=n(!1),V=n([]),T=n(!1),$=n(!1),q=n(null),y=n(!1),u=n(null),v=n(""),A=n([]),j=n(!1),P=n(null),W=ge(async()=>{if(w.value.length<2){x.value=[];return}L.value=!0;try{const s=await $fetch("/api/outlet/authors/search",{params:{q:w.value}});x.value=s.data}catch{c().add({title:"Error",description:"Failed to search authors",color:"red"}),x.value=[]}finally{L.value=!1}},300);S(w,()=>{W()});const B=async()=>{if(p.value){T.value=!0;try{const{data:s}=await $fetch("/api/outlet/authors/list",{params:{status:"linked"}});V.value=s||[]}catch{c().add({title:"Error",description:"Failed to load authors",color:"red"})}finally{T.value=!1}}},J=s=>s?!!V.value.find(d=>d.id===s)?.profile_id:!1,Q=async s=>{if(confirm(`Are you sure you want to unlink ${s.name}?`)){q.value=s.id;try{await $fetch("/api/outlet/authors/unlink",{method:"POST",body:{authorId:s.id}}),await B(),c().add({title:"Success",description:"Author unlinked successfully",color:"green"})}catch{c().add({title:"Error",description:"Failed to unlink author",color:"red"})}finally{q.value=null}}},_=async()=>{if(p.value){j.value=!0;try{const{data:s}=await $fetch("/api/outlet/authors/listInvites");A.value=s?.filter(e=>e.status==="pending"||e.status==="link_requested")||[]}catch{c().add({title:"Error",description:"Failed to load invites",color:"red"})}finally{j.value=!1}}},z=async s=>{if(confirm(`Are you sure you want to cancel invite for ${s.author.name}?`)){P.value=s.id;try{await $fetch(`/api/outlet/authors/cancelInvite?id=${s.id}`,{method:"DELETE"}),await _(),c().add({title:"Success",description:"Invite cancelled successfully",color:"green"})}catch{c().add({title:"Error",description:"Failed to cancel invite",color:"red"})}finally{P.value=null}}};F(()=>{D()});const G=s=>s?A.value.some(e=>e.author_id===s&&(e.status==="pending"||e.status==="link_requested")):!1;F(()=>{_()}),S(y,async s=>{!s&&p.value&&await _()});const p=n(!1),U=n(!0),I=n(null),D=async()=>{U.value=!0;try{const{data:s}=await ae("/api/outlet/getCurrent","$AL84i4WS7R");p.value=!!s.value?.data,I.value=s.value?.data?.id||null,p.value&&await Promise.all([B(),_()])}catch{p.value=!1,I.value=null}finally{U.value=!1}};F(()=>{D()}),I.value;const E=n(null),H=s=>{u.value=s,v.value="",y.value=!0},C=n(null),f=n(!1),K=async()=>{if(!v.value){c().add({title:"Error",description:"Please enter an email address",color:"red"});return}E.value=u.value?.id;try{const s=await $fetch("/api/outlet/authors/sendInvite",{method:"POST",body:{authorId:u.value.id,outletId:I.value,email:v.value}});if(s.status==="existing_user"){C.value=s.profile;const e={...u.value},d=v.value;y.value=!1,u.value=e,v.value=d,f.value=!0;return}s.success&&(c().add({title:"Success",description:"Invite sent successfully",color:"green"}),y.value=!1,await _())}catch(s){c().add({title:"Error",description:s?.data?.message||"Failed to send invite",color:"red"})}finally{E.value=null}};S(f,s=>{});const X=async()=>
1{if(!(!C.value||!u.value)){$.value=!0;try{(await $fetch("/api/outlet/authors/requestAccountLink",{method:"POST",body:{profileId:C.value.id,authorId:u.value.id,outletId:I.value,email:v.value}})).success&&(c().add({title:"Success",description:"Link request sent successfully",color:"green"}),f.value=!1,await _())}catch(s){c().add({title:"Error",description:s?.data?.message||"Failed to send link request",color:"red"})}finally{$.value=!1}}};return S(y,s=>{!s&&!f.value&&(u.value=null,v.value="")}),S(f,s=>{s||(u.value=null,C.value=null,v.value="")}),le(),(s,e)=>{const d=se,Y=re,R=ie,h=de,Z=ue,ee=oe("ULoadingBar"),te=ce,N=ve;return i(),r("div",ye,[U.value?(i(),r("div",fe,[o(d,{class:"bg-white dark:bg-gray-800"},{default:l(()=>[e[8]||(e[8]=t("div",{class:"p-6 border-b dark:border-gray-700"},[t("div",{class:"flex items-center justify-between"},[t("div",{class:"h-6 bg-gray-200 dark:bg-gray-700 rounded w-32"})])],-1)),t("div",me,[e[7]||(e[7]=t("div",{class:"h-10 bg-gray-200 dark:bg-gray-700 rounded"},null,-1)),t("div",pe,[(i(),r(k,null,b(3,a=>t("div",{key:a,class:"flex items-center justify-between py-4"},[...e[6]||(e[6]=[t("div",{class:"flex items-center gap-3"},[t("div",{class:"w-10 h-10 rounded-full bg-gray-200 dark:bg-gray-700"}),t("div",{class:"space-y-2"},[t("div",{class:"h-4 bg-gray-200 dark:bg-gray-700 rounded w-32"}),t("div",{class:"h-3 bg-gray-200 dark:bg-gray-700 rounded w-24"})])],-1),t("div",{class:"h-8 bg-gray-200 dark:bg-gray-700 rounded w-24"},null,-1)])])),64))])])]),_:1}),o(d,{class:"bg-white dark:bg-gray-800"},{default:l(()=>[e[10]||(e[10]=t("div",{class:"p-6 border-b dark:border-gray-700"},[t("div",{class:"flex items-center justify-between"},[t("div",{class:"h-6 bg-gray-200 dark:bg-gray-700 rounded w-32"})])],-1)),t("div",he,[t("div",ke,[(i(),r(k,null,b(3,a=>t("div",{key:a,class:"flex items-center justify-between py-4"},[...e[9]||(e[9]=[t("div",{class:"flex items-center gap-3"},[t("div",{class:"w-10 h-10 rounded-full bg-gray-200 dark:bg-gray-700"}),t("div",{class:"space-y-2"},[t("div",{class:"h-4 bg-gray-200 dark:bg-gray-700 rounded w-32"}),t("div",{class:"h-3 bg-gray-200 dark:bg-gray-700 rounded w-24"})])],-1),t("div",{class:"h-8 bg-gray-200 dark:bg-gray-700 rounded w-24"},null,-1)])])),64))])])]),_:1}),o(d,{class:"bg-white dark:bg-gray-800"},{default:l(()=>[e[12]||(e[12]=t("div",{class:"p-6 border-b dark:border-gray-700"},[t("div",{class:"flex items-center justify-between"},[t("div",{class:"h-6 bg-gray-200 dark:bg-gray-700 rounded w-32"})])],-1)),t("div",_e,[t("div",be,[(i(),r(k,null,b(2,a=>t("div",{key:a,class:"flex items-center justify-between py-4"},[...e[11]||(e[11]=[t("div",{class:"space-y-2"},[t("div",{class:"h-4 bg-gray-200 dark:bg-gray-700 rounded w-32"}),t("div",{class:"h-3 bg-gray-200 dark:bg-gray-700 rounded w-48"}),t("div",{class:"h-3 bg-gray-200 dark:bg-gray-700 rounded w-24"})],-1),t("div",{class:"h-8 bg-gray-200 dark:bg-gray-700 rounded w-24"},null,-1)])])),64))])])]),_:1})])):(i(),r(k,{key:1},[p.value?(i(),r("div",we,[t("div",xe,[e[14]||(e[14]=t("h3",{class:"font-medium text-gray-900 dark:text-white mb-4"},"Search Authors",-1)),o(d,null,{default:l(()=>[t("div",Ae,[o(R,{modelValue:w.value,"onUpdate:modelValue":e[0]||(e[0]=a=>w.value=a),placeholder:"Search authors...",loading:L.value},{leading:l(()=>[o(Y,{name:"i-heroicons-magnifying-glass"})]),_:1},8,["modelValue","loading"]),x.value.length>0?(i(),r("div",Ie,[(i(!0),r(k,null,b(x.value,a=>(i(),r("div",{key:a.id,class:"py-4 flex items-center justify-between"},[t("div",Se,g(a.name),1),!J(a.id)&&!G(a.id)?(i(),ne(h,{key:0,color:"primary",variant:"soft",loading:E.value===a.id,onClick:M=>H(a)},{default:l(()=>[...e[13]||(e[13]=[m(" Invite ",-1)])]),_:1},8,["loading","onClick"])):O("",!0)]))),128))])):O("",!0)])]),_:1})]),t("div",Ve,[e[17]||(e[17]=t("h3",{class:"font-medium text-gray-900 dark:text-white mb-4"},"Authors",-1)),o(d,null,{default:l(()=>[V.value.length===0?(i(),r("div",Ee," No linked authors yet ")):(i(),r("div",Ce,[(i(!0),r(k,null,b(V.value,a=>(i(),r("div",{key:a.id,class:"p-4 flex items-center justify-between"},[t("div",null,[t("div",Le,g(a.name),1),t("div",$e,g(a.author_invites?.[0]?.email),1)]),t("div",qe,[o(Z,{color:"green",variant:"soft"},{default:l(()=>[...e[15]||(e[15]=[m(" Linked ",-1)])]),_:1}),o(h,{color:"red",variant:"soft",loading:q.value===a.id,onClick:M=>Q(a)},{default:l(()=>
1[...e[16]||(e[16]=[m(" Unlink ",-1)])]),_:1},8,["loading","onClick"])])]))),128))]))]),_:1})]),A.value.length>0?(i(),r("div",je,[e[20]||(e[20]=t("h3",{class:"font-medium text-gray-900 dark:text-white mb-4"},"Pending Invites",-1)),o(d,null,{default:l(()=>[e[19]||(e[19]=t("div",{class:"p-6 border-b dark:border-gray-700"},[t("div",{class:"flex items-center justify-between"},[t("h3",{class:"text-lg font-semibold"},"Pending Invites")])],-1)),t("div",Pe,[j.value?(i(),r("div",Ue,[o(ee)])):A.value.length?(i(),r("div",Oe,[(i(!0),r(k,null,b(A.value,a=>(i(),r("div",{key:a.id,class:"flex items-center justify-between py-4"},[t("div",Te,[t("div",Be,g(a.author?.name),1),t("div",De,"Invited: "+g(a.email),1),t("div",Re," Sent "+g(new Date(a.created_at).toLocaleDateString()),1)]),o(h,{color:"gray",variant:"soft",loading:P.value===a.id,onClick:M=>z(a)},{default:l(()=>[...e[18]||(e[18]=[m(" Cancel ",-1)])]),_:1},8,["loading","onClick"])]))),128))])):(i(),r("div",Fe," No pending invites "))])]),_:1})])):O("",!0)])):(i(),r("div",Ne,[o(te)]))],64)),o(N,{modelValue:y.value,"onUpdate:modelValue":e[3]||(e[3]=a=>y.value=a)},{default:l(()=>[o(d,null,{header:l(()=>[t("div",Me,[t("h3",We," Invite "+g(u.value?.name),1)])]),footer:l(()=>[t("div",Qe,[o(h,{color:"gray",variant:"soft",onClick:e[2]||(e[2]=a=>y.value=!1)},{default:l(()=>[...e[22]||(e[22]=[m(" Cancel ",-1)])]),_:1}),o(h,{color:"primary",loading:E.value===u.value?.id,onClick:K},{default:l(()=>[...e[23]||(e[23]=[m(" Send Invite ",-1)])]),_:1},8,["loading"])])]),default:l(()=>[t("div",Je,[t("div",null,[e[21]||(e[21]=t("label",{class:"block text-sm font-medium mb-1"},"Email Address",-1)),o(R,{modelValue:v.value,"onUpdate:modelValue":e[1]||(e[1]=a=>v.value=a),type:"email",placeholder:"Enter email address"},null,8,["modelValue"])])])]),_:1})]),_:1},8,["modelValue"]),o(N,{modelValue:f.value,"onUpdate:modelValue":e[5]||(e[5]=a=>f.value=a)},{default:l(()=>[o(d,null,{header:l(()=>[...e[24]||(e[24]=[t("div",{class:"flex items-center justify-between"},[t("h3",{class:"text-base font-semibold"}," Request Account Link ")],-1)])]),footer:l(()=>[t("div",Ge,[o(h,{color:"gray",variant:"soft",onClick:e[4]||(e[4]=a=>f.value=!1)},{default:l(()=>[...e[26]||(e[26]=[m(" Cancel ",-1)])]),_:1}),o(h,{color:"primary",loading:$.value,onClick:X},{default:l(()=>[...e[27]||(e[27]=[m(" Send Link Request ",-1)])]),_:1},8,["loading"])])]),default:l(()=>[t("div",ze,[t("p",null," The email "+g(v.value)+" is already registered to a user. Would you like to send a request to link this account to "+g(u.value?.name)+"? ",1),e[25]||(e[25]=t("p",{class:"text-sm text-gray-500"}," The user will receive an email to approve the link request. ",-1))])]),_:1})]),_:1},8,["modelValue"])])}}};export{dt 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.