2025-12-30 14:23:33 +03:30
|
|
|
import{_ as re}from"./BasicMainCard-6d707328.js";import{M as ue,_ as ce}from"./BasicModal.vue_vue_type_style_index_0_lang-a11eae64.js";import{_ as de}from"./BasicTextArea.vue_vue_type_style_index_0_lang-4ee7776d.js";import{_ as pe}from"./BasicInput.vue_vue_type_style_index_0_lang-392b5b97.js";import{_ as me}from"./index-ccdd9f59.js";import{_ as _e}from"./button.vue_vue_type_style_index_0_lang-ad1ddd30.js";import{a3 as ve,a5 as X,d as fe,r as b,Y as he,i as ge,o as M,c as S,b as c,w,a as t,e as xe,a2 as ye,L as T,N as B,X as H,O as W,F as be,S as we,a0 as D,a4 as P}from"./index-89ffa310.js";import{t as ke}from"./useDataTime-8307199e.js";import{I as R}from"./Icon-71136976.js";import{u as Ce}from"./useBaseTable-3aeb2499.js";import{_ as $e}from"./TextPreview.vue_vue_type_script_setup_true_lang-ca174b43.js";import{S as Ue}from"./index-d95ef8ac.js";import{T as G}from"./styleChecker-47862663.js";import{U as J}from"./index-816ff657.js";import"./_plugin-vue_export-helper-0eb14515.js";import"./index-956b313f.js";import"./useState-33268b88.js";import"./vnode-75acd593.js";import"./Col-fc0de6a1.js";import"./index-7d158bfa.js";import"./usePrice-7afab779.js";import"./index-a33d0202.js";async function Me(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:f,error:_}=await X.from("challenge").insert([d]);if(_)throw console.error("Supabase insert error:",_),_;return console.log("Supabase insert success:",f),f}async function Se(m,d){const{data:f,error:_}=await X.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 f}async function Ie(m){const{error:d}=await X.from("challenge").delete().eq("id",m);if(d)throw d}async function Le(m){const{TableEngineRequest:d}=await ve(()=>import("./buildSupabaseQuery-64b2d9ac.js"),["assets/buildSupabaseQuery-64b2d9ac.js","assets/index-89ffa310.js","assets/index-c73797be.css"]),f={...m};!f.sort&&!f.order&&(f.order="-id");const _=await d(f,"challenge");try{if(Array.isArray(_==null?void 0:_.rows)){const C=f.page||1,k=f.limit||200,I=(C-1)*k,x=_.rows.map((h,U)=>({id:h.id,title:h.title??"",description:h.description??"",steps:h.steps??[],created_at:h.created_at??"",index:I+U,...h}));return{..._,rows:x}}}catch(C){console.log("[getChallengeTable] normalize error:",C)}return _}const De=[{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 f=d.reduce((C,k)=>C+(Number(k.minute)||0),0),_=d.reduce((C,k)=>C+(Number(k.score)||0),0);return`${d.length} مرحله / ${f} دقیقه / ${_} امتیاز`}},{title:"زمان ایجاد",dataIndex:"created_at",key:"created_at",customRender:m=>ke(m.record.created_at)},{title:"عملیات",dataIndex:"action",key:"action",slot:"action",filterable:!1,align:"center"}],Te={class:"flex justify-between items-center mb-4"},Be=t("h2",null,"چالش ها",-1),Pe={class:"gap-2 flex justify-center"},Re=t("span",null,"حذف",-1),qe=t("span",null,"ویرایش",-1),Ae={class:"space-y-4 relative"},Ne={key:0,class:"absolute inset-0 bg-white/60 z-10 flex items-center justify-center"},Ve=t("div",{class:"mb-1 text-sm text-gray-600"},"عنوان چالش",-1),ze=t("div",{class:"mb-1 text-sm text-gray-600"},"شرح چالش",-1),Oe={class:"flex justify-center gap-10 pb-4"},Fe=t("div",{class:"mb-1 text-sm text-gray-600"},"آپلود تصویر",-1),He={key:0},We=t("div",null,"آپلود تصویر",-1),Je={key:0,class:"mt-1"},Xe={class:"h-2 rounded bg-gray-200 overflow-hidden"},je={class:"text-xs text-gray
|