Compare commits
4 Commits
d1c69c9c15
...
ed8e71694f
Author | SHA1 | Date |
---|---|---|
|
ed8e71694f | |
|
d54b8180ce | |
|
b36f0edfb1 | |
|
25f8f728c9 |
|
@ -0,0 +1,3 @@
|
||||||
|
export function letterCase(str: String) {
|
||||||
|
return str.charAt(0).toUpperCase() + str.slice(1)
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
import prisma from "../../lib/db.mjs"
|
// "use server"
|
||||||
|
import prisma from "app/lib/db"
|
||||||
|
|
||||||
async function getStory(id: string) {
|
async function getStory(id: string) {
|
||||||
const story = await prisma.story.findFirst({ where: { id: Number(id) } })
|
const story = await prisma.story.findFirst({ where: { id: Number(id) } })
|
||||||
|
|
|
@ -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>
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"baseUrl": "src/",
|
||||||
"lib": [
|
"lib": [
|
||||||
"dom",
|
"dom",
|
||||||
"dom.iterable",
|
"dom.iterable",
|
||||||
|
@ -26,7 +27,8 @@
|
||||||
"next-env.d.ts",
|
"next-env.d.ts",
|
||||||
".next/types/**/*.ts",
|
".next/types/**/*.ts",
|
||||||
"**/*.ts",
|
"**/*.ts",
|
||||||
"**/*.tsx"
|
"**/*.tsx",
|
||||||
|
"src/app/lib/db.ts"
|
||||||
],
|
],
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"node_modules"
|
"node_modules"
|
||||||
|
|
Loading…
Reference in New Issue