PageSourceSearch

https://parkcityutah.ai/assets/DashboardListingEventForm-DxKwud-s.js

js parkcityutah.ai collected 2026-10-05 13:31:59 UTC 9,643 bytes, 1 lines download raw bytes

1import{a3 as F,u as I,f as q,r as g,b as L,s as v,j as e,C as m,K as h,N as _,c as x,I as l,D as A,M as R,U as P,B as C,L as V,J as p}from"./index-PtGACUVf.js";import{S as M,a as O}from"./safe-select-DK0jC4_p.js";import{u as U}from"./BusinessContext-BOK9Au9O.js";import{L as d}from"./label-BGYTmHnu.js";import{T as W}from"./textarea-B113Ozlu.js";import{S as w}from"./skeleton-DaIvcz7V.js";import{A as S,a as k}from"./alert-aNjvcd0z.js";import{C as B}from"./checkbox-Be-GC6mS.js";import{a as K,b as $,c as H,d as j}from"./select-BwSQ4ldD.js";import{C as D}from"./circle-alert-zZK6adB6.js";import{D as J}from"./dollar-sign-CxkVLaIr.js";import{S as Q}from"./send-pTCFlKr_.js";import"./index-BdQq_4o_.js";import"./chevron-up-BZ1Up2zp.js";const Y=[{value:"sunday",label:"Sun"},{value:"monday",label:"Mon"},{value:"tuesday",label:"Tue"},{value:"wednesday",label:"Wed"},{value:"thursday",label:"Thu"},{value:"friday",label:"Fri"},{value:"saturday",label:"Sat"}];function ue(){const{eventId:o}=F(),y=I(),{user:i}=q(),{business:f}=U(),u=!!o,[N,b]=g.useState(!1),[a,r]=g.useState({title:"",description:"",start_date:"",end_date:"",start_time:"",end_time:"",recurrence_type:"none",recurrence_days:[],location_name:"",street_address:"",city_address:"",state_address:"",zip_address:"",image_url:"",ticket_url:"",event_url:"",organizer_name:"",phone:"",email:"",price_info:""}),{data:t,isLoading:E}=L({queryKey:["user-event",o,i==null?void 0:i.id],queryFn:async()=>{if(!o||!i)return null;const{data:s,error:n}=await v.from("events").select("*").eq("id",o).eq("user_id",i.id).maybeSingle();if(n)throw n;return s}
1,enabled:!!o&&!!i});g.useEffect(()=>{t&&r({title:t.title||"",description:t.description||"",start_date:t.start_date||"",end_date:t.end_date||"",start_time:t.start_time||"",end_time:t.end_time||"",recurrence_type:t.recurrence_type||"none",recurrence_days:t.recurrence_days||[],location_name:t.location_name||"",street_address:t.street_address||t.location_address||"",city_address:t.city_address||"",state_address:t.state_address||"",zip_address:t.zip_address||"",image_url:t.image_url||"",ticket_url:t.ticket_url||"",event_url:t.event_url||"",organizer_name:t.organizer_name||"",phone:t.phone||"",email:t.email||"",price_info:t.price_info||""})},[t]);const z=s=>{r(n=>({...n,recurrence_days:n.recurrence_days.includes(s)?n.recurrence_days.filter(c=>c!==s):[...n.recurrence_days,s]}))},T=async s=>{if(s.preventDefault(),!(!i||!f)){if(!a.title.trim()||!a.start_date){p.error("Title and start date are required");return}b(!0);try{const n={title:a.title.trim(),description:a.description.trim()||null,start_date:a.start_date,end_date:a.end_date||null,start_time:a.start_time||null,end_time:a.end_time||null,recurrence_type:a.recurrence_type||"none",recurrence_days:a.recurrence_type==="weekly"?a.recurrence_days:null,location_name:a.location_name.trim()||null,street_address:a.street_address.trim()||null,city_address:a.city_address.trim()||null,state_address:a.state_address.trim()||null,zip_address:a.zip_address.trim()||null,image_url:a.image_url.trim()||null,ticket_url:a.ticket_url.trim()||null,event_url:a.event_url.trim()||null,organizer_name:a.organizer_name.trim()||null,phone:a.phone.trim()||null,email:a.email.trim()||null,price_info:a.price_info.trim()||null};if(u&&t){const{error:c}=await v.from("events").update({...n,status:"pending",rejection_reason:null,submitted_at:new Date().toISOString()}).eq("id",o).eq("user_id",i.id);if(c)throw c;p.success("Event resubmitted for review")}else{const{error:c}=await v.from("events").insert({...n,user_id:i.id,city_id:f.city_id,status:"pending"});if(c)throw c;p.success("Event submitted for review")}y("..")}catch(n){p.error(n.message||"Failed to submit event")}finally{b(!1)}}};return u&&E?e.jsxs("div",{className:"max-w-3xl",children:[e.jsx(w,{className:"h-8 w-48 mb-6"}),e.jsx(w,{className:"h-96 w-full"})]}):u&&(t==null?void 0:t.status)==="approved"?e.jsx("div",{className:"max-w-3xl",children:e.jsxs(S,{children:[e.jsx(D,{className:"h-4 w-4"}),e.jsx(k,{children:"This event has been approved and cannot be edited."})]})}):e.jsxs("div",{className:"max-w-3xl space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-display text-2xl font-bold",children:u?"Edit Event":"Submit New Event"}),e.jsx("p",{className:"text-muted-foreground",children:"Submit an event for review"})]}),(t==null?void 0:t.status)==="rejected"&&t.rejection_reason&&e.jsxs(S,{variant:"destructive",children:[e.jsx(D,{className:"h-4 w-4"}),e.jsxs(k,{children:[e.jsx("p",{className:"font-medium",children:"Rejected:"}),e.jsx("p",{children:t.rejection_reason})]})]}),e.jsxs("form",{onSubmit:T,className:"space-y-6",children:[e.jsxs(m,{children:[e.jsx(h,{children:e.jsx(_,{className:"text-lg",children:"Event Details"})}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"title",children:"Title *"}),e.jsx(l,{id:"title",value:a.title,onChange:s=>r({...a,title:s.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"description",children:"Description"}),e.jsx(W,{id:"description",value:a.description,onChange:s=>r({...a,description:s.target.value}),rows:4})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Event Image"}),e.jsx(l,{placeholder:"Image URL",value:a.image_url,onChange:s=>r({...a,image_url:s.target.value})})]})]})]}),e.jsxs(m,{children:[e.jsx(h,{children:e.jsxs(_,{className:"flex items-center gap-2 text-lg",children:[e.jsx(A,{className:"h-5 w-5"}),"Date & Time"]})}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"start_date",children:"Start Date *"}),e.jsx(l,{id:"start_date",type:"date",value:a.start_date,onChange:s=>r({...a,start_date:s.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"end_date",children:"End Date"}),e.jsx(l,{id:"end_date",type:"date",value:a.end_date,onChange:s=>r({...a,end_date:s.target.value})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"start_time",children:"Start Time"}),e.jsx(l,{id:"start_time",type:"time",value:a.start_time,onChange:s=>r({...a,start_time:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"end_time",children:"End Time"}),e.jsx(l,{id:"end_time",type:"time",value:a.end_time,onChange:s=>r({...a,end_time:s.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Recurrence"}),e.jsxs(M,{knownValues:["none","daily","weekly","monthly"],value:a.recurrence_type,onValueChange:s=>r({...a,recurrence_type:s}),children:[e.jsx(K,{children:e.jsx($,{})}
1),e.jsxs(H,{children:[e.jsx(O,{}),e.jsx(j,{value:"none",children:"None"}),e.jsx(j,{value:"daily",children:"Daily"}),e.jsx(j,{value:"weekly",children:"Weekly"}),e.jsx(j,{value:"monthly",children:"Monthly"})]})]})]}),a.recurrence_type==="weekly"&&e.jsx("div",{className:"flex flex-wrap gap-2",children:Y.map(s=>e.jsxs("label",{className:`px-3 py-2 rounded-lg border cursor-pointer ${a.recurrence_days.includes(s.value)?"bg-primary text-primary-foreground":"bg-background"}`,children:[e.jsx(B,{checked:a.recurrence_days.includes(s.value),onCheckedChange:()=>z(s.value),className:"sr-only"}),e.jsx("span",{className:"text-sm font-medium",children:s.label})]},s.value))})]})]}),e.jsxs(m,{children:[e.jsx(h,{children:e.jsxs(_,{className:"flex items-center gap-2 text-lg",children:[e.jsx(R,{className:"h-5 w-5"}),"Location"]})}),e.jsxs(x,{className:"space-y-4",children:[e.jsx(l,{placeholder:"Venue Name",value:a.location_name,onChange:s=>r({...a,location_name:s.target.value})}),e.jsx(l,{placeholder:"Street Address",value:a.street_address,onChange:s=>r({...a,street_address:s.target.value})}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsx(l,{placeholder:"City",value:a.city_address,onChange:s=>r({...a,city_address:s.target.value})}),e.jsx(l,{placeholder:"State",value:a.state_address,onChange:s=>r({...a,state_address:s.target.value})}),e.jsx(l,{placeholder:"ZIP",value:a.zip_address,onChange:s=>r({...a,zip_address:s.target.value})})]})]})]}),e.jsxs(m,{children:[e.jsx(h,{children:e.jsxs(_,{className:"flex items-center gap-2 text-lg",children:[e.jsx(P,{className:"h-5 w-5"}),"Organizer"]})}),e.jsxs(x,{className:"space-y-4",children:[e.jsx(l,{placeholder:"Organizer Name",value:a.organizer_name,onChange:s=>r({...a,organizer_name:s.target.value})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(l,{placeholder:"Phone",value:a.phone,onChange:s=>r({...a,phone:s.target.value})}),e.jsx(l,{placeholder:"Email",type:"email",value:a.email,onChange:s=>r({...a,email:s.target.value})})]})]})]}),e.jsxs(m,{children:[e.jsx(h,{children:e.jsxs(_,{className:"flex items-center gap-2 text-lg",children:[e.jsx(J,{className:"h-5 w-5"}),"Details"]})}),e.jsxs(x,{className:"space-y-4",children:[e.jsx(l,{placeholder:"Price Info (e.g., Free, $20)",value:a.price_info,onChange:s=>r({...a,price_info:s.target.value})}),e.jsx(l,{placeholder:"Ticket URL",value:a.ticket_url,onChange:s=>r({...a,ticket_url:s.target.value})}),e.jsx(l,{placeholder:"Event Website",value:a.event_url,onChange:s=>r({...a,event_url:s.target.value})})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(C,{type:"button",variant:"outline",onClick:()=>y(".."),children:"Cancel"}),e.jsxs(C,{type:"submit",disabled:N,children:[N?e.jsx(V,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Q,{className:"h-4 w-4 mr-2"}),u?"Resubmit":"Submit Event"]})]})]})]})}export{ue 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.