Skip to content

Commit

Permalink
Merge pull request #1919 from ever-co/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
evereq authored Nov 30, 2023
2 parents 4458d93 + 9507fa1 commit 1a5b932
Show file tree
Hide file tree
Showing 13 changed files with 141 additions and 18 deletions.
13 changes: 6 additions & 7 deletions apps/mobile/app/helpers/get-timer-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,23 @@ type timerStatusReturnValue = 'pause' | 'running' | 'idle' | 'online' | 'suspend

export const getTimerStatusValue = (
timerStatus: ITimerStatus | null,
member: OT_Member,

member: OT_Member | undefined,
publicTeam?: boolean
): timerStatusReturnValue => {
return !member?.employee?.isActive && !publicTeam
? 'suspended'
: member?.employee?.isOnline
? // && member?.timerStatus !== 'running'
'online'
: member?.timerStatus === 'pause'
? 'pause'
: !timerStatus?.running &&
timerStatus?.lastLog &&
timerStatus?.lastLog?.startedAt &&
timerStatus?.lastLog?.employeeId === member?.employeeId &&
moment().diff(moment(timerStatus?.lastLog?.startedAt), 'hours') < 24 &&
timerStatus?.lastLog?.source !== 'MOBILE'
? 'pause'
: member?.timerStatus === 'pause'
? 'pause'
: member?.employee?.isOnline
? // && member?.timerStatus !== 'running'
'online'
: !member?.totalTodayTasks?.length
? 'idle'
: member?.timerStatus || 'idle';
Expand Down
5 changes: 4 additions & 1 deletion apps/mobile/app/i18n/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ const ar: Translations = {
removeAccount: 'Remove Account',
removeAccountHint: 'Account will be removed from all teams, except where you are the only manager',
deleteAccount: 'Delete Account',
deleteAccountHint: 'Your account will be deleted permanently with remolving from all teams',
deleteAccountHint: 'Your account will be deleted permanently with removing from all teams',
detect: 'Detect'
},
teamSection: {
Expand All @@ -209,6 +209,9 @@ const ar: Translations = {
quitTeam: 'Quit the team',
quitTeamHint: 'You are about to quit the team',
areYouSure: 'Are you sure ?',
teamType: 'نوع الفريق',
publicTeam: 'الفريق العام',
privateTeam: 'الفريق الخاص',
changeTeamName: {
mainTitle: 'Change Team Name',
inputPlaceholder: 'Team Name'
Expand Down
5 changes: 4 additions & 1 deletion apps/mobile/app/i18n/bg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ const bg = {
removeAccount: 'Remove Account',
removeAccountHint: 'Account will be removed from all teams, except where you are the only manager',
deleteAccount: 'Delete Account',
deleteAccountHint: 'Your account will be deleted permanently with remolving from all teams',
deleteAccountHint: 'Your account will be deleted permanently with removing from all teams',
detect: 'Detect'
},
teamSection: {
Expand All @@ -205,6 +205,9 @@ const bg = {
quitTeam: 'Quit the team',
quitTeamHint: 'You are about to quit the team',
areYouSure: 'Are you sure ?',
teamType: 'Team Type',
publicTeam: 'Public Team',
privateTeam: 'Private Team',
changeTeamName: {
mainTitle: 'Change Team Name',
inputPlaceholder: 'Team Name'
Expand Down
5 changes: 4 additions & 1 deletion apps/mobile/app/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ const en = {
removeAccount: 'Remove Account',
removeAccountHint: 'Account will be removed from all teams, except where you are the only manager',
deleteAccount: 'Delete Account',
deleteAccountHint: 'Your account will be deleted permanently with remolving from all teams',
deleteAccountHint: 'Your account will be deleted permanently with removing from all teams',
detect: 'Detect'
},
teamSection: {
Expand All @@ -206,6 +206,9 @@ const en = {
quitTeam: 'Quit the team',
quitTeamHint: 'You are about to quit the team',
areYouSure: 'Are you sure ?',
teamType: 'Team Type',
publicTeam: 'Public Team',
privateTeam: 'Private Team',
changeTeamName: {
mainTitle: 'Change Team Name',
inputPlaceholder: 'Team Name'
Expand Down
5 changes: 4 additions & 1 deletion apps/mobile/app/i18n/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ const es = {
removeAccount: 'Remove Account',
removeAccountHint: 'Account will be removed from all teams, except where you are the only manager',
deleteAccount: 'Delete Account',
deleteAccountHint: 'Your account will be deleted permanently with remolving from all teams',
deleteAccountHint: 'Your account will be deleted permanently with removing from all teams',
detect: 'Detect'
},
teamSection: {
Expand All @@ -205,6 +205,9 @@ const es = {
quitTeam: 'Quit the team',
quitTeamHint: 'You are about to quit the team',
areYouSure: 'Are you sure ?',
teamType: 'Team Type',
publicTeam: 'Public Team',
privateTeam: 'Private Team',
changeTeamName: {
mainTitle: 'Change Team Name',
inputPlaceholder: 'Team Name'
Expand Down
3 changes: 3 additions & 0 deletions apps/mobile/app/i18n/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ const fr = {
quitTeam: "Quitter l'équipe",
quitTeamHint: "Vous êtes sur le point de quitter l'équipe",
areYouSure: 'Etes-vous sûr ?',
teamType: "Type d'équipe",
publicTeam: 'Équipe publique',
privateTeam: 'Équipe privée',
changeTeamName: {
mainTitle: 'Change Team Name',
inputPlaceholder: 'Team Name'
Expand Down
5 changes: 4 additions & 1 deletion apps/mobile/app/i18n/he.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ const he = {
removeAccount: 'Remove Account',
removeAccountHint: 'Account will be removed from all teams, except where you are the only manager',
deleteAccount: 'Delete Account',
deleteAccountHint: 'Your account will be deleted permanently with remolving from all teams',
deleteAccountHint: 'Your account will be deleted permanently with removing from all teams',
detect: 'Detect'
},
teamSection: {
Expand All @@ -205,6 +205,9 @@ const he = {
quitTeam: 'Quit the team',
quitTeamHint: 'You are about to quit the team',
areYouSure: 'Are you sure ?',
teamType: 'Team Type',
publicTeam: 'Public Team',
privateTeam: 'Private Team',
changeTeamName: {
mainTitle: 'Change Team Name',
inputPlaceholder: 'Team Name'
Expand Down
5 changes: 4 additions & 1 deletion apps/mobile/app/i18n/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ const ko: Translations = {
removeAccount: 'Remove Account',
removeAccountHint: 'Account will be removed from all teams, except where you are the only manager',
deleteAccount: 'Delete Account',
deleteAccountHint: 'Your account will be deleted permanently with remolving from all teams',
deleteAccountHint: 'Your account will be deleted permanently with removing from all teams',
detect: 'Detect'
},
teamSection: {
Expand All @@ -208,6 +208,9 @@ const ko: Translations = {
quitTeam: 'Quit the team',
quitTeamHint: 'You are about to quit the team',
areYouSure: 'Are you sure ?',
teamType: '팀 타입',
publicTeam: '공개 팀',
privateTeam: '비공개 팀',
changeTeamName: {
mainTitle: 'Change Team Name',
inputPlaceholder: 'Team Name'
Expand Down
5 changes: 4 additions & 1 deletion apps/mobile/app/i18n/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ const ru = {
removeAccount: 'Remove Account',
removeAccountHint: 'Account will be removed from all teams, except where you are the only manager',
deleteAccount: 'Delete Account',
deleteAccountHint: 'Your account will be deleted permanently with remolving from all teams',
deleteAccountHint: 'Your account will be deleted permanently with removing from all teams',
detect: 'Detect'
},
teamSection: {
Expand All @@ -205,6 +205,9 @@ const ru = {
quitTeam: 'Quit the team',
quitTeamHint: 'You are about to quit the team',
areYouSure: 'Are you sure ?',
teamType: 'Team Type',
publicTeam: 'Public Team',
privateTeam: 'Private Team',
changeTeamName: {
mainTitle: 'Change Team Name',
inputPlaceholder: 'Team Name'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { useTaskPriority } from '../../../../services/hooks/features/useTaskPrio
import { useTaskSizes } from '../../../../services/hooks/features/useTaskSizes';
import { useTaskLabels } from '../../../../services/hooks/features/useTaskLabels';
import { useTaskVersion } from '../../../../services/hooks/features/useTaskVersion';
import SwitchTeamPublicity from '../components/SwitchTeamPublicity';

interface ITeamSettingProps {
props: any;
Expand All @@ -27,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 All @@ -51,6 +52,7 @@ const TeamSettings: FC<ITeamSettingProps> = observer(({ props, onOpenBottomSheet
value={activeTeam?.name}
onPress={() => onOpenBottomSheet('Team Name', 4)}
/>
{isTeamManager ? <SwitchTeamPublicity /> : null}
{isTeamManager ? <SwithTimeTracking /> : null}
<SingleInfo
title={'Task Versions'}
Expand Down Expand Up @@ -97,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
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/* eslint-disable react-native/no-color-literals */
/* eslint-disable react-native/no-inline-styles */
import React, { FC, useCallback, useEffect, useState } from 'react';
import { View, Text, StyleSheet } from 'react-native';
import { observer } from 'mobx-react-lite';
import { useOrganizationTeam } from '../../../../services/hooks/useOrganization';
import { translate } from '../../../../i18n';
import { Toggle } from '../../../../components/Toggle';
import { typography, useAppTheme } from '../../../../theme';

interface Props {}
const SwitchTeamPublicity: FC<Props> = observer(() => {
const { colors } = useAppTheme();
const { onUpdateOrganizationTeam, currentTeam, activeTeam } = useOrganizationTeam();

const [isTeamPublic, setIsTeamPublic] = useState<boolean>(activeTeam?.public);

const toggleSwitch = useCallback(async () => {
await onUpdateOrganizationTeam({
id: currentTeam?.id,
data: { ...currentTeam, public: !isTeamPublic }
}).then(() => setIsTeamPublic((prev) => !prev));
}, [isTeamPublic, currentTeam]);

useEffect(() => {
setIsTeamPublic(activeTeam?.public);
}, [currentTeam]);
return (
<View style={styles.container}>
<View style={styles.wrapperInfo}>
<Text style={[styles.infoTitle, { color: colors.primary }]}>
{translate('settingScreen.teamSection.teamType')}
</Text>
<Text style={[styles.infoText, { color: colors.tertiary }]}>
{isTeamPublic
? translate('settingScreen.teamSection.publicTeam')
: translate('settingScreen.teamSection.privateTeam')}
</Text>
</View>
<Toggle
inputInnerStyle={{ backgroundColor: '#DBD3FA' }}
inputDetailStyle={{ backgroundColor: '#3826A6' }}
onPress={() => toggleSwitch()}
variant="switch"
value={isTeamPublic}
/>
</View>
);
});

export default SwitchTeamPublicity;

const styles = StyleSheet.create({
container: {
alignItems: 'center',
flexDirection: 'row',
justifyContent: 'space-between',
marginTop: 32,
width: '100%'
},
detectWrapper: {
borderRadius: 8,
paddingHorizontal: 13,
paddingVertical: 8
},
infoText: {
color: '#938FA4',
fontFamily: typography.primary.medium,
fontSize: 14,
marginTop: 10
},
infoTitle: {
fontFamily: typography.primary.semiBold,
fontSize: 16
},
toggle: {
height: 40,
right: -10,
top: -10
},
wrapperInfo: {
maxWidth: '90%'
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export const ListItemContent: React.FC<IcontentProps> = observer(({ memberInfo,

const ListCardItem: React.FC<Props> = observer((props) => {
const { colors } = useAppTheme();
// // STATS
// STATS
const memberInfo = useTeamMemberCard(props.member);
const taskEdition = useTMCardTaskEdit(memberInfo.memberTask);
const { timerStatus } = useTimer();
Expand Down

0 comments on commit 1a5b932

Please sign in to comment.