Skip to content

Commit

Permalink
Merge pull request #1916 from ever-co/feat/team-publicity-switcher
Browse files Browse the repository at this point in the history
added team publicity switcher, and changed the timer status code order
  • Loading branch information
evereq authored Nov 30, 2023
2 parents d86276b + 69a79ad commit ac517e0
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 8 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
3 changes: 3 additions & 0 deletions apps/mobile/app/i18n/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions apps/mobile/app/i18n/bg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions apps/mobile/app/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions apps/mobile/app/i18n/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions apps/mobile/app/i18n/he.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions apps/mobile/app/i18n/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions apps/mobile/app/i18n/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 Down Expand Up @@ -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
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 ac517e0

Please sign in to comment.