From f6fffa432829c998c7f93b8bbb79db3dd3f5ce17 Mon Sep 17 00:00:00 2001 From: itzamanjain Date: Wed, 9 Oct 2024 00:17:41 +0530 Subject: [PATCH 01/11] added form to submit blog --- app/blog/submit-blog/page.tsx | 164 ++++++++++++++++++++++++++++++++++ components/ui/textarea.tsx | 24 +++++ next-env.d.ts | 1 - yarn.lock | 14 ++- 4 files changed, 201 insertions(+), 2 deletions(-) create mode 100644 app/blog/submit-blog/page.tsx create mode 100644 components/ui/textarea.tsx diff --git a/app/blog/submit-blog/page.tsx b/app/blog/submit-blog/page.tsx new file mode 100644 index 000000000..9c8706d29 --- /dev/null +++ b/app/blog/submit-blog/page.tsx @@ -0,0 +1,164 @@ +"use client"; + +import { useState } from "react"; +import { Button } from "@/components/ui/button"; +import { + Card, + CardContent, + CardDescription, + CardFooter, + CardHeader, + CardTitle, +} from "@/components/ui/card"; +import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; +import { Textarea } from "@/components/ui/textarea"; +import { Loader2 } from "lucide-react"; + +export default function SubmitBlog() { + const [blogData, setBlogData] = useState({ + title: "", + url: "", + excerpt: "", + date: "", + author: "", + readingTime: "", + thumbnail: "", + tags: "", + content: "", + }); + const [isLoading, setIsLoading] = useState(false); + + const handleChange = ( + e: React.ChangeEvent, + ) => { + const { name, value } = e.target; + setBlogData({ ...blogData, [name]: value }); + console.log(blogData); + }; + + const handleSubmit = async (e: React.FormEvent) => { + e.preventDefault(); + setIsLoading(true); + + try { + // TODO : make an API call to submit the blog + await new Promise((resolve) => setTimeout(resolve, 2000)); + // TODO: Reset form or show success message here + } catch (error) { + console.error("Error submitting blog:", error); + } finally { + setIsLoading(false); + } + }; + + return ( + + + Submit Your Blog + + Fill in the details to submit your blog post. + + + +
+
+ + +
+
+ + +
+
+ +