Skip to content

Commit

Permalink
378 change hours big modal (#383)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigridge authored Dec 11, 2023
1 parent a0db6b8 commit a0c7314
Show file tree
Hide file tree
Showing 17 changed files with 621 additions and 201 deletions.
2 changes: 1 addition & 1 deletion backend/Api/Projects/ProjectController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public ActionResult<ProjectWithCustomerModel> Put([FromRoute] string orgUrlKey,
service.ClearConsultantCache(orgUrlKey);

var responseModel =
new ProjectWithCustomerModel(project.Name, customer.Name, project.State, project.IsBillable);
new ProjectWithCustomerModel(project.Name, customer.Name, project.State, project.IsBillable, project.Id);

return Ok(responseModel);
}
Expand Down
5 changes: 3 additions & 2 deletions backend/Api/Projects/ProjectModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ public record EngagementReadModel(
[property: Required] EngagementState BookingType,
[property: Required] bool IsBillable);

public record EngagementWriteModel(List<int> ConsultantIds, EngagementState BookingType,
public record EngagementWriteModel( EngagementState BookingType,
bool IsBillable, string ProjectName, string CustomerName);

public record ProjectWithCustomerModel(
[property: Required] string ProjectName,
[property: Required] string CustomerName,
[property: Required] EngagementState BookingType,
[property: Required] bool IsBillable);
[property: Required] bool IsBillable,
[property: Required] int ProjectId);

public record UpdateProjectWriteModel(int EngagementId, EngagementState ProjectState, int StartYear, int StartWeek,
int WeekSpan);
2 changes: 1 addition & 1 deletion backend/Api/StaffingController/ReadModelFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public ConsultantReadModel GetConsultantReadModelForWeek(int consultantId, Week
var readModel = MapToReadModelList(consultant, new List<Week> { week });

return new ConsultantReadModel(consultant, new List<BookedHoursPerWeek> { readModel.Bookings.First() },
new List<DetailedBooking> { readModel.DetailedBooking.First() }, readModel.IsOccupied);
readModel.DetailedBooking.ToList(), readModel.IsOccupied);
}

public ConsultantReadModel GetConsultantReadModelForWeeks(int consultantId, List<Week> weeks)
Expand Down
79 changes: 39 additions & 40 deletions frontend/src/api-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,20 @@ export interface EngagementReadModel {
engagementId: number;
/** @minLength 1 */
engagementName: string;
bookingType: ProjectState;
bookingType: EngagementState;
isBillable: boolean;
}

export enum EngagementState {
Closed = "Closed",
Order = "Order",
Lost = "Lost",
Offer = "Offer",
Active = "Active",
}

export interface EngagementWriteModel {
consultantIds?: number[];
bookingType?: ProjectState;
bookingType?: EngagementState;
isBillable?: boolean;
projectName?: string;
customerName?: string;
Expand All @@ -109,53 +116,59 @@ export interface OrganisationReadModel {
urlKey: string;
}

export enum ProjectState {
Closed = "Closed",
Order = "Order",
Lost = "Lost",
Offer = "Offer",
Active = "Active",
}

export interface ProjectWithCustomerModel {
/** @minLength 1 */
projectName: string;
/** @minLength 1 */
customerName: string;
bookingType: ProjectState;
bookingType: EngagementState;
isBillable: boolean;
/** @format int32 */
projectId: number;
}

export interface SeveralStaffingWriteModel {
type: BookingType;
type?: BookingType;
/** @format int32 */
consultantId: number;
consultantId?: number;
/** @format int32 */
engagementId: number;
engagementId?: number;
/** @format int32 */
startYear: number;
startYear?: number;
/** @format int32 */
startWeek: number;
startWeek?: number;
/** @format int32 */
endYear: number;
endYear?: number;
/** @format int32 */
endWeek: number;
endWeek?: number;
/** @format double */
hours: number;
hours?: number;
}

export interface StaffingWriteModel {
type: BookingType;
type?: BookingType;
/** @format int32 */
consultantId: number;
consultantId?: number;
/** @format int32 */
engagementId: number;
engagementId?: number;
/** @format int32 */
startYear: number;
startYear?: number;
/** @format int32 */
startWeek: number;
startWeek?: number;
/** @format double */
hours: number;
hours?: number;
}

export interface UpdateProjectWriteModel {
/** @format int32 */
engagementId?: number;
projectState?: EngagementState;
/** @format int32 */
startYear?: number;
/** @format int32 */
startWeek?: number;
/** @format int32 */
weekSpan?: number;
}

export interface WeeklyBookingReadModel {
Expand All @@ -181,17 +194,3 @@ export interface WeeklyHours {
/** @format double */
hours: number;
}

export interface ProjectWithCustomerModel {
projectName: string;
customerName: string;
projectState: ProjectState;
isBillable: boolean;
}

export interface EngagementWriteModel {
projectState?: ProjectState;
isBillable?: boolean;
projectName?: string;
customerName?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export async function PUT(
const body: StaffingWriteModel | SeveralStaffingWriteModel = {
type: requestBody.bookingType,
consultantId: Number(requestBody.consultantId),
engagementId: Number(requestBody.bookingId),
engagementId: Number(requestBody.projectId),
startYear: startWeek?.year ?? 0,
startWeek: startWeek?.weekNumber ?? 0,
endYear: endWeek?.year ?? 0,
Expand Down
81 changes: 40 additions & 41 deletions frontend/src/components/FilteredConsultantsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import InfoPill from "./Staffing/InfoPill";
import { Calendar } from "react-feather";
import StaffingSums from "./StaffingSums";
import React from "react";
import { BookedHoursPerWeek } from "@/api-types";

export default function StaffingTable() {
const {
Expand All @@ -20,35 +19,34 @@ export default function StaffingTable() {
const { weekSpan } = useUrlRouteFilter();

return (
<table
className={`w-full ${
weekSpan > 23
? "min-w-[1400px]"
: weekSpan > 11
? "min-w-[850px]"
: "min-w-[700px]"
} table-fixed`}
>
<colgroup>
<col span={1} className="w-14" />
<col span={1} className="w-[190px]" />
{filteredConsultants
.at(0)
?.bookings.map((_, index) => <col key={index} span={1} />)}
</colgroup>
<thead>
<tr className="sticky -top-6 bg-white z-10">
<th colSpan={2} className="pt-3 pl-2 -left-2 relative bg-white">
<div className="flex flex-row gap-3 pb-4 items-center">
<p className="normal-medium ">Konsulenter</p>
<p className="text-primary small-medium rounded-full bg-primary/5 px-2 py-1">
{filteredConsultants?.length}
</p>
</div>
</th>
<>
<table
className={`w-full ${
weekSpan > 23
? "min-w-[1400px]"
: weekSpan > 11
? "min-w-[850px]"
: "min-w-[700px]"
} table-fixed`}
>
<colgroup>
<col span={1} className="w-14" />
<col span={1} className="w-[190px]" />
{filteredConsultants
.at(0)
?.bookings.map((booking: BookedHoursPerWeek) => (
?.bookings.map((_, index) => <col key={index} span={1} />)}
</colgroup>
<thead>
<tr className="sticky -top-6 bg-white z-10">
<th colSpan={2} className="pt-3 pl-2 -left-2 relative bg-white">
<div className="flex flex-row gap-3 pb-4 items-center">
<p className="normal-medium ">Konsulenter</p>
<p className="text-primary small-medium rounded-full bg-primary/5 px-2 py-1">
{filteredConsultants?.length}
</p>
</div>
</th>
{filteredConsultants.at(0)?.bookings?.map((booking) => (
<th key={booking.weekNumber} className=" px-2 py-1 pt-3 ">
<div className="flex flex-col gap-1">
{isCurrentWeek(booking.weekNumber, booking.year) ? (
Expand Down Expand Up @@ -101,18 +99,19 @@ export default function StaffingTable() {
</div>
</th>
))}
</tr>
</thead>
<tbody>
{filteredConsultants?.map((consultant) => (
<ConsultantRows key={consultant.id} consultant={consultant} />
))}
</tbody>
<StaffingSums
weeklyTotalBillable={weeklyTotalBillable}
weeklyTotalBillableAndOffered={weeklyTotalBillableAndOffered}
weeklyInvoiceRates={weeklyInvoiceRates}
/>
</table>
</tr>
</thead>
<tbody>
{filteredConsultants.map((consultant) => (
<ConsultantRows key={consultant.id} consultant={consultant} />
))}
</tbody>
<StaffingSums
weeklyTotalBillable={weeklyTotalBillable}
weeklyTotalBillableAndOffered={weeklyTotalBillableAndOffered}
weeklyInvoiceRates={weeklyInvoiceRates}
/>
</table>
</>
);
}
2 changes: 1 addition & 1 deletion frontend/src/components/Modals/LargeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function LargeModal(props: EasyModalProps) {
}

return (
<BaseModal modalRef={modalRef} classNames="h-[640px] max-w-[1200px]">
<BaseModal modalRef={modalRef} classNames="h-[640px] ">
<div className="flex flex-col h-full">
<LargeModalHeader project={project} />
<div className="flex-1">{children}</div>
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/Modals/LargeModalHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ export function LargeModalHeader({
}: {
project?: ProjectWithCustomerModel;
}) {
const projectStateColor = getColorByProjectState(project?.projectState);
const projectStateColor = getColorByProjectState(project?.bookingType);

return (
<div className="flex flex-row gap-3 items-center">
<div
className={`w-[60px] h-[60px] bg-offer rounded-lg flex justify-center items-center ${projectStateColor}`}
>
{getIconByProjectState(32, project?.projectState)}
{getIconByProjectState(32, project?.bookingType)}
</div>
<div className="flex flex-col justify-center">
<h1>{project?.projectName}</h1>
<div className="flex flex-row gap-2 items-center">
<p className="normal text-black">{project?.customerName}</p>
<div className="w-1 h-1 rounded-full bg-black"></div>
<p className="normal text-black">{project?.projectState}</p>
<p className="normal text-black">{project?.bookingType}</p>
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit a0c7314

Please sign in to comment.