29 lines
973 B
TypeScript
29 lines
973 B
TypeScript
import { NextRequest, NextResponse } from 'next/server';
|
|
import { query } from '@/lib/db';
|
|
|
|
export const dynamic = 'force-dynamic';
|
|
|
|
export async function GET(req: NextRequest, { params }: { params: { id: string } }) {
|
|
try {
|
|
const { id } = params;
|
|
const res = await query(
|
|
`SELECT
|
|
id,
|
|
price_numeric::float AS price,
|
|
genius_price_numeric::float AS genius_price,
|
|
price_per_night::float AS price_per_night,
|
|
price_per_person::float AS price_per_person,
|
|
nights,
|
|
persons,
|
|
tracked_at AS created_at
|
|
FROM hotel_price_history
|
|
WHERE hotel_id::text = $1::text
|
|
ORDER BY tracked_at ASC`,
|
|
[id]
|
|
);
|
|
return NextResponse.json({ success: true, prices: res.rows });
|
|
} catch (error: any) {
|
|
console.error('Fehler beim Laden der Preishistorie:', error.message);
|
|
return NextResponse.json({ success: false, error: error.message, prices: [] }, { status: 500 });
|
|
}
|
|
} |