Files
appco_dist/.output/public/_nuxt/3FOIvPSo.js
T
2025-08-21 21:29:10 +03:30

2 lines
3.3 KiB
JavaScript

import{d as A,u as H,G as T,J as U,k as h,r,a5 as z,a6 as D,o as I,y as w,z as p,A as i,C as _,H as n,B as E,a4 as $,F as b,S as F,a7 as M,a2 as j,a3 as G,a8 as J,a9 as C,Q as L}from"./BfTJNDeT.js";import{B as Q}from"./Oa7mBdYC.js";import{_ as K,C as W,P as X,d as Y,c as Z}from"./CSJVkf_F.js";import{u as ee}from"./B0uDPcCw.js";import{d as se,c as oe}from"./DapCUDvv.js";import{_ as te}from"./DyBbOpHe.js";import{u as ae}from"./vkGh5s6y.js";const ne={class:"px-4 flex items-center justify-between"},le={class:"flex gap-5 py-3"},re={class:"font-semibold"},ie={class:"pt-15 overflow-y-auto userPostScroll h-95vh pb-3rem scrollHome"},_e=A({__name:"index",async setup(de){let u,S;const l=H(),d=T(),c=U(),m=h(()=>l.currentRoute.value.query.userId),P=r(),f=r(!1),v=r(!1),x=r(),g=r(!1),s=ee(),k=h(()=>l.currentRoute.value.query.target||null);function B(t,e){try{if(g.value=!0,C())if(t){Y(e);const o=s.posts?.findIndex(a=>a.id===e);s.posts[o]?.likes.splice(s.posts[o]?.likes?.findIndex(a=>a.user_id===c.user.id))}else{Z(e);const o=s.posts?.findIndex(a=>a.id===e);s.posts[o]?.likes.push({product_id:e,user_id:c.user.id})}else l.push({name:"auth-login"}),L.warn(d.useString("pleaseLoginOrRegister"))}catch(o){console.log(o)}finally{g.value=!1}}const y=r();z(y,async([{isIntersecting:t}])=>{if(t&&!s.loading&&!s.endPage){const e=s.currentPage+1;console.log(s.endPage,e,s.currentPage);const o=await s.loadPosts(m.value,e);s.loadStateNextPage(o)}});const{data:O}=([u,S]=D(async()=>ae("productPostMainSeller",async()=>await s.loadPosts(m.value,1))),u=await u,S(),u);I(()=>s.loadStateNextPage(O.value));function N(t,e){if(C())if(t){se(e);const o=s.posts?.findIndex(a=>a.id===e);s.posts[o]?.saved.splice(s.posts[o]?.saved?.findIndex(a=>a.user_id===c.user.id))}else{oe(e);const o=s.posts?.findIndex(a=>a.id===e);s.posts[o]?.saved.push({product_id:e,user_id:c.user.id})}else l.push({name:"auth-login"}),L.warn(d.useString("pleaseLoginOrRegister"))}function R(t){x.value=t,v.value=!0}function V(t){P.value=t,f.value=!0}function q(){const t=document.querySelector(".userPostScroll");if(k.value)setTimeout(()=>{const e=document.getElementById("post-"+k.value);console.log(e),e?.scrollIntoView({behavior:"smooth",block:"start"}),l.replace({name:"posts",query:{userId:m.value}})},200);else{let e=sessionStorage.getItem("scrollPositionSeller");console.log(e,t),t&&e&&(t.scrollTop=parseInt(e,10),sessionStorage.removeItem("scrollPositionSeller"))}}return I(()=>q()),(t,e)=>(p(),w("div",null,[i("div",{class:$(["z-20 fixed w-full top-0",n(d).isNightStore?"bg-header-color-dark ":"bg-header-color"])},[i("div",ne,[i("div",le,[_(Q,{icon:n(d).isRTL?"vuesax-linear:arrow-right":"vuesax-linear:arrow-left",onClick:e[0]||(e[0]=o=>n(l).back())},null,8,["icon"]),i("div",re,E(n(d).sellerConfig?.store?.username),1)])])],2),i("div",ie,[(p(!0),w(j,null,G(n(s).posts,(o,a)=>(p(),b(X,{onOpenOption:R,onOpenComment:V,onHandleLike:B,onHandleSave:N,index:a,post:o,key:a,"scroll-save":"scrollPositionSeller","add-like-loading":g.value},null,8,["index","post","add-like-loading"]))),128)),n(s).loading?(p(),b(K,{key:0})):F("",!0),M(i("div",{ref_key:"observer",ref:y,class:"w-full opacity-0 relative"}," load ",512),[[J,!n(s).loading]])]),_(W,{id:P.value,open:f.value,"onUpdate:open":e[1]||(e[1]=o=>f.value=o)},null,8,["id","open"]),_(te,{id:x.value,open:v.value,"onUpdate:open":e[2]||(e[2]=o=>v.value=o)},null,8,["id","open"])]))}});export{_e as _};