Skip to content

Commit

Permalink
feat: loading network calls (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasprima authored Mar 21, 2024
1 parent 8fa33c7 commit 01886ad
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/features/todos/TodoList.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ const TodoList = () => {
const [ addTodo ] = useAddTodoMutation()
const [ doneTodo ] = useDoneTodoMutation()
const [ deleteTodo ] = useDeleteTodoMutation()
const [ reorderTodo ] = useReorderTodoMutation()
const [ resetTodo ] = useResetTodoMutation()
const [ reorderTodo, { isLoading: reorderTodoLoading } ] = useReorderTodoMutation()
const [ resetTodo, { isLoading: resetTodoLoading } ] = useResetTodoMutation()


// Effect to load todos from local storage if there is cache
Expand Down Expand Up @@ -133,7 +133,7 @@ const TodoList = () => {
}

let content;
if (isLoading) {
if (isLoading || reorderTodoLoading || resetTodoLoading) {
content = <Loader />
} else if (isSuccess){
let sortedTodos = todos;
Expand Down Expand Up @@ -190,6 +190,9 @@ const TodoList = () => {
handleSubmit={handleSubmit}
/>
</div>
<div className="infos">
<span className="ps">Because the backend is hosted on a free cloud provider, the request may take a while.</span>
</div>
</main>
)
}
Expand Down
18 changes: 18 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -285,4 +285,22 @@ input:checked + .slider:before {
display: flex;
justify-content: center;
align-items: center;
}

.infos{
position: fixed;
margin-top: 1rem;
bottom: 0;
display: flex;
justify-content: center;
align-items: center;
width: 600px;
}

.ps {
justify-content: center;
margin-left: 1rem;
align-items: center;
width: 600px;
font-size: 15px;
}

0 comments on commit 01886ad

Please sign in to comment.