PageSourceSearch

https://pontyclunrfc.base44.app/assets/ManageTraining-Bw-aAYeM.js

js pontyclunrfc.base44.app collected 2026-10-03 03:08:12 UTC 5,338 bytes, 1 lines download raw bytes

1import{r as c,u as M,R as S,h as d,i as A,j as e,p as F,B as g,D as I,b as L,d as q,e as P,I as m}from"./index-ahKmeLsL.js";import{u as f}from"./useMutation-Ctp3n8-h.js";import{L as u}from"./label-B7sUAfiI.js";import{A as R}from"./AdminPageHeader-gld7h3w1.js";import{S as Q}from"./square-pen-9sXZq6ce.js";import"./arrow-left-BvPOYeIN.js";const U=[{team_name:"Senior Men's Team",team_key:"first",display_order:1},{team_name:"Youth",team_key:"youth_U18",display_order:2},{team_name:"Falcons (Women)",team_key:"women",display_order:3}],j={team_name:"",team_key:"",training_day:"",training_time:"",training_location:"",notes:"",display_order:0};function Y(){const[v,s]=c.useState(!1),[o,h]=c.useState(null),[t,r]=c.useState(j),y=M(),[l,x]=c.useState(null);S.useEffect(()=>{d.auth.me().then(x).catch(()=>x(null))},[]);const{data:_=[],isLoading:b}=A({queryKey:["teamTrainingInfo"],queryFn:()=>d.entities.TeamTrainingInfo.list("display_order")}),N=f({mutationFn:async a=>{var n;const i=await d.functions.invoke("manageTeamTrainingInfo",{action:"create",data:a});if((n=i.data)!=null&&n.error)throw new Error(i.data.error);return i.data},onSuccess:()=>{y.invalidateQueries({queryKey:["teamTrainingInfo"]}),s(!1)},onError:a=>alert(`Failed to save training info: ${a.message||"Please try again."}`)}),T=f({mutationFn:async({id:a,data:i})=>{var p;const n=await d.functions.invoke("manageTeamTrainingInfo",{action:"update",id:a,data:i});if((p=n.data)!=null&&p.error)throw new Error(n.data.error);return n.data},onSuccess:()=>{y.invalidateQueries({queryKey:["teamTrainingInfo"]}),s(!1)},onError:a=>alert(`Failed to save training info: ${a.message||"Please try again."}`)}),k=a=>{h(a),r(a),s(!0)},C=a=>{h(null),r({...j,...a}),s(!0)},D=a=>{a.preventDefault(),o?T.mutate({id:o.id,data:t}):N.mutate(t)},E=a=>_.find(i=>i.team_key===a),w=l&&(l.role==="admin"||l.role==="team_manager");return l!==null&&!w?e.jsx("div",{className:"min-h-screen flex items-center justify-center",style:{backgroundColor:"#f5f5f5"},children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-800 mb-4",children:"Access Denied"}),e.jsx("p",{className:"text-gray-600",children:"You need Team Manager or Admin access to view this page."})]})}):b?e.jsx("div",{className:"min-h-screen flex items-center justify-center",style:{backgroundColor:"#f5f5f5"},children:e.jsx("p",{children:"Loading..."})}):e.jsxs("div",{className:"min-h-screen bg-[#f5f5f5]",children:[e.jsx(R,{title:"Manage Training",subtitle:"Edit training days and times for senior & youth teams"}),e.jsxs("div",{className:"max-w-4xl mx-auto px-6 py-8",children:[e.jsx("div",{className:"bg-white rounded-xl shadow-sm p-6",children:e.jsx("div",{className:"space-y-3",children:U.map((a,i)=>{const n=E(a.team_key);return e.jsxs(F.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:i*.04},className:"flex items-center justify-between p-4 border border-gray-200 rounded-lg hover:bg-gray-50",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold",style:{color:"var(--club-primary)"},children:a.team_name}),n?e.jsxs("div",{className:"text-sm text-gray-600 mt-1 space-y-0.5",children:[n.training_day&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Day:"})," ",n.training_day]}),n.training_time&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Time:"})," ",n.training_time]}),n.training_location&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Location:"})," ",n.training_location]}),n.notes&&e.jsx("p",{className:"text-gray-500 italic",children:n.notes})]}):e.jsx("p",{className:"text-sm text-gray-400 italic mt-1",children:"No training info set"})]}),e.jsxs(g,{onClick:()=>n?k(n):C(a),variant:"outline",size:"sm",className:"ml-4 flex-shrink-0",children:[e.jsx(Q,{size:16,className:"mr-1"}),n?"Edit":"Add"]})]},a.team_key)})})}),e.jsx(I,{open:v,onOpenChange:s,children:e.jsxs(L,{className:"sm:max-w-lg",children:[e.jsx(q,{children:e.jsx(P,{children:o?`Edit Training - ${o.team_name}`:`Add Training - ${t.team_name}`})}),e.jsxs("form",{onSubmit:D,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(u,{children:"Training Day"}),e.jsx(m,{value:t.training_day||"",onChange:a=>r({...t,training_day:a.target.value}),placeholder:"e.g. Tuesday & Thursday"})]}),e.jsxs("div",{children:[e.jsx(u,{children:"Training Time"}),e.jsx(m,{value:t.training_time||"",onChange:a=>r({...t,training_time:a.target.value}),placeholder:"e.g. 7:00 PM - 9:00 PM"})]})]}),e.jsxs("div",{children:[e.jsx(u,{children:"Location"}),e.jsx(m,{value:t.training_location||"",onChange:a=>r({...t,training_location:a.target.value}),placeholder:"e.g. Main training ground"})]}),e.jsxs("div",{children:[e.jsx(u,{children:"Notes"}),e.jsx(m,{value:t.notes||"",onChange:a=>r({...t,notes:a.target.value}),placeholder:"Any additional info"})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[e.jsx(g,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(g,{type:"submit",style:{backgroundColor:"var(--club-primary)"},onMouseEnter:a=>a.target.style.backgroundColor="var(--club-primary-mid)",onMouseLeave:a=>a.target.style.backgroundColor="var(--club-primary)",children:"Save"})]})]})]})})]})]})}export{Y as default};

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.