From bc69241e53c96cd74d54cb7cc99021bfd4548580 Mon Sep 17 00:00:00 2001 From: desperado1802 Date: Thu, 30 Nov 2023 19:50:55 +0200 Subject: [PATCH] added conditionally disabling same as web app to team danger zone --- .../Authenticated/SettingScreen/Team/index.tsx | 11 ++++++++++- .../SettingScreen/components/SingleInfo.tsx | 9 +++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/apps/mobile/app/screens/Authenticated/SettingScreen/Team/index.tsx b/apps/mobile/app/screens/Authenticated/SettingScreen/Team/index.tsx index a342b5052..ef5102cce 100644 --- a/apps/mobile/app/screens/Authenticated/SettingScreen/Team/index.tsx +++ b/apps/mobile/app/screens/Authenticated/SettingScreen/Team/index.tsx @@ -28,7 +28,7 @@ const TeamSettings: FC = observer(({ props, onOpenBottomSheet const { teamStore: { activeTeam } } = useStores(); - const { isTeamManager } = useOrganizationTeam(); + const { isTeamManager, activeTeamManagers, currentUser } = useOrganizationTeam(); const [open, setOpen] = useState(false); const { navigation } = props; @@ -99,16 +99,25 @@ const TeamSettings: FC = observer(({ props, onOpenBottomSheet title={translate('settingScreen.teamSection.transferOwnership')} value={translate('settingScreen.teamSection.transferOwnership')} onPress={() => setOpen(true)} + disabled={!(isTeamManager && activeTeamManagers.length >= 2)} /> onOpenBottomSheet('Remove Team', 5)} + disabled={!(isTeamManager && activeTeamManagers.length === 1)} /> onOpenBottomSheet('Quit Team', 5)} + disabled={ + !( + (isTeamManager && activeTeamManagers.length > 1) || + (!isTeamManager && + activeTeam?.members?.some((member) => member.employee.userId === currentUser?.id)) + ) + } /> diff --git a/apps/mobile/app/screens/Authenticated/SettingScreen/components/SingleInfo.tsx b/apps/mobile/app/screens/Authenticated/SettingScreen/components/SingleInfo.tsx index 2c041133c..a3a9bbaea 100644 --- a/apps/mobile/app/screens/Authenticated/SettingScreen/components/SingleInfo.tsx +++ b/apps/mobile/app/screens/Authenticated/SettingScreen/components/SingleInfo.tsx @@ -12,10 +12,11 @@ import { moonDarkLarge, moonLightLarge, sunDarkLarge, sunLightLarge } from '../. interface Props { title: string; value: string; + disabled?: boolean; onPress?: () => unknown; onDetectTimezone?: () => unknown; } -const SingleInfo: FC = ({ title, value, onPress, onDetectTimezone }) => { +const SingleInfo: FC = ({ title, value, onPress, onDetectTimezone, disabled = false }) => { const { colors, dark } = useAppTheme(); return ( @@ -38,7 +39,11 @@ const SingleInfo: FC = ({ title, value, onPress, onDetectTimezone }) => { ) : null} {title !== translate('settingScreen.personalSection.themes') ? ( - (onPress ? onPress() : {})}> + (onPress ? onPress() : {})} + > ) : (