2 lines
14 KiB
JavaScript
2 lines
14 KiB
JavaScript
import{_ as Q}from"./BasicMainCard-bd323dbb.js";import{_ as X}from"./BasicModal.vue_vue_type_style_index_0_lang-fc68b6f7.js";import{u as Z}from"./usePrefix-59ffbd1f.js";import{T as ee}from"./index-ab4bfd10.js";import{d as V,g as te,o as S,c as T,a as t,O as se,b as n,L as U,W as ae,T as le,a2 as oe,a3 as j,r as w,Y as ie,i as ne,w as g,e as re,a4 as ce,N as L,F as ue,S as de,a0 as b}from"./index-a8433551.js";import{_ as pe}from"./BasicInput.vue_vue_type_style_index_0_lang-fff7ede0.js";import{_ as me}from"./BaseTable.vue_vue_type_style_index_0_lang-882f1017.js";import{_ as _e}from"./button.vue_vue_type_style_index_0_lang-33000dc3.js";import{t as ve}from"./useDataTime-8719acff.js";import{I as D}from"./Icon-4420454e.js";import{u as fe}from"./useBaseTable-3aeb2499.js";import{M as he}from"./index-3386ab22.js";import{T as P}from"./index-1c2b64f4.js";import{S as ge}from"./index-bcdceab6.js";import{U as E}from"./index-2ef5192d.js";import"./_plugin-vue_export-helper-c27b6911.js";import"./index-ead9b4ae.js";import"./index-4dee99dd.js";import"./raf-ca407421.js";import"./colors-338a38fb.js";import"./index-4a4899f5.js";import"./styleChecker-4074517c.js";import"./useState-ea5d1f15.js";import"./Col-6a6e9347.js";import"./index-cd5dab0a.js";import"./debounce-12f80d64.js";import"./SearchOutlined-14c653fb.js";import"./EyeOutlined-a79acaa2.js";import"./usePrice-7afab779.js";import"./index-47f6ee7f.js";import"./index-b96224b7.js";import"./pickAttrs-cd8d934f.js";import"./CheckOutlined-fe3ce043.js";import"./objectDestructuringEmpty-24e23e90.js";import"./eagerComputed-9b88cc2c.js";import"./index-9790e4ab.js";const xe=V({__name:"BasicTextArea",props:{title:{},value:{},showCount:{type:Boolean},maxlength:{},placeHolder:{}},emits:["update:value"],setup(r,{emit:o}){const d=r,u=te({get(){return d.value},set(f){o("update:value",f)}}),{prefixCls:h}=Z("input-area");return(f,x)=>{const _=ee;return S(),T("div",{class:le([U(h)])},[t("div",null,se(d.title),1),n(_,{value:U(u),"onUpdate:value":x[0]||(x[0]=y=>ae(u)?u.value=y:null),class:"",type:d.type,"show-count":d.showCount,placeHolder:d.placeHolder},null,8,["value","type","show-count","placeHolder"])],2)}}});async function ye(r){console.log("API addChallenge payload:",r);const o={title:r.title,description:r.description,owner_id:r.owner_id,minute:r.minute,score:r.score,image_url:r.image_url||null,clip_url:r.clip_url||null,steps:r.steps||[]};console.log("Supabase insert data:",o);const{data:d,error:u}=await j.from("challenge").insert([o]);if(u)throw console.error("Supabase insert error:",u),u;return console.log("Supabase insert success:",d),d}async function we(r,o){const{data:d,error:u}=await j.from("challenge").update({title:o.title,description:o.description,owner_id:o.owner_id,minute:o.minute,score:o.score,image_url:o.image_url||null,clip_url:o.clip_url||null,steps:o.steps||[]}).eq("id",r).select();if(u)throw u;return d}async function be(r){const{error:o}=await j.from("challenge").delete().eq("id",r);if(o)throw o}async function ke(r){const{TableEngineRequest:o}=await oe(()=>import("./buildSupabaseQuery-944c77f8.js"),["assets/buildSupabaseQuery-944c77f8.js","assets/index-a8433551.js","assets/index-d933e911.css"]),d={...r};!d.sort&&!d.order&&(d.order="-id");const u=await o(d,"challenge");try{if(Array.isArray(u==null?void 0:u.rows)){const h=d.page||1,f=d.limit||200,x=(h-1)*f,_=u.rows.map((y,A)=>({id:y.id,title:y.title??"",description:y.description??"",steps:y.steps??[],created_at:y.created_at??"",index:x+A,...y}));return{...u,rows:_}}}catch(h){console.log("[getChallengeTable] normalize error:",h)}return u}const Ce=[{title:"ردیÙ�",dataIndex:"id",key:"id",filterable:!1,customRender:r=>r.record.index+1},{title:"عنوان",dataIndex:"title",key:"title"},{title:"شرØ",dataIndex:"description",key:"description"},{title:"مراØÙ„",dataIndex:"steps",key:"steps",customRender:r=>{const o=r.record.steps||[];if(o.length===0)return"-";const d=o.reduce((h,f)=>h+(Number(f.minute)||0),0),u=o.reduce((h,f)=>h+(Number(f.score)||0),0);return`${o.length} مرØÙ„Ù‡ / ${d} دقیقه / ${u} امتیاز`}},{title:"تاریØ
|