2 lines
6.2 KiB
JavaScript
2 lines
6.2 KiB
JavaScript
import{_ as S}from"./BasicMainCard-67848c66.js";import{M as $,_ as V}from"./BasicModal.vue_vue_type_style_index_0_lang-5f33b1bd.js";import{_ as L}from"./BaseTable.vue_vue_type_style_index_0_lang-b119055b.js";import{_ as N}from"./button.vue_vue_type_style_index_0_lang-cb1c0b11.js";import{I as b}from"./Icon-849abc1d.js";import{u as U}from"./useBaseTable-3aeb2499.js";import{t as q}from"./useDataTime-17280abb.js";import{a3 as A,a5 as T,d as z,r as g,Y as j,o as J,c as X,b as r,w as c,a as _,e as Y,a2 as F,L as h,a0 as v}from"./index-fc0f201a.js";import{_ as G}from"./TextPreview.vue_vue_type_script_setup_true_lang-dc6235f2.js";import{I as H}from"./index-f91375e1.js";import{T as C}from"./styleChecker-57cae3cb.js";import"./_plugin-vue_export-helper-d141c691.js";import"./index-4ec5e789.js";import"./useState-cd7fa8d5.js";import"./vnode-7d714013.js";import"./Col-160e0742.js";import"./index-1ccab49f.js";const K=[{title:"ردیف",dataIndex:"id",key:"id",filterable:!1,width:70,align:"center",customRender:t=>t.record.index+1},{title:"نام کاربر",dataIndex:"owner_id",key:"owner_id",customRender:t=>t.record.owner_name||t.record.owner_id||"-"},{title:"متن نظر یا ایده",dataIndex:"text",key:"text",slot:"text"},{title:"زمان ایجاد",dataIndex:"created_at",key:"created_at",customRender:t=>q(t.record.created_at)},{title:"عملیات",dataIndex:"action",key:"action",slot:"action",filterable:!1,align:"center"}];async function Q(t){const{data:d,error:f}=await T.from("comments").insert([t]).select();if(f)throw f;return d}async function P(t,d){const{data:f,error:a}=await T.from("comments").update(d).eq("id",t).select();if(a)throw a;return f}async function W(t){const{error:d}=await T.from("comments").delete().eq("id",t);if(d)throw d}async function Z(t){const{TableEngineRequest:d}=await A(()=>import("./buildSupabaseQuery-5444b22b.js"),["assets/buildSupabaseQuery-5444b22b.js","assets/index-fc0f201a.js","assets/index-8ee05d54.css"]),{getUsersList:f}=await A(()=>import("./index-fc0f201a.js").then(s=>s.cX),["assets/index-fc0f201a.js","assets/index-8ee05d54.css"]),a={...t};!a.sort&&!a.order&&(a.order="-id");const p=await d(a,"comments");try{if(Array.isArray(p==null?void 0:p.rows)){let s=new Map;try{const e=await f();Array.isArray(e)&&e.forEach(i=>{if(i.id){const k=`${i.first_name||""} ${i.last_name||""}`.trim()||i.phone||`کاربر ${i.id}`;s.set(i.id,k)}})}catch(e){console.log("[getCommentsTable] Error fetching users:",e)}const w=a.page||1,y=a.limit||200,x=(w-1)*y,u=p.rows.map((e,i)=>({id:e.id,owner_id:e.owner_id??null,owner_name:e.owner_id?s.get(e.owner_id)||`کاربر ${e.owner_id}`:null,text:e.text??"",created_at:e.created_at??"",updated_at:e.updated_at??"",index:x+i,...e}));return{...p,rows:u}}}catch(s){console.log("[getCommentsTable] normalize error:",s)}return p}const ee={class:"flex justify-between items-center mb-4"},te=_("h2",null,"ایده و نظرات",-1),ne={class:"gap-2 flex justify-center"},ae=_("span",null,"پین کردن",-1),oe=_("span",null,"حذف",-1),se=_("span",null,"ویرایش",-1),re={class:"space-y-4"},ie=_("div",{class:"mb-1 text-sm text-gray-600"},"متن پیام *",-1),Ce=z({__name:"index",setup(t){const{TextArea:d}=H,[f,a]=U(),p=g({columns:K,api:Z,defaultPageLimit:20}),s=g(!1),w=g(!1),y=g(null),x=j(),u=g({owner_id:null,text:""});async function e(){var n;w.value=!1,y.value=null,x.userInfo||await x.getMyInfo();const o=((n=x.userInfo)==null?void 0:n.id)||null;u.value={owner_id:o,text:""},s.value=!0}function i(){s.value=!1}async function k(o){y.value=o.id,w.value=!0,u.value={owner_id:null,text:o.text||""},s.value=!0}async function B(o){const n=o.pined===!0;$.confirm({title:"آیا مطمئن هستید؟",content:n?"این پیام در حال حاضر پین شده است. آیا میخواهید آن را از حالت پین خارج کنید؟":"آیا میخواهید این پیام را پین کنید؟",okText:"بله",cancelText:"خیر",onOk:async()=>{try{const l=!n,I={pined:l,pined_at:l?new Date().toISOString():null};await P(o.id,I),v.success(l?"پیام با موفقیت پ
|