-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
228 additions
and
144 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { type EndpointBuilder } from "@reduxjs/toolkit/query/react" | ||
|
||
import { | ||
buildUrl, | ||
tagData, | ||
type ListArg, | ||
type ListResult, | ||
} from "../../utils/api" | ||
import type { AuthFactor } from "../models" | ||
import { type TagTypes } from "../tagTypes" | ||
import urls from "../urls" | ||
|
||
export const AUTH_FACTOR_TAG: TagTypes = "AuthFactor" | ||
|
||
export type ListAuthFactorsResult = ListResult<AuthFactor, "type"> | ||
export type ListAuthFactorsArg = ListArg | ||
|
||
export default function getReadAuthFactorEndpoints( | ||
build: EndpointBuilder<any, any, any>, | ||
) { | ||
return { | ||
listAuthFactors: build.query<ListAuthFactorsResult, ListAuthFactorsArg>({ | ||
query: search => ({ | ||
url: buildUrl(urls.authFactor.list, { search }), | ||
method: "GET", | ||
}), | ||
providesTags: tagData(AUTH_FACTOR_TAG), | ||
}), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import getReadAuthFactorEndpoints, { | ||
type ListAuthFactorsArg, | ||
type ListAuthFactorsResult, | ||
AUTH_FACTOR_TAG, | ||
} from "./authFactor" | ||
import getReadClassEndpoints, { | ||
type ListClassesArg, | ||
type ListClassesResult, | ||
type RetrieveClassArg, | ||
type RetrieveClassResult, | ||
CLASS_TAG, | ||
} from "./klass" | ||
import getReadSchoolEndpoints, { | ||
type RetrieveSchoolArg, | ||
type RetrieveSchoolResult, | ||
SCHOOL_TAG, | ||
} from "./school" | ||
import getReadUserEndpoints, { | ||
type ListUsersArg, | ||
type ListUsersResult, | ||
type RetrieveUserArg, | ||
type RetrieveUserResult, | ||
USER_TAG, | ||
} from "./user" | ||
|
||
export { | ||
AUTH_FACTOR_TAG, | ||
CLASS_TAG, | ||
getReadAuthFactorEndpoints, | ||
getReadClassEndpoints, | ||
getReadSchoolEndpoints, | ||
getReadUserEndpoints, | ||
SCHOOL_TAG, | ||
USER_TAG, | ||
type ListAuthFactorsArg, | ||
type ListAuthFactorsResult, | ||
type ListClassesArg, | ||
type ListClassesResult, | ||
type ListUsersArg, | ||
type ListUsersResult, | ||
type RetrieveClassArg, | ||
type RetrieveClassResult, | ||
type RetrieveSchoolArg, | ||
type RetrieveSchoolResult, | ||
type RetrieveUserArg, | ||
type RetrieveUserResult, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { type EndpointBuilder } from "@reduxjs/toolkit/query/react" | ||
|
||
import { | ||
buildUrl, | ||
tagData, | ||
type ListArg, | ||
type ListResult, | ||
type RetrieveArg, | ||
type RetrieveResult, | ||
} from "../../utils/api" | ||
import type { Class } from "../models" | ||
import { type TagTypes } from "../tagTypes" | ||
import urls from "../urls" | ||
|
||
export const CLASS_TAG: TagTypes = "Class" | ||
|
||
export type RetrieveClassResult = RetrieveResult< | ||
Class, | ||
| "name" | ||
| "read_classmates_data" | ||
| "receive_requests_until" | ||
| "school" | ||
| "teacher" | ||
> | ||
export type RetrieveClassArg = RetrieveArg<Class> | ||
|
||
export type ListClassesResult = ListResult< | ||
Class, | ||
| "name" | ||
| "read_classmates_data" | ||
| "receive_requests_until" | ||
| "school" | ||
| "teacher" | ||
> | ||
export type ListClassesArg = ListArg | ||
|
||
export default function getReadClassEndpoints( | ||
build: EndpointBuilder<any, any, any>, | ||
) { | ||
return { | ||
retrieveClass: build.query<RetrieveClassResult, RetrieveClassArg>({ | ||
query: id => ({ | ||
url: buildUrl(urls.class.detail, { url: { id } }), | ||
method: "GET", | ||
}), | ||
providesTags: tagData(CLASS_TAG), | ||
}), | ||
listClasses: build.query<ListClassesResult, ListClassesArg>({ | ||
query: search => ({ | ||
url: buildUrl(urls.class.list, { search }), | ||
method: "GET", | ||
}), | ||
providesTags: tagData(CLASS_TAG), | ||
}), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { type EndpointBuilder } from "@reduxjs/toolkit/query/react" | ||
|
||
import { | ||
buildUrl, | ||
tagData, | ||
type RetrieveArg, | ||
type RetrieveResult, | ||
} from "../../utils/api" | ||
import type { School } from "../models" | ||
import { type TagTypes } from "../tagTypes" | ||
import urls from "../urls" | ||
|
||
export const SCHOOL_TAG: TagTypes = "School" | ||
|
||
export type RetrieveSchoolResult = RetrieveResult< | ||
School, | ||
"name" | "country" | "uk_county" | ||
> | ||
export type RetrieveSchoolArg = RetrieveArg<School> | ||
|
||
export default function getReadSchoolEndpoints( | ||
build: EndpointBuilder<any, any, any>, | ||
) { | ||
return { | ||
retrieveSchool: build.query<RetrieveSchoolResult, RetrieveSchoolArg>({ | ||
query: id => ({ | ||
url: buildUrl(urls.school.detail, { url: { id } }), | ||
method: "GET", | ||
}), | ||
providesTags: tagData(SCHOOL_TAG), | ||
}), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { type EndpointBuilder } from "@reduxjs/toolkit/query/react" | ||
|
||
import { | ||
buildUrl, | ||
tagData, | ||
type ListArg, | ||
type ListResult, | ||
type RetrieveArg, | ||
type RetrieveResult, | ||
} from "../../utils/api" | ||
import type { User } from "../models" | ||
import { type TagTypes } from "../tagTypes" | ||
import urls from "../urls" | ||
|
||
export const USER_TAG: TagTypes = "User" | ||
|
||
export type RetrieveUserResult = RetrieveResult< | ||
User, | ||
| "first_name" | ||
| "last_name" | ||
| "email" | ||
| "is_active" | ||
| "date_joined" | ||
| "requesting_to_join_class" | ||
| "student" | ||
| "teacher" | ||
> | ||
export type RetrieveUserArg = RetrieveArg<User> | ||
|
||
export type ListUsersResult = ListResult< | ||
User, | ||
| "first_name" | ||
| "last_name" | ||
| "email" | ||
| "is_active" | ||
| "date_joined" | ||
| "requesting_to_join_class" | ||
| "student" | ||
| "teacher" | ||
> | ||
export type ListUsersArg = ListArg<{ students_in_class: string }> | ||
|
||
export default function getReadUserEndpoints( | ||
build: EndpointBuilder<any, any, any>, | ||
) { | ||
return { | ||
retrieveUser: build.query<RetrieveUserResult, RetrieveUserArg>({ | ||
query: id => ({ | ||
url: buildUrl(urls.user.detail, { url: { id } }), | ||
method: "GET", | ||
}), | ||
providesTags: tagData(USER_TAG), | ||
}), | ||
listUsers: build.query<ListUsersResult, ListUsersArg>({ | ||
query: search => ({ | ||
url: buildUrl(urls.user.list, { search }), | ||
method: "GET", | ||
}), | ||
providesTags: tagData(USER_TAG), | ||
}), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters