Files
machartaa_admin_dist/dist/assets/index-e591dc33.js
T

2 lines
17 KiB
JavaScript
Raw Normal View History

2026-06-03 16:59:33 +03:30
import{_ as ge}from"./BasicMainCard-0a3c966a.js";import{_ as ve}from"./BasicModal.vue_vue_type_style_index_0_lang-b6c04ed1.js";import{_ as ye}from"./BasicTextArea.vue_vue_type_style_index_0_lang-e48f6249.js";import{_ as xe,a as we,u as Q}from"./useBaseTable-f0604f98.js";import{_ as be}from"./BasicInput.vue_vue_type_style_index_0_lang-5e5b83f8.js";import{_ as Se}from"./button.vue_vue_type_style_index_0_lang-9ce24083.js";import{I as T,_ as ke,d as Ie,g as M,A as Ce,o as R,c as B,b as r,w as _,j as b,a as s,e as j,G as Y,t as V,k as W,z as Ue,F as Te,p as Me,D as I,a8 as Ae,a9 as qe,H as $e}from"./index-108817e3.js";import{t as K}from"./useDataTime-0f06f32d.js";import{I as O}from"./Icon-03d9588d.js";import{e as Z,g as ee}from"./convert-67c23be8.js";import{T as te}from"./index-d1557459.js";import{M as Le}from"./index-0d047161.js";import{S as Re}from"./index-f0ba03aa.js";import{S as se}from"./index-802c3c8f.js";import{T as H}from"./shallowequal-105194c4.js";import{U as Be}from"./index-7f62fea2.js";import{_ as Pe}from"./_plugin-vue_export-helper-ec62f026.js";import"./index-60d145d7.js";import"./Col-b2cbfe37.js";import"./vnode-9b8abbbf.js";import"./isPlainObject-a22b8354.js";import"./index-707b194d.js";import"./FormItemContext-cecaca7f.js";import"./useState-472505a2.js";import"./index-7c9c2b70.js";import"./pickAttrs-f899bdd0.js";import"./toArray-a421612c.js";import"./usePrice-7afab779.js";import"./useRefs-eb5e3b2f.js";import"./index-4f951158.js";function ae(e,l){return l.map((n,i)=>({challenge_id:e,step_order:i+1,description:n.description,duration_seconds:Math.max(1,Math.round(Number(n.duration_minutes)*60)),aparat_embed_code:n.aparat_embed_code||null,punishment_description:n.punishment_description,requires_photo_upload:!!n.requires_photo_upload}))}async function De(e){const{data:l,error:n}=await T.from("step_challenges").select("*").eq("id",e).single();if(n)throw n;const{data:i,error:h}=await T.from("step_challenge_steps").select("*").eq("challenge_id",e).order("step_order",{ascending:!0});if(h)throw h;return{...l,steps:(i||[]).map(f=>({...f,duration_minutes:Math.round((f.duration_seconds||60)/60)}))}}async function Ee(e,l){const{data:n,error:i}=await T.from("step_challenges").insert([{title:e.title,character_image_url:e.character_image_url,show:e.show??!1,access_type:e.access_type??"free",sort_order:e.sort_order??0,owner_id:l||null}]).select().single();if(i)throw i;const h=ae(n.id,e.steps),{error:f}=await T.from("step_challenge_steps").insert(h);if(f)throw f;return n}async function ze(e,l){const{error:n}=await T.from("step_challenges").update({title:l.title,character_image_url:l.character_image_url,show:l.show??!1,access_type:l.access_type??"free",sort_order:l.sort_order??0,updated_at:new Date().toISOString()}).eq("id",e);if(n)throw n;const{error:i}=await T.from("step_challenge_steps").delete().eq("challenge_id",e);if(i)throw i;const h=ae(e,l.steps),{error:f}=await T.from("step_challenge_steps").insert(h);if(f)throw f;return{id:e}}async function Oe(e){const{error:l}=await T.from("step_challenges").delete().eq("id",e);if(l)throw l}async function Fe(e,l){const{data:n,error:i}=await T.from("step_challenges").update({...l,updated_at:new Date().toISOString()}).eq("id",e).select();if(i)throw i;return n}async function Ne(e){const{TableEngineRequest:l}=await ke(()=>import("./buildSupabaseQuery-03e3555e.js"),["assets/buildSupabaseQuery-03e3555e.js","assets/index-108817e3.js","assets/index-6f54f748.css"]),n={...e};!n.sort&&!n.order&&(n.order="-id");const i=await l(n,"step_challenges");try{if(Array.isArray(i==null?void 0:i.rows)){const h=i.rows,f=h.map(c=>c.id).filter(Boolean);let C={};if(f.length>0){const{data:c}=await T.from("step_challenge_steps").select("id, challenge_id, step_order, duration_seconds").in("challenge_id",f);C=(c||[]).reduce((m,o)=>(m[o.challenge_id]||(m[o.challenge_id]=[]),m[o.challenge_id].push(o),m),{})}const A=n.page||1,S=n.limit||20,q=(A-1)*S,L=h.map((c,m)=>{const o=C[c.id]||[],U=o.reduce((y,P)=>y+Math.round((P.duration_seconds||0)/60),0);return{...c,index:q+m,steps_count:o.length,total_minutes:U}});return{...i,