Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat]: Productivity project table view #3616

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions apps/web/app/[locale]/dashboard/app-url/[teamId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ import { ArrowLeftIcon } from '@radix-ui/react-icons';
import { useRouter } from 'next/navigation';
import { Breadcrumb, Container } from '@/lib/components';
import { DashboardHeader } from '../../team-dashboard/[teamId]/components/dashboard-header';
import { useReportActivity } from '@/app/hooks/features/useReportActivity';
import { ProductivityStats } from '../components/ProductivityStats';
import { ProductivityChart } from '../components/ProductivityChart';
import { GroupByType, useReportActivity } from '@/app/hooks/features/useReportActivity';
import { Card } from '@components/ui/card';
import { ProductivityHeader } from '../components/ProductivityHeader';
import { ProductivityChart } from '../components/ProductivityChart';
import { ProductivityStats } from '../components/ProductivityStats';
import { ProductivityProjectTable } from '../components/productivity-project';
import { ProductivityTable } from '../components/ProductivityTable';
import { Card } from '@components/ui/card';
import { ProductivityEmployeeTable } from '../components/productivity-employee/ProductivityEmployeeTable';

interface ProductivityData {
date: string;
Expand All @@ -33,6 +35,7 @@ function AppUrls() {
const paramsUrl = useParams<{ locale: string }>();
const currentLocale = paramsUrl?.locale;
const { isTrackingEnabled } = useOrganizationTeams();
const [groupByType, setGroupByType] = React.useState<GroupByType>('date');

const {
activityReport,
Expand All @@ -43,6 +46,11 @@ function AppUrls() {
isManage
} = useReportActivity({ types: 'APPS-URLS' });

const handleGroupTypeChange = (type: GroupByType) => {
setGroupByType(type);
handleGroupByChange(type);
};

const generateMonthData = (date: Date): ProductivityData[] => {
const year = date.getFullYear();
const month = date.getMonth();
Expand Down Expand Up @@ -102,10 +110,10 @@ function AppUrls() {
<DashboardHeader
onUpdateDateRange={updateDateRange}
onUpdateFilters={updateFilters}
onGroupByChange={handleGroupTypeChange}
showGroupBy={true}
title="Apps & URLs Dashboard"
isManage={isManage}
showGroupBy={true}
onGroupByChange={handleGroupByChange}
/>
<Card className="bg-white rounded-xl border border-gray-100 dark:border-gray-700 dark:bg-dark--theme-light h-[403px] p-8 py-0 px-0">
<div className="flex flex-col gap-6 w-full">
Expand All @@ -128,7 +136,16 @@ function AppUrls() {
}
>
<Container fullWidth={fullWidth} className={cn('flex flex-col gap-8 !px-4 py-6 w-full')}>
<ProductivityTable data={activityReport} isLoading={loadingActivityReport} />
{(() => {
switch (groupByType) {
case 'project':
return <ProductivityProjectTable data={activityReport} isLoading={loadingActivityReport} />;
case 'date':
return <ProductivityTable data={activityReport} isLoading={loadingActivityReport} />;
case 'employee':
return <ProductivityEmployeeTable data={activityReport} isLoading={loadingActivityReport} />;
}
})()}
</Container>
</MainLayout>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function GroupBySelect({ onGroupByChange }: GroupBySelectProps) {
<SelectContent className="dark:bg-dark--theme-light">
<SelectItem value="date">Date</SelectItem>
<SelectItem value="project">Project</SelectItem>
<SelectItem value="person">Person</SelectItem>
<SelectItem value="employee">Person</SelectItem>
<SelectItem value="application">Application</SelectItem>
</SelectContent>
</Select>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function ProductivityTable({
<TableCell><Skeleton className="w-24 h-4"/></TableCell>
<TableCell><Skeleton className="w-16 h-4"/></TableCell>
<TableCell><Skeleton className="w-16 h-4"/></TableCell>
<TableCell><Skeleton className="w-24 h-4"/></TableCell>
<TableCell><Skeleton className="w-full h-4"/></TableCell>
</TableRow>
))}
</TableBody>
Expand Down Expand Up @@ -142,7 +142,7 @@ export function ProductivityTable({
<TableCell>{formatDuration(activity.duration.toString())}</TableCell>
<TableCell>
<div className="flex gap-2 items-center">
<div className="overflow-hidden w-24 h-2 bg-gray-200 rounded-full">
<div className="overflow-hidden w-full h-2 bg-gray-200 rounded-full">
<div
className="h-full bg-blue-500"
style={{ width: `${activity.duration_percentage}%` }}
Expand Down
Loading