Skip to content

Commit

Permalink
Feat: Quit from jointed team #3759 (#3797)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

Feat: Quit from jointed team #3759

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
  • Loading branch information
cike8899 authored Dec 2, 2024
1 parent 8fba5c4 commit 976d112
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 2 deletions.
2 changes: 2 additions & 0 deletions web/src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,8 @@ The above is the content you need to summarize.`,
teamMembers: 'Team Members',
joinedTeams: 'Joined Teams',
sureDelete: 'Are you sure to remove this member?',
quit: 'Quit',
sureQuit: 'Are you sure you want to quit the team you joined?',
},
message: {
registered: 'Registered!',
Expand Down
2 changes: 2 additions & 0 deletions web/src/locales/zh-traditional.ts
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,8 @@ export default {
teamMembers: '團隊成員',
joinedTeams: '加入的團隊',
sureDelete: '您確定刪除該成員嗎?',
quit: '退出',
sureQuit: '確定退出加入的團隊嗎?',
},
message: {
registered: '註冊成功',
Expand Down
2 changes: 2 additions & 0 deletions web/src/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,8 @@ export default {
teamMembers: '团队成员',
joinedTeams: '加入的团队',
sureDelete: '您确定要删除该成员吗?',
quit: '退出',
sureQuit: '确定退出加入的团队吗?',
},
message: {
registered: '注册成功',
Expand Down
17 changes: 17 additions & 0 deletions web/src/pages/user-setting/setting-team/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,20 @@ export const useHandleAgreeTenant = () => {

return { handleAgree };
};

export const useHandleQuitUser = () => {
const { deleteTenantUser, loading } = useDeleteTenantUser();
const showDeleteConfirm = useShowDeleteConfirm();
const { t } = useTranslation();

const handleQuitTenantUser = (userId: string, tenantId: string) => () => {
showDeleteConfirm({
title: t('setting.sureQuit'),
onOk: async () => {
deleteTenantUser({ userId, tenantId });
},
});
};

return { handleQuitTenantUser, loading };
};
15 changes: 13 additions & 2 deletions web/src/pages/user-setting/setting-team/tenant-table.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { useListTenant } from '@/hooks/user-setting-hooks';
import { useFetchUserInfo, useListTenant } from '@/hooks/user-setting-hooks';
import { ITenant } from '@/interfaces/database/user-setting';
import { formatDate } from '@/utils/date';
import type { TableProps } from 'antd';
import { Button, Space, Table } from 'antd';
import { useTranslation } from 'react-i18next';
import { TenantRole } from '../constants';
import { useHandleAgreeTenant } from './hooks';
import { useHandleAgreeTenant, useHandleQuitUser } from './hooks';

const TenantTable = () => {
const { t } = useTranslation();
const { data, loading } = useListTenant();
const { handleAgree } = useHandleAgreeTenant();
const { data: user } = useFetchUserInfo();
const { handleQuitTenantUser } = useHandleQuitUser();

const columns: TableProps<ITenant>['columns'] = [
{
Expand Down Expand Up @@ -46,6 +48,15 @@ const TenantTable = () => {
</Button>
</Space>
);
} else if (role === TenantRole.Normal && user.id !== tenant_id) {
return (
<Button
type="link"
onClick={handleQuitTenantUser(user.id, tenant_id)}
>
{t('setting.quit')}
</Button>
);
}
},
},
Expand Down

0 comments on commit 976d112

Please sign in to comment.