diff --git a/apps/hackathon/src/app/teams/[teamId]/submission/page.tsx b/apps/hackathon/src/app/teams/[teamId]/submission/page.tsx index 6dd829a..17a2e4e 100644 --- a/apps/hackathon/src/app/teams/[teamId]/submission/page.tsx +++ b/apps/hackathon/src/app/teams/[teamId]/submission/page.tsx @@ -60,20 +60,46 @@ const SubmissionViewPage: FC = (): ReactElement => {
{/* Status Banner */} -
-
- -
-

Project Submitted Successfully

-

- Submitted on {submittedDate} -

-

- This submission is now read-only and cannot be edited -

+ {submission.status === 'submitted' ? ( +
+
+ +
+

Project Submitted Successfully

+

+ Submitted on {submittedDate} +

+

+ This submission is now read-only and cannot be edited +

+
-
+ ) : submission.status === 'pending_verification' ? ( +
+
+ +
+

Submission Pending Verification

+

+ Your submission is being processed +

+
+
+
+ ) : ( +
+
+ 📝 +
+

Draft Submission

+

+ This submission is still in draft and has not been finalized +

+
+
+
+ )}
{/* Project Header */} @@ -173,8 +199,18 @@ const SubmissionViewPage: FC = (): ReactElement => {
Status: - - {submission.status === 'submitted' ? '✓ Submitted' : 'Draft'} + + {submission.status === 'submitted' + ? '✓ Submitted' + : submission.status === 'pending_verification' + ? '⏳ Pending Verification' + : '📝 Draft'}
diff --git a/libs/service/src/hooks/teams/index.ts b/libs/service/src/hooks/teams/index.ts index 57626a5..7eb462f 100644 --- a/libs/service/src/hooks/teams/index.ts +++ b/libs/service/src/hooks/teams/index.ts @@ -450,6 +450,8 @@ export const useSubmitProject = (teamId: string) => { return useMutation({ mutationFn: async (data: TSubmitProjectRequest) => { + let submissionId: string; + // First, check if submission exists try { const existingResponse = await hackathonApi.get>( @@ -467,28 +469,41 @@ export const useSubmitProject = (teamId: string) => { demo_url: data.demo_url, video_url: data.video_url, presentation_url: data.presentation_url, + screenshots: data.screenshots, } ); - return { data: response.data.data }; + submissionId = response.data.data.id; + } else { + throw new Error('No existing submission'); } } catch { // No existing submission, create new one + const response = await hackathonApi.post>( + `/submissions/teams/${teamId}`, + { + project_name: data.project_name, + description: data.description, + repository_url: data.repository_url, + demo_url: data.demo_url, + video_url: data.video_url, + presentation_url: data.presentation_url, + screenshots: data.screenshots, + } + ); + submissionId = response.data.data.id; } - // Create new submission - const response = await hackathonApi.post>( - `/submissions/teams/${teamId}`, - { - project_name: data.project_name, - description: data.description, - repository_url: data.repository_url, - demo_url: data.demo_url, - video_url: data.video_url, - presentation_url: data.presentation_url, - } + // Step 2: Submit the project (draft -> pending_verification) + await hackathonApi.post>( + `/submissions/${submissionId}/submit` ); - return { data: response.data.data }; + // Step 3: Confirm the submission (pending_verification -> submitted) + const finalResponse = await hackathonApi.post>( + `/submissions/${submissionId}/confirm` + ); + + return { data: finalResponse.data.data }; }, onSuccess: () => { queryClient.invalidateQueries({ queryKey: teamKeys.submission(teamId) });