Skip to content

Commit

Permalink
added conditionally disabling same as web app to team danger zone
Browse files Browse the repository at this point in the history
  • Loading branch information
desperado1802 committed Nov 30, 2023
1 parent ac517e0 commit bc69241
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const TeamSettings: FC<ITeamSettingProps> = observer(({ props, onOpenBottomSheet
const {
teamStore: { activeTeam }
} = useStores();
const { isTeamManager } = useOrganizationTeam();
const { isTeamManager, activeTeamManagers, currentUser } = useOrganizationTeam();

const [open, setOpen] = useState(false);
const { navigation } = props;
Expand Down Expand Up @@ -99,16 +99,25 @@ const TeamSettings: FC<ITeamSettingProps> = observer(({ props, onOpenBottomSheet
title={translate('settingScreen.teamSection.transferOwnership')}
value={translate('settingScreen.teamSection.transferOwnership')}
onPress={() => setOpen(true)}
disabled={!(isTeamManager && activeTeamManagers.length >= 2)}
/>
<SingleInfo
title={translate('settingScreen.teamSection.removeTeam')}
value={translate('settingScreen.teamSection.removeTeamHint')}
onPress={() => onOpenBottomSheet('Remove Team', 5)}
disabled={!(isTeamManager && activeTeamManagers.length === 1)}
/>
<SingleInfo
title={translate('settingScreen.teamSection.quitTeam')}
value={translate('settingScreen.teamSection.quitTeamHint')}
onPress={() => onOpenBottomSheet('Quit Team', 5)}
disabled={
!(
(isTeamManager && activeTeamManagers.length > 1) ||
(!isTeamManager &&
activeTeam?.members?.some((member) => member.employee.userId === currentUser?.id))
)
}
/>
</View>
</ScrollView>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Props> = ({ title, value, onPress, onDetectTimezone }) => {
const SingleInfo: FC<Props> = ({ title, value, onPress, onDetectTimezone, disabled = false }) => {
const { colors, dark } = useAppTheme();

return (
Expand All @@ -38,7 +39,11 @@ const SingleInfo: FC<Props> = ({ title, value, onPress, onDetectTimezone }) => {
) : null}

{title !== translate('settingScreen.personalSection.themes') ? (
<TouchableOpacity onPress={() => (onPress ? onPress() : {})}>
<TouchableOpacity
disabled={disabled}
style={{ opacity: disabled ? 0.5 : 1 }}
onPress={() => (onPress ? onPress() : {})}
>
<AntDesign name="right" size={24} color="#938FA4" />
</TouchableOpacity>
) : (
Expand Down

0 comments on commit bc69241

Please sign in to comment.