From 7b87091cb53bf339dc546b11459f26d1ca84a25c Mon Sep 17 00:00:00 2001 From: Tania Kuzmenko Date: Tue, 26 Nov 2024 00:33:47 +0200 Subject: [PATCH] Fix remarks --- src/App.tsx | 5 ----- src/UserWarning.tsx | 15 --------------- src/api/todos.ts | 4 ---- src/components/TodoItem.tsx | 4 ++-- src/index.tsx | 1 - 5 files changed, 2 insertions(+), 27 deletions(-) delete mode 100644 src/UserWarning.tsx diff --git a/src/App.tsx b/src/App.tsx index c43e347f8..c227561cc 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,6 +1,5 @@ /* eslint-disable jsx-a11y/control-has-associated-label */ import React, { useEffect } from 'react'; -import { UserWarning } from './UserWarning'; import { getTodos } from './api/todos'; import { Header } from './components/Header'; import { Footer } from './components/Footer'; @@ -57,10 +56,6 @@ export const App: React.FC = () => { } }); - if (!USER_ID) { - return ; - } - return (

todos

diff --git a/src/UserWarning.tsx b/src/UserWarning.tsx deleted file mode 100644 index fa25838e6..000000000 --- a/src/UserWarning.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import React from 'react'; - -export const UserWarning: React.FC = () => ( -
-

- Please get your userId {' '} - - here - {' '} - and save it in the app

const USER_ID = ...
- All requests to the API must be sent with this - userId. -

-
-); diff --git a/src/api/todos.ts b/src/api/todos.ts index 2cb0bf6fd..f999be41a 100644 --- a/src/api/todos.ts +++ b/src/api/todos.ts @@ -1,10 +1,6 @@ import { Todo } from '../types/Todo'; import { client } from '../utils/fetchClient'; -// Your userId is 1414 -// Please use it for all your requests to the Students API. For example: -// https://mate.academy/students-api/todos?userId=1414 - export const getTodos = (userid: number) => { return client.get(`/todos?userId=${userid}`); }; diff --git a/src/components/TodoItem.tsx b/src/components/TodoItem.tsx index dd22a7a99..96ea5d382 100644 --- a/src/components/TodoItem.tsx +++ b/src/components/TodoItem.tsx @@ -81,7 +81,7 @@ export const TodoItem: React.FC = ({ todo }) => { if (newTitle.trim() === '') { try { - await handleDeleteTodo(todo.id); + await handleDeleteTodo(id); } catch (err) { if (err) { errorMsg = true; @@ -89,7 +89,7 @@ export const TodoItem: React.FC = ({ todo }) => { focusInput(inputRef); } - } else if (newTitle.trim() !== todo.title) { + } else if (newTitle.trim() !== title) { try { await handleUpdateTodo(todo, newTitle.trim()); } catch (err) { diff --git a/src/index.tsx b/src/index.tsx index 8caeb506f..827ee1946 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,5 +1,4 @@ import { createRoot } from 'react-dom/client'; - import 'bulma/css/bulma.css'; import '@fortawesome/fontawesome-free/css/all.css'; import './styles/index.scss';