import{_ as S}from"./B8SxLQeB.js";import{_ as C,r as g,c as n,F as y,i as L,t as a,g as _,b as c,w as d,o as i,a as r,d as u,f as w,j as B,e as N,h as U,n as D}from"./Cmgq8IVP.js";const j=N({name:"NotesList",props:{notes:{type:Array,required:!0},show_dates:{type:Boolean,default:!1},show_inline_dates:{type:Boolean,default:!1},show_likers:{type:Boolean,default:!1},logged_out_mode:{type:Boolean,default:!1}},data(){return{months_shown:{},likedByCurrentUser:{},likesString:{},reloadNotes:0}},watch:{notes:{handler(){this.processNoteLikes()},immediate:!0}},methods:{shouldShowMonth(e){var o;const s=(o=e.speech_created_at)==null?void 0:o.slice(0,7);return s&&!this.months_shown[s]?(this.months_shown[s]=!0,new Date(e.speech_created_at).toLocaleDateString("en-US",{month:"long",year:"numeric"}).toUpperCase()):null},formatInlineDate(e){return e.speech_created_at?new Date(e.speech_created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):""},async likeNote(e){var s,o,p;if((s=this.$auth)!=null&&s.isLoggedIn)try{const h=U(),l=await $fetch(`/api/v1/badges/like_badge_speech/${e}`,{method:"POST",baseURL:h.public.railsApiUrl||"http://localhost:8080",headers:{Authorization:`Bearer ${(o=this.$auth)==null?void 0:o.token}`,"Content-Type":"application/json"}});this.likedByCurrentUser[e]=l.liked_by_current_user,l.badge_reactions.length===0?this.likesString[e]="Like this note":l.badge_reactions.length===1?this.likesString[e]="Liked by "+l.badge_reactions.join(", "):this.likesString[e]=`Liked by ${l.badge_reactions.length} people: ${l.badge_reactions.join(", ")}`,this.reloadNotes+=1}catch(h){console.error("Error liking note:",h),(h.status===401||h.statusCode===401)&&(await((p=this.$auth)==null?void 0:p.logout()),await D("/login"))}},processNoteLikes(){this.notes&&this.notes.forEach(e=>{var s,o;e.reaction_handles&&(e.reaction_handles.length===0?this.likesString[e.id]="Like this note":e.reaction_handles.length===1?this.likesString[e.id]="Liked by "+e.reaction_handles.join(", "):this.likesString[e.id]=`Liked by ${e.reaction_handles.length} people: ${e.reaction_handles.join(", ")}`,(o=(s=this.$auth)==null?void 0:s.user)!=null&&o.writer_handle&&(this.likedByCurrentUser[e.id]=e.reaction_handles.includes(this.$auth.user.writer_handle)))})}}}),z={style:{margin:"0",padding:"0"}},T=["id"],V={key:0,class:"sans-serif text-capitalize pl-1 mt-5"},A={key:0,style:{float:"right",width:"80px"}},E={class:"num-cups"},M={class:"note-of-inspiration sans-serif"},F={class:"note-of-inspiration-title sans-serif"},R={key:2},q={key:3},I={key:0,class:"mt-3 px-0 reaction sans-serif"};function O(e,s,o,p,h,l){const m=g("v-card-text"),f=S,b=g("v-icon"),v=g("v-btn"),$=g("v-card");return i(),n("div",z,[(i(!0),n(y,null,L(e.notes,t=>(i(),n("div",{key:t.id,class:"mb-5 p-2",id:"note-"+t.id},[e.show_dates&&e.shouldShowMonth(t)?(i(),n("h3",V,a(e.shouldShowMonth(t)),1)):_("",!0),c(,ドル{class:"note theme-exempt",elevation:"0",style:{padding:"0"}},{default:d(()=>[c(m,null,{default:d(()=>[t.num_cups&&t.num_cups>0?(i(),n("div",A,[r("h3",E,[s[0]||(s[0]=r("img",{src:"/images/badges/coffee.png",width:"14",height:"14"},null,-1)),u(" "+a(t.num_cups)+" cups",1)])])):_("",!0),r("div",M,a(t.speech),1)]),_:2},1024),c(m,{style:{"padding-top":"0"}},{default:d(()=>{var k;return[r("div",F,[e.logged_out_mode?(i(),n(y,{key:0},[r("strong",null,a(t.user_info.writer_handle),1),s[1]||(s[1]=u("'s ",-1)),r("strong",null,a(t.badge_info.name)+" note",1)],64)):(i(),w(f,{key:1,to:"/person/"+t.user_info.writer_handle+"#note-"+t.id,class:"note-title-link"},{default:d(()=>[r("strong",null,a(t.user_info.writer_handle),1),s[2]||(s[2]=u("'s ",-1)),r("strong",null,a(t.badge_info.name)+" note",1)]),_:2},1032,["to"])),e.show_inline_dates?(i(),n("span",R," • "+a(e.formatInlineDate(t)),1)):_("",!0),t.reaction_handles&&t.reaction_handles.length>0&&!e.show_likers&&!e.logged_out_mode?(i(),n("span",q,[s[3]||(s[3]=u(" • ",-1)),c(f,{to:"/person/"+t.user_info.writer_handle+"#note-"+t.id,class:"note-reaction-link"},{default:d(()=>[u("❤️ "+a(t.reaction_handles.length),1)]),_:2},1032,["to"])])):_("",!0)]),e.show_likers&&!e.logged_out_mode?(i(),n("div",I,[(k=e.$auth)!=null&&k.isLoggedIn?(i(),w(v,{key:0,variant:"outlined",size:"small",color:e.likedByCurrentUser[t.id]?"grey":"pink",class:"pa-0 ma-0",style:{padding:"0 !important",margin:"0 !important"},onClick:P=>e.likeNote(t.id)},{default:d(()=>[c(b,{class:B(["like-button-heart pa-0 ma-0",{"heart-liked":e.likedByCurrentUser[t.id]}]),style:{"font-size":"14px"}},{default:d(()=>[...s[4]||(s[4]=[u("mdi-heart",-1)])]),_:1},8,["class"])]),_:2},1032,["color","onClick"])):_("",!0),(i(),n("span",{class:"pl-2 note-likes-text",key:e.reloadNotes},a(e.likesString[t.id]||"Like this note"),1))])):_("",!0)]}),_:2},1024)]),_:2},1024)],8,T))),128))])}const J=C(j,[["render",O],["__scopeId","data-v-9a455722"]]);export{J as _};

AltStyle によって変換されたページ (->オリジナル) /