-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
79 lines (70 loc) · 2.07 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import {useTranslation} from 'react-i18next';
import {PlusCircle} from 'phosphor-react';
import {useTaskList} from './hooks/useTaskList';
import {Header} from './components/Header';
import {Input} from './components/Input';
import {ListHeader} from './components/List/ListHeader';
import {EmptyList} from './components/List/EmptyList';
import {Task} from './components/List/Task';
import styles from './App.module.css';
function App() {
const {t} = useTranslation();
const {
tasks,
newTaskName,
tasksLength,
tasksCompleted,
isEmptyList,
onToggleCheckTask,
onDeleteTask,
handleCreateNewTask,
handleChangeNewTaskName,
handleNewTaskNameInvalid,
} = useTaskList();
return (
<div className={styles.container}>
<Header />
<main className={styles.content}>
<form className={styles.formWrapper} onSubmit={handleCreateNewTask}>
<Input
placeholder={t('form.taskNameInput.placeholder')}
aria-label={t('form.taskNameInput.ariaLabel')}
value={newTaskName}
required
onChange={handleChangeNewTaskName}
onInvalid={handleNewTaskNameInvalid}
/>
<button
className={styles.createButton}
type="submit"
title={t('form.createButton.title')}
aria-label={t('form.createButton.ariaLabel')}
>
{t('form.createButton.text')} <PlusCircle size={18} />
</button>
</form>
<section>
<ListHeader
tasksLength={tasksLength}
tasksCompleted={tasksCompleted}
/>
{isEmptyList ? (
<EmptyList />
) : (
<ul className={styles.taskListWrapper}>
{tasks.map((task) => (
<Task
key={task.id}
task={task}
toggleCheckTask={onToggleCheckTask}
deleteTask={onDeleteTask}
/>
))}
</ul>
)}
</section>
</main>
</div>
);
}
export default App;