Files
machartaa_admin_dist/dist/assets/index-0f0e041a.js
T

2 lines
16 KiB
JavaScript
Raw Normal View History

2026-06-02 20:08:47 +03:30
import{_ as ue}from"./BasicMainCard-6dd48f47.js";import{_ as _e}from"./BasicModal.vue_vue_type_style_index_0_lang-c60160bb.js";import{_ as pe}from"./BasicTextArea.vue_vue_type_style_index_0_lang-bb001247.js";import{_ as me,a as he,u as G}from"./useBaseTable-c7721a03.js";import{_ as fe}from"./BasicInput.vue_vue_type_style_index_0_lang-cb979b48.js";import{_ as ge}from"./button.vue_vue_type_style_index_0_lang-4dc9d3e9.js";import{I as S,_ as ve,d as xe,g as T,A as ye,o as q,c as A,b as l,w as v,j as I,a as s,e as we,G as X,t as j,k as W,z as be,F as ke,p as Se,D as b,H as Q,a8 as Ce,a9 as Ie}from"./index-9a17e55b.js";import{t as H}from"./useDataTime-7a9ebe02.js";import{I as D}from"./Icon-83dbbbe4.js";import{T as Y}from"./index-f08856bb.js";import{M as Ue}from"./index-d5d26f82.js";import{S as Te}from"./index-26298d7e.js";import{T as V}from"./shallowequal-5f876352.js";import{U as Me}from"./index-b78b7a1c.js";import{_ as $e}from"./_plugin-vue_export-helper-09135f79.js";import"./index-58b0d53e.js";import"./Col-dc7ee55f.js";import"./vnode-0a46e202.js";import"./isPlainObject-7dd54c5e.js";import"./index-369204e0.js";import"./FormItemContext-101590b9.js";import"./index-4182a454.js";import"./toArray-c5dd79c4.js";import"./pickAttrs-0804445f.js";import"./useState-6ac08ff3.js";import"./index-e6e78cc4.js";import"./usePrice-7afab779.js";import"./useRefs-707c512d.js";import"./index-dad403b6.js";function Z(e,i){return i.map((n,c)=>({challenge_id:e,step_order:c+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 qe(e){const{data:i,error:n}=await S.from("step_challenges").select("*").eq("id",e).single();if(n)throw n;const{data:c,error:p}=await S.from("step_challenge_steps").select("*").eq("challenge_id",e).order("step_order",{ascending:!0});if(p)throw p;return{...i,steps:(c||[]).map(m=>({...m,duration_minutes:Math.round((m.duration_seconds||60)/60)}))}}async function Ae(e,i){const{data:n,error:c}=await S.from("step_challenges").insert([{title:e.title,character_image_url:e.character_image_url,show:e.show??!1,sort_order:e.sort_order??0,owner_id:i||null}]).select().single();if(c)throw c;const p=Z(n.id,e.steps),{error:m}=await S.from("step_challenge_steps").insert(p);if(m)throw m;return n}async function Le(e,i){const{error:n}=await S.from("step_challenges").update({title:i.title,character_image_url:i.character_image_url,show:i.show??!1,sort_order:i.sort_order??0,updated_at:new Date().toISOString()}).eq("id",e);if(n)throw n;const{error:c}=await S.from("step_challenge_steps").delete().eq("challenge_id",e);if(c)throw c;const p=Z(e,i.steps),{error:m}=await S.from("step_challenge_steps").insert(p);if(m)throw m;return{id:e}}async function Be(e){const{error:i}=await S.from("step_challenges").delete().eq("id",e);if(i)throw i}async function Re(e,i){const{data:n,error:c}=await S.from("step_challenges").update({...i,updated_at:new Date().toISOString()}).eq("id",e).select();if(c)throw c;return n}async function De(e){const{TableEngineRequest:i}=await ve(()=>import("./buildSupabaseQuery-dba94894.js"),["assets/buildSupabaseQuery-dba94894.js","assets/index-9a17e55b.js","assets/index-33951367.css"]),n={...e};!n.sort&&!n.order&&(n.order="-id");const c=await i(n,"step_challenges");try{if(Array.isArray(c==null?void 0:c.rows)){const p=c.rows,m=p.map(r=>r.id).filter(Boolean);let C={};if(m.length>0){const{data:r}=await S.from("step_challenge_steps").select("id, challenge_id, step_order, duration_seconds").in("challenge_id",m);C=(r||[]).reduce((u,a)=>(u[a.challenge_id]||(u[a.challenge_id]=[]),u[a.challenge_id].push(a),u),{})}const P=n.page||1,k=n.limit||20,M=(P-1)*k,E=p.map((r,u)=>{const a=C[r.id]||[],U=a.reduce((d,z)=>d+Math.round((z.duration_seconds||0)/60),0);return{...r,index:M+u,steps_count:a.length,total_minutes:U}});return{...c,rows:E}}}catch(p){console.log("[getStepChallengesTable] normalize error:",p)}return c}async function Pe(e){const{limit:i=20,page:n=1,se