mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-31 09:05:30 +08:00
### What problem does this PR solve? feat: Bind data to TenantTable #2846 feat: Add TenantTable ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
68
web/src/pages/user-setting/setting-team/hooks.ts
Normal file
68
web/src/pages/user-setting/setting-team/hooks.ts
Normal file
@ -0,0 +1,68 @@
|
||||
import { useSetModalState, useShowDeleteConfirm } from '@/hooks/common-hooks';
|
||||
import {
|
||||
useAddTenantUser,
|
||||
useAgreeTenant,
|
||||
useDeleteTenantUser,
|
||||
useFetchUserInfo,
|
||||
} from '@/hooks/user-setting-hooks';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
export const useAddUser = () => {
|
||||
const { addTenantUser } = useAddTenantUser();
|
||||
const {
|
||||
visible: addingTenantModalVisible,
|
||||
hideModal: hideAddingTenantModal,
|
||||
showModal: showAddingTenantModal,
|
||||
} = useSetModalState();
|
||||
|
||||
const handleAddUserOk = useCallback(
|
||||
async (email: string) => {
|
||||
const retcode = await addTenantUser(email);
|
||||
if (retcode === 0) {
|
||||
hideAddingTenantModal();
|
||||
}
|
||||
},
|
||||
[addTenantUser, hideAddingTenantModal],
|
||||
);
|
||||
|
||||
return {
|
||||
addingTenantModalVisible,
|
||||
hideAddingTenantModal,
|
||||
showAddingTenantModal,
|
||||
handleAddUserOk,
|
||||
};
|
||||
};
|
||||
|
||||
export const useHandleDeleteUser = () => {
|
||||
const { deleteTenantUser, loading } = useDeleteTenantUser();
|
||||
const showDeleteConfirm = useShowDeleteConfirm();
|
||||
|
||||
const handleDeleteTenantUser = (userId: string) => () => {
|
||||
showDeleteConfirm({
|
||||
onOk: async () => {
|
||||
const retcode = await deleteTenantUser({ userId });
|
||||
if (retcode === 0) {
|
||||
}
|
||||
return;
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
return { handleDeleteTenantUser, loading };
|
||||
};
|
||||
|
||||
export const useHandleAgreeTenant = () => {
|
||||
const { agreeTenant } = useAgreeTenant();
|
||||
const { deleteTenantUser } = useDeleteTenantUser();
|
||||
const { data: user } = useFetchUserInfo();
|
||||
|
||||
const handleAgree = (tenantId: string, isAgree: boolean) => () => {
|
||||
if (isAgree) {
|
||||
agreeTenant(tenantId);
|
||||
} else {
|
||||
deleteTenantUser({ tenantId, userId: user.id });
|
||||
}
|
||||
};
|
||||
|
||||
return { handleAgree };
|
||||
};
|
||||
Reference in New Issue
Block a user