2026-07-14 12:58:42 +03:30
|
|
|
import{_ as de}from"./BasicMainCard-9c458ce7.js";import{_ as pe}from"./BasicModal.vue_vue_type_style_index_0_lang-5bce5515.js";import{_ as me}from"./BasicTextArea.vue_vue_type_style_index_0_lang-ec68dcd2.js";import{_ as _e}from"./BasicInput.vue_vue_type_style_index_0_lang-cee0843c.js";import{_ as ve,u as fe}from"./useBaseTable-3b2d0853.js";import{_ as ge}from"./button.vue_vue_type_style_index_0_lang-95946c23.js";import{_ as he,G,d as xe,g as y,A as ye,v as be,o as I,c as S,b as c,w as b,a as t,e as we,H as ke,j as B,k as R,y as J,t as j,F as Ce,n as Ue,D as P,I as X}from"./index-20d5dab1.js";import{t as Me}from"./useDataTime-c147e135.js";import{I as q}from"./Icon-06d3f751.js";import{e as T,g as N}from"./convert-2ad76038.js";import{_ as Ie}from"./TextPreview.vue_vue_type_script_setup_true_lang-bacd5482.js";import{M as Se}from"./index-4f6342fa.js";import{T as Y}from"./isSymbol-f04930e1.js";import{S as $e}from"./index-38a2f111.js";import{U as W}from"./index-44ec8c49.js";import"./index-857151a7.js";import"./index-4284a867.js";import"./_plugin-vue_export-helper-26f60d29.js";import"./useState-3cc4a0be.js";import"./vnode-18b1f518.js";import"./useRefs-03151dab.js";import"./_flatRest-12208321.js";import"./index-0d016563.js";import"./Col-6ec89065.js";import"./styleChecker-6ae1ce26.js";import"./isPlainObject-769b8c03.js";import"./index-f6eb678e.js";import"./FormItemContext-28b30746.js";import"./usePrice-bc935b83.js";import"./updateLocale-6ea9ed84.js";import"./toArray-fb96c8b9.js";import"./pickAttrs-93039156.js";import"./lodash-28ee46da.js";import"./css-0bca533a.js";import"./DialogWrap-a4cda90f.js";import"./index-f75dc027.js";import"./textUtils-c37780ad.js";import"./index-84af5005.js";async function De(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 Le(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-4c9afa46.js"),["assets/buildSupabaseQuery-4c9afa46.js","assets/index-20d5dab1.js","assets/index-2b0c085a.css","assets/supabaseTableQuery-95762ff3.js"]),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,$=(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:$+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),Ae={class:"gap-2 flex justify-center"},Ve=t("span",null,"ØØ°Ù�",-1),ze=t("span",null,"ویراÛ
|