Skip to content

Commit

Permalink
feat: graphs for project statuses per team
Browse files Browse the repository at this point in the history
  • Loading branch information
Amama-Fatima committed Apr 30, 2024
1 parent b659957 commit 1e40a7c
Show file tree
Hide file tree
Showing 5 changed files with 363 additions and 6 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"react-hot-toast": "^2.4.1",
"react-icons": "^4.12.0",
"react-resizable-panels": "^2.0.18",
"recharts": "^2.12.6",
"resend": "^3.2.0",
"tailwind-merge": "^2.1.0",
"tailwindcss-animate": "^1.0.7",
Expand Down
217 changes: 216 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 32 additions & 5 deletions src/app/(lobby)/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react';
import { getUser } from '@/lib/server-user';
import { createSupabaseServerClient } from '@/lib/supabase/server-clients';

import { DashboardGraph } from '@/components/dashboard-graph';
import DashboardTaskCard from '@/components/dashboard-task-card';
import {
Card,
Expand All @@ -12,7 +13,11 @@ import {
CardTitle,
} from '@/components/ui/card';

import { TaskDataWithProjectName } from '@/types';
import {
ProjectDataWithTeamName,
ProjectsByTeam,
TaskDataWithProjectName,
} from '@/types';

export default async function DashboardPage() {
const user = await getUser();
Expand All @@ -28,8 +33,9 @@ export default async function DashboardPage() {

const { data: projectData } = await serverSupabase
.from('projects')
.select('project_id')
.in('team_id', teamData?.map((team) => team.team_id) || []);
.select('project_id, name, project_status, teams(name)')
.in('team_id', teamData?.map((team) => team.team_id) || [])
.not('teams', 'is', null);
const { data: tasksData } = await serverSupabase
.from('tasks')
.select('title, details, projects(name)')
Expand All @@ -38,13 +44,34 @@ export default async function DashboardPage() {
.not('projects', 'is', null);
const tasksDataWithProjectName =
tasksData as unknown as TaskDataWithProjectName[];
const projectDataWithTeamName =
projectData as unknown as ProjectDataWithTeamName[];

const projectsByTeam: ProjectsByTeam = {};

projectDataWithTeamName.forEach((project) => {
const teamName = project.teams.name;
if (!projectsByTeam[teamName]) {
projectsByTeam[teamName] = [];
}
projectsByTeam[teamName].push(project);
});

return (
<div>
<div className='grid grid-flow-col gap-2'>
<Card className='col-span-4'>
<CardHeader>
<CardTitle>Project Statuses Per Team</CardTitle>
</CardHeader>
<CardContent className='flex'>
<DashboardGraph projectsByTeam={projectsByTeam} />
</CardContent>
</Card>

<Card className='w-[350px]'>
<CardHeader className='flex flex-col gap-3'>
<CardTitle>Tasks</CardTitle>
<CardDescription>Following are you ongoing tasks.</CardDescription>
<CardDescription>Following are your ongoing tasks.</CardDescription>
<CardContent className='flex flex-col gap-4'>
{tasksDataWithProjectName?.map((taskWithProjectName, index) => (
<DashboardTaskCard
Expand Down
Loading

0 comments on commit 1e40a7c

Please sign in to comment.