Skip to content

Completed small to do list app...#7

Open
AisaBektas wants to merge 3 commits intoForstaGlobal:masterfrom
AisaBektas:master
Open

Completed small to do list app...#7
AisaBektas wants to merge 3 commits intoForstaGlobal:masterfrom
AisaBektas:master

Conversation

@AisaBektas
Copy link

This app is made with React Typescript. For the design, I used MUI which helped me to implement my custom design system using their components. For routing, react-router dom is used. Redux and redux toolkit are applied for making the application's state. It allowed me to set up the store and make logic for creating reducers and actions.
In the end, to write a few tests for the functionality of this TO-DO app I chose testing-library react. Also, you can find initiated redux saga in my store as I have experience with that so you can find my way of implementing that functionality.

@alessiop-forsta
Copy link
Collaborator

The tests are not testing the app's funcitonality (create, edit, toggle completed, delete), they are only testing that the correct elements are rendered.

key={value}
value={value}
labelId={labelId}
itemId={item._id}
Copy link
Collaborator

Choose a reason for hiding this comment

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

A lot of props are being sent into this component. You could have sent item={item} and thus could have avoided sending itemId={item._id} itemTask={item.task} itemStatus={item.status}


return (
<UILayout text="Today's To-Do List">
<AddNewItemForm
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's a little confusing that this component is named AddNewItemForm, but it's also used for editing todos.

const [editId, setEditId] = useState("");

const allTodos = useSelector((state: any) => state.allTodos?.allTodos);
const sortedItems = [...allTodos].reverse();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of using reverse here, you could add new todos at the top of the array in the reducer

      return {
        ...state,
        allTodos: [
          { _id: uniqueId, task: action.payload, status: false },
          ...state.allTodos,
        ],
      };

// To get all todo items from the state hook called useSelector from react-redux is used
// useState hook is used to store data of the selected item which is later on used for its updating
interface ItemProps {
status: boolean;
Copy link
Collaborator

Choose a reason for hiding this comment

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

status: boolean is understandable, but I think it could be better. For example:
status: 'PENDING' | 'COMPLETED' or completed: boolean

interface ItemProps {
status: boolean;
task: string;
_id: string;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why underscore?

@alessiop-forsta
Copy link
Collaborator

The edit functionality is a little buggy... The user can delete a todo while it's being edited, then click edit and the text will just disappear from the input box.

],
},
reducers: {
addNewTodo(state: any, action: PayloadAction<string>) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why state: any?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants