PageSourceSearch

https://trainerstudio.de/assets/useGames-Cjd0owLs.js

js trainerstudio.de collected 2026-10-09 22:04:41 UTC 1,683 bytes, 1 lines download raw bytes

1import{r as l,a3 as b,a4 as D,s as u,N as a}from"./index-SUgZbrft.js";function T(){const[m,n]=l.useState([]),[p,h]=l.useState(!0),{user:s}=b(),{activeTeamId:c}=D(),d=l.useCallback(async()=>{if(!s||!c){n([]),h(!1);return}try{const{data:e,error:r}=await u.from("games").select("*").eq("team_id",c).order("game_date",{ascending:!0});if(r)throw r;n(e||[])}catch(e){console.error("Error fetching games:",e)}finally{h(!1)}},[s,c]);l.useEffect(()=>{d()},[d]);const w=async e=>{if(!s||!c)return a.error("Bitte melde dich an"),null;try{const{data:r,error:t}=await u.from("games").insert({...e,user_id:s.id,team_id:c}).select().single();if(t)throw t;return n(o=>[...o,r].sort((g,i)=>new Date(g.game_date).getTime()-new Date(i.game_date).getTime())),a.success("Spiel hinzugefügt!"),r}catch(r){return console.error("Error adding game:",r),a.error("Fehler beim Hinzufügen"),null}},y=async(e,r)=>{if(!s)return null;try{const{data:t,error:o}=await u.from("games").update(r).eq("id",e).select().single();if(o)throw o;return n(g=>g.map(i=>i.id===e?t:i)),a.success("Spiel aktualisiert!"),t}catch(t){return console.error("Error updating game:",t),a.error("Fehler beim Aktualisieren"),null}},_=async e=>{if(s)try{const{error:r}=await u.from("games").delete().eq("id",e);if(r)throw r;n(t=>t.filter(o=>o.id!==e)),a.success("Spiel gelöscht")}catch(r){console.error("Error deleting game:",r),a.error("Fehler beim Löschen")}},f=new Date;f.setHours(0,0,0,0);const G=m.filter(e=>new Date(e.game_date)>=f&&e.result_home===null),E=m.filter(e=>e.result_home!==null||new Date(e.game_date)<f);return{games:m,upcomingGames:G,pastGames:E,isLoading:p,addGame:w,updateGame:y,deleteGame:_,refetch:d}}export{T as u};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.