implement basic story[id] page

This commit is contained in:
andrzej 2024-06-20 12:29:56 +02:00
parent d87eb3b342
commit c63175a0f8
5 changed files with 69 additions and 12 deletions

Binary file not shown.

View File

@ -1,15 +1,42 @@
// "use server" // "use server"
import prisma from "app/lib/db" import prisma from "app/lib/db"
import { columns } from "app/submission/columns"
import { PageHeader, PageSubHeader } from "app/ui/pageHeader"
import { DataTable } from "app/ui/tables/data-table"
import { Badge } from "@/components/ui/badge"
async function getStory(id: string) { //ids are string here because they're coming from url params
const story = await prisma.story.findFirst({ where: { id: Number(id) } }) async function getStoryWithGenres(id: string) {
return story return prisma.story.findFirst({
where: { id: Number(id) }, include: {
genres: true
}
})
}
async function getStorySubmissions(id: string) {
return prisma.sub.findMany({
where: { storyId: Number(id) }, include: {
story: true,
pub: true,
response: true
}
})
} }
export default async function Page({ params }: { params: { id: string } }) { export default async function Page({ params }: { params: { id: string } }) {
const data = await getStory(params.id) const data = await getStoryWithGenres(params.id)
return <div>Title: {data?.title ?? ""}</div> const storySubs = await getStorySubmissions(params.id)
return <>
<div className="container">
<PageHeader>{data?.title ?? ""}</PageHeader>
{data.genres.map(e => (<Badge>{e.name}</Badge>))}
<PageSubHeader>Submissions:</PageSubHeader>
<DataTable columns={columns} data={storySubs} />
</div>
</>
} }

View File

@ -46,7 +46,7 @@ html,
-o-tab-size: 4; -o-tab-size: 4;
tab-size: 4; tab-size: 4;
/* 3 */ /* 3 */
font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-family: ui-sans-serif, system-ui;
/* 4 */ /* 4 */
font-feature-settings: normal; font-feature-settings: normal;
/* 5 */ /* 5 */
@ -135,7 +135,7 @@ code,
kbd, kbd,
samp, samp,
pre { pre {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-family: ui-monospace, SFMono-Regular;
/* 1 */ /* 1 */
font-feature-settings: normal; font-feature-settings: normal;
/* 2 */ /* 2 */
@ -1248,6 +1248,10 @@ body {
vertical-align: middle; vertical-align: middle;
} }
.font-display {
font-family: Playfair;
}
.text-3xl { .text-3xl {
font-size: 1.875rem; font-size: 1.875rem;
line-height: 2.25rem; line-height: 2.25rem;
@ -1277,6 +1281,11 @@ body {
line-height: 1rem; line-height: 1rem;
} }
.text-xl {
font-size: 1.25rem;
line-height: 1.75rem;
}
.font-black { .font-black {
font-weight: 900; font-weight: 900;
} }
@ -1293,6 +1302,10 @@ body {
font-weight: 600; font-weight: 600;
} }
.font-bold {
font-weight: 700;
}
.capitalize { .capitalize {
text-transform: capitalize; text-transform: capitalize;
} }

View File

@ -0,0 +1,9 @@
import { ComponentProps } from "react"
export function PageHeader(props: ComponentProps<"h1">) {
return <h1 className="text-3xl font-display font-bold">{props.children}</h1>
}
export function PageSubHeader(props: ComponentProps<"h2">) {
return <h2 className="text-xl font-display font-bold">{props.children}</h2>
}

View File

@ -2,13 +2,20 @@
module.exports = { module.exports = {
darkMode: ["class"], darkMode: ["class"],
content: [ content: [
'./pages/**/*.{ts,tsx}', "./pages/**/*.{ts,tsx}",
'./components/**/*.{ts,tsx}', "./components/**/*.{ts,tsx}",
'./app/**/*.{ts,tsx}', "./app/**/*.{ts,tsx}",
'./src/**/*.{ts,tsx}', "./src/**/*.{ts,tsx}",
], ],
prefix: "", prefix: "",
theme: { theme: {
fontFamily: {
sans: ["ui-sans-serif", "system-ui"],
serif: ["ui-serif", "Georgia"],
mono: ["ui-monospace", "SFMono-Regular"],
display: ["Playfair"],
body: ['"Open Sans"'],
},
container: { container: {
center: true, center: true,
padding: "2rem", padding: "2rem",
@ -74,4 +81,5 @@ module.exports = {
}, },
}, },
plugins: [require("tailwindcss-animate")], plugins: [require("tailwindcss-animate")],
} };