fix submission status

This commit is contained in:
Maulana Sodiqin
2025-11-30 22:55:52 +07:00
parent 0c646ceb85
commit 417ff3390b
2 changed files with 78 additions and 27 deletions
@@ -60,6 +60,7 @@ const SubmissionViewPage: FC = (): ReactElement => {
<div className="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 py-8"> <div className="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
{/* Status Banner */} {/* Status Banner */}
{submission.status === 'submitted' ? (
<div className="bg-green-50 dark:bg-green-900/20 border border-green-500 rounded-lg p-6 mb-6"> <div className="bg-green-50 dark:bg-green-900/20 border border-green-500 rounded-lg p-6 mb-6">
<div className="flex items-center space-x-3"> <div className="flex items-center space-x-3">
<span className="text-4xl">✅</span> <span className="text-4xl">✅</span>
@@ -74,6 +75,31 @@ const SubmissionViewPage: FC = (): ReactElement => {
</div> </div>
</div> </div>
</div> </div>
) : submission.status === 'pending_verification' ? (
<div className="bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-500 rounded-lg p-6 mb-6">
<div className="flex items-center space-x-3">
<span className="text-4xl">⏳</span>
<div>
<h3 className="font-bold text-yellow-900 dark:text-yellow-100 text-lg">Submission Pending Verification</h3>
<p className="text-yellow-700 dark:text-yellow-300 text-sm">
Your submission is being processed
</p>
</div>
</div>
</div>
) : (
<div className="bg-orange-50 dark:bg-orange-900/20 border border-orange-500 rounded-lg p-6 mb-6">
<div className="flex items-center space-x-3">
<span className="text-4xl">📝</span>
<div>
<h3 className="font-bold text-orange-900 dark:text-orange-100 text-lg">Draft Submission</h3>
<p className="text-orange-700 dark:text-orange-300 text-sm">
This submission is still in draft and has not been finalized
</p>
</div>
</div>
</div>
)}
<div className="bg-white dark:bg-neutral-900 rounded-lg shadow-md dark:shadow-neutral-950/50 overflow-hidden"> <div className="bg-white dark:bg-neutral-900 rounded-lg shadow-md dark:shadow-neutral-950/50 overflow-hidden">
{/* Project Header */} {/* Project Header */}
@@ -173,8 +199,18 @@ const SubmissionViewPage: FC = (): ReactElement => {
<div className="grid gap-2 text-sm"> <div className="grid gap-2 text-sm">
<div className="flex justify-between"> <div className="flex justify-between">
<span className="text-gray-600 dark:text-neutral-400">Status:</span> <span className="text-gray-600 dark:text-neutral-400">Status:</span>
<span className="font-medium text-green-600 dark:text-green-400"> <span className={`font-medium ${
{submission.status === 'submitted' ? ' Submitted' : 'Draft'} submission.status === 'submitted'
? 'text-green-600 dark:text-green-400'
: submission.status === 'pending_verification'
? 'text-yellow-600 dark:text-yellow-400'
: 'text-orange-600 dark:text-orange-400'
}`}>
{submission.status === 'submitted'
? ' Submitted'
: submission.status === 'pending_verification'
? ' Pending Verification'
: '📝 Draft'}
</span> </span>
</div> </div>
<div className="flex justify-between"> <div className="flex justify-between">
+20 -5
View File
@@ -450,6 +450,8 @@ export const useSubmitProject = (teamId: string) => {
return useMutation({ return useMutation({
mutationFn: async (data: TSubmitProjectRequest) => { mutationFn: async (data: TSubmitProjectRequest) => {
let submissionId: string;
// First, check if submission exists // First, check if submission exists
try { try {
const existingResponse = await hackathonApi.get<HackathonApiResponse<Submission | null>>( const existingResponse = await hackathonApi.get<HackathonApiResponse<Submission | null>>(
@@ -467,15 +469,15 @@ export const useSubmitProject = (teamId: string) => {
demo_url: data.demo_url, demo_url: data.demo_url,
video_url: data.video_url, video_url: data.video_url,
presentation_url: data.presentation_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 { } catch {
// No existing submission, create new one // No existing submission, create new one
}
// Create new submission
const response = await hackathonApi.post<HackathonApiResponse<Submission>>( const response = await hackathonApi.post<HackathonApiResponse<Submission>>(
`/submissions/teams/${teamId}`, `/submissions/teams/${teamId}`,
{ {
@@ -485,10 +487,23 @@ export const useSubmitProject = (teamId: string) => {
demo_url: data.demo_url, demo_url: data.demo_url,
video_url: data.video_url, video_url: data.video_url,
presentation_url: data.presentation_url, presentation_url: data.presentation_url,
screenshots: data.screenshots,
} }
); );
submissionId = response.data.data.id;
}
return { data: response.data.data }; // Step 2: Submit the project (draft -> pending_verification)
await hackathonApi.post<HackathonApiResponse<Submission>>(
`/submissions/${submissionId}/submit`
);
// Step 3: Confirm the submission (pending_verification -> submitted)
const finalResponse = await hackathonApi.post<HackathonApiResponse<Submission>>(
`/submissions/${submissionId}/confirm`
);
return { data: finalResponse.data.data };
}, },
onSuccess: () => { onSuccess: () => {
queryClient.invalidateQueries({ queryKey: teamKeys.submission(teamId) }); queryClient.invalidateQueries({ queryKey: teamKeys.submission(teamId) });