From 5fd72747bee05d88d37193f7c2253bf6a2cc86a2 Mon Sep 17 00:00:00 2001 From: desperado1802 Date: Mon, 23 Oct 2023 18:30:48 +0300 Subject: [PATCH] added the status icons as svgs --- apps/mobile/app/components/svgs/icons.tsx | 46 ++++++++++ apps/mobile/app/helpers/get-timer-status.ts | 13 +-- .../TeamScreen/components/UserHeaderCard.tsx | 89 +++++++++---------- 3 files changed, 97 insertions(+), 51 deletions(-) diff --git a/apps/mobile/app/components/svgs/icons.tsx b/apps/mobile/app/components/svgs/icons.tsx index 890f2d658..c08493ed8 100644 --- a/apps/mobile/app/components/svgs/icons.tsx +++ b/apps/mobile/app/components/svgs/icons.tsx @@ -410,3 +410,49 @@ export const settingsIconDark = ` ` +export const suspendedStatusIcon = ` + + ` + +export const idleStatusIcon = ` + + ` + +export const onlineAndTrackingTimeStatusIcon = ` + + + ` +export const pauseStatusIcon = ` + + + ` diff --git a/apps/mobile/app/helpers/get-timer-status.ts b/apps/mobile/app/helpers/get-timer-status.ts index d2b3cc7cd..dba29b012 100644 --- a/apps/mobile/app/helpers/get-timer-status.ts +++ b/apps/mobile/app/helpers/get-timer-status.ts @@ -8,22 +8,23 @@ type timerStatusReturnValue = "pause" | "running" | "idle" | "online" | "suspend export const getTimerStatusValue = ( timerStatus: ITimerStatus | null, member: OT_Member, + publicTeam?: boolean, ): timerStatusReturnValue => { return !member?.employee?.isActive && !publicTeam ? "suspended" - : member?.timerStatus === "pause" - ? "pause" + : member?.employee?.isOnline + ? // && member?.timerStatus !== 'running' + "online" : !timerStatus?.running && timerStatus?.lastLog && timerStatus?.lastLog?.startedAt && timerStatus?.lastLog?.employeeId === member?.employeeId && moment().diff(moment(timerStatus?.lastLog?.startedAt), "hours") < 24 && - timerStatus?.lastLog?.source !== "TEAMS" + timerStatus?.lastLog?.source !== "MOBILE" + ? "pause" + : member?.timerStatus === "pause" ? "pause" - : member?.employee?.isOnline - ? // && member?.timerStatus !== 'running' - "online" : !member?.totalTodayTasks?.length ? "idle" : member?.timerStatus || "idle" diff --git a/apps/mobile/app/screens/Authenticated/TeamScreen/components/UserHeaderCard.tsx b/apps/mobile/app/screens/Authenticated/TeamScreen/components/UserHeaderCard.tsx index 968ca95a9..106989b07 100644 --- a/apps/mobile/app/screens/Authenticated/TeamScreen/components/UserHeaderCard.tsx +++ b/apps/mobile/app/screens/Authenticated/TeamScreen/components/UserHeaderCard.tsx @@ -1,5 +1,6 @@ /* eslint-disable camelcase */ /* eslint-disable react-native/no-color-literals */ +/* eslint-disable react-native/no-inline-styles */ import { StyleSheet, View, Text } from "react-native" import React, { FC } from "react" import { IUser } from "../../../../services/interfaces/IUserData" @@ -10,58 +11,56 @@ import { useTimer } from "../../../../services/hooks/useTimer" import { imgTitleProfileAvatar } from "../../../../helpers/img-title-profile-avatar" import { useOrganizationTeam } from "../../../../services/hooks/useOrganization" import { getTimerStatusValue } from "../../../../helpers/get-timer-status" +import { SvgXml } from "react-native-svg" +import { + idleStatusIcon, + onlineAndTrackingTimeStatusIcon, + pauseStatusIcon, + suspendedStatusIcon, +} from "../../../../components/svgs/icons" interface ITimerStatus { status: "running" | "online" | "idle" | "suspended" | "pause" } const TimerStatus: FC = ({ status }) => { - return ( - - {status === "online" && ( - /* For now until we have realtime we will use Play icon instead of Online icon */ - // - - )} + let iconSvgXml = "" - {status === "running" && ( - - )} + switch (status) { + case "online": + iconSvgXml = onlineAndTrackingTimeStatusIcon + break + case "pause": + iconSvgXml = pauseStatusIcon + break + case "idle": + iconSvgXml = idleStatusIcon + break + case "suspended": + iconSvgXml = suspendedStatusIcon + break + } - {status === "idle" && ( - - )} - - {status === "suspended" && ( - - )} - - {status === "pause" && ( - - )} + return ( + + ) }