diff --git a/frontend/src/app/components/OneYearAllocation.tsx b/frontend/src/app/components/OneYearAllocation.tsx index d78de809..2ac8e5d9 100644 --- a/frontend/src/app/components/OneYearAllocation.tsx +++ b/frontend/src/app/components/OneYearAllocation.tsx @@ -23,6 +23,8 @@ interface ContributionProps { clientName?: string; sponsor?: string; caseTitle?: string; + kind?: "consulting" | "handsOn" | "squad" | "internal"; + hideTotals?: boolean; } interface WeekInfo { @@ -111,6 +113,8 @@ const OneYearAllocation: React.FC = ({ clientName, sponsor, caseTitle, + kind, + hideTotals = false, }) => { type KindType = "consulting" | "handsOn" | "squad" | "internal"; @@ -130,7 +134,7 @@ const OneYearAllocation: React.FC = ({ }; // Initialize with empty string to ensure we select first non-zero value - const [selectedKind, setSelectedKind] = useState(""); + const [selectedKind, setSelectedKind] = useState(kind || ""); const [selectedBinIndex, setSelectedBinIndex] = useState(null); const currentDate = new Date(); const specifiedMonth = month || currentDate.getMonth() + 1; @@ -177,6 +181,14 @@ const OneYearAllocation: React.FC = ({ }, ] : []), + ...(kind + ? [ + { + field: "Kind", + selectedValues: [kind.charAt(0).toUpperCase() + kind.slice(1)], + }, + ] + : []), ]; const { loading, error, data } = useQuery(ALLOCATION_QUERY, { @@ -232,8 +244,8 @@ const OneYearAllocation: React.FC = ({ }); } - // Set initial selected kind to first non-zero value if not already set - if (selectedKind === "") { + // Set initial selected kind to first non-zero value if not already set and kind is not provided + if (selectedKind === "" && !kind) { const firstNonZeroKind = Object.entries(totals).find( ([_, value]) => value > 0 )?.[0] as KindType; @@ -552,7 +564,7 @@ const OneYearAllocation: React.FC = ({ const histogramData = calculateHistogram(); const renderKinds = () => { - if (!data) return null; + if (!data || kind) return null; const totalHours = totals.consulting + totals.handsOn + totals.squad + totals.internal; @@ -637,21 +649,21 @@ const OneYearAllocation: React.FC = ({ ); return ( -
-
+
+
{histogramData.map((bin, index) => (
@@ -659,16 +671,16 @@ const OneYearAllocation: React.FC = ({ } >
- + {bin.min.toFixed(1)}h - {bin.max.toFixed(1)}h -
- {bin.count} - occurrences +
+ {bin.count} + ×
-
- {((bin.count / totalOccurrences) * 100).toFixed(1)}% +
+ {((bin.count / totalOccurrences) * 100).toFixed(0)}%
))} @@ -934,14 +946,16 @@ const OneYearAllocation: React.FC = ({ ))} ))} - - Total (h) - {totalHoursRow.map((cell, index) => ( - - {Number.isInteger(cell) ? cell.toString() : cell.toFixed(1)} - - ))} - + {!hideTotals && ( + + Total (h) + {totalHoursRow.map((cell, index) => ( + + {Number.isInteger(cell) ? cell.toString() : cell.toFixed(1)} + + ))} + + )}
@@ -950,11 +964,17 @@ const OneYearAllocation: React.FC = ({ if (loading) return
Loading...
; if (error) return
Error: {(error as ApolloError).message}
; + + var title = "One Year Allocation" + if (kind) { + const capitalizedKind = kind.charAt(0).toUpperCase() + kind.slice(1); + title = `${title} - ${capitalizedKind}` + } return (
(new Date()); @@ -187,11 +188,11 @@ export default function RevenueForecastPage() { title: "Consulting", subtitle: "By Consultant", }, - { - id: "consultingFuture", - title: "Consulting", - subtitle: "Next three months", - }, + // { + // id: "consultingFuture", + // title: "Consulting", + // subtitle: "Next three months", + // }, { id: "consultingPre", title: "Consulting Pre", @@ -212,6 +213,10 @@ export default function RevenueForecastPage() { ]} /> +
+ +
+ - + /> */} toggleClient(clientSlug, "consultingPre")} /> +
+ +
+ +
+ +
+