diff --git a/.eslintrc b/.eslintrc
index a2ceebe..97a2bb8 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -1,3 +1,3 @@
{
- "extends": ["next/babel", "next/core-web-vitals"]
+ "extends": ["next", "next/core-web-vitals"]
}
diff --git a/components/AddTask.js b/components/AddTask.js
index 9652adb..d136def 100644
--- a/components/AddTask.js
+++ b/components/AddTask.js
@@ -1,10 +1,34 @@
+import { useState } from "react"
+import axios from "../utils/axios";
+import { useAuth } from "../context/auth"
+import {toast} from 'react-toastify'
+import 'react-toastify/dist/ReactToastify.css'
+
export default function AddTask() {
+ const [newtodo,setNewTodo]=useState('');
+ const {token} = useAuth();
const addTask = () => {
- /**
- * @todo Complete this function.
- * @todo 1. Send the request to add the task to the backend server.
- * @todo 2. Add the task in the dom.
- */
+
+ const dataToPost={
+ "title": newtodo
+ }
+ axios
+ .post(
+ 'todo/create/',
+ dataToPost,
+ {
+ headers:{
+ Authorization: 'Token ' + token
+ }
+ })
+ .then((res)=>{
+ setNewTodo('');
+ toast.success('Task added succesfully!!',{position:"bottom-right",theme:"colored"});
+ }).catch((err)=>{
+ toast.error('Some error Occured!',{position:"bottom-right",theme:"colored"})
+ console.log(err);
+ })
+
}
return (
@@ -12,6 +36,8 @@ export default function AddTask() {
type='text'
className='todo-add-task-input px-4 py-2 placeholder-blueGray-300 text-blueGray-600 bg-white rounded text-sm border border-blueGray-300 outline-none focus:outline-none focus:ring w-full'
placeholder='Enter Task'
+ value={newtodo}
+ onChange={(e)=>{setNewTodo(e.target.value)}}
/>