add forms+
This commit is contained in:
		
							parent
							
								
									50409895c0
								
							
						
					
					
						commit
						e0e9ac68de
					
				| 
						 | 
				
			
			@ -0,0 +1,5 @@
 | 
			
		|||
import PubForm from "app/ui/forms/pub";
 | 
			
		||||
 | 
			
		||||
export default function Page() {
 | 
			
		||||
	return <PubForm />
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -4,8 +4,7 @@ import { letterCase } from "app/lib/functions"
 | 
			
		|||
export default async function GenreCheckboxes() {
 | 
			
		||||
	async function getGenres() {
 | 
			
		||||
		"use server"
 | 
			
		||||
		const genres = await prisma.genre.findMany()
 | 
			
		||||
		return genres
 | 
			
		||||
		return prisma.genre.findMany()
 | 
			
		||||
	}
 | 
			
		||||
	const genres = await getGenres()
 | 
			
		||||
	const genreCheckboxes = genres.map(e => {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,11 @@
 | 
			
		|||
export default async function PubForm() {
 | 
			
		||||
	return <form>
 | 
			
		||||
		<label htmlFor="title">Title:</label>
 | 
			
		||||
		<input type="text" id="title" />
 | 
			
		||||
		<label htmlFor="link">Link:</label>
 | 
			
		||||
		<input type="text" id="link" />
 | 
			
		||||
		<label htmlFor="number" id="query-after" >Query after (days):</label>
 | 
			
		||||
		<input type="number" step="30" />
 | 
			
		||||
		<input type="submit" value="Submit" />
 | 
			
		||||
	</form>
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,15 @@
 | 
			
		|||
import prisma from "app/lib/db"
 | 
			
		||||
 | 
			
		||||
export default async function PubsDropdown() {
 | 
			
		||||
	async function getPubs() {
 | 
			
		||||
		"use server"
 | 
			
		||||
		return prisma.pub.findMany()
 | 
			
		||||
	}
 | 
			
		||||
	const pubs = await getPubs()
 | 
			
		||||
	const pubsDropdown = pubs.map(e => {
 | 
			
		||||
		return <option value={e.id} key={e.title}>{e.title}</option>
 | 
			
		||||
	})
 | 
			
		||||
	return <select key="pubsDropdown">
 | 
			
		||||
		{pubsDropdown}
 | 
			
		||||
	</select>
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -4,7 +4,7 @@ export default async function StoryForm() {
 | 
			
		|||
		<label htmlFor="title">Title:</label>
 | 
			
		||||
		<input type="text" id="title" />
 | 
			
		||||
		<label htmlFor="word-count">Word Count:</label>
 | 
			
		||||
		<input type="text" id="word-count" />
 | 
			
		||||
		<input type="number" id="word-count" step="500" />
 | 
			
		||||
		<GenreCheckboxes />
 | 
			
		||||
		<input type="submit" value="Submit" />
 | 
			
		||||
	</form>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,15 @@
 | 
			
		|||
import prisma from "app/lib/db"
 | 
			
		||||
 | 
			
		||||
export default async function StoryDropdown() {
 | 
			
		||||
	async function getStories() {
 | 
			
		||||
		"use server"
 | 
			
		||||
		return prisma.story.findMany()
 | 
			
		||||
	}
 | 
			
		||||
	const stories = await getStories()
 | 
			
		||||
	const storiesDrowpdown = stories.map(e => {
 | 
			
		||||
		return <option value={e.id} key={`${e.title}`}>{e.title}</option>
 | 
			
		||||
	})
 | 
			
		||||
	return <select key="storyDropdown">
 | 
			
		||||
		{storiesDrowpdown}
 | 
			
		||||
	</select>
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,9 @@
 | 
			
		|||
import PubsDropdown from "./pubsDropdown";
 | 
			
		||||
import StoryDropdown from "./storyDropdown";
 | 
			
		||||
 | 
			
		||||
export default async function SubmissionForm() {
 | 
			
		||||
	return <form>
 | 
			
		||||
		<StoryDropdown />
 | 
			
		||||
		<PubsDropdown />
 | 
			
		||||
	</form>
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue