File size: 2,305 Bytes
96c0248
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140361e
 
96c0248
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7d889ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { api } from "./client";
import type { CapacityWeek, Dashboard, ProjectAllocationRow, UtilizationRow } from "../types";

export const getDashboard = async () => (await api.get<Dashboard>("/dashboard")).data;

export const getUtilization = async (start: string, end: string) =>
  (await api.get<UtilizationRow[]>("/reports/utilization", { params: { start, end } })).data;

export const getCapacity = async (start: string, end: string) =>
  (await api.get<CapacityWeek[]>("/reports/capacity", { params: { start, end } })).data;

export const getAvailability = async (start: string, end: string) =>
  (await api.get<UtilizationRow[]>("/reports/availability", { params: { start, end } })).data;

export const getOverallocated = async (start: string, end: string) =>
  (await api.get<UtilizationRow[]>("/reports/overallocated", { params: { start, end } })).data;

export const getProjectAllocation = async (start: string, end: string) =>
  (await api.get<ProjectAllocationRow[]>("/reports/project-allocation", { params: { start, end } })).data;

export interface PeopleWeeklyAvailability {
  weeks: string[];
  people: Array<{
    person_id: number;
    name: string;
    role: string | null;
    team: string | null;
    avatar_color: string;
    weekly_capacity_hrs: number;
    weeks: Array<{
      week_start: string;
      available_hours: number;
      allocated_hours: number;
      tentative_hours: number;
      utilization_pct: number;
    }>;
  }>;
}

export const getPeopleWeeklyAvailability = async (start: string, end: string) =>
  (
    await api.get<PeopleWeeklyAvailability>("/reports/people-weekly-availability", {
      params: { start, end },
    })
  ).data;

export interface PeopleDailyAvailability {
  days: string[];
  people: Array<{
    person_id: number;
    name: string;
    role: string | null;
    team: string | null;
    avatar_color: string;
    weekly_capacity_hrs: number;
    days: Array<{
      date: string;
      available_hours: number;
      allocated_hours: number;
      tentative_hours: number;
      utilization_pct: number;
    }>;
  }>;
}

export const getPeopleDailyAvailability = async (start: string, end: string) =>
  (
    await api.get<PeopleDailyAvailability>("/reports/people-daily-availability", {
      params: { start, end },
    })
  ).data;