Updated with more secure modelling on backend

This commit is contained in:
2021-11-20 01:28:53 +01:00
parent 4f3b19891a
commit bb99f99a22
11 changed files with 151 additions and 230 deletions

View File

@@ -23,6 +23,22 @@ export const todosApi = createApi({
: [],
}),
getActiveTodos: build.query<Todo[], void>({
query: () => ({
url: `api/todos`,
params: {
onlyActive: true,
},
}),
providesTags: (result) =>
result
? [
...result.map(({ id }) => ({ type: "todo" as const, id })),
{ type: "todo", id: "LIST" },
]
: [],
}),
createTodo: build.mutation<string, Partial<Todo>>({
query(body) {
return {

View File

@@ -6,7 +6,7 @@ import { todosApi } from "@src/infrastructure/apis/todosApi";
import { AddTodo } from "@src/components/todos/addTodo";
const HomePage = () => {
const { data, isLoading } = todosApi.useGetAllTodosQuery();
const { data, isLoading } = todosApi.useGetActiveTodosQuery();
if (isLoading) {
return "loading...";