PageSourceSearch

https://revby.co/_nuxt/Ch214g3g.js

js revby.co collected 2026-10-03 21:02:58 UTC 10,764 bytes, 14 lines download raw bytes

1import{_ as se,a as ie}from"./BKV_QSHu.js";import{_ as ne}from"./BN2F2iYJ.js";import{_ as le}from"./Csc4NbIj.js";import{_ as de}from"./B6x3R7Wg.js";import{x as R,g as S,A as ce,e as ue,m as me,c as w,b as _,a as i,k as s,N as W,j as D,F as X,r as J,w as L,o as y,t as k,a4 as pe,X as fe,K as A,h as be,s as Q,d as B}from"./DbfHA8MV.js";import{_ as ge}from"./D5trcJRU.js";import{_ as he}from"./B-DgmWu8.js";import{u as Z}from"./DzYWTBSO.js";import{u as ve}from"./BhXNNl9z.js";import{_ as ye}from"./DlAUqK2U.js";import"./BAvZbUIn.js";import"./fH7ddL5S.js";import"./BAMDYEQl.js";import"./DvO3trJ3.js";import"./DlolBEDk.js";import"./B5rxJs06.js";import"./DDCDXqUw.js";import"./ZlfaKzO8.js";import"./DSFJCE4a.js";import"./DLIKFUPq.js";import"./Hs3FbryR.js";import"./L2V1ucyS.js";import"./BqpT7-Em.js";import"./D1YVV2vN.js";import"./CMfv1oH3.js";import"./wqLag8B5.js";import"./B0Z4wVyf.js";import"./GlsadZZj.js";import"./C8JQ058B.js";import"./BskQ2YPd.js";const _e=()=>{const V=Z(),n=R(),C=S([]),h=S([]),$=async({subject:u,message:m})=>{try{await $fetch("/api/sendgrid",{method:"POST",body:{subject:u,personalizations:[{to:[{email:"[email protected]"}]}],from:{email:"[email protected]",name:"Revby Ideas"},content:[{type:"text/plain",value:m}]}})}catch(v){console.error("Error sending idea notification email:",v)}};return{toolboxItems:C,fetchIdeas:async()=>{var x;const{data:u,error:m}=await V.from("product_ideas").select("*");if(m)throw m;let v={};if((x=n.value)!=null&&x.id){const{data:o,error:a}=await V.from("product_votes").select("idea_id, rank").eq("user_id",n.value.id);a?console.error("Error loading product votes:",a):o&&(v=o.reduce((g,p)=>(p!=null&&p.idea_id&&(g[p.idea_id]=p.rank??null),g),{}))}const f=(u||[]).slice();for(let o=f.length-1;o>0;o--){const a=Math.floor(Math.random()*(o+1));[f[o],f[a]]=[f[a],f[o]]}return C.value=f.map(o=>({id:o.id??null,image:o.image??o.image_url??"",title:o.title??"",description:o.description??"",rank:v[o.id]??o.rank??null})),C.value},ideaComments:h,fetchIdeaComments:async()=>{const{data:u,error:m}=await V.from("product_comments").select("*");if(m)throw console.error("Error fetching product comments:",m),m;return h.value=u||[],h.value},submitIdeaComment:async({ideaId:u,comment:m,ideaTitle:v})=>{var a,g,p;if(!u)return{error:new Error("Missing idea identifier")};const f=(m||"").trim();if(!f)return{error:new Error("Comment cannot be empty")};if(!((a=n.value)!=null&&a.id))return{error:new Error("You must be logged in to leave a comment.")};const{data:x,error:o}=await V.from("product_comments").insert({user_id:n.value.id,comment:f,idea_id:u}).select().single();return o?(console.error("Error submitting product comment:",o),{error:o}):(x&&(h.value=[...h.value,x],await $({subject:`New comment on idea: ${v||u}`,message:`An idea just received a new comment.
2
3Idea ID: ${u}
4Idea title: ${v||"Unknown title"}
5Comment: ${f}
6Commented by: ${((g=n.value)==null?void 0:g.email)||((p=n.value)==null?void 0:p.id)||"Unknown user"}`})),{error:null})},notifyIdeaEvent:$}},xe={class:"min-h-screen bg-gray-50 dark:bg-gray-900 pb-20"},we={class:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-2 md:py-8 flex flex-col md:flex-row gap-4"},ke={class:"md:min-w-1/4 md:sticky md:top-24 md:self-start"},Ie={class:"w-full"},Ce={key:1,class:"flex justify-center items-center py-20"},$e={key:2,class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8"},Ue={class:"text-lg font-bold"},Ee={class:"text-sm flex-1"},Ve={class:"flex flex-row gap-2"},Se={key:0,class:"mt-1"},Te=["onClick"],Ne={key:1,class:"mt-2 space-y-2 border-t border-gray-200 dark:border-gray-700 pt-2"},je={class:"flex flex-col gap-2"},De={class:"text-xs text-gray-500 dark:text-gray-400 text-right"},Le={class:"flex flex-col gap-2"},Ae={class:"text-xs text-gray-500 dark:text-gray-400 text-right"},M=50,P=250,Be={__name:"toolbox",setup(V){const n=R(),C=Z(),h=ce(),$=S(!0),c=S(null),U=A({}),{toolboxItems:j,fetchIdeas:u,ideaComments:m,fetchIdeaComments:v,submitIdeaComment:f,notifyIdeaEvent:x}=_e(),o=A({}),a=A({title:"",description:""}),g=S(!1),p=Q(()=>{const t={};for(const e of m.value){const l=e==null?void 0:e.idea_id;l&&(t[l]||(t[l]=[]),t[l].push(e))}return t}),{profile:q,fetchProfile:ee}=ve(),K=async()=>{$.value=!0,c.value=null;try{await Promise.all([ee(),u(),v()])}catch(t){console.error("Error loading dashboard data:",t),c.value=t.message||"Unable to load dashboard data right now."}finally{$.value=!1}},Y=async t=>{const e=t==null?void 0:t.id;
6if(!e){console.warn("Cannot submit comment for idea without an id",t);return}const l=(U[e]||"").trim();if(!l)return;const{error:d}=await f({ideaId:e,comment:l,ideaTitle:t.title});if(d){c.value=d.message||"Unable to save your comment right now.";return}c.value=null,U[e]="",o[e]=!0},te=t=>{t&&(o[t]=!o[t])},O=Q(()=>{const t=a.title.trim().length,e=a.description.trim().length;return t>0&&e>0&&t<=M&&e<=P}),oe=async()=>{var t,e,l;if(!g.value){if(!((t=n.value)!=null&&t.id)){c.value="You must be logged in to submit an idea.",h.add({title:"Login required",description:"Please sign in to share your idea.",color:"error"});return}if(!O.value){c.value="Please provide both a title and description within the character limits.",h.add({title:"Missing information",description:"Check the title and description before submitting.",color:"warning"});return}g.value=!0;try{const d={title:a.title.trim(),description:a.description.trim(),user_id:n.value.id},{data:E,error:I}=await C.from("product_ideas").insert(d).select().single();if(I)throw I;E&&(await u(),await v(),await x({subject:`New idea submitted: ${d.title}`,message:`A new idea has been submitted.
7
8Title: ${d.title}
9Description: ${d.description}
10Submitted by: ${((e=n.value)==null?void 0:e.email)||((l=n.value)==null?void 0:l.id)||"Unknown user"}`})),a.title="",a.description="",c.value=null,h.add({title:"Idea submitted!",description:"Thanks for sharing your idea with us.",color:"success"}),setTimeout(()=>{window.location.reload()},600)}catch(d){console.error("Error submitting new idea:",d),c.value=d.message||"Unable to submit your idea right now.",h.add({title:"Unable to submit idea",description:d.message||"Please try again shortly.",color:"error"})}finally{g.value=!1}}},re=async(t,e)=>{var d,E,I;if(!e)return;if(t.rank=e,!n.value){c.value="You must be logged in to rank ideas.";return}if(!t.id){console.warn("Cannot submit vote for idea without an id",t);return}const{error:l}=await C.from("product_votes").upsert({user_id:n.value.id,rank:e,idea_id:t.id,name:t.title??""},{onConflict:"user_id,idea_id"});if(l)console.error("Error submitting product vote:",l),c.value=l.message||"Unable to save your vote right now.";else{c.value=null;const T=((d=F.find(N=>N.value===e))==null?void 0:d.label)||e;await x({subject:`Idea ranked: ${t.title??t.id}`,message:`An idea has been ranked.
11
12Idea: ${t.title??"Untitled"}
13Selected rank: ${T}
14Ranked by: ${((E=n.value)==null?void 0:E.email)||((I=n.value)==null?void 0:I.id)||"Unknown user"}`})}},F=[{label:"I see little need for this",value:"low"},{label:"Maybe for some people",value:"medium"},{label:"Yeah, that's useful",value:"high"},{label:"That is super valuable",value:"very-high"}];return ue(()=>{n.value&&K()}),me(n,t=>{t?K():(q.value=null,j.value=[],m.value=[],Object.keys(o).forEach(e=>{delete o[e]}),a.title="",a.description="")}),(t,e)=>{const l=se,d=ie,E=ne,I=le,T=de,N=be,H=ge,ae=he;return y(),w("div",xe,[_(l,{profile:s(q)},null,8,["profile"]),i("div",we,[i("div",ke,[_(d)]),i("div",Ie,[s(c)?(y(),W(E,{key:0,icon:"i-heroicons-exclamation-triangle",color:"error",variant:"soft",title:s(c),class:"mb-6"},null,8,["title"])):D("",!0),e[8]||(e[8]=i("h2",{class:"text-2xl font-bold mb-4"},"Toolbox",-1)),e[9]||(e[9]=i("p",{class:"text-xl mb-8"},"We'd like to hear your thoughts on what tools would be valuable to help you with your small business",-1)),s($)?(y(),w("div",Ce,[...e[2]||(e[2]=[i("div",{class:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary-500"},null,-1),i("span",{class:"sr-only"},"Loading toolbox ideas…",-1)])])):(y(),w("div",$e,[(y(!0),w(X,null,J(s(j),r=>(y(),W(H,{key:r.title,ui:{root:"flex flex-col h-full",body:"flex flex-col flex-1 gap-3"}},{default:L(()=>{var z,G;return[i("h3",Ue,k(r.title),1),i("p",Ee,k(r.description),1),_(I,{modelValue:r.rank,"onUpdate:modelValue":[b=>r.rank=b,b=>re(r,b)],items:F,placeholder:"Rank this idea",class:"mt-auto"},null,8,["modelValue","onUpdate:modelValue"]),i("div",Ve,[_(T,{modelValue:s(U)[r.id],"onUpdate:modelValue":b=>s(U)[r.id]=b,placeholder:"Add a comment...",disabled:!r.id,class:"flex-1",onKeydown:pe(fe(b=>Y(r),["prevent"]),["enter"])},null,8,["modelValue","onUpdate:modelValue","disabled","onKeydown"]),_(N,{"leading-icon":"i-lucide-plus",variant:"subtle",class:"shrink-0",disabled:!r.id||!(s(U)[r.id]||"").trim(),onClick:b=>Y(r)},null,8,["disabled","onClick"])]),(z=s(p)[r.id])!=null&&z.length?(y(),w("div",Se,[i("button",{type:"button",class:"text-xs font-semibold text-primary-600 hover:text-primary-700 dark:text-primary-400 dark:hover:text-primary-300",onClick:b=>te(r.id)},k(s(o)[r.id]?"Hide comments":`See comments (${s(p)[r.id].length}
14)`),9,Te)])):D("",!0),s(o)[r.id]&&((G=s(p)[r.id])!=null&&G.length)?(y(),w("div",Ne,[e[3]||(e[3]=i("p",{class:"text-xs font-semibold text-gray-500 dark:text-gray-400"}," Comments ",-1)),(y(!0),w(X,null,J(s(p)[r.id],b=>(y(),w("div",{key:b.id||b.created_at,class:"text-sm text-gray-700 dark:text-gray-200"},k(b.comment),1))),128))])):D("",!0)]}),_:2},1024))),128)),_(H,{ui:{root:"flex flex-col h-full border-dashed border-2 border-gray-200 dark:border-gray-700",body:"flex flex-col flex-1 gap-4"}},{default:L(()=>[e[7]||(e[7]=i("h3",{class:"text-lg font-bold"},"Add your own idea",-1)),i("div",je,[e[4]||(e[4]=i("label",{class:"text-sm font-semibold",for:"new-idea-title"},[B("Title"),i("span",{class:"text-error"},"*")],-1)),_(T,{id:"new-idea-title",modelValue:s(a).title,"onUpdate:modelValue":e[0]||(e[0]=r=>s(a).title=r),placeholder:"Give your idea a short title",maxlength:M,required:""},null,8,["modelValue"]),i("p",De,k(s(a).title.trim().length)+"/"+k(M),1)]),i("div",Le,[e[5]||(e[5]=i("label",{class:"text-sm font-semibold",for:"new-idea-description"},[B("Short description"),i("span",{class:"text-error"},"*")],-1)),_(ae,{id:"new-idea-description",modelValue:s(a).description,"onUpdate:modelValue":e[1]||(e[1]=r=>s(a).description=r),placeholder:"Describe your idea in a couple of sentences",maxlength:P,required:""},null,8,["modelValue"]),i("p",Ae,k(s(a).description.trim().length)+"/"+k(P),1)]),_(N,{variant:"subtle","leading-icon":"i-lucide-plus",color:"primary",disabled:!s(O)||s(g),loading:s(g),onClick:oe},{default:L(()=>[...e[6]||(e[6]=[B(" Submit ",-1)])]),_:1},8,["disabled","loading"])]),_:1})]))])])])}}},ft=ye(Be,[["__scopeId","data-v-7b8ff0f5"]]);export{ft 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.