25 lines
842 B
TypeScript
25 lines
842 B
TypeScript
import { getSquareClient } from "@/lib/square-client"
|
|
|
|
export async function GET(
|
|
request: Request,
|
|
{ params }: { params: { imageId: string } }
|
|
) {
|
|
try {
|
|
const client = await getSquareClient()
|
|
const catalogApi = client.catalogApi
|
|
const response = await catalogApi.retrieveCatalogObject(params.imageId, true)
|
|
|
|
if (response.result.object?.type === "IMAGE" && response.result.object.imageData?.url) {
|
|
// Redirect to the actual Square image URL
|
|
return Response.redirect(response.result.object.imageData.url, 302)
|
|
}
|
|
|
|
// Fallback to placeholder
|
|
return Response.redirect("/placeholder.svg?height=400&width=400&text=No+Image", 302)
|
|
|
|
} catch (error) {
|
|
console.error("Square image retrieval error:", error)
|
|
return Response.redirect("/placeholder.svg?height=400&width=400&text=Error", 302)
|
|
}
|
|
}
|