From 7de9e46521e6ad2ce1187cb5dac4cb51b6459dae Mon Sep 17 00:00:00 2001 From: bill Date: Mon, 2 Dec 2024 15:16:31 +0800 Subject: [PATCH] Feat: Quit from jointed team #3759 --- web/src/locales/en.ts | 2 ++ web/src/locales/zh-traditional.ts | 2 ++ web/src/locales/zh.ts | 2 ++ .../pages/user-setting/setting-team/hooks.ts | 17 +++++++++++++++++ .../user-setting/setting-team/tenant-table.tsx | 15 +++++++++++++-- 5 files changed, 36 insertions(+), 2 deletions(-) diff --git a/web/src/locales/en.ts b/web/src/locales/en.ts index ce0525dbefd..0c5d54755e4 100644 --- a/web/src/locales/en.ts +++ b/web/src/locales/en.ts @@ -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!', diff --git a/web/src/locales/zh-traditional.ts b/web/src/locales/zh-traditional.ts index 2753e781ed4..3a35402daf9 100644 --- a/web/src/locales/zh-traditional.ts +++ b/web/src/locales/zh-traditional.ts @@ -569,6 +569,8 @@ export default { teamMembers: '團隊成員', joinedTeams: '加入的團隊', sureDelete: '您確定刪除該成員嗎?', + quit: '退出', + sureQuit: '確定退出加入的團隊嗎?', }, message: { registered: '註冊成功', diff --git a/web/src/locales/zh.ts b/web/src/locales/zh.ts index 8a3fe97bd97..96ea9b82c9a 100644 --- a/web/src/locales/zh.ts +++ b/web/src/locales/zh.ts @@ -589,6 +589,8 @@ export default { teamMembers: '团队成员', joinedTeams: '加入的团队', sureDelete: '您确定要删除该成员吗?', + quit: '退出', + sureQuit: '确定退出加入的团队吗?', }, message: { registered: '注册成功', diff --git a/web/src/pages/user-setting/setting-team/hooks.ts b/web/src/pages/user-setting/setting-team/hooks.ts index 0e5d3508f38..b766d3a7108 100644 --- a/web/src/pages/user-setting/setting-team/hooks.ts +++ b/web/src/pages/user-setting/setting-team/hooks.ts @@ -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 }; +}; diff --git a/web/src/pages/user-setting/setting-team/tenant-table.tsx b/web/src/pages/user-setting/setting-team/tenant-table.tsx index cc7a4e2d505..618785308f1 100644 --- a/web/src/pages/user-setting/setting-team/tenant-table.tsx +++ b/web/src/pages/user-setting/setting-team/tenant-table.tsx @@ -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['columns'] = [ { @@ -46,6 +48,15 @@ const TenantTable = () => { ); + } else if (role === TenantRole.Normal && user.id !== tenant_id) { + return ( + + ); } }, },