2 lines
15 KiB
JavaScript
2 lines
15 KiB
JavaScript
import{_ as G}from"./BasicMainCard-c54bb9b0.js";import{_ as H}from"./BasicModal.vue_vue_type_style_index_0_lang-81f74944.js";import{_ as K}from"./BasicTextArea.vue_vue_type_style_index_0_lang-a99d3ef0.js";import{_ as X}from"./BasicInput.vue_vue_type_style_index_0_lang-ef403492.js";import{_ as Z}from"./BaseTable.vue_vue_type_style_index_0_lang-9998cbb6.js";import{_ as ee}from"./button.vue_vue_type_style_index_0_lang-0fccfabb.js";import{a2 as te,a3 as k,d as oe,r as b,Y as ae,i as ie,o as D,c as C,b as s,w as y,a as o,e as se,a4 as ne,L as B,N as A,F as re,S as le,a0 as h}from"./index-8faf65eb.js";import{t as ce}from"./useDataTime-3ab158a8.js";import{I as T}from"./Icon-6ae98f2d.js";import{u as de}from"./useBaseTable-3aeb2499.js";import{M as ue}from"./index-d80e0fa6.js";import{S as pe}from"./index-4bd6caba.js";import{U as me}from"./index-7a7ffacc.js";import{T as Q}from"./index-873bc0b7.js";import"./_plugin-vue_export-helper-c27b6911.js";import"./index-1450fc27.js";import"./index-478507bf.js";import"./raf-c414ae0b.js";import"./colors-85157c08.js";import"./index-190b1277.js";import"./styleChecker-9e8bab95.js";import"./useState-419315b3.js";import"./Col-0090e201.js";import"./index-ded199d9.js";import"./debounce-87bd7043.js";import"./usePrefix-ed2fcde4.js";import"./index-ad541e1d.js";import"./SearchOutlined-ea23f2d8.js";import"./EyeOutlined-96e68258.js";import"./usePrice-7afab779.js";import"./index-bb9a7086.js";import"./index-a9568980.js";import"./pickAttrs-8b8fb5c4.js";import"./CheckOutlined-fd1b090a.js";import"./objectDestructuringEmpty-24e23e90.js";import"./eagerComputed-8c813d73.js";import"./index-30cb688a.js";async function ve(r){const{data:_,error:u}=await k.from("matchs").select("*").eq("id",r).single();if(u)throw u;const{data:m,error:n}=await k.from("questions").select("*").eq("match_id",r);if(n)throw n;return{..._,questions:m||[]}}async function _e(r){console.log("addMatchWithQuestions payload:",r);const{data:_,error:u}=await k.from("matchs").insert([r.match]).select().single();if(console.log("Match insert result:",{matchData:_,matchError:u}),u)throw console.error("Match insert error:",u),u;for(const m of r.questions){const{data:n,error:f}=await k.from("questions").insert([{match_id:_.id,question:m.question,options:m.options,correct_answer:m.correct_answer}]).select().single();if(f)throw f;console.log("Question created:",n)}return _}async function fe(r,_){const{error:u}=await k.from("matchs").update(_.match).eq("id",r);if(u)throw u;const{data:m}=await k.from("questions").select("id").eq("match_id",r);if(m)for(const n of m)await k.from("questions").delete().eq("id",n.id);for(const n of _.questions){const{data:f,error:g}=await k.from("questions").insert([{match_id:r,question:n.question,options:n.options,correct_answer:n.correct_answer}]).select().single();if(g)throw g;console.log("Question updated:",f)}return{id:r}}async function he(r){await k.from("questions").delete().eq("match_id",r);const{error:_}=await k.from("matchs").delete().eq("id",r);if(_)throw _}async function ge(r){const{TableEngineRequest:_}=await te(()=>import("./buildSupabaseQuery-50063746.js"),["assets/buildSupabaseQuery-50063746.js","assets/index-8faf65eb.js","assets/index-d933e911.css"]),u={...r};!u.sort&&!u.order&&(u.order="-id");const m=await _(u,"matchs");try{if(Array.isArray(m==null?void 0:m.rows)){const n=u.page||1,f=u.limit||200,g=(n-1)*f,S=m.rows.map((E,V)=>({id:E.id,title:E.title??"",description:E.description??"",created_at:E.created_at??"",index:g+V,...E}));return{...m,rows:S}}}catch(n){console.log("[getMatchTable] normalize error:",n)}return m}const xe=[{title:"ردیف",dataIndex:"id",key:"id",filterable:!1,width:70,align:"center",fixed:"left",customRender:r=>r.record.index+1},{title:"عنوان",dataIndex:"title",key:"title"},{title:"شرح",dataIndex:"description",key:"description"},{title:"سوالات",dataIndex:"questions",key:"questions",customRender:r=>"سوالات مسابقه"},{title:"تاریخ ایجاد",dataIndex:"created_at",key:"created_at",customRender:r=>ce(r.record.created_at)},{title:"عملیات",dataIndex:"action",key
|