-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Completed The Tasks #4
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import Image from 'next/image' | ||
|
||
const ListItem = ({title,iid,editTask,deleteTask,updateTask}) => { | ||
return ( | ||
<li className='border flex border-gray-500 rounded px-2 py-2 justify-between items-center mb-2'> | ||
<input | ||
id={`input-button-${iid}`} | ||
type='text' | ||
className='hideme appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:ring todo-edit-task-input' | ||
placeholder='Edit The Task' | ||
/> | ||
<div id={`done-button-${iid}`} className='hideme'> | ||
<button | ||
className='bg-transparent hover:bg-gray-500 text-gray-700 text-sm hover:text-white py-2 px-3 border border-gray-500 hover:border-transparent rounded todo-update-task' | ||
type='button' | ||
onClick={()=>updateTask(iid)} | ||
> | ||
Done | ||
</button> | ||
</div> | ||
<div id={`task-${iid}`} className='todo-task text-gray-600'> | ||
{title} | ||
</div> | ||
<span id={`task-actions-${iid}`} className=''> | ||
<button | ||
style={{ marginRight: '5px' }} | ||
type='button' | ||
onClick={()=>editTask(iid)} | ||
className='bg-transparent hover:bg-yellow-500 hover:text-white border border-yellow-500 hover:border-transparent rounded px-2 py-2' | ||
> | ||
<Image | ||
src='https://res.cloudinary.com/nishantwrp/image/upload/v1587486663/CSOC/edit.png' | ||
width='18px' | ||
height='20px' | ||
alt='Edit' | ||
/> | ||
</button> | ||
<button | ||
type='button' | ||
className='bg-transparent hover:bg-red-500 hover:text-white border border-red-500 hover:border-transparent rounded px-2 py-2' | ||
onClick={()=>deleteTask(iid)} | ||
> | ||
<Image | ||
src='https://res.cloudinary.com/nishantwrp/image/upload/v1587486661/CSOC/delete.svg' | ||
width='18px' | ||
height='22px' | ||
alt='Delete' | ||
/> | ||
</button> | ||
</span> | ||
</li> | ||
) | ||
} | ||
|
||
export default ListItem; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
import { useAuth } from '../context/auth' | ||
/*** | ||
* @todo Redirect the user to login page if token is not present. | ||
*/ | ||
const checkLogin = () => { | ||
// console.log(document.cookie); | ||
if(document.cookie=='')window.location.href = './login' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make use of Framework specific methods rather than using Vanilla JS one There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I have to use router instead of window.location.href and rather than checking document.cookie again and again I should use State ?? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made a few changes to resolve those mistakes. Please review them. |
||
} | ||
|
||
export default checkLogin; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should have make use of React Hooks like useState to manage the states