File size: 1,197 Bytes
6c34734
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import {
  buildAllocationBarSegment,
  formatHoursPerDay,
  projectBarStyle,
} from "../../planner/allocationTimeline";

interface ProjectAllocationTimelineProps {
  dayDates: Date[];
  startDate: string;
  endDate: string;
  color: string;
  allocationPct: number;
  weeklyCapacityHrs: number;
  onClick?: () => void;
}

export function ProjectAllocationTimeline({
  dayDates,
  startDate,
  endDate,
  color,
  allocationPct,
  weeklyCapacityHrs,
  onClick,
}: ProjectAllocationTimelineProps) {
  const totalDays = dayDates.length;
  const segment = buildAllocationBarSegment(dayDates, startDate, endDate);
  const label = formatHoursPerDay(allocationPct, weeklyCapacityHrs);

  return (
    <div className="planner-timeline">
      <div className="planner-day-grid" />
      {segment ? (
        <button
          className={segment.className}
          onClick={onClick}
          style={{
            ...projectBarStyle(segment, totalDays),
            background: color,
            borderTopColor: color,
          }}
          title={label}
          type="button"
        >
          <span className="planner-bar-label">{label}</span>
        </button>
      ) : null}
    </div>
  );
}