import { type GetServerSideProps } from "next"; import Head from "next/head"; import Link from "next/link"; import { formatCurrency } from "~/currency/formatter"; import { getServerAuthSession } from "~/server/auth"; import { prisma } from "~/server/db"; import { Training } from "~/content/training"; import { Layout } from "~/components/Layout"; import { Button } from "~/components/Button"; type Trainings = [ { id: string; name: string; slug: string; days: number; draft: boolean; priceOpen: number; priceCorporate: number; } ]; export const getServerSideProps: GetServerSideProps = async (ctx) => { const session = await getServerAuthSession(ctx); if (!session) return { redirect: { destination: '/api/auth/signin', permanent: false } }; const trainings = await prisma.training.findMany({ select: { id: true, name: true, slug: true, days: true, draft: true, priceOpen: true, priceCorporate: true, } }); return { props: { trainings: trainings, session } }; } function Table({trainings}: { trainings: Trainings }) { return (
A list of all the users in your account including their name, title, email and role.
*/}| Name | Days | Draft | Price Open | Price Corporate | Edit |
|---|---|---|---|---|---|
| {training.name} | {training.days} | {training.draft ? 'Yes' : 'No'} | {formatCurrency(training.priceOpen)} | {formatCurrency(training.priceCorporate)} | Detail of {training.name} |