From c8fdfe55756b16de049f7332a449804ac3216f52 Mon Sep 17 00:00:00 2001 From: Saksham Misra <122719607+vinfinity7@users.noreply.github.com> Date: Sun, 9 Jul 2023 18:55:22 +0530 Subject: [PATCH 1/9] commit 1 tasks have been done --- components/AddTask.js | 35 +- components/LoginForm.js | 71 +- components/Nav.js | 31 +- components/RegisterForm.js | 14 +- components/TodoListItem.js | 110 +- context/auth.js | 1 + middlewares/auth_required.js | 13 + middlewares/no_auth_required.js | 16 + package-lock.json | 6716 +++++++++++++++++++++++++++++++ package.json | 7 +- pages/_app.js | 3 + pages/index.js | 58 +- styles/globals.css | 6 + yarn.lock | 1964 ++++----- 14 files changed, 8049 insertions(+), 996 deletions(-) create mode 100644 package-lock.json diff --git a/components/AddTask.js b/components/AddTask.js index 8b8177f..5089f2d 100644 --- a/components/AddTask.js +++ b/components/AddTask.js @@ -1,18 +1,51 @@ +import { useState } from "react"; +import axios from "../utils/axios"; +import { useAuth } from "../context/auth"; +import { toast } from 'react-toastify'; + export default function AddTask() { + + const [Thistask , setThistask]=useState('task'); + 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 data={ + "title": Thistask + } + axios + .post( + 'todo/create/', + data, + { + headers:{ + 'Authorization': 'Token ' + token, + 'Content-Type': 'application/json', + } + }) + .then(()=>{ + setThistask(''); + toast.success('Task added succesfully!!'); + }).catch((err)=>{ + toast.error('Some error Occured!') + console.log(err); + }) }; return ( -
+
setThistask(e.target.value)} /> +
No account yet ? No Worries! Register Here!
diff --git a/components/Nav.js b/components/Nav.js index 00c05d1..2d10f7e 100644 --- a/components/Nav.js +++ b/components/Nav.js @@ -7,47 +7,50 @@ import { useAuth } from "../context/auth"; * @todo Condtionally render login/register and Profile name in NavBar */ + + + export default function Nav() { const { logout, profileName, avatarImage } = useAuth(); return ( -