Some checks failed
CI / build-and-test (pull_request) Has been cancelled
### 1. __artists-grid.tsx__ (Main Artist Browsing)
- Uses hook from
- Fetches from endpoint
- Includes loading states, error handling, and filtering
- __Impact:__ Primary artist browsing experience now fully API-driven
### 2. __artist-portfolio.tsx__ (Individual Artist Pages)
- Uses hook
- Fetches from endpoint
- Fixed all TypeScript errors (changed image ID from number to string)
- Added loading/error states
- __Impact:__ Artist detail pages now fully API-driven
### 3. __booking-form.tsx__ (Artist Selection Dropdown)
- Uses hook for artist selection
- Updated to use API data structure ( array, , etc.)
- Added loading state for dropdown
- __Impact:__ Booking flow now uses real artist data
## ⚠️ REMAINING (Decorative/Marketing Components)
Two complex components still use hardcoded :
### 4. __artists-section.tsx__ (Homepage Hero - 348 lines)
- Homepage marketing section with complex parallax scrolling
- Uses hardcoded artist data for visual cards
- __Non-blocking:__ This is a decorative homepage element
### 5. __artists-page-section.tsx__ (Artists Page Section - 413 lines)
- Full-page artists showcase with parallax effects
- Uses hardcoded artist data for visual layout
- __Non-blocking:__ Alternative to artists-grid.tsx (which IS using API)
##
83 lines
2.0 KiB
TypeScript
83 lines
2.0 KiB
TypeScript
import { NextRequest, NextResponse } from "next/server"
|
|
import { requireArtistAuth } from "@/lib/auth"
|
|
import { addPortfolioImage } from "@/lib/db"
|
|
import { uploadToR2 } from "@/lib/r2-upload"
|
|
|
|
export const dynamic = "force-dynamic"
|
|
|
|
// POST /api/portfolio - Upload a new portfolio image
|
|
export async function POST(
|
|
request: NextRequest,
|
|
{ params }: { params?: any } = {},
|
|
context?: any
|
|
) {
|
|
try {
|
|
// Require artist authentication
|
|
const { artist } = await requireArtistAuth()
|
|
|
|
// Parse form data
|
|
const formData = await request.formData()
|
|
const file = formData.get("file") as File
|
|
const caption = formData.get("caption") as string
|
|
const tagsString = formData.get("tags") as string
|
|
const isPublic = formData.get("isPublic") === "true"
|
|
|
|
if (!file) {
|
|
return NextResponse.json(
|
|
{ error: "No file provided" },
|
|
{ status: 400 }
|
|
)
|
|
}
|
|
|
|
// Validate file type
|
|
if (!file.type.startsWith("image/")) {
|
|
return NextResponse.json(
|
|
{ error: "File must be an image" },
|
|
{ status: 400 }
|
|
)
|
|
}
|
|
|
|
// Upload to R2
|
|
const imageUrl = await uploadToR2(file, `portfolio/${artist.id}`, context?.env)
|
|
|
|
// Parse tags
|
|
let tags: string[] = []
|
|
try {
|
|
tags = tagsString ? JSON.parse(tagsString) : []
|
|
} catch (e) {
|
|
tags = []
|
|
}
|
|
|
|
// Add to database
|
|
const portfolioImage = await addPortfolioImage(
|
|
artist.id,
|
|
{
|
|
url: imageUrl,
|
|
caption: caption || null,
|
|
tags,
|
|
orderIndex: 0,
|
|
isPublic
|
|
},
|
|
context?.env
|
|
)
|
|
|
|
return NextResponse.json(portfolioImage, { status: 201 })
|
|
} catch (error) {
|
|
console.error("Error uploading portfolio image:", error)
|
|
|
|
if (error instanceof Error) {
|
|
if (error.message.includes("Artist authentication required")) {
|
|
return NextResponse.json(
|
|
{ error: "Artist authentication required" },
|
|
{ status: 401 }
|
|
)
|
|
}
|
|
}
|
|
|
|
return NextResponse.json(
|
|
{ error: "Failed to upload image" },
|
|
{ status: 500 }
|
|
)
|
|
}
|
|
}
|