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

2 lines
17 KiB
JavaScript
Raw Normal View History

2026-06-07 15:06:40 +03:30
import{_ as ge}from"./BasicMainCard-40d6570b.js";import{_ as ve}from"./BasicModal.vue_vue_type_style_index_0_lang-cd9077ad.js";import{_ as ye}from"./BasicTextArea.vue_vue_type_style_index_0_lang-013c7c81.js";import{_ as xe,a as we,u as Q}from"./useBaseTable-084adda9.js";import{_ as be}from"./BasicInput.vue_vue_type_style_index_0_lang-1513fc09.js";import{_ as Se}from"./button.vue_vue_type_style_index_0_lang-379723a2.js";import{H as T,_ as ke,d as Ce,g as M,z as Ie,o as R,c as B,b as r,w as _,j as b,a as s,e as j,E as Y,t as V,k as W,y as Ue,F as Te,n as Me,C,I as qe,J as Ae,G as $e}from"./index-5870e6d3.js";import{t as J}from"./useDataTime-b0920a9a.js";import{I as O}from"./Icon-61906fca.js";import{e as Z,g as ee}from"./convert-67c23be8.js";import{T as te}from"./index-3e5e4620.js";import{M as Le}from"./index-12089cb1.js";import{S as Re}from"./index-ccb2a61b.js";import{S as se}from"./fa_IR-09853d0d.js";import{T as H}from"./shallowequal-2bdf6cc7.js";import{U as Be}from"./index-3a1b3da6.js";import{_ as Pe}from"./_plugin-vue_export-helper-5e3c08f4.js";import"./index-6338714e.js";import"./Col-619d881f.js";import"./vnode-22dd7580.js";import"./isPlainObject-9db900ef.js";import"./index-f48a08af.js";import"./FormItemContext-817438bc.js";import"./useState-9f642396.js";import"./lodash-c64d74c3.js";import"./index-46729aba.js";import"./pickAttrs-38dcf0c9.js";import"./toArray-f3da0fcb.js";import"./usePrice-7afab779.js";import"./useRefs-f4db4963.js";import"./index-c8d614fc.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-e573bc87.js"),["assets/buildSupabaseQuery-e573bc87.js","assets/index-5870e6d3.js","assets/index-fc36161b.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 I={};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);I=(c||[]).reduce((m,o)=>(m[o.challenge_id]||(m[o.challenge_id]=[]),m[o.challenge_id].push(o),m),{})}const q=n.page||1,S=n.limit||20,A=(q-1)*S,L=h.map((c,m)=>{const o=I[c.id]||[],U=o.reduce((y,P)=>y+Math.round((P.duration_seconds||0)/60),0);return{...c,index:A+m,steps_count:o.length,total_min