From ba2dc96e3a5b4a08b3af81a2abfc5333a1742acb Mon Sep 17 00:00:00 2001 From: Nuno Polonia Date: Tue, 26 Mar 2024 15:23:45 +0000 Subject: [PATCH] feat: change proposal estimates to count unique team members instead of team slots --- .../proposals/proposal-estimates.svelte | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/components/proposals/proposal-estimates.svelte b/src/components/proposals/proposal-estimates.svelte index f0af2426..979ec08b 100644 --- a/src/components/proposals/proposal-estimates.svelte +++ b/src/components/proposals/proposal-estimates.svelte @@ -10,6 +10,14 @@ import { formatter } from '$lib/utils/currency'; import { slide } from 'svelte/transition'; + type PhaseTeamType = { + name: string; + role: string | undefined; + rateType: string; + rateValue: number; + duration: number; + }[]; + export let data: ProposalEstimateEntryStoryblok[]; export let team: ProposalTeamEntryStoryblok[] | ProposalPackageTeamEntryStoryblok[]; export let discount: string | undefined; @@ -30,6 +38,7 @@ ); return { + name: teamMember?.team_member.member.name, role: teamMember?.role[0].title, rateType: teamMember?.rate_type, rateValue: +teamMember?.rate_value, @@ -64,12 +73,20 @@ 0 ); + const totalTeam = [ + ...new Set( + enhancedPhases + .reduce((acc: PhaseTeamType, { team }) => [...acc, ...team], []) + .map((member) => member.name) + ) + ].length; + return { color, title, totals: { phases: enhancedPhases.length, - team: enhancedPhases.reduce((total, { team }) => (total += team.length), 0), + team: totalTeam, cost: totalRate + (totalRate * totalPercentage) / 100, duration: enhancedPhases.reduce((total, { duration }) => (total += duration), 0) },