diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 0000000..eb4d9d5 --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,31 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs + +name: Node.js CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [14.x, 16.x, 18.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm ci + - run: npm run build --if-present + - run: npm test diff --git a/README.md b/README.md index 93d3d81..57a2e26 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # ReactJS Todo Application - CSoC Dev Web Task 3 +### While registering on the register page , keep the inspect/console panel ON TO know if you have to try again ! ## Introduction In this task you will be working on a todo application made using NextJS a SSR framework for ReactJS. The main motive of this task is to make you familiar with: 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 ( -