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