Skip to content

Commit

Permalink
minor changes to teams
Browse files Browse the repository at this point in the history
  • Loading branch information
psiddharthdesign committed Jul 31, 2024
1 parent fd908c8 commit 0c18dfc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { TeamsCardList } from "@/components/Teams/TeamsCardList";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { getOrganizationTitle } from "@/data/user/organizations";
import { getProjects } from "@/data/user/projects";
import { getTeams } from "@/data/user/teams";
import { getAllProjectsInOrganization } from "@/data/user/projects";
import { getSlimTeamById, getTeams } from "@/data/user/teams";
import {
organizationParamSchema,
projectsfilterSchema
Expand All @@ -27,12 +27,19 @@ async function Projects({
organizationId: string;
filters: z.infer<typeof projectsfilterSchema>;
}) {
const projects = await getProjects({
const projects = await getAllProjectsInOrganization({
organizationId,
teamId: null,
...filters,
});
return <ProjectsCardList projects={projects} />;
const projectWithTeamNames = await Promise.all(projects.map(async (project) => {
if (project.team_id) {
const team = await getSlimTeamById(project.team_id);
const projectWithTeamName = { ...project, teamName: team.name };
return projectWithTeamName;
}
return project;
}));
return <ProjectsCardList projects={projectWithTeamNames} />;
}
async function Teams({
organizationId,
Expand Down
10 changes: 7 additions & 3 deletions src/components/Projects/ProjectsCardList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { format } from "date-fns";
import { motion } from "framer-motion";
import { CalendarDays, Clock, Link as LinkIcon } from "lucide-react";
import Link from "next/link";
import { Badge } from "../ui/badge";

export enum ProjectStatus {
draft = "draft",
Expand Down Expand Up @@ -40,11 +41,13 @@ const itemVariants = {
visible: { opacity: 1, y: 0 },
};

type ProjectCardsProps = {
projects: (Table<"projects"> & { teamName?: string })[];
}

export const ProjectsCardList = ({
projects,
}: {
projects: Table<"projects">[];
}) => {
}: ProjectCardsProps) => {
if (projects.length === 0) {
return (
<p className="text-muted-foreground my-6">
Expand All @@ -69,6 +72,7 @@ export const ProjectsCardList = ({
<MotionCardContent className="p-0 space-y-3" variants={contentVariants} initial="hidden" animate="visible">
<motion.div className="flex justify-between items-center" variants={itemVariants}>
<span className="text-xs text-muted-foreground">ID: {project.id.slice(0, 7)}</span>
<Badge variant="outline" className="bg-primary/10 text-foreground">{project.teamName}</Badge>
</motion.div>
<motion.h2 className="text-lg font-semibold" variants={itemVariants}>{project.name}</motion.h2>
<motion.div className="flex items-center text-xs text-muted-foreground" variants={itemVariants}>
Expand Down

0 comments on commit 0c18dfc

Please sign in to comment.