fix: get test works without a provided date
This commit is contained in:
parent
fe914efa41
commit
b9b0c079d8
|
@ -5,6 +5,8 @@ export async function GET(req: NextRequest){
|
|||
const date = req.nextUrl.searchParams.get("date");
|
||||
const key = req.nextUrl.searchParams.get("key");
|
||||
|
||||
const usableDate = new Date(date || new Date());
|
||||
|
||||
const test = await prisma.test.findFirst({
|
||||
select: {
|
||||
id: true,
|
||||
|
@ -31,7 +33,7 @@ export async function GET(req: NextRequest){
|
|||
}
|
||||
},
|
||||
where: {
|
||||
testOn: (date ? new Date(date) : new Date())
|
||||
testOn: new Date(usableDate.getFullYear() + "-" + (usableDate.getMonth() + 1) + "-" + (usableDate.getDate().toString().length === 1 ? "0" + usableDate.getDate() : usableDate.getDate()))
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue