Skip to content

Commit

Permalink
moved my types out of api-types
Browse files Browse the repository at this point in the history
  • Loading branch information
MariaBonde committed Jan 10, 2025
1 parent d39119a commit 62a6fae
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 54 deletions.
2 changes: 1 addition & 1 deletion frontend/mockdata/mockData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {
DepartmentReadModel,
DetailedBooking,
EngagementPerCustomerReadModel,
Forecast,
OrganisationReadModel,
WeeklyBookingReadModel,
} from "@/api-types";
import { Forecast } from "@/types";

const MockWeeklyBookingReadModel: WeeklyBookingReadModel = {
totalHolidayHours: 0,
Expand Down
26 changes: 2 additions & 24 deletions frontend/src/api-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* ---------------------------------------------------------------
*/

import { Forecast } from "./types";

export interface BookedHoursPerWeek {
/** @format int32 */
year: number;
Expand All @@ -20,11 +22,6 @@ export interface BookedHoursPerWeek {
dateString: string;
bookingModel: WeeklyBookingReadModel;
}
export interface BookedHoursPerMonth {
month: number;
year: number;
bookingModel: WeeklyBookingReadModel;
}
export interface BookingDetails {
/** @minLength 1 */
projectName: string;
Expand Down Expand Up @@ -70,15 +67,6 @@ export interface ConsultantReadModel {
forecasts?: Forecast[];
}

export interface Forecast {
id: number;
month: number;
year: number;
forecastValue: number;
hasBeenChanged: boolean;
valueAddedManually: number;
}

export interface ConsultantWriteModel {
/** @minLength 1 */
name: string;
Expand Down Expand Up @@ -137,11 +125,6 @@ export interface DetailedBooking {
hours: WeeklyHours[];
}

export interface MonthlyDetailedBooking {
bookingDetails: BookingDetails;
hours: MonthlyHours[];
}

export interface EngagementPerCustomerReadModel {
/** @format int32 */
customerId: number;
Expand Down Expand Up @@ -308,11 +291,6 @@ export interface WeeklyHours {
hours: number;
}

export interface MonthlyHours {
month: number;
hours: number;
}

export interface CustomersWithProjectsReadModel {
customerId: number;
customerName: string;
Expand Down
17 changes: 2 additions & 15 deletions frontend/src/components/Forecast/ForecastRows.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
"use client";
import {
BookedHoursPerWeek,
ConsultantReadModel,
ProjectWithCustomerModel,
WeeklyBookingReadModel,
} from "@/api-types";
import { ConsultantReadModel, ProjectWithCustomerModel } from "@/api-types";
import React, { useContext, useEffect, useState } from "react";
import { AlertCircle, CheckCircle, ChevronDown, Plus } from "react-feather";
import { Plus } from "react-feather";
import { DetailedBookingRows } from "@/components/Staffing/DetailedBookingRows";
import { WeekCell } from "@/components/Staffing/WeekCell";
import { useModal } from "@/hooks/useModal";
import { usePathname } from "next/navigation";
import {
Expand All @@ -20,14 +14,7 @@ import { setDetailedBookingHours } from "@/components/Staffing/DetailedBookingRo
import { FilteredContext } from "@/hooks/ConsultantFilterProvider";
import { DateTime } from "luxon";
import Image from "next/image";
import { INTERNAL_CUSTOMER_NAME } from "../Staffing/helpers/utils";
import { MonthCell } from "./MonthCell";
import {
getMonthOfWeek,
MonthDistributionOfWeek,
weekToWeekType,
} from "./WeekToMonthConverter";
import { Month } from "date-fns";
import {
bookingForMonth,
transformToMonthlyData,
Expand Down
10 changes: 4 additions & 6 deletions frontend/src/components/Forecast/HoveredMonth.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
BookingType,
ConsultantReadModel,
MonthlyDetailedBooking,
} from "@/api-types";
import { BookingType, ConsultantReadModel } from "@/api-types";
import {
getColorByStaffingType,
getIconByBookingType,
Expand All @@ -12,6 +8,8 @@ import {
transformDetailedBookingToMonthlyData,
transformToMonthlyData,
} from "./TransformWeekDataToMonth";
import { MonthlyDetailedBooking, MonthlyHours } from "@/types";

function isMonthBookingZeroHours(
detailedBooking: MonthlyDetailedBooking,
hoveredRowMonth: number,
Expand Down Expand Up @@ -116,7 +114,7 @@ export function HoveredMonth(props: {
<p className="small text-black/75">
{
detailedBooking.hours.find(
(hour) => hour.month % 100 == hoveredRowMonth,
(hour: MonthlyHours) => hour.month % 100 == hoveredRowMonth,
)?.hours
}
</p>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/Forecast/MonthCell.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BookedHoursPerMonth, ConsultantReadModel } from "@/api-types";
import { HoveredWeek } from "@/components/Staffing/HoveredWeek";
import { ConsultantReadModel } from "@/api-types";
import { BookedHoursPerMonth } from "@/types";
import InfoPill from "@/components/Staffing/InfoPill";
import {
AlertTriangle,
Expand Down
8 changes: 5 additions & 3 deletions frontend/src/components/Forecast/TransformWeekDataToMonth.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import {
BookedHoursPerMonth,
BookedHoursPerWeek,
BookingDetails,
DetailedBooking,
MonthlyDetailedBooking,
MonthlyHours,
WeeklyBookingReadModel,
} from "@/api-types";
import { getMonthOfWeek, weekToWeekType } from "./WeekToMonthConverter";
import {
BookedHoursPerMonth,
MonthlyDetailedBooking,
MonthlyHours,
} from "@/types";

function round2Decimals(num: number) {
return Math.round(num * 2) / 2;
Expand Down
1 change: 0 additions & 1 deletion frontend/src/components/Staffing/HoveredWeek.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
getIconByBookingType,
isWeekBookingZeroHours,
} from "@/components/Staffing/helpers/utils";
import React from "react";

export function HoveredWeek(props: {
hoveredRowWeek: number;
Expand Down
1 change: 0 additions & 1 deletion frontend/src/components/Staffing/helpers/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
ConsultantReadModel,
DetailedBooking,
EngagementState,
MonthlyDetailedBooking,
} from "@/api-types";
import React, { ReactElement } from "react";
import {
Expand Down
32 changes: 31 additions & 1 deletion frontend/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { BookingType, ConsultantReadModel, EngagementState } from "@/api-types";
import {
BookingDetails,
BookingType,
ConsultantReadModel,
EngagementState,
WeeklyBookingReadModel,
} from "@/api-types";

export type YearRange = {
label: string;
Expand All @@ -21,6 +27,30 @@ export interface updateBookingHoursBody {
endWeek?: number;
}

export interface BookedHoursPerMonth {
month: number;
year: number;
bookingModel: WeeklyBookingReadModel;
}

export interface Forecast {
id: number;
month: number;
year: number;
forecastValue: number;
hasBeenChanged: boolean;
valueAddedManually: number;
}

export interface MonthlyDetailedBooking {
bookingDetails: BookingDetails;
hours: MonthlyHours[];
}
export interface MonthlyHours {
month: number;
hours: number;
}

export interface updateProjectStateBody {
engagementId: string;
projectState: EngagementState;
Expand Down

0 comments on commit 62a6fae

Please sign in to comment.