@@ -15,13 +15,19 @@ import { useRouter } from "next/navigation";
1515import type { ClientEventInput } from "src/types" ;
1616import { useBetaMode } from "src/hooks/useBetaMode" ;
1717
18- const Edit = ( { params } : { params : { eventHash : string } } ) => {
18+ const Edit = ( { params } : { params : Promise < { eventHash : string } > } ) => {
1919 const { push } = useRouter ( ) ;
20- const { eventHash } = params ;
20+ const [ eventHash , setEventHash ] = useState < string | null > ( null ) ;
21+
22+ useEffect ( ( ) => {
23+ params . then ( ( { eventHash } ) => {
24+ setEventHash ( eventHash ) ;
25+ } ) ;
26+ } , [ params ] ) ;
2127 // Set dontFetch explicitly to true for edit pages to prevent refetching and form resets
2228 // Added staleTime: Infinity in useEvent hook to prevent refetching when tab regains focus
2329 const { data, isLoading : isEventLoading } = useEvent ( {
24- hash : eventHash ,
30+ hash : eventHash || "" ,
2531 dontFetch : true , // Ensure we don't poll for updates on edit pages
2632 } ) ;
2733 const { deleteEvent, isDeleting } = useDeleteEvent ( ) ;
@@ -57,7 +63,7 @@ const Edit = ({ params }: { params: { eventHash: string } }) => {
5763 // Also ensure other dependencies are correct
5864 } , [ user , data , isBetaMode , setInvalidRequest ] ) ;
5965
60- if ( isEventLoading || ! user ) {
66+ if ( isEventLoading || ! user || ! eventHash ) {
6167 return (
6268 < Main >
6369 < div className = "flex flex-col items-center justify-center" >
@@ -89,6 +95,7 @@ const Edit = ({ params }: { params: { eventHash: string } }) => {
8995 }
9096
9197 const handleDelete = async ( ) => {
98+ if ( ! eventHash ) return ;
9299 const success = await deleteEvent ( eventHash ) ;
93100 if ( success ) {
94101 // Redirect to home page after successful deletion
0 commit comments