Adds complete initial codebase for the RJ Bulk Supplies fuel delivery backoffice: - Authentication pages and protected route layouts - Customer, supplier, fuel purchase, and delivery note management - Custom reporting and customer statement sending tools - Full UI component library and Tailwind styling - Server actions, API routes, and PocketBase integration - Development scripts and project configuration updates - Updated README and package metadata
22 lines
850 B
TypeScript
22 lines
850 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { getAuth } from "@/lib/auth";
|
|
import { getCustomerPriceForDate } from "@/lib/delivery-notes";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
export async function GET(req: NextRequest) {
|
|
const { token } = await getAuth();
|
|
if (!token) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
|
const { searchParams } = req.nextUrl;
|
|
const customer = searchParams.get("customer");
|
|
const date = searchParams.get("date");
|
|
if (!customer || !date) {
|
|
return NextResponse.json({ error: "customer and date required" }, { status: 400 });
|
|
}
|
|
try {
|
|
const result = await getCustomerPriceForDate(customer, date, token);
|
|
return NextResponse.json(result);
|
|
} catch (err: any) {
|
|
return NextResponse.json({ error: err?.message || "Failed" }, { status: 500 });
|
|
}
|
|
}
|