|
|
@@ -2,8 +2,12 @@ import { SWRResponse } from 'swr';
|
|
|
import useSWRImmutable from 'swr/immutable';
|
|
|
|
|
|
import { apiv3Get } from '~/client/util/apiv3-client';
|
|
|
+
|
|
|
+import { IPageHasId } from '~/interfaces/page';
|
|
|
import { IUserGroupHasId, IUserGroupRelationHasId } from '~/interfaces/user';
|
|
|
-import { UserGroupListResult, ChildUserGroupListResult, UserGroupRelationListResult } from '~/interfaces/user-group-response';
|
|
|
+import {
|
|
|
+ UserGroupListResult, ChildUserGroupListResult, UserGroupRelationListResult, UserGroupPagesResult,
|
|
|
+} from '~/interfaces/user-group-response';
|
|
|
|
|
|
|
|
|
export const useSWRxUserGroupList = (initialData?: IUserGroupHasId[]): SWRResponse<IUserGroupHasId[], Error> => {
|
|
|
@@ -43,3 +47,10 @@ export const useSWRxUserGroupRelationList = (
|
|
|
},
|
|
|
);
|
|
|
};
|
|
|
+
|
|
|
+export const useSWRxUserGroupPages = (groupId: string | undefined, limit: number, offset: number): SWRResponse<IPageHasId[], Error> => {
|
|
|
+ return useSWRImmutable(
|
|
|
+ groupId != null ? [`/user-groups/${groupId}/pages`, { limit, offset }] : null,
|
|
|
+ endpoint => apiv3Get<UserGroupPagesResult>(endpoint).then(result => result.data.userGroupPages),
|
|
|
+ );
|
|
|
+};
|