pref: member/org/gourp list (#4295)
* refactor: org api * refactor: org api * pref: member/org/group list * feat: change group owner api * fix: manage org member * pref: member search
This commit is contained in:
@@ -105,6 +105,7 @@ export const GetSearchUserGroupOrg = (
|
||||
orgs?: boolean;
|
||||
groups?: boolean;
|
||||
}
|
||||
) => GET<SearchResult>('/proApi/support/user/search', { searchKey, ...options });
|
||||
) =>
|
||||
GET<SearchResult>('/proApi/support/user/search', { searchKey, ...options }, { maxQuantity: 1 });
|
||||
|
||||
export const ExportMembers = () => GET<{ csv: string }>('/proApi/support/user/team/member/export');
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { DELETE, GET, POST, PUT } from '@/web/common/api/request';
|
||||
import type { MemberGroupListType } from '@fastgpt/global/support/permission/memberGroup/type';
|
||||
import type {
|
||||
GroupMemberItemType,
|
||||
MemberGroupListType
|
||||
} from '@fastgpt/global/support/permission/memberGroup/type';
|
||||
import type {
|
||||
postCreateGroupData,
|
||||
putUpdateGroupData
|
||||
@@ -15,3 +18,9 @@ export const deleteGroup = (groupId: string) =>
|
||||
|
||||
export const putUpdateGroup = (data: putUpdateGroupData) =>
|
||||
PUT('/proApi/support/user/team/group/update', data);
|
||||
|
||||
export const getGroupMembers = (groupId: string) =>
|
||||
GET<GroupMemberItemType[]>(`/proApi/support/user/team/group/members`, { groupId });
|
||||
|
||||
export const putGroupChangeOwner = (groupId: string, tmbId: string) =>
|
||||
PUT(`/proApi/support/user/team/group/changeOwner`, { groupId, tmbId });
|
||||
|
||||
@@ -6,8 +6,11 @@ import type {
|
||||
} from '@fastgpt/global/support/user/team/org/api';
|
||||
import type { OrgType } from '@fastgpt/global/support/user/team/org/type';
|
||||
import type { putMoveOrgType } from '@fastgpt/global/support/user/team/org/api';
|
||||
import { PaginationProps, PaginationResponse } from '@fastgpt/web/common/fetch/type';
|
||||
import { TeamMemberItemType } from '@fastgpt/global/support/user/team/type';
|
||||
|
||||
export const getOrgList = () => GET<OrgType[]>('/proApi/support/user/team/org/list');
|
||||
export const getOrgList = (path: string) =>
|
||||
GET<OrgType[]>(`/proApi/support/user/team/org/list`, { orgPath: path });
|
||||
|
||||
export const postCreateOrg = (data: postCreateOrgData) =>
|
||||
POST('/proApi/support/user/team/org/create', data);
|
||||
@@ -28,3 +31,6 @@ export const putUpdateOrgMembers = (data: putUpdateOrgMembersData) =>
|
||||
|
||||
// export const putChnageOrgOwner = (data: putChnageOrgOwnerData) =>
|
||||
// PUT('/proApi/support/user/team/org/changeOwner', data);
|
||||
|
||||
export const getOrgMembers = (data: PaginationProps<{ orgId: string }>) =>
|
||||
GET<PaginationResponse<TeamMemberItemType>>(`/proApi/support/user/team/org/members`, data);
|
||||
|
||||
@@ -32,8 +32,6 @@ type State = {
|
||||
loadAndGetGroups: (init?: boolean) => Promise<MemberGroupListType>;
|
||||
|
||||
teamOrgs: OrgType[];
|
||||
myOrgs: OrgType[];
|
||||
loadAndGetOrgs: (init?: boolean) => Promise<OrgType[]>;
|
||||
};
|
||||
|
||||
export const useUserStore = create<State>()(
|
||||
@@ -122,23 +120,6 @@ export const useUserStore = create<State>()(
|
||||
);
|
||||
});
|
||||
|
||||
return res;
|
||||
},
|
||||
myOrgs: [],
|
||||
loadAndGetOrgs: async (init = false) => {
|
||||
if (!useSystemStore.getState()?.feConfigs?.isPlus) return [];
|
||||
|
||||
const randomRefresh = Math.random() > 0.7;
|
||||
if (!randomRefresh && !init && get().myOrgs.length) return Promise.resolve(get().myOrgs);
|
||||
|
||||
const res = await getOrgList();
|
||||
set((state) => {
|
||||
state.teamOrgs = res;
|
||||
state.myOrgs = res.filter((item) =>
|
||||
item.members.map((i) => String(i.tmbId)).includes(String(state.userInfo?.team?.tmbId))
|
||||
);
|
||||
});
|
||||
|
||||
return res;
|
||||
}
|
||||
})),
|
||||
|
||||
Reference in New Issue
Block a user