Skip to content

Commit

Permalink
add task solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Luk2asz committed Sep 12, 2023
1 parent d8429a7 commit ea455e7
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export const App: React.FC = () => {
<button
type="button"
className="delete"
onClick={() => handleError(Errors.noEroor)}
onClick={() => handleError(Errors.noError)}
/>

{errorMessage}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const Footer: React.FC<Props> = ({

<a
href="#/active"
className={sortBy === 'active'
className={sortBy === SortBy.active
? 'filter__link selected'
: 'filter__link'}
onClick={() => handleSetSortBy(SortBy.active)}
Expand All @@ -66,7 +66,7 @@ export const Footer: React.FC<Props> = ({

<a
href="#/completed"
className={sortBy === 'completed'
className={sortBy === SortBy.completed
? 'filter__link selected'
: 'filter__link'}
onClick={() => handleSetSortBy(SortBy.completed)}
Expand Down
61 changes: 29 additions & 32 deletions src/components/TempTodo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,35 @@ type Props = {
handleDeleteTodo: (value: number) => void,
};

export const TempTodo: React.FC<Props> = ({ tempTodo, handleDeleteTodo }) => {
return (
<li
className="todo"
key={tempTodo.id}
>
<label className="todo__status-label">
<input
type="checkbox"
className="todo__status"
checked={false}
/>
</label>
export const TempTodo: React.FC<Props> = ({ tempTodo, handleDeleteTodo }) => (
<li
className="todo"
>
<label className="todo__status-label">
<input
type="checkbox"
className="todo__status"
checked={tempTodo.completed}
/>
</label>

<span className="todo__title">
{tempTodo.title}
</span>
<span className="todo__title">
{tempTodo.title}
</span>

<button
type="button"
className="todo__remove"
onClick={() => handleDeleteTodo(tempTodo.id)}
>
×
</button>
<button
type="button"
className="todo__remove"
onClick={() => handleDeleteTodo(tempTodo.id)}
>
×
</button>

<div
className="modal overlay is-active"
>
<div className="modal-background has-background-white-ter" />
<div className="loader" />
</div>
</li>
);
};
<div
className="modal overlay is-active"
>
<div className="modal-background has-background-white-ter" />
<div className="loader" />
</div>
</li>
);
4 changes: 2 additions & 2 deletions src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Errors, Todo } from './types';
export const useGetTodos = (USER_ID: number, makeAnyChange: boolean) => {
const [isLoading, setIsLoading] = useState(true);
const [todos, setTodos] = useState<Todo[]>([]);
const [errorMessage, setErrorMessage] = useState<Errors>(Errors.noEroor);
const [errorMessage, setErrorMessage] = useState<Errors>(Errors.noError);

useEffect(() => {
async function fetchTodos() {
Expand All @@ -26,7 +26,7 @@ export const useGetTodos = (USER_ID: number, makeAnyChange: boolean) => {
useEffect(() => {
if (errorMessage) {
setTimeout(() => {
setErrorMessage(Errors.noEroor);
setErrorMessage(Errors.noError);
}, 3000);
}
}, [errorMessage]);
Expand Down
2 changes: 1 addition & 1 deletion src/types/Errors.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export enum Errors {
noEroor = '',
noError = '',
emptyTitle = "Title can't be empty",
delete = 'Unable to delete a todo',
add = 'Unable to add a todo',
Expand Down

0 comments on commit ea455e7

Please sign in to comment.