@@ -24,7 +24,8 @@ import {
2424export default function EditEventPage ( ) {
2525 const router = useRouter ( )
2626 const params = useParams ( )
27- const slug = params . slug as string
27+ const companySlug = params . slug as string
28+ const eventSlug = params . eventSlug as string
2829 const { currentCompany, loading : companyLoading } = useCompanyContext ( )
2930 const [ event , setEvent ] = useState < Event | null > ( null )
3031 const [ loading , setLoading ] = useState ( true )
@@ -33,28 +34,29 @@ export default function EditEventPage() {
3334 const fetchEvent = useCallback ( async ( ) => {
3435 try {
3536 setLoading ( true )
36- const response = await fetch ( `/api/events/${ slug } ` )
37+ const response = await fetch ( `/api/events/${ eventSlug } ` )
3738
3839 if ( ! response . ok ) {
3940 throw new Error ( 'Failed to fetch event' )
4041 }
4142
4243 const data = await response . json ( )
43- setEvent ( data . event )
44+ // API returns event directly, not wrapped in { event: ... }
45+ setEvent ( data )
4446 } catch ( error ) {
4547 console . error ( 'Error fetching event:' , error )
4648 toast . error ( 'Failed to load event' )
47- router . push ( ' /dashboard/company/events' )
49+ router . push ( ` /dashboard/company/${ companySlug } / events` )
4850 } finally {
4951 setLoading ( false )
5052 }
51- } , [ slug , router ] )
53+ } , [ eventSlug , companySlug , router ] )
5254
5355 useEffect ( ( ) => {
54- if ( slug ) {
56+ if ( eventSlug ) {
5557 fetchEvent ( )
5658 }
57- } , [ slug , fetchEvent ] )
59+ } , [ eventSlug , fetchEvent ] )
5860
5961 const handleSuccess = ( updatedEvent : Event ) => {
6062 setEvent ( updatedEvent )
@@ -64,7 +66,7 @@ export default function EditEventPage() {
6466 const handleDelete = async ( ) => {
6567 try {
6668 setDeleting ( true )
67- const response = await fetch ( `/api/events/${ slug } ` , {
69+ const response = await fetch ( `/api/events/${ eventSlug } ` , {
6870 method : 'DELETE' ,
6971 } )
7072
@@ -73,7 +75,7 @@ export default function EditEventPage() {
7375 }
7476
7577 toast . success ( 'Event deleted successfully!' )
76- router . push ( ' /dashboard/company/events' )
78+ router . push ( ` /dashboard/company/${ companySlug } / events` )
7779 } catch ( error ) {
7880 console . error ( 'Error deleting event:' , error )
7981 toast . error ( 'Failed to delete event' )
@@ -98,7 +100,7 @@ export default function EditEventPage() {
98100 < p className = "text-muted-foreground mb-4" >
99101 The event you're looking for doesn't exist or you don't have access to it.
100102 </ p >
101- < Link href = " /dashboard/company/events" >
103+ < Link href = { ` /dashboard/company/${ companySlug } / events` } >
102104 < Button > Back to Events</ Button >
103105 </ Link >
104106 </ div >
@@ -111,7 +113,7 @@ export default function EditEventPage() {
111113 { /* Header */ }
112114 < div className = "flex items-center justify-between" >
113115 < div className = "flex items-center gap-4" >
114- < Link href = " /dashboard/company/events" >
116+ < Link href = { ` /dashboard/company/${ companySlug } / events` } >
115117 < Button variant = "outline" size = "sm" >
116118 < ArrowLeft className = "h-4 w-4 mr-2" />
117119 Back to Events
0 commit comments