-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented the UI of the uqestion form
- Loading branch information
Showing
4 changed files
with
144 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
import QuestionForm from "@/components/forms/QuestionForm"; | ||
|
||
const AskAQuestion = () => { | ||
return <p>Question</p>; | ||
return ( | ||
<> | ||
<h1 className="h1-bold text-dark100_light900">Ask a question</h1> | ||
<div className="mt-9"> | ||
<QuestionForm /> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default AskAQuestion; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
"use client"; | ||
import { AskQuestionSchema } from "@/lib/validations"; | ||
import { zodResolver } from "@hookform/resolvers/zod"; | ||
import React from "react"; | ||
import { useForm } from "react-hook-form"; | ||
import { | ||
Form, | ||
FormControl, | ||
FormDescription, | ||
FormField, | ||
FormItem, | ||
FormLabel, | ||
FormMessage, | ||
} from "../ui/form"; | ||
import { Input } from "../ui/input"; | ||
import { Button } from "../ui/button"; | ||
|
||
const QuestionForm = () => { | ||
const form = useForm({ | ||
resolver: zodResolver(AskQuestionSchema), | ||
defaultValues: { | ||
title: "", | ||
content: "", | ||
tags: [], | ||
}, | ||
}); | ||
|
||
const handleCreateQuestion = () => {}; | ||
return ( | ||
<Form {...form}> | ||
<form | ||
className="flex w-full flex-col gap-10" | ||
onSubmit={form.handleSubmit(handleCreateQuestion)} | ||
> | ||
<FormField | ||
control={form.control} | ||
name="title" | ||
render={({ field }) => ( | ||
<FormItem className="flex w-full flex-col"> | ||
<FormLabel className="paragraph-semibold text-dark400_light800"> | ||
Question Title <span className="text-primary-500">*</span> | ||
</FormLabel> | ||
<FormControl> | ||
<Input | ||
{...field} | ||
className="paragraph-regular background-700_dark300 light-border-2 text-dark300_light700 no-focus min-h-[56px] border" | ||
/> | ||
</FormControl> | ||
<FormDescription className="body-regular text-light-500 mt-2.5"> | ||
Be specific and imaginf your asking a question to another | ||
person. | ||
</FormDescription> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
<FormField | ||
control={form.control} | ||
name="content" | ||
render={({ field }) => ( | ||
<FormItem className="flex w-full flex-col"> | ||
<FormLabel className="paragraph-semibold text-dark400_light800"> | ||
Detailed Explaination of your problem{" "} | ||
<span className="text-primary-500">*</span> | ||
</FormLabel> | ||
<FormControl>Editor</FormControl> | ||
<FormDescription className="body-regular text-light-500 mt-2.5"> | ||
Introduce the problem and expand on what you have put in the | ||
title. | ||
</FormDescription> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
<FormField | ||
control={form.control} | ||
name="tags" | ||
render={({ field }) => ( | ||
<FormItem className="flex w-full flex-col gap-3"> | ||
<FormLabel className="paragraph-semibold text-dark400_light800"> | ||
Tags <span className="text-primary-500">*</span> | ||
</FormLabel> | ||
<FormControl> | ||
<div> | ||
<Input | ||
className="paragraph-regular background-700_dark300 light-border-2 text-dark300_light700 no-focus min-h-[56px] border" | ||
placeholder="Add tags.." | ||
{...field} | ||
/> | ||
Tags | ||
</div> | ||
</FormControl> | ||
<FormDescription className="body-regular text-light-500 mt-2.5"> | ||
Add upto three tags describe what your question is about. Press | ||
Enter to add a TAG | ||
</FormDescription> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
<div className="mt-16 flex justify-end"> | ||
<Button | ||
type="submit" | ||
className="primary-gradient !text-light-900 w-fit" | ||
> | ||
Ask a Question | ||
</Button> | ||
</div> | ||
</form> | ||
</Form> | ||
); | ||
}; | ||
|
||
export default QuestionForm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters