diff --git a/src/app/(home)/admin/releases/releases-client.tsx b/src/app/(home)/admin/releases/releases-client.tsx index 5f6db7c..337f7e6 100644 --- a/src/app/(home)/admin/releases/releases-client.tsx +++ b/src/app/(home)/admin/releases/releases-client.tsx @@ -94,7 +94,6 @@ export function ReleasesClient() { // Fetch branches from the database const [branches] = api.branches.getBranches.useSuspenseQuery() - console.log(branches) // Handle file upload const [editIsUploading, setEditIsUploading] = useState(false) @@ -104,6 +103,9 @@ export function ReleasesClient() { if (files.length === 0) return const file = files[0] + if (!file) { + return + } if (!file.name.endsWith('.zip')) { toast.error('Only zip files are allowed') return @@ -119,6 +121,9 @@ export function ReleasesClient() { try { const formData = new FormData() + if (!file) { + return + } formData.append('file', file) const response = await fetch('/api/upload', { @@ -544,7 +549,7 @@ export function ReleasesClient() { {editIsUploading ? (
-
+
) : ( diff --git a/src/app/api/upload/route.ts b/src/app/api/upload/route.ts index da6176f..2cc33cd 100644 --- a/src/app/api/upload/route.ts +++ b/src/app/api/upload/route.ts @@ -1,16 +1,13 @@ import { auth } from '@/server/auth' import { uploadFile } from '@/server/minio' -import { NextRequest, NextResponse } from 'next/server' +import { type NextRequest, NextResponse } from 'next/server' export async function POST(req: NextRequest) { try { // Check if user is authenticated and is an admin const session = await auth() if (!session || session.user.role !== 'admin') { - return NextResponse.json( - { error: 'Unauthorized' }, - { status: 401 } - ) + return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }) } // Parse the multipart form data @@ -18,10 +15,7 @@ export async function POST(req: NextRequest) { const file = formData.get('file') as File | null if (!file) { - return NextResponse.json( - { error: 'No file provided' }, - { status: 400 } - ) + return NextResponse.json({ error: 'No file provided' }, { status: 400 }) } // Check if the file is a zip file @@ -47,4 +41,4 @@ export async function POST(req: NextRequest) { { status: 500 } ) } -} \ No newline at end of file +}