Skip to content

Commit

Permalink
items left message was fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
misha-shevchuk committed Sep 21, 2023
1 parent 7312d0d commit 66913f6
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,19 @@ export const App: React.FC = () => {
});
};

function getItemsLeftCountMessage() {
switch (activeTodos.length) {
case 1:
return '1 item left';

case 0:
return 'Everything is done';

default:
return `${activeTodos.length} items left`;
}
}

if (!USER_ID) {
return <UserWarning />;
}
Expand Down Expand Up @@ -224,7 +237,7 @@ export const App: React.FC = () => {

<footer className="todoapp__footer">
<span className="todo-count">
{`${activeTodos.length} items left`}
{getItemsLeftCountMessage()}
</span>

<TodoStatus
Expand Down

0 comments on commit 66913f6

Please sign in to comment.