2 lines
13 KiB
JavaScript
2 lines
13 KiB
JavaScript
import{a3 as A,a4 as D,d as Z,r as y,i as tt,o as $,c as M,b as c,w as k,a as s,e as et,a2 as ot,L as C,K as st,N,a0 as f}from"./index-d2d57467.js";import{_ as at}from"./BasicMainCard-1f376738.js";import{M as it,_ as lt}from"./BasicModal.vue_vue_type_style_index_0_lang-6383d729.js";import{_ as rt}from"./BasicInput.vue_vue_type_style_index_0_lang-63c96304.js";import{_ as nt}from"./BaseTable.vue_vue_type_style_index_0_lang-1f6ecc5d.js";import{_ as ut}from"./button.vue_vue_type_style_index_0_lang-55d2b252.js";import{I as T}from"./Icon-8d3280fe.js";import{_ as j}from"./BasicSelect.vue_vue_type_style_index_0_lang-b193b7e1.js";import{u as ct}from"./useBaseTable-3aeb2499.js";import{t as dt}from"./useDataTime-0a2e32aa.js";import{getBooks as mt}from"./books-2a9fed20.js";import{S as vt}from"./index-95f4305d.js";import{T as P}from"./styleChecker-f8db9dd1.js";import{U as z}from"./index-7d52e501.js";import"./_plugin-vue_export-helper-d0931117.js";import"./index-fd255577.js";import"./useState-b367b6d6.js";import"./vnode-78cb12ff.js";import"./Col-e6f89ff6.js";import"./index-6a84bb1d.js";import"./usePrice-7afab779.js";import"./index-2621c75f.js";const pt=[{title:"ردیف",dataIndex:"id",key:"id",filterable:!1,width:70,align:"center",customRender:l=>l.record.index+1},{title:"عنوان",dataIndex:"title",key:"title"},{title:"زیرعنوان",dataIndex:"sub_title",key:"sub_title"},{title:"کتاب مرتبط",dataIndex:"book_id",key:"book_id",align:"center",customRender:l=>{const n=l.record.book_title,p=l.record.book_id;return n||(p?`کتاب #${p}`:"-")}},{title:"زمان",dataIndex:"time",key:"time",customRender:l=>{const n=l.record.time||{minutes:0,seconds:0},p=Number(n.minutes||0),h=Number(n.seconds||0),_=g=>String(g).padStart(2,"0");return`${_(p)}:${_(h)}`}},{title:"صوت",dataIndex:"src",key:"src",customRender:l=>l.record.src?"دارد":"-"},{title:"تاریخ ایجاد",dataIndex:"created_at",key:"created_at",customRender:l=>dt(l.record.created_at)},{title:"عملیات",dataIndex:"action",key:"action",slot:"action",filterable:!1,align:"center"}];async function _t(l){const{data:n,error:p}=await D.from("storys").insert([{title:l.title,sub_title:l.sub_title,cover:l.cover,src:l.src,time:l.time,book_id:l.book_id||null}]).select();if(p)throw p;return n}async function O(l,n){const{data:p,error:h}=await D.from("storys").update({title:n.title,sub_title:n.sub_title,cover:n.cover,src:n.src,time:n.time,book_id:n.book_id||null}).eq("id",l).select();if(h)throw h;return p}async function ft(l){const{error:n}=await D.from("storys").delete().eq("id",l);if(n)throw n}async function ht(l){const{TableEngineRequest:n}=await A(()=>import("./buildSupabaseQuery-68dfd2a3.js"),["assets/buildSupabaseQuery-68dfd2a3.js","assets/index-d2d57467.js","assets/index-7f144acc.css"]),{getBooks:p}=await A(()=>import("./books-2a9fed20.js"),["assets/books-2a9fed20.js","assets/index-d2d57467.js","assets/index-7f144acc.css"]),h={...l};!h.sort&&!h.order&&(h.order="-id");const _=await n(h,"storys");try{if(Array.isArray(_==null?void 0:_.rows)){let g=new Map;try{const d=await p();Array.isArray(d)&&d.forEach(w=>{w.id&&w.title&&g.set(w.id,w.title)})}catch(d){console.log("[getStorysTable] Error loading books:",d)}const E=h.page||1,B=h.limit||200,I=(E-1)*B,x=_.rows.map((d,w)=>({id:d.id,title:d.title??"",sub_title:d.sub_title??"",cover:d.cover??null,src:d.src??null,time:d.time??{minutes:0,seconds:0},book_id:d.book_id??null,book_title:d.book_id&&g.get(d.book_id)||null,created_at:d.created_at??"",index:I+w,...d}));return{..._,rows:x}}}catch(g){console.log("[getStorysTable] normalize error:",g)}return _}const bt={class:"flex justify-between items-center mb-4"},kt=s("h2",null,"قصه ها",-1),yt={class:"gap-2 flex justify-center"},gt=s("span",null,"حذف",-1),xt=s("span",null,"ویرایش",-1),wt=s("span",null,"مرتبط کردن کتاب",-1),Bt={class:"space-y-4 relative"},It={key:0,class:"absolute inset-0 bg-white/60 z-10 flex items-center justify-center"},Ct=s("div",{class:"mb-1 text-sm text-gray-600"},"عنوان",-1),Et=s("div",{class:"mb-1 text-sm text-gray-600"},"زیر
|