updated client-frontend additions

This commit is contained in:
2025-05-06 17:48:13 +03:00
parent e0ae1ee80a
commit bc43471259
140 changed files with 4320 additions and 1117 deletions

View File

@@ -0,0 +1,41 @@
import { z } from "zod";
import { loginSelectOccupant } from "@/apicalls/login/login";
import { NextResponse } from "next/server";
const loginSchemaOccupant = z.object({
build_living_space_uu_id: z.string(),
});
export async function POST(req: Request): Promise<NextResponse> {
try {
const headers = req.headers;
console.log("headers", Object.entries(headers));
const body = await req.json();
const dataValidated = {
build_living_space_uu_id: body.build_living_space_uu_id,
};
const validatedLoginBody = loginSchemaOccupant.safeParse(body);
if (!validatedLoginBody.success) {
return NextResponse.json({
status: 422,
message: validatedLoginBody.error.message,
});
}
const userLogin = await loginSelectOccupant(dataValidated);
if (userLogin.status === 200 || userLogin.status === 202) {
return NextResponse.json({
status: 200,
message: "Selection successfully completed",
data: userLogin.data,
});
} else {
return NextResponse.json({
status: userLogin.status,
message: userLogin.message,
});
}
} catch (error) {
return NextResponse.json({ status: 401, message: "Invalid credentials" });
}
}