diff --git a/src/components/home/Events.tsx b/src/components/home/Events.tsx index ad16ea7..a8aa9e2 100644 --- a/src/components/home/Events.tsx +++ b/src/components/home/Events.tsx @@ -18,6 +18,8 @@ export default function Events(props: Props): React.ReactNode { const { isLoading } = props const { t } = useTranslation() + const eventId: string = 'mC8cCmWH5Ws8IZQy' + return ( <> - + {t('404.not-found')} diff --git a/src/pages/events/[id]/index.tsx b/src/pages/events/[id]/index.tsx index e4ac900..1d75e31 100644 --- a/src/pages/events/[id]/index.tsx +++ b/src/pages/events/[id]/index.tsx @@ -49,7 +49,8 @@ function Event(): JSX.Element { const [owner, setOwner] = useState(undefined) const router = useRouter() // TODO: generate nanoId - const slug: string | string[] | undefined = router.query?.id + const splitedPath: string[] = router.asPath.split('/') + const id = splitedPath[splitedPath.length - 1] const { t } = useTranslation() const toast = useToast() @@ -180,7 +181,7 @@ function Event(): JSX.Element { } const fetchEventInformation = async () => { - setTimeout(async () => { + try { const rpcProvider: ethers.providers.JsonRpcProvider = new ethers.providers.JsonRpcProvider(PROVIDER) @@ -190,8 +191,7 @@ function Event(): JSX.Element { rpcProvider ) as MeetdAppFactory - const eventId: string = 'mC8cCmWH5Ws8IZQy' - const bytesEventId = ethers.utils.toUtf8Bytes(eventId) + const bytesEventId = ethers.utils.toUtf8Bytes(id as string) const hashBytes32EventId = ethers.utils.keccak256(bytesEventId) const eventContractAdress: string = @@ -228,7 +228,9 @@ function Event(): JSX.Element { setMeetdAppEventContract(eventContract) setIsLoading(false) - }, 1000) + } catch (error) { + router.push('/404') + } } useEffect(() => {