2 lines
16 KiB
JavaScript
2 lines
16 KiB
JavaScript
import{_ as de}from"./BasicMainCard-40d6570b.js";import{_ as pe}from"./BasicModal.vue_vue_type_style_index_0_lang-cd9077ad.js";import{_ as me}from"./BasicTextArea.vue_vue_type_style_index_0_lang-013c7c81.js";import{_ as _e}from"./BasicInput.vue_vue_type_style_index_0_lang-1513fc09.js";import{_ as ve,u as fe}from"./useBaseTable-084adda9.js";import{_ as ge}from"./button.vue_vue_type_style_index_0_lang-379723a2.js";import{_ as he,H as G,d as xe,g as y,z as ye,v as be,o as S,c as $,b as c,w as b,a as t,e as we,E as ke,j as B,k as R,y as J,t as j,F as Ce,n as Ue,C as P,G as X}from"./index-5870e6d3.js";import{t as Me}from"./useDataTime-b0920a9a.js";import{I as q}from"./Icon-61906fca.js";import{e as T,g as N}from"./convert-67c23be8.js";import{_ as Se}from"./TextPreview.vue_vue_type_script_setup_true_lang-cdd90622.js";import{M as $e}from"./index-12089cb1.js";import{S as Ie}from"./index-ccb2a61b.js";import{T as Q}from"./shallowequal-2bdf6cc7.js";import{U as W}from"./index-3a1b3da6.js";import"./_plugin-vue_export-helper-5e3c08f4.js";import"./index-6338714e.js";import"./index-3e5e4620.js";import"./Col-619d881f.js";import"./vnode-22dd7580.js";import"./useState-9f642396.js";import"./useRefs-f4db4963.js";import"./isPlainObject-9db900ef.js";import"./index-f48a08af.js";import"./FormItemContext-817438bc.js";import"./usePrice-7afab779.js";import"./fa_IR-09853d0d.js";import"./toArray-f3da0fcb.js";import"./pickAttrs-38dcf0c9.js";import"./lodash-c64d74c3.js";import"./index-46729aba.js";import"./index-c8d614fc.js";async function Le(m){console.log("API addChallenge payload:",m);const d={title:m.title,description:m.description,owner_id:m.owner_id,minute:m.minute,score:m.score,image_url:m.image_url||null,clip_url:m.clip_url||null,steps:m.steps||[]};console.log("Supabase insert data:",d);const{data:v,error:_}=await G.from("challenge").insert([d]);if(_)throw console.error("Supabase insert error:",_),_;return console.log("Supabase insert success:",v),v}async function De(m,d){const{data:v,error:_}=await G.from("challenge").update({title:d.title,description:d.description,owner_id:d.owner_id,minute:d.minute,score:d.score,image_url:d.image_url||null,clip_url:d.clip_url||null,steps:d.steps||[]}).eq("id",m).select();if(_)throw _;return v}async function Pe(m){const{error:d}=await G.from("challenge").delete().eq("id",m);if(d)throw d}async function Te(m){const{TableEngineRequest:d}=await he(()=>import("./buildSupabaseQuery-e573bc87.js"),["assets/buildSupabaseQuery-e573bc87.js","assets/index-5870e6d3.js","assets/index-fc36161b.css"]),v={...m};!v.sort&&!v.order&&(v.order="-id");const _=await d(v,"challenge");try{if(Array.isArray(_==null?void 0:_.rows)){const C=v.page||1,w=v.limit||200,I=(C-1)*w,h=_.rows.map((f,M)=>({id:f.id,title:f.title??"",description:f.description??"",steps:f.steps??[],created_at:f.created_at??"",index:I+M,...f}));return{..._,rows:h}}}catch(C){console.log("[getChallengeTable] normalize error:",C)}return _}const Be=[{title:"ردیف",dataIndex:"id",key:"id",filterable:!1,width:70,align:"center",customRender:m=>m.record.index+1},{title:"عنوان",dataIndex:"title",key:"title"},{title:"شرح",dataIndex:"description",key:"description",slot:"description"},{title:"مراحل",dataIndex:"steps",key:"steps",customRender:m=>{const d=m.record.steps||[];if(d.length===0)return"-";const v=d.reduce((C,w)=>C+(Number(w.minute)||0),0),_=d.reduce((C,w)=>C+(Number(w.score)||0),0);return`${d.length} مرحله / ${v} دقیقه / ${_} امتیاز`}},{title:"زمان ایجاد",dataIndex:"created_at",key:"created_at",customRender:m=>Me(m.record.created_at)},{title:"عملیات",dataIndex:"action",key:"action",slot:"action",filterable:!1,align:"center"}],Re={class:"flex justify-between items-center mb-4"},qe=t("h2",null,"چالش ها",-1),ze={class:"gap-2 flex justify-center"},Ae=t("span",null,"حذف",-1),Ve=t("span",null,"ویرایش",-1),Ne={class:"space-y-4 relative"},Oe={key:0,class:"absolute inset-0 bg-white/60 z-10 flex items-center justify-center"},Fe=t("div",{class:"mb-1 text-sm text-gray-600"},"عنوان چالش",-1),He=t("div",{class:"mb-1
|