add create story page
This commit is contained in:
parent
d54b8180ce
commit
ed8e71694f
|
@ -0,0 +1,5 @@
|
|||
import StoryForm from "app/ui/forms/story";
|
||||
|
||||
export default function Page() {
|
||||
return <StoryForm />
|
||||
}
|
|
@ -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}</>
|
||||
|
||||
}
|
|
@ -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>
|
||||
}
|
Loading…
Reference in New Issue