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

2 lines
18 KiB
JavaScript
Raw Normal View History

2026-06-18 20:24:23 +03:30
import{_ as xe}from"./BasicMainCard-9d8af607.js";import{_ as we}from"./BasicModal.vue_vue_type_style_index_0_lang-2c965652.js";import{_ as be}from"./BasicTextArea.vue_vue_type_style_index_0_lang-5b0e2685.js";import{_ as Se,a as Ie,u as Q}from"./useBaseTable-e8654654.js";import{_ as ke}from"./BasicInput.vue_vue_type_style_index_0_lang-96e71e2f.js";import{_ as Ce}from"./button.vue_vue_type_style_index_0_lang-61c18c46.js";import{I as y,_ as Ue,d as Te,g as A,A as Me,o as $,c as B,b as c,w as m,j as S,a as s,e as z,G as Y,t as V,k as W,y as Re,F as Ae,n as qe,D as C,J as Pe,K as $e,H as Be}from"./index-fe7e9f3a.js";import{f as Z,b as Ee,c as De,d as Le,e as Fe,t as Oe,M as ne,g as Ne}from"./supabaseTableQuery-be932edd.js";import{t as K}from"./useDataTime-6319c12a.js";import{I as O}from"./Icon-b952e603.js";import{e as ee,g as te}from"./convert-67c23be8.js";import{T as se}from"./index-66219801.js";import{M as je}from"./index-4bebce71.js";import{S as ze}from"./index-c3b05d68.js";import{S as ae}from"./fa_IR-23a1f71d.js";import{T as H}from"./shallowequal-84daf276.js";import{U as Ve}from"./index-207b9df5.js";import{_ as We}from"./_plugin-vue_export-helper-84433aaa.js";import"./index-a0d96113.js";import"./index-265527df.js";import"./Col-4a3e6527.js";import"./vnode-4e2eb49f.js";import"./isPlainObject-8df7c091.js";import"./index-6e5ff446.js";import"./FormItemContext-b538849a.js";import"./useState-fbb2e402.js";import"./lodash-7b4e0250.js";import"./index-63f18912.js";import"./pickAttrs-c6e9cc38.js";import"./toArray-1e9f5cfb.js";import"./usePrice-bc935b83.js";import"./useRefs-f56804c8.js";import"./index-9caf69a4.js";function re(e,i){return i.map((o,n)=>({challenge_id:e,step_order:n+1,description:o.description,duration_seconds:Math.max(1,Math.round(Number(o.duration_minutes)*60)),aparat_embed_code:o.aparat_embed_code||null,punishment_description:o.punishment_description,requires_photo_upload:!!o.requires_photo_upload}))}async function He(e){const{data:i,error:o}=await y.from("step_challenges").select("*").eq("id",e).single();if(o)throw o;const{data:n,error:u}=await y.from("step_challenge_steps").select("*").eq("challenge_id",e).order("step_order",{ascending:!0});if(u)throw u;return{...i,steps:(n||[]).map(l=>({...l,duration_minutes:Math.round((l.duration_seconds||60)/60)}))}}async function Ke(e,i){const{data:o,error:n}=await y.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:i||null}]).select().single();if(n)throw n;const u=re(o.id,e.steps),{error:l}=await y.from("step_challenge_steps").insert(u);if(l)throw l;return o}async function Je(e,i){const{error:o}=await y.from("step_challenges").update({title:i.title,character_image_url:i.character_image_url,show:i.show??!1,access_type:i.access_type??"free",sort_order:i.sort_order??0,updated_at:new Date().toISOString()}).eq("id",e);if(o)throw o;const{error:n}=await y.from("step_challenge_steps").delete().eq("challenge_id",e);if(n)throw n;const u=re(e,i.steps),{error:l}=await y.from("step_challenge_steps").insert(u);if(l)throw l;return{id:e}}async function Ge(e){const{error:i}=await y.from("step_challenges").delete().eq("id",e);if(i)throw i}async function Xe(e,i){const{data:o,error:n}=await y.from("step_challenges").update({...i,updated_at:new Date().toISOString()}).eq("id",e).select();if(n)throw n;return o}async function Qe(e){const{TableEngineRequest:i}=await Ue(()=>import("./buildSupabaseQuery-64c97ab8.js"),["assets/buildSupabaseQuery-64c97ab8.js","assets/index-fe7e9f3a.js","assets/index-457f5e42.css","assets/supabaseTableQuery-be932edd.js"]),o={...e};!o.sort&&!o.order&&(o.order="-id");const n=await i(o,"step_challenges");try{if(Array.isArray(n==null?void 0:n.rows)){const u=n.rows,l=u.map(I=>I.id).filter(Boolean);let U={};if(l.length>0){const{data:I}=await y.from("step_challenge_steps").select("id, challenge_id, step_order, duration_seconds").in("challenge_id",l);U=(I||[]).reduce((x,v)=>(x[v.challenge_id]||(x[v.challenge_id]=[]),x[v.challenge_id].push(v),x),{})}const T=o