PageSourceSearch

https://homegames.lovable.app/assets/EventDetails-De6R0xT4-1743085711271.js

js homegames.lovable.app collected 2026-10-03 05:35:54 UTC 16,837 bytes, 20 lines download raw bytes

1var b=(s,r,a)=>new Promise((d,c)=>{var t=o=>{try{n(a.next(o))}catch(u){c(u)}},i=o=>{try{n(a.throw(o))}catch(u){c(u)}},n=o=>o.done?d(o.value):Promise.resolve(o.value).then(t,i);n((a=a.apply(s,r)).next())});import{c as te,a as B,a4 as X,u as q,s as g,a5 as H,j as e,B as j,D as U,b as G,d as I,e as K,a6 as M,a7 as J,r as f,L as re,a8 as ie,i as ne,a9 as oe,T as le,f as ce,g as z,aa as Q}from"./index-CRpzyGIh-1743085711271.js";import{H as A}from"./Header-BJz6UQp3-1743085711271.js";import{M as de,E as me,a as ue}from"./EventCardContent-BYi97iRj-1743085711271.js";import{C as T}from"./card-CBnp1Sbd-1743085711271.js";import{b as Y,e as E,C as he,T as xe,a as ge,c as D,d as pe}from"./table-DVOAktf6-1743085711271.js";import{B as S}from"./badge-BbMpVt_C-1743085711271.js";import{A as Z,a as fe,b as je}from"./avatar-DYaqzYzx-1743085711271.js";import{C as ve}from"./circle-x-y-pJ0qIw-1743085711271.js";import{C as we}from"./clock-BRVlEpCl-1743085711271.js";import{f as _e,S as ye}from"./format-BSJcw0vT-1743085711271.js";import{T as ee}from"./textarea-Bbr4yWhq-1743085711271.js";import{R as be,a as Ne}from"./switch-9yl5L1fW-1743085711271.js";import{S as se}from"./star-DB7mY9w4-1743085711271.js";import{E as Ce}from"./EditEventModal-igdi2aP1-1743085711271.js";import"./HeaderActions-C5pH9sFd-1743085711271.js";import"./scroll-area-CIOZJ49f-1743085711271.js";import"./chevron-right-CwKLnYMz-1743085711271.js";import"./users-C3G3S4nr-1743085711271.js";import"./chevron-left-CkBaIhFW-1743085711271.js";import"./trophy-Bb-lgE-1-1743085711271.js";import"./heart-BsaCR9ef-1743085711271.js";import"./shield-z_8oCEpA-1743085711271.js";import"./file-check-D3X0-3gR-1743085711271.js";import"./calendar-BunftNcp-1743085711271.js";import"./map-pin-CTAadEpz-1743085711271.js";import"./indian-rupee-CR4RfupB-1743085711271.js";import"./index-zxONP1HF-1743085711271.js";import"./index-DrUzXwf7-1743085711271.js";import"./types-ChdFSoQj-1743085711271.js";import"./loader-circle-7cVqjX3H-1743085711271.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const Re=te("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]),ke=s=>{const{toast:r}=B(),a=X(),{data:d,isLoading:c}=q({queryKey:["bookings",s],queryFn:()=>b(void 0,null,function*(){if(!s)return[];const{data:i,error:n}=yield g.from("game_bookings").select(`
7          *,
8          profile:user_id (
9            first_name,
10            last_name,
11            avatar_url
12          )
13        `).eq("event_id",s).order("created_at",{ascending:!1});if(n)throw console.error("Error fetching bookings:",n),n;return i}),enabled:!!s}),{mutate:t}=H({mutationFn:u=>b(void 0,[u],function*({bookingId:i,status:n,rejectionNotes:o}){const{data:l,error:v}=yield g.rpc("update_booking_status",{booking_id:i,new_status:n,rejection_notes:o});if(v)throw v;return l}),onSuccess:()=>{a.invalidateQueries({queryKey:["bookings",s]}),r({title:"Booking updated",description:"The booking status has been updated successfully."})},onError:i=>{console.error("Error updating booking:",i),r({title:"Error",description:"Failed to update booking status. Please try again.",variant:"destructive"})}});return{bookings:d,isLoading:c,updateBookingStatus:t}},Se=({booking:s,onApprove:r,onReject:a,onCancel:d,onProfileClick:c})=>{var i,n,o,u,l,v,w;const t=_=>{switch(_){case"approved":return e.jsx(S,{className:"bg-green-500",children:"Approved"});case"rejected":return e.jsx(S,{variant:"destructive",children:"Rejected"});case"cancelled":return e.jsx(S,{variant:"destructive",children:"Cancelled"});default:return e.jsx(S,{variant:"secondary",children:"Pending"})}};return e.jsxs(Y,{children:[e.jsx(E,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Z,{className:"h-8 w-8 cursor-pointer",onClick:()=>c(s.user_id),children:[e.jsx(fe,{src:(i=s.profile)==null?void 0:i.avatar_url}),e.jsxs(je,{children:[(o=(n=s.profile)==null?void 0:n.first_name)==null?void 0:o[0],(l=(u=s.profile)==null?void 0:u.last_name)==null?void 0:l[0]]})]}),e.jsxs("span",{className:"cursor-pointer hover:underline",onClick:()=>
13c(s.user_id),children:[(v=s.profile)==null?void 0:v.first_name," ",(w=s.profile)==null?void 0:w.last_name]})]})}),e.jsx(E,{children:_e(new Date(s.created_at),"PP")}),e.jsx(E,{children:t(s.status)}),e.jsxs(E,{children:[s.status==="pending"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(j,{size:"sm",variant:"outline",className:"flex items-center gap-1",onClick:()=>r(s.id),children:[e.jsx(he,{className:"h-4 w-4"}),"Approve"]}),e.jsxs(j,{size:"sm",variant:"outline",className:"flex items-center gap-1",onClick:()=>a(s),children:[e.jsx(ve,{className:"h-4 w-4"}),"Reject"]})]}),s.status==="approved"&&e.jsxs(j,{size:"sm",variant:"outline",className:"flex items-center gap-1",onClick:()=>d(s),children:[e.jsx(Re,{className:"h-4 w-4"}),"Cancel Booking"]}),(s.status==="rejected"||s.status==="cancelled")&&e.jsxs(S,{variant:"outline",className:"flex items-center gap-1",children:[e.jsx(we,{className:"h-4 w-4"}),"Processed"]})]})]})},Ee=({bookings:s,onApprove:r,onReject:a,onCancel:d,onProfileClick:c})=>e.jsxs(xe,{children:[e.jsx(ge,{children:e.jsxs(Y,{children:[e.jsx(D,{children:"User"}),e.jsx(D,{children:"Requested On"}),e.jsx(D,{children:"Status"}),e.jsx(D,{children:"Actions"})]})}),e.jsx(pe,{children:s.map(t=>e.jsx(Se,{booking:t,onApprove:r,onReject:a,onCancel:d,onProfileClick:c},t.id))})]}),De=({isOpen:s,onClose:r,onConfirm:a,notes:d,onNotesChange:c,title:t,description:i,confirmText:n})=>e.jsx(U,{open:s,onOpenChange:r,children:e.jsxs(G,{children:[e.jsxs(I,{children:[e.jsx(K,{children:t}),e.jsx(M,{children:i})]}),e.jsx(ee,{value:d,onChange:o=>c(o.target.value),placeholder:"Enter reason...",className:"min-h-[100px]"}),e.jsxs(J,{children:[e.jsx(j,{variant:"outline",onClick:r,children:"Cancel"}),e.jsx(j,{variant:"destructive",onClick:a,disabled:!d.trim(),children:n})]})]})}),$=[{id:"emergency",label:"Unexpected Personal Emergency"},{id:"low-players",label:"Low Number of Confirmed Players"},{id:"venue",label:"Venue Unavailability"},{id:"technical",label:"Technical or Logistic Issues"},{id:"weather",label:"Weather or External Disruptions"},{id:"health",label:"Health & Safety Concerns"},{id:"personal",label:"Personal Reasons"},{id:"reschedule",label:"Host Decided to Reschedule the Event"}],Te=({isOpen:s,onClose:r,onConfirm:a})=>{const[d,c]=f.useState("");return e.jsx(U,{open:s,onOpenChange:r,children:e.jsxs(G,{className:"max-w-md",children:[e.jsxs(I,{children:[e.jsx(K,{children:"Cancel Booking"}),e.jsx(M,{children:"Please select a reason for canceling this booking. This will be shared with the member."})]}),e.jsx(be,{value:d,onValueChange:c,className:"gap-3",children:$.map(t=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ne,{value:t.id,id:t.id}),e.jsx(re,{htmlFor:t.id,children:t.label})]},t.id))}),e.jsxs(J,{children:[e.jsx(j,{variant:"outline",onClick:r,children:"Back"}),e.jsx(j,{variant:"destructive",onClick:()=>{var i;const t=((i=$.find(n=>n.id===d))==null?void 0:i.label)||"";a(t)},disabled:!d,children:"Confirm Cancellation"})]})]})})},qe=({eventId:s})=>{const{toast:r}=B(),{bookings:a,isLoading:d,updateBookingStatus:c}=ke(s),[t,i]=f.useState(null),[n,o]=f.useState(""),[u,l]=f.useState(!1),[v,w]=f.useState(!1),[_,m]=f.useState(null),[N,C]=f.useState(!1),L=x=>{c({bookingId:x,status:"approved"})},R=x=>{i(x),o(""),l(!0)},P=x=>{i(x),w(!0)},O=()=>{t&&(c({bookingId:t.id,status:"rejected",rejectionNotes:n}),l(!1))},p=x=>b(void 0,null,function*(){if(t&&t.profile)try{yield c({bookingId:t.id,status:"cancelled",rejectionNotes:x});const{error:y}=yield g.functions.invoke("send-cancellation-email",{body:{userEmail:t.profile.email,firstName:t.profile.first_name,reason:x}});y&&(console.error("Error sending cancellation email:",y),r({title:"Warning",description:"Booking cancelled but failed to send notification email.",variant:"destructive"})),w(!1)}catch(y){console.error("Error in cancellation process:",y),r({title:"Error",description:"Failed to cancel booking. Please try again.",variant:"destructive"})}}),h=x=>{m(x),C(!0)};return d?e.jsx("div",{children:"Loading bookings..."}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Event Bookings"}),a&&a.length>0?e.jsx(Ee,{bookings:a,onApprove:L,onReject:R,onCancel:P,onProfileClick:h}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No bookings found for this event."}),e.jsx(De,{isOpen:u,onClose:()=>l(!1),onConfirm:O,notes:n,onNotesChange:o,title:"Reject Booking Request",description:"Please provide a reason for rejecting this booking request.",confirmText:"Confirm Rejection"}),e.jsx(Te,{isOpen:v,onClose:()=>w(!1),onConfirm:p}),e.jsx(de,{userId:_||"",isOpen:N,onClose:()=>C(!1)})]})},V=({isOpen:s,onClose:r,onSubmit:a,title:d,description:c})=>{const[t,i]=f.useState(0),[n,o]=f.useState(""),u=()=>{a(t,n),r(),i(0),o("")};return e.jsx(U,{open:s,onOpenChange:r,children:e.jsxs(G,{className:"sm:max-w-[425px]",children:[e.jsxs(I,{children:[e.jsx(K,{children:d}),e.jsx(M,{children:c})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx("div",{className:"flex justify-center gap-2",children:[1,2,3,4,5].map(l=>e.jsx("button",{onClick:()=>i(l),className:"focus:outline-none",children:e.jsx(se,{className:`w-8 h-8 ${l<=t?"fill-yellow-400 text-yellow-400":"text-gray-300"}`})},l))}),e.jsx(ee,{placeholder:"Leave a comment (optional)",value:n,onChange:l=>o(l.target.value)})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx(j,{variant:"outline",onClick:r,children:"Cancel"}),e.jsx(j,{onClick:u,disabled:t===0,children:"Submit"})]})]})})},W=({ratings:s,type:r})=>s.length?e.jsx("div",{className:"space-y-4",children:s.map(a=>{var d,c,t,i,n,o;return e.jsx(T,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(Z,{className:"h-10 w-10",children:e.jsx("img",{src:r==="user"?(d=a.rater)==null?void 0:d.avatar_url:(c=a.reviewer)==null?void 0:c.avatar_url,alt:"User avatar"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:r==="user"?`${(t=a.rater)==null?void 0:t.first_name} ${(i=a.rater)==null?void 0:i.last_name}`:`${(n=a.reviewer)==null?void 0:n.first_name} ${(o=a.reviewer)==null?void 0:o.last_name}`}),e.jsx("div",{className:"flex items-center gap-1 mt-1",children:Array.from({length:a.rating}).map((u,l)=>e.jsx(se,{className:"w-4 h-4 fill-yellow-400 text-yellow-400"},l))})]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:new Date(a.created_at).toLocaleDateString()})]}),(r==="user"?a.feedback:a.review_text)&&e.jsx("p",{className:"mt-2 text-muted-foreground",children:r==="user"?a.feedback:a.review_text})]})]})},a.id)})}):e.jsx("div",{className:"text-center text-muted-foreground py-4",children:"No ratings yet"}),Be=s=>{const{toast:r}=B(),a=X(),{data:d,isLoading:c}=q({queryKey:["user-ratings",s],queryFn:()=>b(void 0,null,function*(){const{data:u,error:l}=yield g.from("user_ratings").select(`
14          *,
15          rater:rater_id(first_name, last_name, avatar_url),
16          rated:rated_user_id(first_name, last_name, avatar_url)
17        `).eq("event_id",s);if(l)throw l;return u}),enabled:!!s}),{data:t,isLoading:i}=q({queryKey:["game-reviews",s],queryFn:()=>b(void 0,null,function*(){const{data:u,error:l}=yield g.from("game_reviews").select(`
18          *,
19          reviewer:user_id(first_name, last_name, avatar_url)
20        `).eq("event_id",s);if(l)throw l;return u}),enabled:!!s}),{mutate:n}=H({mutationFn:w=>b(void 0,[w],function*({ratedUserId:u,rating:l,feedback:v}){const{data:_,error:m}=yield g.auth.getUser();if(m)throw m;const{data:N,error:C}=yield g.from("user_ratings").insert({rated_user_id:u,rater_id:_.user.id,event_id:s,rating:l,feedback:v}).select().single();if(C)throw C;return N}),onSuccess:()=>{a.invalidateQueries({queryKey:["user-ratings",s]}
20),r({title:"Rating submitted",description:"Thank you for your feedback!"})}}),{mutate:o}=H({mutationFn:v=>b(void 0,[v],function*({rating:u,reviewText:l}){const{data:w,error:_}=yield g.auth.getUser();if(_)throw _;const{data:m,error:N}=yield g.from("game_reviews").insert({event_id:s,user_id:w.user.id,rating:u,review_text:l}).select().single();if(N)throw N;return m}),onSuccess:()=>{a.invalidateQueries({queryKey:["game-reviews",s]}),r({title:"Review submitted",description:"Thank you for reviewing this game!"})}});return{userRatings:d,gameReviews:t,isLoading:c||i,submitUserRating:n,submitGameReview:o}},ms=()=>{const{eventId:s}=ie(),{user:r}=ne(),{toast:a}=B(),[d,c]=f.useState(!1),[t,i]=f.useState(!1),[n,o]=f.useState(!1),{userRatings:u,gameReviews:l,isLoading:v,submitUserRating:w,submitGameReview:_}=Be(s),{data:m,isLoading:N,refetch:C}=q({queryKey:["event",s],queryFn:()=>b(void 0,null,function*(){try{const{data:p,error:h}=yield g.from("events").select("*").eq("id",s).single();if(h)throw h;if(p.event_name==="Pizza & Poker Night"){const{error:x}=yield g.from("events").update({eventimage_url:"/lovable-uploads/cc5152b1-a8ea-4348-a5d3-4c12b426ebb7.png"}).eq("id",s);if(x)throw x;const{data:y,error:k}=yield g.from("events").select("*").eq("id",s).single();if(k)throw k;return y}return p}catch(p){throw console.error("Error fetching/updating event:",p),p}})}),L=(p,h)=>b(void 0,null,function*(){try{let x="",y="";if(h.gaming_space_id){const{data:F,error:ae}=yield g.from("gaming_spaces").select("name, description, property_type").eq("id",h.gaming_space_id).single();!ae&&F&&(y="Bengaluru",x=F.description||F.name||"")}else x=(m==null?void 0:m.locality)||"",y=(m==null?void 0:m.event_city)||"";const{error:k}=yield g.from("events").update({event_name:h.event_name,game_category:h.game_category,event_date:h.event_date,event_start_time:h.event_time,locality:x,event_city:y,event_price:parseFloat(h.event_price),available_seats:parseInt(h.available_seats),host_name:h.host_name,status:h.status,gaming_space_id:h.gaming_space_id}).eq("id",p);if(k)throw k;yield C(),a({title:"Success",description:"Event updated successfully"}),o(!1)}catch(x){console.error("Error updating event:",x),a({title:"Error",description:"Failed to update event. Please try again.",variant:"destructive"})}});if(N||v)return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[e.jsx(A,{}),e.jsx("div",{className:"container mx-auto py-8",children:e.jsx(oe,{})})]});if(!m)return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[e.jsx(A,{}),e.jsx("div",{className:"container mx-auto py-8",children:e.jsx("div",{className:"text-center text-red-600",children:"Event not found"})})]});const R=(r==null?void 0:r.id)===m.host_id;console.log("Is host check:",{userId:r==null?void 0:r.id,hostId:m.host_id,isHost:R});const P=(p,h)=>{w({ratedUserId:m.host_id,rating:p,feedback:h})},O=(p,h)=>{_({rating:p,reviewText:h})};return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[e.jsx(A,{}),e.jsx("div",{className:"container mx-auto py-8",children:e.jsxs("div",{className:"max-w-3xl mx-auto space-y-8",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h1",{className:"text-2xl font-semibold text-gray-900",children:m.event_name}),R&&e.jsxs(j,{variant:"outline",onClick:()=>o(!0),children:[e.jsx(ye,{className:"h-4 w-4 mr-2"}),"Edit Event"]})]}),e.jsxs(T,{className:"overflow-hidden",children:[e.jsx(me,{eventName:m.event_name,gameCategory:m.game_category,eventUrl:m.eventimage_url,isGuestFavorite:m.is_guest_favorite}),e.jsx(ue,{event:m})]}),e.jsx(T,{className:"p-6",children:e.jsx(qe,{eventId:m.id})}),e.jsxs(T,{className:"p-6",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold",children:"Ratings & Reviews"}),e.jsxs("div",{className:"space-x-4",children:[e.jsx(j,{variant:"outline",onClick:()=>c(!0),children:"Rate Host"}),e.jsx(j,{onClick:()=>i(!0),children:"Review Game"})]})]}),e.jsxs(le,{defaultValue:"ratings",className:"w-full",children:[e.jsxs(ce,{className:"grid w-full grid-cols-2 bg-gray-100/80",children:[e.jsx(z,{value:"ratings",children:"Host Ratings"}),e.jsx(z,{value:"reviews",children:"Game Reviews"})]}),e.jsx(Q,{value:"ratings",className:"mt-6",children:e.jsx(W,{ratings:u||[],type:"user"})}),e.jsx(Q,{value:"reviews",className:"mt-6",children:e.jsx(W,{ratings:l||[],type:"game"})})]})]})]})}),e.jsx(V,{isOpen:d,onClose:()=>c(!1),onSubmit:P,title:"Rate the Host",description:"Share your experience with the host"}),e.jsx(V,{isOpen:t,onClose:()=>i(!1),onSubmit:O,title:"Review the Game",description:"How was your gaming experience?"}),R&&e.jsx(Ce,{event:m,isOpen:n,onClose:()=>o(!1),onSave:L})]})};export{ms 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.