|
@@ -1,16 +1,13 @@
|
|
|
-import { GroupType } from '@growi/core';
|
|
|
|
|
-
|
|
|
|
|
import {
|
|
import {
|
|
|
useSWRxAncestorExternalUserGroups,
|
|
useSWRxAncestorExternalUserGroups,
|
|
|
useSWRxChildExternalUserGroupList,
|
|
useSWRxChildExternalUserGroupList,
|
|
|
useSWRxExternalUserGroup,
|
|
useSWRxExternalUserGroup,
|
|
|
useSWRxExternalUserGroupRelationList,
|
|
useSWRxExternalUserGroupRelationList,
|
|
|
useSWRxExternalUserGroupRelations,
|
|
useSWRxExternalUserGroupRelations,
|
|
|
- useSWRxMyExternalUserGroups,
|
|
|
|
|
} from '~/features/external-user-group/client/stores/external-user-group';
|
|
} from '~/features/external-user-group/client/stores/external-user-group';
|
|
|
import {
|
|
import {
|
|
|
useSWRxAncestorUserGroups,
|
|
useSWRxAncestorUserGroups,
|
|
|
- useSWRxChildUserGroupList, useSWRxMyUserGroups, useSWRxUserGroup, useSWRxUserGroupRelationList, useSWRxUserGroupRelations,
|
|
|
|
|
|
|
+ useSWRxChildUserGroupList, useSWRxUserGroup, useSWRxUserGroupRelationList, useSWRxUserGroupRelations,
|
|
|
} from '~/stores/user-group';
|
|
} from '~/stores/user-group';
|
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
@@ -51,37 +48,3 @@ export const useAncestorUserGroups = (userGroupId: string, isExternalGroup: bool
|
|
|
const externalUserGroupRes = useSWRxAncestorExternalUserGroups(isExternalGroup ? userGroupId : null);
|
|
const externalUserGroupRes = useSWRxAncestorExternalUserGroups(isExternalGroup ? userGroupId : null);
|
|
|
return isExternalGroup ? externalUserGroupRes : userGroupRes;
|
|
return isExternalGroup ? externalUserGroupRes : userGroupRes;
|
|
|
};
|
|
};
|
|
|
-
|
|
|
|
|
-// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
|
|
|
-export const useMyUserGroups = (shouldFetch: boolean) => {
|
|
|
|
|
- const { data: myUserGroups, mutate: mutateMyUserGroups } = useSWRxMyUserGroups(shouldFetch);
|
|
|
|
|
- const { data: myExternalUserGroups, mutate: mutateMyExternalUserGroups } = useSWRxMyExternalUserGroups(shouldFetch);
|
|
|
|
|
-
|
|
|
|
|
- const update = () => {
|
|
|
|
|
- mutateMyUserGroups();
|
|
|
|
|
- mutateMyExternalUserGroups();
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- if (myUserGroups == null || myExternalUserGroups == null) {
|
|
|
|
|
- return { data: null, update };
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- const myUserGroupsData = myUserGroups
|
|
|
|
|
- .map((group) => {
|
|
|
|
|
- return {
|
|
|
|
|
- item: group,
|
|
|
|
|
- type: GroupType.userGroup,
|
|
|
|
|
- };
|
|
|
|
|
- });
|
|
|
|
|
- const myExternalUserGroupsData = myExternalUserGroups
|
|
|
|
|
- .map((group) => {
|
|
|
|
|
- return {
|
|
|
|
|
- item: group,
|
|
|
|
|
- type: GroupType.externalUserGroup,
|
|
|
|
|
- };
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- const data = [...myUserGroupsData, ...myExternalUserGroupsData];
|
|
|
|
|
-
|
|
|
|
|
- return { data, update };
|
|
|
|
|
-};
|
|
|