Skip to content

Commit

Permalink
added team publicity switcher, and changed the timer status code order
Browse files Browse the repository at this point in the history
  • Loading branch information
desperado1802 committed Nov 30, 2023
1 parent d86276b commit a3d6d34
Show file tree
Hide file tree
Showing 4 changed files with 93 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
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 { limitTextCharaters } from '../../../../helpers/sub-text';
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 }]}>Team Type</Text>
<Text style={[styles.infoText, { color: colors.tertiary }]}>
{limitTextCharaters({
text: isTeamPublic ? 'Public Team' : 'Private Team',
numChars: 77
})}
</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 a3d6d34

Please sign in to comment.