2 lines
6.2 KiB
JavaScript
2 lines
6.2 KiB
JavaScript
import{_ as S}from"./BasicMainCard-b6d3a742.js";import{M as $,_ as V}from"./BasicModal.vue_vue_type_style_index_0_lang-2af0515b.js";import{_ as L}from"./index-3b98377f.js";import{_ as N}from"./button.vue_vue_type_style_index_0_lang-06e5b584.js";import{I as b}from"./Icon-d4177b3f.js";import{u as U}from"./useBaseTable-3aeb2499.js";import{t as q}from"./useDataTime-1975c6da.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-87709b34.js";import{_ as G}from"./TextPreview.vue_vue_type_script_setup_true_lang-65db399b.js";import{I as H}from"./index-23a38418.js";import{T as C}from"./styleChecker-196e7653.js";import"./_plugin-vue_export-helper-52cf77f2.js";import"./index-5379f56d.js";import"./useState-9f80f738.js";import"./vnode-73bc4aca.js";import"./Col-797226f3.js";import"./index-cd93622d.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-153a7745.js"),["assets/buildSupabaseQuery-153a7745.js","assets/index-87709b34.js","assets/index-8ee05d54.css"]),{getUsersList:f}=await A(()=>import("./index-87709b34.js").then(s=>s.cX),["assets/index-87709b34.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?"پیام با موÙ�قیت پین شد!":"پیام با موÙ�Ù‚Û
|