|
@@ -4,6 +4,7 @@ import useSWR from 'swr';
|
|
|
import useSWRImmutable from 'swr/immutable';
|
|
import useSWRImmutable from 'swr/immutable';
|
|
|
|
|
|
|
|
import { apiv3Get } from '~/client/util/apiv3-client';
|
|
import { apiv3Get } from '~/client/util/apiv3-client';
|
|
|
|
|
+import type { PopulatedGrantedGroup } from '~/interfaces/page-grant';
|
|
|
import { checkAndUpdateImageUrlCached } from '~/stores/middlewares/user';
|
|
import { checkAndUpdateImageUrlCached } from '~/stores/middlewares/user';
|
|
|
|
|
|
|
|
export const useSWRxUsersList = (userIds: string[]): SWRResponse<IUserHasId[], Error> => {
|
|
export const useSWRxUsersList = (userIds: string[]): SWRResponse<IUserHasId[], Error> => {
|
|
@@ -49,3 +50,14 @@ export const useSWRxUsernames = (q: string, offset?: number, limit?: number, opt
|
|
|
}).then(result => result.data),
|
|
}).then(result => result.data),
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|
|
|
|
|
+
|
|
|
|
|
+type RelatedGroupsResponse = {
|
|
|
|
|
+ relatedGroups: PopulatedGrantedGroup[]
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+export const useSWRxUserRelatedGroups = (): SWRResponse<RelatedGroupsResponse, Error> => {
|
|
|
|
|
+ return useSWRImmutable<RelatedGroupsResponse>(
|
|
|
|
|
+ ['/user/related-groups'],
|
|
|
|
|
+ ([endpoint]) => apiv3Get(endpoint).then(response => response.data),
|
|
|
|
|
+ );
|
|
|
|
|
+};
|