diff --git a/apps/hackathon/src/app/teams/[teamId]/submit/page.tsx b/apps/hackathon/src/app/teams/[teamId]/submit/page.tsx index 47572d7..f54ef95 100644 --- a/apps/hackathon/src/app/teams/[teamId]/submit/page.tsx +++ b/apps/hackathon/src/app/teams/[teamId]/submit/page.tsx @@ -9,7 +9,7 @@ import { useSubmitProject, useTeamById, useTeamSubmission, - useUploadFile, + useUploadSubmission, useAuthStore, } from '@imphnen-frontend-service/service'; import { zodResolver } from '@hookform/resolvers/zod'; @@ -67,7 +67,7 @@ const SubmitProjectPage: FC = (): ReactElement => { const { data: submissionData } = useTeamSubmission(teamId || '', !!teamId); const { mutateAsync: submitProject, isPending: isSubmitting } = useSubmitProject(teamId || ''); - const { mutateAsync: uploadFile, isPending: isUploading } = useUploadFile(); + const { mutateAsync: uploadFile, isPending: isUploading } = useUploadSubmission(); const team = teamData?.data; const currentUserId = session?.user?.id; diff --git a/libs/service/src/hooks/upload/index.ts b/libs/service/src/hooks/upload/index.ts index e44fde1..1811567 100644 --- a/libs/service/src/hooks/upload/index.ts +++ b/libs/service/src/hooks/upload/index.ts @@ -14,6 +14,9 @@ export const useUploadFile = () => { mutationKey: ['upload-file'], mutationFn: async (file: File) => { if (!session?.user?.id) throw new Error('You must be logged in to upload files'); + const allowedTypes = ['image/jpeg', 'image/jpg', 'image/png', 'image/webp', 'image/gif']; + if (!allowedTypes.includes(file.type)) throw new Error('Invalid file type. Allowed: JPEG, PNG, WebP, GIF'); + if (file.size > 5 * 1024 * 1024) throw new Error('File too large. Maximum size: 5MB'); const data = await uploadHackathonTeamFile(file); return { data }; }, @@ -28,7 +31,7 @@ export const useUploadAvatar = () => { if (!session?.user?.id) throw new Error('You must be logged in to upload avatar'); const allowedTypes = ['image/jpeg', 'image/jpg', 'image/png', 'image/webp', 'image/gif']; if (!allowedTypes.includes(file.type)) throw new Error('Invalid file type. Allowed: JPEG, PNG, WebP, GIF'); - if (file.size > 5 * 1024 * 1024) throw new Error('File too large. Maximum size: 5MB'); + if (file.size > 2 * 1024 * 1024) throw new Error('File too large. Maximum size: 2MB'); const data = await uploadHackathonAvatar(file); return { data }; },