tidy up
This commit is contained in:
		
							parent
							
								
									3b32316688
								
							
						
					
					
						commit
						75e5a95348
					
				
							
								
								
									
										
											BIN
										
									
								
								prisma/dev.db
								
								
								
								
							
							
						
						
									
										
											BIN
										
									
								
								prisma/dev.db
								
								
								
								
							
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -1,27 +1,24 @@
 | 
			
		|||
import { PrismaClient } from '@prisma/client'
 | 
			
		||||
import { PrismaClient } from "@prisma/client";
 | 
			
		||||
 | 
			
		||||
const prisma = new PrismaClient()
 | 
			
		||||
const prisma = new PrismaClient();
 | 
			
		||||
 | 
			
		||||
async function main() {
 | 
			
		||||
	// ... you will write your Prisma Client queries here
 | 
			
		||||
	const story = await prisma.story.update({
 | 
			
		||||
		where: { id: 1 },
 | 
			
		||||
		data: {
 | 
			
		||||
			title: "Ghost Aliens of Mars",
 | 
			
		||||
			genres: { set: [{ id: 1 }, { id: 2 }], create: { name: "alien-punk" } }
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	})
 | 
			
		||||
	console.log(story)
 | 
			
		||||
 | 
			
		||||
  // ... you will write your Prisma Client queries here
 | 
			
		||||
  const story = await prisma.story.update({
 | 
			
		||||
    where: { id: 1 },
 | 
			
		||||
    data: {
 | 
			
		||||
      title: "Ghost Aliens of Mars",
 | 
			
		||||
      genres: { set: [{ id: 1 }, { id: 2 }], create: { name: "alien-punk" } },
 | 
			
		||||
    },
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
main()
 | 
			
		||||
	.then(async () => {
 | 
			
		||||
		await prisma.$disconnect()
 | 
			
		||||
	})
 | 
			
		||||
	.catch(async (e) => {
 | 
			
		||||
		console.error(e)
 | 
			
		||||
		await prisma.$disconnect()
 | 
			
		||||
		process.exit(1)
 | 
			
		||||
	})
 | 
			
		||||
  .then(async () => {
 | 
			
		||||
    await prisma.$disconnect();
 | 
			
		||||
  })
 | 
			
		||||
  .catch(async (e) => {
 | 
			
		||||
    console.error(e);
 | 
			
		||||
    await prisma.$disconnect();
 | 
			
		||||
    process.exit(1);
 | 
			
		||||
  });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,7 +15,6 @@ const dynamic = 'force-dynamic'
 | 
			
		|||
//POST endpoint
 | 
			
		||||
export async function POST(request: NextRequest) {
 | 
			
		||||
	const body = await request.json()
 | 
			
		||||
	console.log(`body: ${JSON.stringify(body)}`)
 | 
			
		||||
	const { email, password } = body
 | 
			
		||||
 | 
			
		||||
	if (!email || !password) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,16 +1,12 @@
 | 
			
		|||
"use server"
 | 
			
		||||
import { Genre, Pub, Story, Sub } from "@prisma/client"
 | 
			
		||||
import { Pub, Story, Sub } from "@prisma/client"
 | 
			
		||||
import prisma from "./db"
 | 
			
		||||
import { revalidatePath } from "next/cache"
 | 
			
		||||
import { redirect } from "next/navigation"
 | 
			
		||||
import { z } from "zod"
 | 
			
		||||
import { storySchema } from "app/ui/forms/schemas"
 | 
			
		||||
import { pubSchema } from "app/ui/forms/schemas"
 | 
			
		||||
import { subSchema } from "app/ui/forms/schemas"
 | 
			
		||||
import { prepGenreData, prepStoryData } from "./validate"
 | 
			
		||||
import { SubForm } from "app/ui/forms/sub"
 | 
			
		||||
 | 
			
		||||
//TODO - data validation, error handling, unauthorized access handling
 | 
			
		||||
 | 
			
		||||
export async function createStory({ story, genres }: { story: Story, genres: number[] }): Promise<{ success: string }> {
 | 
			
		||||
	// will return undefined if middleware authorization fails
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,7 +18,6 @@ export default function LoginForm() {
 | 
			
		|||
	const router = useRouter()
 | 
			
		||||
	const searchParams = useSearchParams()
 | 
			
		||||
	const redirect = searchParams.get("from") ?? "/submission"
 | 
			
		||||
	console.log(redirect)
 | 
			
		||||
	const form = useForm<z.infer<typeof loginSchema>>({
 | 
			
		||||
		resolver: zodResolver(loginSchema),
 | 
			
		||||
	})
 | 
			
		||||
| 
						 | 
				
			
			@ -37,6 +36,7 @@ export default function LoginForm() {
 | 
			
		|||
			toast({ title: "login successful!" })
 | 
			
		||||
			setSubmitted(true)
 | 
			
		||||
			await revalidate(redirect)
 | 
			
		||||
			//BUG:the first time user logs in, page refreshes instead of redirecting
 | 
			
		||||
			router.push(redirect)
 | 
			
		||||
		} else {
 | 
			
		||||
			toast({ title: "login failed!" })
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -136,7 +136,7 @@ export function DataTable<TData, TValue>({
 | 
			
		|||
      <div className="flex gap-2">
 | 
			
		||||
        <DropdownMenu>
 | 
			
		||||
          <DropdownMenuTrigger asChild>
 | 
			
		||||
            <Button variant="outline" className="hidden md:display-blockml-auto">
 | 
			
		||||
            <Button variant="outline" className="hidden sm:block ml-auto">
 | 
			
		||||
              Filter by
 | 
			
		||||
            </Button>
 | 
			
		||||
          </DropdownMenuTrigger>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue