|
1 | 1 | 'use client'; |
2 | 2 |
|
3 | | -import { use, useEffect } from 'react'; |
| 3 | +import { use, useEffect, useState } from 'react'; |
4 | 4 | import { useRouter } from 'next/navigation'; |
5 | 5 | import { useHackathonData } from '@/lib/providers/hackathonProvider'; |
6 | 6 | import { useAuthStatus } from '@/hooks/use-auth'; |
@@ -70,15 +70,33 @@ export default function SubmitProjectPage({ |
70 | 70 | router.push(`/hackathons/${hackathonSlug}?tab=submission`); |
71 | 71 | }; |
72 | 72 |
|
73 | | - if ( |
74 | | - isLoading || |
75 | | - hackathonLoading || |
76 | | - isLoadingMySubmission || |
77 | | - !currentHackathon |
78 | | - ) { |
| 73 | + const [hasInitialLoaded, setHasInitialLoaded] = useState(false); |
| 74 | + |
| 75 | + useEffect(() => { |
| 76 | + if (!isLoading && !hackathonLoading && !isLoadingMySubmission) { |
| 77 | + setHasInitialLoaded(true); |
| 78 | + } |
| 79 | + }, [isLoading, hackathonLoading, isLoadingMySubmission]); |
| 80 | + |
| 81 | + if (!hasInitialLoaded) { |
79 | 82 | return <LoadingScreen />; |
80 | 83 | } |
81 | 84 |
|
| 85 | + if (!currentHackathon) { |
| 86 | + return ( |
| 87 | + <div className='flex min-h-screen flex-col items-center justify-center bg-black px-5 py-5 text-white'> |
| 88 | + <h1 className='mb-4 text-2xl font-bold'>Hackathon Not Found</h1> |
| 89 | + <Button |
| 90 | + onClick={handleClose} |
| 91 | + variant='ghost' |
| 92 | + className='text-gray-400 hover:text-white' |
| 93 | + > |
| 94 | + <ArrowLeft className='mr-2 h-4 w-4' /> |
| 95 | + Go Back |
| 96 | + </Button> |
| 97 | + </div> |
| 98 | + ); |
| 99 | + } |
82 | 100 | return ( |
83 | 101 | <div className='min-h-screen bg-black px-5 py-5 text-white md:px-[50px] lg:px-[100px]'> |
84 | 102 | <div className='mx-auto max-w-[1200px] pb-10'> |
@@ -107,6 +125,8 @@ export default function SubmitProjectPage({ |
107 | 125 | introduction: mySubmission.introduction, |
108 | 126 | links: mySubmission.links, |
109 | 127 | participationType: (mySubmission as any).participationType, |
| 128 | + teamName: (mySubmission as any).teamName, |
| 129 | + teamMembers: (mySubmission as any).teamMembers, |
110 | 130 | } |
111 | 131 | : undefined |
112 | 132 | } |
|
0 commit comments