Newer
Older

Planoetscher Daniel (Student Com20)
committed
import './project-details.scss';
import DetailGrid from 'components/layout/DetailGrid';
import BarChart, { ChartItem } from 'components/graphs/BarChart';

Planoetscher Daniel (Student Com20)
committed
import ButtonLink from 'components/navigation/ButtonLink';
import { getProjectActivity, Project } from 'adapters/project';
import { useEffect, useState } from 'react';
import { getTeam } from 'adapters/team';
import LoadingScreen from 'components/ui/LoadingScreen';
import { parseActivity } from 'adapters/util';
interface Props {
project: Project
}
export default function ProjectDetails({ project }: Props) {
const [teams, setTeams] = useState<string[]>([]);
const [activity, setActivity] = useState<ChartItem[]>([]);
useEffect(() => {
project.teams.forEach(teamId => {
getTeam(teamId).then((team) => setTeams(prev => [...prev, team.name]));
});
getProjectActivity(project.id).then((a) => setActivity(parseActivity(a)))
}, [project]);

Planoetscher Daniel (Student Com20)
committed

Planoetscher Daniel (Student Com20)
committed
icon: 'group',
title: 'Teams',
label: teams.join(', ')

Planoetscher Daniel (Student Com20)
committed
}];
if (project.deadline) {
details.push({
icon: 'warning',
title: 'Deadline',
label: project.deadline?.getMonth().toString() ?? ''
});
}

Planoetscher Daniel (Student Com20)
committed
return (
<section className="project-details">
<DetailGrid details={details} />
{
activity ?
<BarChart data={activity} /> :
<LoadingScreen />
}
<ButtonLink routing href={`/projects/${project.id}/edit`} className="expanded">

Planoetscher Daniel (Student Com20)
committed
Edit
</ButtonLink>
</section>
)
}