chore: update reservation platform to newest codebase

This commit is contained in:
TOHAACK
2024-05-27 11:49:02 +02:00
parent ea9283e167
commit 3fd586caaf
130 changed files with 9395 additions and 3636 deletions

View File

@@ -1,7 +0,0 @@
import NextAuth from "next-auth";
import { authOptions } from "@/server/auth";
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const handler = NextAuth(authOptions);
export { handler as GET, handler as POST };

View File

@@ -0,0 +1,34 @@
import { db } from "@/server/db";
import { printJobs } from "@/server/db/schema";
import { eq } from "drizzle-orm";
interface RemainingTimeRouteProps {
params: {
jobId: string;
};
}
export async function GET(request: Request, { params }: RemainingTimeRouteProps) {
// Get the job details
const jobDetails = await db.query.printJobs.findFirst({
where: eq(printJobs.id, params.jobId),
});
// Check if the job exists
if (!jobDetails) {
return Response.json({
id: params.jobId,
error: "Job not found",
});
}
// Calculate the remaining time
const startAt = new Date(jobDetails.startAt).getTime();
const endAt = startAt + jobDetails.durationInMinutes * 60 * 1000;
const remainingTime = Math.max(0, endAt - Date.now());
// Return the remaining time
return Response.json({
id: params.jobId,
remainingTime,
});
}

View File

@@ -0,0 +1,7 @@
import { getPrinters } from "@/server/actions/printers";
export async function GET() {
const printers = await getPrinters();
return Response.json(printers);
}