2 lines
6.3 KiB
JavaScript
2 lines
6.3 KiB
JavaScript
import{_ as S}from"./BasicMainCard-ddae39ab.js";import{M as $,_ as V}from"./BasicModal.vue_vue_type_style_index_0_lang-5afc1014.js";import{_ as L}from"./index-9454089e.js";import{_ as N}from"./button.vue_vue_type_style_index_0_lang-241a9705.js";import{I as b}from"./Icon-967ca316.js";import{u as U}from"./useBaseTable-3aeb2499.js";import{t as q}from"./useDataTime-56db82be.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-a9671513.js";import{_ as G}from"./TextPreview.vue_vue_type_script_setup_true_lang-21db7f3a.js";import{I as H}from"./index-837b6155.js";import{T as C}from"./styleChecker-8312d0ee.js";import"./_plugin-vue_export-helper-d21b9c52.js";import"./index-470b960b.js";import"./useState-4aa9b7fe.js";import"./vnode-e4b7f976.js";import"./Col-ca1a058e.js";import"./index-d4552ccf.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"},{title:"پین شده",dataIndex:"pined",key:"pined",type:"Boolean",filterable:!0,show:!1}];async function Q(t){const{data:d,error:f}=await T.from("comments").insert([t]).select();if(f)throw f;return d}async function B(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-895aec07.js"),["assets/buildSupabaseQuery-895aec07.js","assets/index-a9671513.js","assets/index-6c22dd25.css"]),{getUsersList:f}=await A(()=>import("./index-a9671513.js").then(s=>s.cX),["assets/index-a9671513.js","assets/index-6c22dd25.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 P(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};awa
|