- Photos -
-{hello.data.greeting}
:Loading..
} -{JSON.stringify(getAll.data, null, 2)}-
{hello.data.greeting}
:Loading..
} -{JSON.stringify(getAll.data, null, 2)}-
+ A list of all Todos added by everyone. +
++ Description + | ++ Creator + | ++ Last Updated + | ++ Status + | ++ Actions + | +
---|---|---|---|---|
+ {todo.id === currentlyEditingTodo ? ( + + ) : ( + todo.text + )} + | ++ {todo.user.name} + | ++ {todo.updatedAt.toLocaleString('en-US', { + dateStyle: 'long', + timeStyle: 'medium', + })} + | ++ { + todoUpdateMutation.mutate({ + id: todo.id, + status: + todo.status === 'COMPLETE' + ? 'INCOMPLETE' + : 'COMPLETE', + }); + }} + /> + | ++ {data?.user?.id === todo.userId && ( + <> + {currentlyEditingTodo === todo.id ? ( + { + setCurrentlyEditingTodo(null); + }}> + Cancel + + ) : ( + { + setCurrentlyEditingTodo(todo.id); + }}> + Edit + + )} + { + const confirmDelete = window.confirm( + 'Are you sure you want to delete this Todo?', + ); + + if (!confirmDelete) { + return; + } + + todoDeleteMutation.mutate({ + id: todo.id, + }); + }}> + Delete + + > + )} + | +