Skip to content
Merged
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
10 changes: 8 additions & 2 deletions src/backend/src/prisma-query-args/projects.query-args.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Prisma } from '@prisma/client';
import { Prisma, Task_Status } from '@prisma/client';
import { getUserQueryArgs } from './user.query-args.js';
import { getDescriptionBulletQueryArgs } from './description-bullets.query-args.js';
import { getTeamPreviewQueryArgs } from './teams.query-args.js';
Expand Down Expand Up @@ -123,7 +123,13 @@ export const getProjectOverviewQueryArgs = (organizationId: string) =>
manager: getUserQueryArgs(organizationId),
status: true,
links: getLinkQueryArgs(),
tasks: getTaskQueryArgs(organizationId)
_count: {
select: {
tasks: {
where: { AND: [{ dateDeleted: null }, { NOT: { status: Task_Status.DONE } }] }
}
}
}
}
},
workPackages: getWorkPackagePreviewQueryArgs(),
Expand Down
2 changes: 1 addition & 1 deletion src/backend/src/transformers/projects.transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export const projectPreviewTransformer = (project: Prisma.ProjectGetPayload<Proj
export const projectOverviewTransformer = (project: Prisma.ProjectGetPayload<ProjectOverviewQueryArgs>): ProjectOverview => {
return {
...projectPreviewTransformer(project),
tasks: project.wbsElement.tasks.map(taskTransformer),
tasksRemaining: project.wbsElement._count.tasks,
links: project.wbsElement.links
};
};
Expand Down
3 changes: 1 addition & 2 deletions src/frontend/src/apis/transformers/projects.transformers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ export const projectOverviewTransformer = (project: ProjectOverview): ProjectOve
startDate: new Date(wp.startDate),
endDate: new Date(wp.endDate)
})),
links: project.links,
tasks: project.tasks.map(taskTransformer)
links: project.links
};
};

Expand Down
6 changes: 3 additions & 3 deletions src/frontend/src/components/ProjectDetailCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import AttachMoneyIcon from '@mui/icons-material/AttachMoney';
import ScheduleIcon from '@mui/icons-material/Schedule';
import { Box, Card, CardContent, Link, Typography, Grid } from '@mui/material';
import { Link as RouterLink } from 'react-router-dom';
import { calculateDaysLeftInProject, daysBetween, ProjectOverview, TaskStatus, WbsElementStatus, wbsPipe } from 'shared';
import { calculateDaysLeftInProject, daysBetween, ProjectOverview, WbsElementStatus, wbsPipe } from 'shared';
import { daysOrWeeksLeftOrLate, emDashPipe, fullNamePipe } from '../utils/pipes';
import WorkPackageStageChip from './WorkPackageStageChip';
import FavoriteProjectButton from './FavoriteProjectButton';
Expand All @@ -23,7 +23,6 @@ interface ProjectDetailCardProps {

const ProjectDetailCard: React.FC<ProjectDetailCardProps> = ({ project, projectIsFavorited }) => {
const containsActiveWorkPackages = project.workPackages.filter((wp) => wp.status === WbsElementStatus.Active).length;
const tasksLeft: number = project.tasks.filter((task) => task.status !== TaskStatus.DONE).length;

const ProjectDetailCardTitle = () => (
<Grid container alignItems="center">
Expand Down Expand Up @@ -63,7 +62,8 @@ const ProjectDetailCard: React.FC<ProjectDetailCardProps> = ({ project, projectI
)}
</Grid>
<Grid item display="flex" justifyContent="left" sx={{ marginTop: 0.5 }} xs={4}>
<TaskIcon sx={{ mr: 1 }} /> <Typography>{`${tasksLeft} task${tasksLeft === 1 ? '' : 's'} left`}</Typography>
<TaskIcon sx={{ mr: 1 }} />{' '}
<Typography>{`${project.tasksRemaining} task${project.tasksRemaining === 1 ? '' : 's'} left`}</Typography>
</Grid>
<Grid item display="flex" xs={4}>
<Work sx={{ mr: 1 }} /> <Typography>{fullNamePipe(project.manager)}</Typography>
Expand Down
2 changes: 1 addition & 1 deletion src/shared/src/types/project-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export interface ProjectPreview extends WbsElementPreview {

export interface ProjectOverview extends ProjectPreview {
links: Link[];
tasks: Task[];
tasksRemaining: number;
}

export interface RetrospectiveWorkPackage extends WorkPackage {
Expand Down
Loading