add create story page

This commit is contained in:
andrzej 2024-06-11 19:14:30 +02:00
parent d54b8180ce
commit ed8e71694f
3 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,5 @@
import StoryForm from "app/ui/forms/story";
export default function Page() {
return <StoryForm />
}

View File

@ -0,0 +1,21 @@
import prisma from "app/lib/db"
import React from "react"
import { letterCase } from "app/lib/functions"
export default async function GenreCheckboxes() {
async function getGenres() {
"use server"
const genres = await prisma.genre.findMany()
return genres
}
const genres = await getGenres()
const genreCheckboxes = genres.map(e => {
const label = letterCase(e.name)
return (<React.Fragment key={`fragment${e.name}`}>
<input type="checkbox" id={e.name} key={`genreCheckboxInput${e.id}`} />
<label htmlFor={e.name} key={`genreCheckboxLabel${e.id}`}>{label}</label>
</React.Fragment>
)
})
return <>{genreCheckboxes}</>
}

View File

@ -0,0 +1,10 @@
import GenreCheckboxes from "./genreCheckboxes"
export default async function StoryForm() {
return <form>
<label htmlFor="title">Title:</label>
<input type="text" id="title" />
<label htmlFor="word-count">Word Count:</label>
<input type="text" id="word-count" />
<GenreCheckboxes />
</form>
}