Refactor data fields in dashboard page
This commit is contained in:
parent
11051d85e6
commit
8d6c74f5e5
|
@ -58,7 +58,7 @@ export default function Page() {
|
||||||
];
|
];
|
||||||
|
|
||||||
const rows = [
|
const rows = [
|
||||||
{ id: "1", Vorname:data.message, Nachname: "test", Anstelldatum: "test", Geburtstag: "test" }
|
{ id: "1", Vorname:data.vorname, Nachname: data.nachname, Anstelldatum: data.anstellungsdatum, Geburtstag: data.geburtsdatum }
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -106,6 +106,7 @@ export default function Page() {
|
||||||
sx={{
|
sx={{
|
||||||
marginTop: "1rem",
|
marginTop: "1rem",
|
||||||
borderRadius: "20px",
|
borderRadius: "20px",
|
||||||
|
width: "auto",
|
||||||
}}
|
}}
|
||||||
initialState={{
|
initialState={{
|
||||||
pagination: {
|
pagination: {
|
||||||
|
|
|
@ -1,12 +1,39 @@
|
||||||
import type { NextApiRequest, NextApiResponse } from 'next'
|
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||||
|
import { PrismaClient } from '@prisma/client'
|
||||||
|
|
||||||
|
const prisma = new PrismaClient()
|
||||||
|
|
||||||
type ResponseData = {
|
type ResponseData = {
|
||||||
message: string
|
vorname: string
|
||||||
|
nachname: string
|
||||||
|
geburtsdatum: string
|
||||||
|
anstellungsdatum: string
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function handler(
|
export default async function handler(
|
||||||
req: NextApiRequest,
|
req: NextApiRequest,
|
||||||
res: NextApiResponse<ResponseData>
|
res: NextApiResponse<ResponseData>
|
||||||
) {
|
) {
|
||||||
res.status(200).send({ message: 'Ingrid' })
|
const result = await prisma.mitarbeiter.findFirst({
|
||||||
|
select: { Vorname: true },
|
||||||
|
orderBy: { ID: 'asc' },
|
||||||
|
});
|
||||||
|
const result2 = await prisma.mitarbeiter.findFirst({
|
||||||
|
select: { Nachname: true },
|
||||||
|
orderBy: { ID: 'asc' },
|
||||||
|
});
|
||||||
|
const result3 = await prisma.mitarbeiter.findFirst({
|
||||||
|
select: { Geburtstag: true },
|
||||||
|
orderBy: { ID: 'asc' },
|
||||||
|
});
|
||||||
|
const result4 = await prisma.mitarbeiter.findFirst({
|
||||||
|
select: { Anstelldatum: true },
|
||||||
|
orderBy: { ID: 'asc' },
|
||||||
|
});
|
||||||
|
const firstname = result?.Vorname ?? '';
|
||||||
|
const lastname = result2?.Nachname ?? '';
|
||||||
|
const birthday = result3?.Geburtstag ?? '';
|
||||||
|
const hiredate = result4?.Anstelldatum ?? '';
|
||||||
|
res.status(200).send({ vorname: firstname, nachname: lastname, geburtsdatum: birthday as string, anstellungsdatum: hiredate as string });
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue