import{_ as u,F as m,a as _}from"./footerB-DAi6c01a.js";import{u as p,d as v,o as n,c as w,b as r,t as l,w as g,v as b,F as h,e as R,a as c}from"./index-DccGIixi.js";const f={setup(){const{t:e}=p();return{t:e}},data(){return{reviews:[],newReview:"",showAll:!1}},computed:{displayedReviews(){return this.showAll?this.reviews:this.reviews.slice(0,5)}},mounted(){this.loadReviews()},methods:{async loadReviews(){try{const e=await v.get("https://yalarba.ru/api/reviews/reviews");this.reviews=e.data.sort((s,d)=>new Date(d.created_at)-new Date(s.created_at))}catch(e){console.error("Ошибка при загрузке отзывов:",e)}},async submitReview(){if(this.newReview.trim())try{const e=await v.post("https://yalarba.ru/api/reviews/reviews",{text:this.newReview});this.reviews.unshift(e.data),this.newReview=""}catch(e){console.error("Ошибка при отправке отзыва:",e)}},formatDate(e){return new Date(e).toLocaleString()},toggleShowAll(){this.showAll=!this.showAll}}},x={class:"reviews-container"},y={class:"add-review"},A=["placeholder"],k=["disabled"],D=["disabled"],F={class:"reviews-list"};function S(e,s,d,a,o,i){return n(),w("div",x,[r("h2",null,l(a.t("messages.reviews.h2review")),1),r("h4",null,l(a.t("messages.reviews.h4review")),1),r("div",y,[g(r("textarea",{"onUpdate:modelValue":s[0]||(s[0]=t=>o.newReview=t),placeholder:a.t("messages.reviews.textareaplaceholder"),rows:"4"},null,8,A),[[b,o.newReview]]),r("button",{onClick:s[1]||(s[1]=(...t)=>i.submitReview&&i.submitReview(...t)),disabled:!o.newReview.trim()},l(a.t("messages.reviews.button")),9,k),r("button",{onClick:s[2]||(s[2]=(...t)=>i.toggleShowAll&&i.toggleShowAll(...t)),disabled:o.reviews.length===0},l(o.showAll?a.t("messages.reviews.hide"):a.t("messages.reviews.viewAll")),9,D)]),r("div",F,[(n(!0),w(h,null,R(i.displayedReviews,t=>(n(),w("div",{key:t.id,class:"review-item"},[r("p",null,l(t.text),1),r("small",null,l(i.formatDate(t.created_at)),1)]))),128))])])}const B=u(f,[["render",S],["__scopeId","data-v-d1550644"]]),I={__name:"FeetbackView",setup(e){return(s,d)=>(n(),w(h,null,[c(m),c(B),c(_)],64))}};export{I as default};
