86 lines
2.3 KiB
TypeScript
86 lines
2.3 KiB
TypeScript
import { NextResponse } from "next/server";
|
|
import { FAKARAVA_SPOTS } from "@/lib/data/fakarava-spots";
|
|
|
|
export interface Place {
|
|
id: string;
|
|
name: string;
|
|
category: string;
|
|
description: string;
|
|
image: string;
|
|
location: {
|
|
lat: number;
|
|
lng: number;
|
|
address: string;
|
|
};
|
|
type?: string;
|
|
keywords?: string[];
|
|
contact?: string;
|
|
gmapLink?: string;
|
|
conseil?: string;
|
|
horaires?: string;
|
|
}
|
|
|
|
// Coordonnées approximatives de Fakarava (Rotoava)
|
|
const FAKARAVA_CENTER = {
|
|
lat: -16.3167,
|
|
lng: -145.6167,
|
|
};
|
|
|
|
// Convertir les spots de Fakarava en format Place
|
|
const convertFakaravaSpots = (): Place[] => {
|
|
return FAKARAVA_SPOTS.map((spot, index) => {
|
|
// Mapper la catégorie "Restauration" vers "restaurants"
|
|
const categoryMap: Record<string, string> = {
|
|
"Restauration": "restaurants",
|
|
"Plages": "plages",
|
|
"Epiceries": "epiceries",
|
|
"Activités": "activites",
|
|
};
|
|
|
|
// Déterminer l'image par défaut selon la catégorie
|
|
const getDefaultImage = (category: string) => {
|
|
if (category === "plages") return "/placeholder-beach.jpg";
|
|
if (category === "epiceries") return "/placeholder-store.jpg";
|
|
return "/placeholder-restaurant.jpg";
|
|
};
|
|
|
|
return {
|
|
id: `fakarava-${index + 1}`,
|
|
name: spot.name,
|
|
category: categoryMap[spot.category] || spot.category.toLowerCase(),
|
|
type: spot.type,
|
|
description: spot.description,
|
|
keywords: spot.keywords,
|
|
contact: spot.contact,
|
|
conseil: spot.conseil,
|
|
horaires: spot.horaires,
|
|
image: getDefaultImage(categoryMap[spot.category] || spot.category.toLowerCase()),
|
|
location: {
|
|
// Coordonnées approximatives basées sur le PK
|
|
lat: FAKARAVA_CENTER.lat + (index * 0.01),
|
|
lng: FAKARAVA_CENTER.lng + (index * 0.01),
|
|
address: spot.location,
|
|
},
|
|
gmapLink: spot.gmapLink,
|
|
};
|
|
});
|
|
};
|
|
|
|
const places: Place[] = [
|
|
...convertFakaravaSpots(),
|
|
// Ajoutez ici d'autres lieux spécifiques à Fakarava
|
|
];
|
|
|
|
export async function GET(request: Request) {
|
|
const { searchParams } = new URL(request.url);
|
|
const category = searchParams.get("category");
|
|
|
|
let filteredPlaces = places;
|
|
if (category && category !== "all") {
|
|
filteredPlaces = places.filter((place) => place.category === category);
|
|
}
|
|
|
|
return NextResponse.json(filteredPlaces);
|
|
}
|
|
|