Add error toast for missing naddress in course slugs

This commit is contained in:
austinkelsay 2025-04-24 12:18:47 -05:00
parent 4f093b9e2c
commit 06780ffaa5
No known key found for this signature in database
GPG Key ID: 5A763922E5BA08EE

View File

@ -188,14 +188,16 @@ const Course = () => {
const navbarHeight = 60; // Match the height from Navbar component
useEffect(() => {
if (router.isReady) {
if (router.isReady && router.query.slug) {
const { slug } = router.query;
if (slug.includes('naddr')) {
setNAddress(slug);
} else {
console.warn('No naddress found in slug');
showToast('error', 'Error', 'Course identifier not found in URL');
router.push('/courses'); // Redirect to courses page
setTimeout(() => {
router.push('/courses'); // Redirect to courses page
}, 3000);
}
}
}, [router.isReady, router.query.slug, showToast, router]);