diff --git a/src/App.tsx b/src/App.tsx index d46111e825..2b724c5dad 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,5 +1,5 @@ /* eslint-disable max-len */ -import React from 'react'; +import React, { useEffect, useState } from 'react'; import 'bulma/css/bulma.css'; import '@fortawesome/fontawesome-free/css/all.css'; @@ -7,8 +7,20 @@ import { TodoList } from './components/TodoList'; import { TodoFilter } from './components/TodoFilter'; import { TodoModal } from './components/TodoModal'; import { Loader } from './components/Loader'; +import { Todo } from './types/Todo'; export const App: React.FC = () => { + const [isLoading, setIsLoading] = useState(true); + const [isModalVisible, setIsModalVisible] = useState(false); + const [todos, setTodos] = useState(null); + const [todo, setTodo] = useState(null); + + useEffect(() => { + setTimeout(() => { + setIsLoading(false); + }, 1000); + }, []); + return ( <>
@@ -17,18 +29,32 @@ export const App: React.FC = () => {

Todos:

- +
- - + {isLoading ? ( + + ) : ( + + )}
- + {isModalVisible && ( + + )} ); }; diff --git a/src/api.ts b/src/api.ts index 4bf9d3eccb..c7cdac6c05 100644 --- a/src/api.ts +++ b/src/api.ts @@ -1,3 +1,32 @@ +// import { Todo } from './types/Todo'; +// import { User } from './types/User'; + +// // eslint-disable-next-line operator-linebreak +// const BASE_URL = +// 'https://mate-academy.github.io/react_dynamic-list-of-todos/api'; + +// // This function creates a promise +// // that is resolved after a given delay +// function wait(delay: number): Promise { +// return new Promise(resolve => { +// setTimeout(resolve, delay); +// }); +// } + +// function get(url: string): Promise { +// // eslint-disable-next-line prefer-template +// const fullURL = BASE_URL + url + '.json'; + +// // we add some delay to see how the loader works +// return wait(300) +// .then(() => fetch(fullURL)) +// .then(res => res.json()); +// } + +// export const getTodos = () => get('/todos'); + +// export const getUser = (userId: number) => get(`/users/${userId}`); + import { Todo } from './types/Todo'; import { User } from './types/User'; diff --git a/src/components/TodoFilter/TodoFilter.tsx b/src/components/TodoFilter/TodoFilter.tsx index 193f1cd2b2..9c2350c435 100644 --- a/src/components/TodoFilter/TodoFilter.tsx +++ b/src/components/TodoFilter/TodoFilter.tsx @@ -1,30 +1,78 @@ -export const TodoFilter = () => ( -
-

- - - -

- -

- - - - - - - {/* eslint-disable-next-line jsx-a11y/control-has-associated-label */} -