PageSourceSearch

https://worldofdance.com/assets/CreateCategory-CSIEBA2o.js

js worldofdance.com collected 2026-10-02 07:54:32 UTC 6,326 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-ui-G-YrU37Q.js";import{f as k,k as q,u as D,r as o}from"./vendor-react-BM7Mjnmg.js";import{u as F,B as g,C as T,a as U,b as L,c as A,d as I,L as s,I as d,q as P,r as B,t as $,v as O,w as p,W as _,s as m}from"./index-CxMl47VI.js";import{T as G}from"./textarea-dLdgyKvj.js";import{A as V}from"./arrow-left-A4RAe_Z2.js";import"./vendor-supabase-z-MrzYB5.js";import"./vendor-query-DVwyB0sA.js";function X(){const u=k(),{eventId:a}=q(),C=D(),{userRole:c,partnerScope:x}=C.state||{},[j,h]=o.useState(!1),[N,S]=o.useState(""),l=c==="partner"||c==="partner_admin",[f,w]=o.useState(!1),[r,i]=o.useState({name:"",description:"",price:"",currency:"USD",max_participants:"",requires_approval:!0,external_registration_url:""}),{toast:v}=F();o.useEffect(()=>{(async()=>{if(!a)return;const{data:n}=await m.from("events").select("name").eq("id",a).single();n&&S(n.name)})()},[a]);const E=async t=>{t.preventDefault(),h(!0);try{if(l&&!r.external_registration_url){v({title:"External registration URL required",description:"Partners must provide an external registration link for each category.",variant:"destructive"}),h(!1);return}const n={name:r.name,description:r.description||null,price:r.price?parseFloat(r.price):0,currency:r.currency,max_participants:r.max_participants?parseInt(r.max_participants):null,requires_approval:r.requires_approval,external_registration_url:r.external_registration_url||null};if(f){const{error:b}=await m.from("event_categories").insert([{...n,event_id:null}]);b&&console.error("Error creating template:",b)}const{count:R}=await m.from("event_categories").select("id",{count:"exact",head:!0}).eq("event_id",a),{error:y}=await m.from("event_categories").insert([{...n,event_id:a,display_order:R||0}]);if(y)throw y;v({title:"Success",description:"Registration category created successfully"}),u(`/admin/event/edit/${a}`,{state:{userRole:c,partnerScope:x}})}catch(n){console.error("Error creating category:",n),v({title:"Error",description:"Failed to create registration category",variant:"destructive"})}finally{h(!1)}};return e.jsx("div",{className:"min-h-screen bg-background",children:e.jsxs("div",{className:"container mx-auto px-4 py-8 max-w-2xl",children:[e.jsxs(g,{variant:"ghost",onClick:()=>u(`/admin/event/edit/${a}`,{state:{userRole:c,partnerScope:x}}),className:"mb-6",children:[e.jsx(V,{className:"h-4 w-4 mr-2"}),"Back to Event"]}),e.jsxs(T,{children:[e.jsxs(U,{children:[e.jsx(L,{children:"Create Registration Category"}),e.jsxs(A,{children:["Add a new registration category for ",N||"this event"]})]}),e.jsx(I,{children:e.jsxs("form",{onSubmit:E,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(s,{htmlFor:"name",children:"Category Name *"}),e.jsx(d,{id:"name",value:r.name,onChange:t=>i({...r,name:t.target.value}),placeholder:"e.g., Team Division, Junior Division",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(s,{htmlFor:"description",children:"Description"}),e.jsx(G,{id:"description",value:r.description,onChange:t=>i({...r,description:t.target.value}),placeholder:"Optional description of this category",rows:3})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(s,{htmlFor:"price",children:"Registration Fee (Optional)"}),e.jsx(d,{id:"price",type:"number",min:"0",step:"0.01",value:r.price,onChange:t=>i({...r,price:t.target.value}),placeholder:"0.00 (Free if empty)"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(s,{htmlFor:"currency",children:"Currency"}),e.jsxs(P,{value:r.currency,onValueChange:t=>i({...r,currency:t}),children:[e.jsx(B,{className:"bg-background border-input",children:e.jsx($,{})}),e.jsxs(O,{className:"bg-popover border-border z-50",children:[e.jsx(p,{value:"USD",children:"USD ($)"}),e.jsx(p,{value:"EUR",children:"EUR (€)"}),e.jsx(p,{value:"GBP",children:"GBP (£)"}),e.jsx(p,{value:"CAD",children:"CAD ($)"})]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(s,{htmlFor:"max_participants",children:"Max Participants"}),e.jsx(d,{id:"max_participants",type:"number",min:"1",value:r.max_participants,onChange:t=>i({...r,max_participants:t.target.value}),placeholder:"Unlimited"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(s,{htmlFor:"external_registration_url",children:["External Registration URL ",l&&e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(d,{id:"external_registration_url",type:"url",value:r.external_registration_url,onChange:t=>i({...r,external_registration_url:t.target.value}),placeholder:"https://yoursite.com/payment-form",required:l}
1),l?e.jsx("p",{className:"text-sm text-amber-600 dark:text-amber-400",children:"Required: Teams will be redirected to this URL after approval to complete registration/payment through your system."}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Optional: If provided, teams will be redirected to this URL after approval to complete registration/payment."})]}),e.jsxs("div",{className:"flex items-start justify-between rounded-md border border-border p-4",children:[e.jsxs("div",{className:"pr-4",children:[e.jsx(s,{className:"block",children:"Requires approval before payment"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"If turned off, registrations in this category are auto-approved when submitted."})]}),e.jsx(_,{checked:r.requires_approval,onCheckedChange:t=>i({...r,requires_approval:t}),"aria-label":"Requires approval"})]}),e.jsxs("div",{className:"flex items-start justify-between rounded-md border border-primary/30 bg-primary/5 p-4",children:[e.jsxs("div",{className:"pr-4",children:[e.jsx(s,{className:"block",children:"Save as reusable template"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Enable this to reuse this category in future events. The template will not include deadlines (those are event-specific)."})]}),e.jsx(_,{checked:f,onCheckedChange:w,"aria-label":"Save as template"})]}),e.jsxs("div",{className:"flex justify-end space-x-3 pt-4 border-t",children:[e.jsx(g,{type:"button",variant:"outline",onClick:()=>u(`/admin/event/edit/${a}`,{state:{userRole:c,partnerScope:x}}),children:"Cancel"}),e.jsx(g,{type:"submit",disabled:j,children:j?"Creating...":"Create Category"})]})]})})]})]})})}export{X 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.