Adds the complete Next.js website including i18n routing, house and apartment pages, Beds24 v2 integration for live availability/pricing, Stripe checkout, contact forms, Docker setup and deployment docs. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { getEffectiveMinStay } from "@/src/lib/beds24";
|
|
import { getApartmentBySlug, bookingConfig } from "@/src/config/apartments";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
export async function GET(request: NextRequest) {
|
|
try {
|
|
const { searchParams } = new URL(request.url);
|
|
const apartmentSlug = searchParams.get("apartmentSlug");
|
|
const arrival = searchParams.get("arrival");
|
|
|
|
if (!apartmentSlug || !arrival) {
|
|
return NextResponse.json(
|
|
{ error: "Missing required parameters: apartmentSlug, arrival" },
|
|
{ status: 400 }
|
|
);
|
|
}
|
|
|
|
const apartment = getApartmentBySlug(apartmentSlug);
|
|
if (!apartment) {
|
|
return NextResponse.json(
|
|
{ error: "Apartment not found" },
|
|
{ status: 404 }
|
|
);
|
|
}
|
|
|
|
const minStayNights = await getEffectiveMinStay(
|
|
apartment.houseId,
|
|
apartment.beds24PropertyId,
|
|
apartment.beds24RoomId,
|
|
arrival,
|
|
bookingConfig.minStayNights
|
|
);
|
|
|
|
return NextResponse.json({ apartmentSlug, arrival, minStayNights });
|
|
} catch (error) {
|
|
console.error("Min-stay API error:", error);
|
|
return NextResponse.json(
|
|
{ error: "Failed to determine minimum stay" },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|