diff --git a/src/api/authFactor.ts b/src/api/authFactor.ts index f4bc253..6b61264 100644 --- a/src/api/authFactor.ts +++ b/src/api/authFactor.ts @@ -1,4 +1,8 @@ -import { urls, type AuthFactor } from "codeforlife/api" +import { + getReadAuthFactorEndpoints, + urls, + type AuthFactor, +} from "codeforlife/api" import { buildUrl, tagData, @@ -6,14 +10,13 @@ import { type CreateResult, type DestroyArg, type DestroyResult, - type ListArg, - type ListResult, } from "codeforlife/utils/api" import api from "." const authFactorApi = api.injectEndpoints({ endpoints: build => ({ + ...getReadAuthFactorEndpoints(build), createAuthFactor: build.mutation< CreateResult, CreateArg @@ -31,13 +34,6 @@ const authFactorApi = api.injectEndpoints({ }), invalidatesTags: tagData("AuthFactor"), }), - listAuthFactors: build.query, ListArg>({ - query: search => ({ - url: buildUrl(urls.authFactor.list, { search }), - method: "GET", - }), - providesTags: tagData("AuthFactor"), - }), }), }) diff --git a/src/api/klass.ts b/src/api/klass.ts index 71f980c..2b2428a 100644 --- a/src/api/klass.ts +++ b/src/api/klass.ts @@ -1,4 +1,4 @@ -import { urls, type Class } from "codeforlife/api" +import { getReadClassEndpoints, urls, type Class } from "codeforlife/api" import { buildUrl, tagData, @@ -6,10 +6,6 @@ import { type CreateResult, type DestroyArg, type DestroyResult, - type ListArg, - type ListResult, - type RetrieveArg, - type RetrieveResult, type UpdateArg, type UpdateResult, } from "codeforlife/utils/api" @@ -18,6 +14,7 @@ import api from "." const classApi = api.injectEndpoints({ endpoints: build => ({ + ...getReadClassEndpoints(build), createClass: build.mutation< CreateResult, CreateArg< @@ -54,40 +51,6 @@ const classApi = api.injectEndpoints({ }), invalidatesTags: tagData("Class"), }), - retrieveClass: build.query< - RetrieveResult< - Class, - | "name" - | "read_classmates_data" - | "receive_requests_until" - | "school" - | "teacher" - >, - RetrieveArg - >({ - query: id => ({ - url: buildUrl(urls.class.detail, { url: { id } }), - method: "GET", - }), - providesTags: tagData("Class"), - }), - listClasses: build.query< - ListResult< - Class, - | "name" - | "read_classmates_data" - | "receive_requests_until" - | "school" - | "teacher" - >, - ListArg - >({ - query: search => ({ - url: buildUrl(urls.class.list, { search }), - method: "GET", - }), - providesTags: tagData("Class"), - }), }), }) diff --git a/src/api/school.ts b/src/api/school.ts index 67dd433..87e8ac2 100644 --- a/src/api/school.ts +++ b/src/api/school.ts @@ -1,11 +1,9 @@ -import { urls, type School } from "codeforlife/api" +import { getReadSchoolEndpoints, urls, type School } from "codeforlife/api" import { buildUrl, tagData, type CreateArg, type CreateResult, - type RetrieveArg, - type RetrieveResult, type UpdateArg, type UpdateResult, } from "codeforlife/utils/api" @@ -14,16 +12,7 @@ import api from "." const schoolApi = api.injectEndpoints({ endpoints: build => ({ - retrieveSchool: build.query< - RetrieveResult, - RetrieveArg - >({ - query: id => ({ - url: buildUrl(urls.school.detail, { url: { id } }), - method: "GET", - }), - providesTags: tagData("School"), - }), + ...getReadSchoolEndpoints(build), createSchool: build.mutation< CreateResult, CreateArg diff --git a/src/api/user.ts b/src/api/user.ts index e64f1c9..9a946b5 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -1,4 +1,4 @@ -import { urls, type User } from "codeforlife/api" +import { getReadUserEndpoints, urls, type User } from "codeforlife/api" import { buildUrl, tagData, @@ -7,10 +7,6 @@ import { type CreateResult, type DestroyArg, type DestroyResult, - type ListArg, - type ListResult, - type RetrieveArg, - type RetrieveResult, type UpdateArg, type UpdateResult, } from "codeforlife/utils/api" @@ -19,6 +15,7 @@ import api from "." const userApi = api.injectEndpoints({ endpoints: build => ({ + ...getReadUserEndpoints(build), handleJoinClassRequest: build.mutation< UpdateResult, UpdateArg @@ -101,46 +98,6 @@ const userApi = api.injectEndpoints({ body, }), }), - retrieveUser: build.query< - RetrieveResult< - User, - | "first_name" - | "last_name" - | "email" - | "is_active" - | "date_joined" - | "requesting_to_join_class" - | "student" - | "teacher" - >, - RetrieveArg - >({ - query: id => ({ - url: buildUrl(urls.user.detail, { url: { id } }), - method: "GET", - }), - providesTags: tagData("User"), - }), - listUsers: build.query< - ListResult< - User, - | "first_name" - | "last_name" - | "email" - | "is_active" - | "date_joined" - | "requesting_to_join_class" - | "student" - | "teacher" - >, - ListArg<{ students_in_class: string }> - >({ - query: search => ({ - url: buildUrl(urls.user.list, { search }), - method: "GET", - }), - providesTags: tagData("User"), - }), }), })