diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 70697ef..f7912a9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,6 @@ name: Nextblog CI on: - push: - branches: [main] pull_request: branches: [main] @@ -47,3 +45,4 @@ jobs: NEXT_PUBLIC_CONVEX_URL: "https://insightful-pheasant-237.convex.cloud" NEXT_PUBLIC_CONVEX_SITE_URL: "https://insightful-pheasant-237.convex.site" NEXT_PUBLIC_SITE_URL: "http://localhost:3000" + BETTER_AUTH_SECRET: "dummy-secret-for-ci-build" diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..c8f22cb --- /dev/null +++ b/.prettierrc @@ -0,0 +1,11 @@ +{ + "tabWidth": 2, + "useTabs": false, + "semi": true, + "singleQuote": false, + "trailingComma": "all", + "printWidth": 80, + "bracketSpacing": true, + "arrowParens": "always", + "endOfLine": "lf" +} diff --git a/app/(shared-layout)/create/page.tsx b/app/(shared-layout)/create/page.tsx new file mode 100644 index 0000000..9525e93 --- /dev/null +++ b/app/(shared-layout)/create/page.tsx @@ -0,0 +1,121 @@ +"use client"; + +import { useTransition } from "react"; +import { Loader2 } from "lucide-react"; +import { Controller, useForm } from "react-hook-form"; +import { useMutation } from "convex/react"; +import { + Card, + CardDescription, + CardHeader, + CardTitle, +} from "@/components/ui/card"; +import { CardContent } from "@/components/ui/card"; +import { + Field, + FieldError, + FieldGroup, + FieldLabel, +} from "@/components/ui/field"; +import { Input } from "@/components/ui/input"; +import { Button } from "@/components/ui/button"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { postSchema } from "@/app/schemas/blog"; +import { api } from "@/convex/_generated/api"; +import { Textarea } from "@/components/ui/textarea"; +import { toast } from "sonner"; +import { z } from "zod/v3"; + +export default function CreatePage() { + const form = useForm>({ + resolver: zodResolver(postSchema), + defaultValues: { + title: "", + content: "", + }, + }); + const createPost = useMutation(api.posts.createPost); + const [isPending, startTransition] = useTransition(); + + const onSubmit = (data: z.infer) => { + startTransition(async () => { + try { + await createPost(data); + toast.success("Post created successfully!"); + form.reset(); + } catch { + toast.error("Failed to create post"); + } + }); + }; + return ( +
+
+

+ Create Blog +

+

+ Share your knowledge and ideas with the world. +

+
+ + + + Create Blog Article + Create a new blog article + + +
+ + ( + + Title + + {fieldState.error && ( + {fieldState.error.message} + )} + + )} + /> + ( + + Content +