Update YearOverview component to include 'ready' gift status in calculations and statistics display, adjusting total cost calculations and modifying the presentation of gift counts accordingly.
This commit is contained in:
@@ -26,12 +26,16 @@ export const YearOverview: FC<Props> = async ({ year, heading }) => {
|
|||||||
const planned = gifts.filter((gift) => gift.status === 'planned');
|
const planned = gifts.filter((gift) => gift.status === 'planned');
|
||||||
const decided = gifts.filter((gift) => gift.status === 'decided');
|
const decided = gifts.filter((gift) => gift.status === 'decided');
|
||||||
const bought = gifts.filter((gift) => gift.status === 'bought');
|
const bought = gifts.filter((gift) => gift.status === 'bought');
|
||||||
|
const ready = gifts.filter((gift) => gift.status === 'ready');
|
||||||
const wrapped = gifts.filter((gift) => gift.status === 'wrapped');
|
const wrapped = gifts.filter((gift) => gift.status === 'wrapped');
|
||||||
|
|
||||||
const totalCost = gifts.reduce((acc, gift) => acc + gift.cost, 0);
|
const totalCost = gifts.reduce((acc, gift) => acc + gift.cost, 0);
|
||||||
const totalCostPlanned =
|
const totalCostPlanned =
|
||||||
planned.reduce((acc, gift) => acc + gift.cost, 0) + decided.reduce((acc, gift) => acc + gift.cost, 0);
|
planned.reduce((acc, gift) => acc + gift.cost, 0) + decided.reduce((acc, gift) => acc + gift.cost, 0);
|
||||||
const totalCostBought = bought.reduce((acc, gift) => acc + gift.cost, 0);
|
const totalCostBought =
|
||||||
|
bought.reduce((acc, gift) => acc + gift.cost, 0) +
|
||||||
|
ready.reduce((acc, gift) => acc + gift.cost, 0) +
|
||||||
|
wrapped.reduce((acc, gift) => acc + gift.cost, 0);
|
||||||
|
|
||||||
const remainingBudget = data.budgetLimit - totalCostBought;
|
const remainingBudget = data.budgetLimit - totalCostBought;
|
||||||
|
|
||||||
@@ -42,7 +46,7 @@ export const YearOverview: FC<Props> = async ({ year, heading }) => {
|
|||||||
<StatsCard title='Ilość prezentów' value={gifts.length} />
|
<StatsCard title='Ilość prezentów' value={gifts.length} />
|
||||||
<StatsCard title='Planowane prezenty' value={planned.length} />
|
<StatsCard title='Planowane prezenty' value={planned.length} />
|
||||||
<StatsCard title='Do kupienia' value={decided.length} />
|
<StatsCard title='Do kupienia' value={decided.length} />
|
||||||
<StatsCard title='Kupione' value={bought.length} />
|
<StatsCard title='Do zapakowania' value={ready.length} />
|
||||||
|
|
||||||
<StatsCard
|
<StatsCard
|
||||||
title='Budżet'
|
title='Budżet'
|
||||||
|
|||||||
Reference in New Issue
Block a user