Skip to content
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

react1-week2/maryam #268

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

react1-week2/maryam #268

wants to merge 3 commits into from

Conversation

MaryamAarhus
Copy link
Contributor

No description provided.

@github-actions github-actions bot changed the title TodoList Week2 Done! react1-week2/maryam Mar 23, 2024
@MaryamAarhus MaryamAarhus changed the title react1-week2/maryam react1-week3/maryam Mar 24, 2024
Copy link

@BrantalikP BrantalikP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done! @MaryamAarhus 👏 I really like the app, although I left more comments, just fixing the "onSave" method is required, other things are just suggestions:)

Just a note: next time please use the correct folder, right now you are using "week2" folder for the week3 assignment. Thank you!

);
}

TodoItem.propTypes = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first time I am seeing someone use the proptypes in their homework, good job 👏

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your heartwarming comments 😊 I highly appreciate it!

@@ -0,0 +1,19 @@
import React, { useState, useEffect } from 'react';

function Timer() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The timer is not used anywhere, you can delete it :)

const [editedDescription, setEditedDescription] = useState(description);

const handleSave = () => {
onSave(editedDescription);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The save function is missing a type declaration. Also it's not working right now. Maybe you have forgotten to implement the functionality?

} else if (new Date(newTodoDeadline) < new Date()) {
setErrorMessage('Deadline cannot be in the past.');
return;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well done.

};

const deleteTodo = (id) => {
setTodos(todos.filter(todo => todo.id !== id));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although it's not incorrect, when you modify data with the set method from useState, it's better to use its previous state like this: setTodos(prevTodos => prevTodos.filter(todo => todo.id !== id));. The reason is that the set method is asynchronous, meaning it's not guaranteed that todo will hold the correct data at the time you are modifying it.

function TodoList() {
const [todos, setTodos] = useState([]);
const [newTodoDescription, setNewTodoDescription] = useState('');
const [newTodoDeadline, setNewTodoDeadline] = useState('');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well done with the date time picker! This is just suggestion, but feel free to use it if you want.

  1. You can define the current date by something like this
const today = new Date().toISOString().split("T")[0];
function TodoList() {
 const [newTodoDeadline, setNewTodoDeadline] = useState(today);

Thanks to that the current day will be always as default value
2. set the current value as min date for the input

 <input
                type="date"
                min={today}
                value={newTodoDeadline}

Thanks to this, you do not need to check whether the selected date is in the past, because the picker won't let you pick the date :) I think this could improve the User experience a bit :)

@MaryamAarhus MaryamAarhus changed the title react1-week3/maryam react1-week2/maryam Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants