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

Develop #1021

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

Develop #1021

wants to merge 3 commits into from

Conversation

Nazarin565
Copy link

Copy link

@GUSILLUS GUSILLUS left a comment

Choose a reason for hiding this comment

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

GJ!

src/App.tsx Outdated
Completed
</a>
</nav>
<TodoList />
Copy link

Choose a reason for hiding this comment

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

Will we render this component of todos length equal 0?

src/Store.tsx Outdated
Comment on lines 8 to 14
type State = {
todos: Todo[];
query: string;
filter: SelectedFilter;
editingTodoId: number | null;
currentTitle: string;
};
Copy link

Choose a reason for hiding this comment

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

Consider creating .ts file and move this file to this file

src/Store.tsx Outdated
Comment on lines 24 to 34
type Action =
| { type: 'toogleAllChecked' }
| { type: 'addTodo'; payload: Todo }
| { type: 'setQuery'; payload: string }
| { type: 'deleteTodo'; payload: number }
| { type: 'massDelete'; payload: number[] }
| { type: 'changeCheckbox'; payload: number }
| { type: 'updateTodo'; payload: Todo }
| { type: 'setCurrentTitle'; payload: string }
| { type: 'setEditingTodoId'; payload: number | null }
| { type: 'setFilter'; payload: SelectedFilter };
Copy link

Choose a reason for hiding this comment

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

Same

import { Todo } from '../types/Todo';
import { EditForm } from './EditForm';
import { useGlobalDispatch, useGlobalState } from '../Store';
// import { deleteFromLocalStorage } from '../utils/LocaleStorage';
Copy link

Choose a reason for hiding this comment

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

remove redundant comment

const dispatch = useGlobalDispatch();

const handleDeleteTodo = (index: number) => {
// deleteFromLocalStorage(id);
Copy link

Choose a reason for hiding this comment

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

same

Comment on lines 3 to 15
export const loadFromLocalStorage = (): Todo[] => {
const todos = localStorage.getItem('todos');

return todos ? JSON.parse(todos) : [];
};

export const deleteFromLocalStorage = (id: number) => {
let items = loadFromLocalStorage();

items = items.filter((item: Todo) => item.id !== id);

localStorage.setItem('todos', JSON.stringify(items));
};
Copy link

Choose a reason for hiding this comment

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

Consider creating useLocalStorageHook and replace this function with hook

@Nazarin565 Nazarin565 requested a review from GUSILLUS July 10, 2024 18:02
Copy link

@etojeDenys etojeDenys left a comment

Choose a reason for hiding this comment

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

good job

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.

3 participants