Skip to content

Commit

Permalink
#394: Aligned with newest API spec
Browse files Browse the repository at this point in the history
  • Loading branch information
tuj committed Jan 22, 2024
1 parent 4a0a3d9 commit c0556e8
Show file tree
Hide file tree
Showing 6 changed files with 1,385 additions and 690 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ json-server/

public/config.json
public/access-config.json
public/release.json
15 changes: 9 additions & 6 deletions src/components/activation-code/activation-code-list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,15 @@ function ActivationCodeList() {
const dispatch = useDispatch();

const refreshCallback = (id) => {
const item = items.filter((e) => e['@id'] === id);

if (item.length !== 1) {
return;
}

dispatch(
api.endpoints.postV1UserActivationCodesByIdRefreshCode.initiate({
id,
userActivationCodeEmptyDto: JSON.stringify({}),
api.endpoints.postV1UserActivationCodesRefresh.initiate({
userActivationCodeActivationCode: JSON.stringify({ activationCode: item[0].code }),
})
)
.then((response) => {
Expand All @@ -150,13 +155,11 @@ function ActivationCodeList() {
columns.push({
path: "@id",
dataFunction: (id) => {
const activationCodeId = idFromUrl(id);

return (
<Button
variant="primary"
className="refresh-activation-code"
onClick={() => refreshCallback(activationCodeId)}
onClick={() => refreshCallback(id)}
>
{t("refresh-button")}
</Button>
Expand Down
8 changes: 4 additions & 4 deletions src/components/users/users-list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import {
displayError,
} from "../util/list/toast-component/display-toast";
import {
useApiUsersIdremoveFromTenantMutation,
useApiV1UsersGetCollectionQuery,
useDeleteV1UsersByIdRemoveFromTenantMutation,
useGetV1UsersQuery,
} from "../../redux/api/api.generated";

/**
Expand Down Expand Up @@ -43,15 +43,15 @@ function UsersList() {

// Delete call
const [DeleteV1User, { isSuccess: isDeleteSuccess, error: isDeleteError }] =
useApiUsersIdremoveFromTenantMutation();
useDeleteV1UsersByIdRemoveFromTenantMutation();

// Get method
const {
data,
error: usersGetError,
isLoading,
refetch,
} = useApiV1UsersGetCollectionQuery({
} = useGetV1UsersQuery({
page,
order: { createdAt: "desc" },
fullName: searchText,
Expand Down
32 changes: 16 additions & 16 deletions src/redux/api/api.generated.js

Large diffs are not rendered by default.

121 changes: 54 additions & 67 deletions src/redux/api/api.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,17 @@ export const api = createApi({
query: (queryArg) => ({
url: `/v1/user-activation-codes/activate`,
method: "POST",
body: queryArg.userActivationCodeUserActivateInput,
body: queryArg.userActivationCodeActivationCode,
}),
}),
postV1UserActivationCodesRefresh: build.mutation<
PostV1UserActivationCodesRefreshApiResponse,
PostV1UserActivationCodesRefreshApiArg
>({
query: (queryArg) => ({
url: `/v1/user-activation-codes/refresh`,
method: "POST",
body: queryArg.userActivationCodeActivationCode,
}),
}),
getV1UserActivationCodesById: build.query<
Expand All @@ -733,20 +743,7 @@ export const api = createApi({
method: "DELETE",
}),
}),
postV1UserActivationCodesByIdRefreshCode: build.mutation<
PostV1UserActivationCodesByIdRefreshCodeApiResponse,
PostV1UserActivationCodesByIdRefreshCodeApiArg
>({
query: (queryArg) => ({
url: `/v1/user-activation-codes/${queryArg.id}/refresh-code`,
method: "POST",
body: queryArg.userActivationCodeEmptyDto,
}),
}),
apiV1UsersGetCollection: build.query<
ApiV1UsersGetCollectionApiResponse,
ApiV1UsersGetCollectionApiArg
>({
getV1Users: build.query<GetV1UsersApiResponse, GetV1UsersApiArg>({
query: (queryArg) => ({
url: `/v1/users`,
params: {
Expand All @@ -760,44 +757,41 @@ export const api = createApi({
},
}),
}),
apiV1UsersPost: build.mutation<
ApiV1UsersPostApiResponse,
ApiV1UsersPostApiArg
>({
postV1Users: build.mutation<PostV1UsersApiResponse, PostV1UsersApiArg>({
query: (queryArg) => ({
url: `/v1/users`,
method: "POST",
body: queryArg.userUserInput,
}),
}),
apiV1UsersIdGet: build.query<
ApiV1UsersIdGetApiResponse,
ApiV1UsersIdGetApiArg
getV1UsersById: build.query<
GetV1UsersByIdApiResponse,
GetV1UsersByIdApiArg
>({
query: (queryArg) => ({ url: `/v1/users/${queryArg.id}` }),
}),
apiV1UsersIdPut: build.mutation<
ApiV1UsersIdPutApiResponse,
ApiV1UsersIdPutApiArg
putV1UsersById: build.mutation<
PutV1UsersByIdApiResponse,
PutV1UsersByIdApiArg
>({
query: (queryArg) => ({
url: `/v1/users/${queryArg.id}`,
method: "PUT",
body: queryArg.userUserInput,
}),
}),
apiV1UsersIdDelete: build.mutation<
ApiV1UsersIdDeleteApiResponse,
ApiV1UsersIdDeleteApiArg
deleteV1UsersById: build.mutation<
DeleteV1UsersByIdApiResponse,
DeleteV1UsersByIdApiArg
>({
query: (queryArg) => ({
url: `/v1/users/${queryArg.id}`,
method: "DELETE",
}),
}),
apiUsersIdremoveFromTenant: build.mutation<
ApiUsersIdremoveFromTenantApiResponse,
ApiUsersIdremoveFromTenantApiArg
deleteV1UsersByIdRemoveFromTenant: build.mutation<
DeleteV1UsersByIdRemoveFromTenantApiResponse,
DeleteV1UsersByIdRemoveFromTenantApiArg
>({
query: (queryArg) => ({
url: `/v1/users/${queryArg.id}/remove-from-tenant`,
Expand Down Expand Up @@ -1360,31 +1354,28 @@ export type PostV1UserActivationCodesApiArg = {
export type PostV1UserActivationCodesActivateApiResponse = unknown;
export type PostV1UserActivationCodesActivateApiArg = {
/** The new UserActivationCode resource */
userActivationCodeUserActivateInput: UserActivationCodeUserActivateInput;
userActivationCodeActivationCode: UserActivationCodeActivationCode;
};
export type PostV1UserActivationCodesRefreshApiResponse = unknown;
export type PostV1UserActivationCodesRefreshApiArg = {
/** The new UserActivationCode resource */
userActivationCodeActivationCode: UserActivationCodeActivationCode;
};
export type GetV1UserActivationCodesByIdApiResponse = unknown;
export type GetV1UserActivationCodesByIdApiArg = {
/** UserActivationCodeOutput identifier */
/** UserActivationCode identifier */
id: string;
};
export type DeleteV1UserActivationCodesByIdApiResponse = unknown;
export type DeleteV1UserActivationCodesByIdApiArg = {
/** UserActivationCode identifier */
id: string;
};
export type PostV1UserActivationCodesByIdRefreshCodeApiResponse = unknown;
export type PostV1UserActivationCodesByIdRefreshCodeApiArg = {
/** UserActivationCode identifier */
id: string;
/** The new UserActivationCode resource */
userActivationCodeEmptyDto: UserActivationCodeEmptyDto;
};
export type ApiV1UsersGetCollectionApiResponse = unknown;
export type ApiV1UsersGetCollectionApiArg = {
/** The collection page number */
export type GetV1UsersApiResponse = unknown;
export type GetV1UsersApiArg = {
page?: number;
/** The number of items per page */
itemsPerPage?: number;
itemsPerPage?: string;
fullName?: string;
email?: string;
createdBy?: {
Expand All @@ -1397,31 +1388,28 @@ export type ApiV1UsersGetCollectionApiArg = {
createdAt?: "asc" | "desc";
};
};
export type ApiV1UsersPostApiResponse = unknown;
export type ApiV1UsersPostApiArg = {
export type PostV1UsersApiResponse = unknown;
export type PostV1UsersApiArg = {
id: string;
/** The new User resource */
userUserInput: UserUserInput;
};
export type ApiV1UsersIdGetApiResponse = unknown;
export type ApiV1UsersIdGetApiArg = {
/** UserOutput identifier */
export type GetV1UsersByIdApiResponse = unknown;
export type GetV1UsersByIdApiArg = {
id: string;
};
export type ApiV1UsersIdPutApiResponse = unknown;
export type ApiV1UsersIdPutApiArg = {
/** User identifier */
export type PutV1UsersByIdApiResponse = unknown;
export type PutV1UsersByIdApiArg = {
id: string;
/** The updated User resource */
userUserInput: UserUserInput;
};
export type ApiV1UsersIdDeleteApiResponse = unknown;
export type ApiV1UsersIdDeleteApiArg = {
/** User identifier */
export type DeleteV1UsersByIdApiResponse = unknown;
export type DeleteV1UsersByIdApiArg = {
id: string;
};
export type ApiUsersIdremoveFromTenantApiResponse = unknown;
export type ApiUsersIdremoveFromTenantApiArg = {
/** User identifier */
export type DeleteV1UsersByIdRemoveFromTenantApiResponse = unknown;
export type DeleteV1UsersByIdRemoveFromTenantApiArg = {
id: string;
};
export type Token = {
Expand Down Expand Up @@ -1501,10 +1489,9 @@ export type UserActivationCodeUserActivationCodeInput = {
displayName?: string;
roles?: string[];
};
export type UserActivationCodeUserActivateInput = {
export type UserActivationCodeActivationCode = {
activationCode?: string;
};
export type UserActivationCodeEmptyDto = object;
export type UserUserInput = {
fullName?: any;
};
Expand Down Expand Up @@ -1581,14 +1568,14 @@ export const {
useGetV1UserActivationCodesQuery,
usePostV1UserActivationCodesMutation,
usePostV1UserActivationCodesActivateMutation,
usePostV1UserActivationCodesRefreshMutation,
useGetV1UserActivationCodesByIdQuery,
useDeleteV1UserActivationCodesByIdMutation,
usePostV1UserActivationCodesByIdRefreshCodeMutation,
useApiV1UsersGetCollectionQuery,
useApiV1UsersPostMutation,
useApiV1UsersIdGetQuery,
useApiV1UsersIdPutMutation,
useApiV1UsersIdDeleteMutation,
useApiUsersIdremoveFromTenantMutation,
useGetV1UsersQuery,
usePostV1UsersMutation,
useGetV1UsersByIdQuery,
usePutV1UsersByIdMutation,
useDeleteV1UsersByIdMutation,
useDeleteV1UsersByIdRemoveFromTenantMutation,
} = api;

Loading

0 comments on commit c0556e8

Please sign in to comment.