From e2d7284c98bfa83cac92b361c168627cf206265a Mon Sep 17 00:00:00 2001 From: cedric karungu Date: Thu, 7 Dec 2023 18:06:55 +0200 Subject: [PATCH 1/6] feat: order user by timer status --- apps/web/lib/features/team-members.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/apps/web/lib/features/team-members.tsx b/apps/web/lib/features/team-members.tsx index b5212fed2..1e2697e92 100644 --- a/apps/web/lib/features/team-members.tsx +++ b/apps/web/lib/features/team-members.tsx @@ -9,6 +9,7 @@ import { IssuesView } from '@app/constants'; import TeamMembersBlockView from './team-members-block-view'; import { useRecoilValue } from 'recoil'; import { taskBlockFilterState } from '@app/stores/task-filter'; +import { OT_Member } from '@app/interfaces'; type TeamMembersProps = { publicTeam?: boolean; @@ -21,9 +22,10 @@ export function TeamMembers({ publicTeam = false, kanbanView: view = IssuesView. const { activeTeam } = useOrganizationTeams(); const { teamsFetching } = useOrganizationTeams(); const members = activeTeam?.members || []; + const orderedMembers = [...members].sort((a, b) => (sortByWorkStatus(a, b) ? -1 : 1)); const blockViewMembers = - activeFilter == 'all' ? members : members.filter((m) => m.timerStatus == activeFilter) || []; + activeFilter == 'all' ? orderedMembers : orderedMembers.filter((m) => m.timerStatus == activeFilter) || []; const currentUser = members.find((m) => m.employee.userId === user?.id); const $members = members.filter((member) => member.id !== currentUser?.id); @@ -100,3 +102,12 @@ export function TeamMembers({ publicTeam = false, kanbanView: view = IssuesView. } return teamMembersView; } + +const sortByWorkStatus = (user_a: OT_Member, user_b: OT_Member) => { + return user_a.timerStatus == 'running' || + (user_a.timerStatus == 'online' && user_b.timerStatus != 'running') || + (user_a.timerStatus == 'pause' && user_b.timerStatus !== 'running' && user_b.timerStatus !== 'online') || + (user_a.timerStatus == 'idle' && user_b.timerStatus == 'suspended') + ? true + : false; +}; From 3b06d464e28d11942b0855ddb3aea8baa267f204 Mon Sep 17 00:00:00 2001 From: cedric karungu Date: Thu, 7 Dec 2023 18:40:24 +0200 Subject: [PATCH 2/6] refact: change loading skeleton to text related to timer status --- .../lib/features/team-members-block-view.tsx | 44 ++++++++++--------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/apps/web/lib/features/team-members-block-view.tsx b/apps/web/lib/features/team-members-block-view.tsx index 4ca828133..9eac21b5f 100644 --- a/apps/web/lib/features/team-members-block-view.tsx +++ b/apps/web/lib/features/team-members-block-view.tsx @@ -2,7 +2,8 @@ import * as React from 'react'; import { OT_Member } from '@app/interfaces'; import { Transition } from '@headlessui/react'; import { UserTeamBlock } from './team/user-team-block'; -import UserTeamCardSkeletonCard from '@components/shared/skeleton/UserTeamCardSkeleton'; +import { useRecoilValue } from 'recoil'; +import { taskBlockFilterState } from '@app/stores/task-filter'; interface Props { teamMembers: OT_Member[]; @@ -12,6 +13,23 @@ interface Props { } const TeamMembersBlockView: React.FC = ({ teamMembers: members, publicTeam = false, currentUser }) => { + const activeFilter = useRecoilValue(taskBlockFilterState); + + let emptyMessage = ''; + switch (activeFilter) { + case 'online': + emptyMessage = 'There is no user online now (and not working)'; + break; + case 'running': + emptyMessage = 'No user are working now'; + break; + case 'pause': + emptyMessage = 'No user are in pause now'; + break; + case 'idle': + emptyMessage = 'No user are not working now'; + break; + } return (
{/* Current authenticated user members */} @@ -46,25 +64,11 @@ const TeamMembersBlockView: React.FC = ({ teamMembers: members, publicTea ); })}
-
- - {new Array(3).fill(0).map((_, i) => { - return ( -
- -
- ); - })} -
-
+ {members.length < 1 && ( +
+

{emptyMessage}

+
+ )} ); }; From 98d8c90155d067a59605d4e3107d852a63d7d6ca Mon Sep 17 00:00:00 2001 From: cedric karungu Date: Fri, 8 Dec 2023 20:30:52 +0200 Subject: [PATCH 3/6] refact: add fixed header on Table View of team issues --- apps/web/components/ui/data-table.tsx | 2 +- apps/web/lib/features/team-members-block-view.tsx | 2 +- .../user-team-table/user-team-table-header.tsx | 15 +++++++++++++++ apps/web/pages/index.tsx | 6 ++++++ 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 apps/web/lib/features/team/user-team-table/user-team-table-header.tsx diff --git a/apps/web/components/ui/data-table.tsx b/apps/web/components/ui/data-table.tsx index 2e7afeea2..048181208 100644 --- a/apps/web/components/ui/data-table.tsx +++ b/apps/web/components/ui/data-table.tsx @@ -11,7 +11,7 @@ import { getFilteredRowModel, getPaginationRowModel, getSortedRowModel, - useReactTable, + useReactTable } from "@tanstack/react-table" import { diff --git a/apps/web/lib/features/team-members-block-view.tsx b/apps/web/lib/features/team-members-block-view.tsx index 9eac21b5f..c1692cf31 100644 --- a/apps/web/lib/features/team-members-block-view.tsx +++ b/apps/web/lib/features/team-members-block-view.tsx @@ -18,7 +18,7 @@ const TeamMembersBlockView: React.FC = ({ teamMembers: members, publicTea let emptyMessage = ''; switch (activeFilter) { case 'online': - emptyMessage = 'There is no user online now (and not working)'; + emptyMessage = 'There is no user online now '; break; case 'running': emptyMessage = 'No user are working now'; diff --git a/apps/web/lib/features/team/user-team-table/user-team-table-header.tsx b/apps/web/lib/features/team/user-team-table/user-team-table-header.tsx new file mode 100644 index 000000000..53391fa77 --- /dev/null +++ b/apps/web/lib/features/team/user-team-table/user-team-table-header.tsx @@ -0,0 +1,15 @@ +import React from 'react'; + +function UserTeamTableHeader() { + return ( +
+

Name

+

Task

+

Worked on Task

+

Estimate

+

Action

+
+ ); +} + +export default UserTeamTableHeader; diff --git a/apps/web/pages/index.tsx b/apps/web/pages/index.tsx index 5d4759600..bee85562a 100644 --- a/apps/web/pages/index.tsx +++ b/apps/web/pages/index.tsx @@ -18,8 +18,12 @@ import { useTranslation } from 'react-i18next'; import { useState } from 'react'; import { IssuesView } from '@app/constants'; import { TableCellsIcon, QueueListIcon, Squares2X2Icon } from '@heroicons/react/24/solid'; +<<<<<<< HEAD import { useNetworkState } from '@uidotdev/usehooks'; import Offline from '@components/pages/offline'; +======= +import UserTeamTableHeader from 'lib/features/team/user-team-table/user-team-table-header'; +>>>>>>> 011ba692 (refact: add fixed header on Table View of team issues) function MainPage() { const { t } = useTranslation(); @@ -95,6 +99,8 @@ function MainPage() { ) : view === IssuesView.BLOCKS ? ( + ) : view === IssuesView.TABLE ? ( + ) : null} From 1927c7913f35cb12d6ed53d332eb19d398583740 Mon Sep 17 00:00:00 2001 From: cedric karungu Date: Sat, 9 Dec 2023 10:40:15 +0200 Subject: [PATCH 4/6] fix: merge errors --- apps/web/pages/index.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/apps/web/pages/index.tsx b/apps/web/pages/index.tsx index bee85562a..db6646b0c 100644 --- a/apps/web/pages/index.tsx +++ b/apps/web/pages/index.tsx @@ -18,12 +18,9 @@ import { useTranslation } from 'react-i18next'; import { useState } from 'react'; import { IssuesView } from '@app/constants'; import { TableCellsIcon, QueueListIcon, Squares2X2Icon } from '@heroicons/react/24/solid'; -<<<<<<< HEAD import { useNetworkState } from '@uidotdev/usehooks'; import Offline from '@components/pages/offline'; -======= import UserTeamTableHeader from 'lib/features/team/user-team-table/user-team-table-header'; ->>>>>>> 011ba692 (refact: add fixed header on Table View of team issues) function MainPage() { const { t } = useTranslation(); From a84a76f9c31a0a7846b55fb63e0d7e0bec51d15a Mon Sep 17 00:00:00 2001 From: Ruslan K Date: Sat, 9 Dec 2023 10:25:03 +0100 Subject: [PATCH 5/6] Update team-members-block-view.tsx --- apps/web/lib/features/team-members-block-view.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/web/lib/features/team-members-block-view.tsx b/apps/web/lib/features/team-members-block-view.tsx index c1692cf31..f2e59e796 100644 --- a/apps/web/lib/features/team-members-block-view.tsx +++ b/apps/web/lib/features/team-members-block-view.tsx @@ -16,20 +16,22 @@ const TeamMembersBlockView: React.FC = ({ teamMembers: members, publicTea const activeFilter = useRecoilValue(taskBlockFilterState); let emptyMessage = ''; + switch (activeFilter) { case 'online': - emptyMessage = 'There is no user online now '; + emptyMessage = 'There are no users online.'; break; case 'running': - emptyMessage = 'No user are working now'; + emptyMessage = 'No users are currently working.'; break; case 'pause': - emptyMessage = 'No user are in pause now'; + emptyMessage = 'No users are paused work at the moment.'; break; case 'idle': - emptyMessage = 'No user are not working now'; + emptyMessage = 'No users are idle right now.'; break; } + return (
{/* Current authenticated user members */} From 293aa9fac5e2c560fad878acfac07aa4ac77fcc5 Mon Sep 17 00:00:00 2001 From: cedric karungu Date: Sat, 9 Dec 2023 14:17:47 +0200 Subject: [PATCH 6/6] fix: add loading skeleton and message text --- .../lib/features/team-members-block-view.tsx | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/apps/web/lib/features/team-members-block-view.tsx b/apps/web/lib/features/team-members-block-view.tsx index f2e59e796..5ecad073e 100644 --- a/apps/web/lib/features/team-members-block-view.tsx +++ b/apps/web/lib/features/team-members-block-view.tsx @@ -4,6 +4,7 @@ import { Transition } from '@headlessui/react'; import { UserTeamBlock } from './team/user-team-block'; import { useRecoilValue } from 'recoil'; import { taskBlockFilterState } from '@app/stores/task-filter'; +import { UserTeamCardSkeleton } from './team/user-team-card'; interface Props { teamMembers: OT_Member[]; @@ -12,7 +13,12 @@ interface Props { teamsFetching: boolean; } -const TeamMembersBlockView: React.FC = ({ teamMembers: members, publicTeam = false, currentUser }) => { +const TeamMembersBlockView: React.FC = ({ + teamMembers: members, + publicTeam = false, + currentUser, + teamsFetching +}) => { const activeFilter = useRecoilValue(taskBlockFilterState); let emptyMessage = ''; @@ -66,7 +72,24 @@ const TeamMembersBlockView: React.FC = ({ teamMembers: members, publicTea ); })}
- {members.length < 1 && ( + + {[1, 2].map((_, i) => { + return ( +
  • + +
  • + ); + })} +
    + {members.length < 1 && !teamsFetching && (

    {emptyMessage}