From 0ce7b11c3c5ac00c9a29baf85394aae446fa2c06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Dere=C5=BEi=C4=87?= Date: Tue, 6 Feb 2024 09:56:36 +0100 Subject: [PATCH] optimizirano generiranje popisa lokacija --- app/ui/MonthLocationList.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/ui/MonthLocationList.tsx b/app/ui/MonthLocationList.tsx index eb484a1..01b3584 100644 --- a/app/ui/MonthLocationList.tsx +++ b/app/ui/MonthLocationList.tsx @@ -7,7 +7,7 @@ import { MonthCard } from "./MonthCard"; import Pagination from "./Pagination"; import { LocationCard } from "./LocationCard"; import { BillingLocation, YearMonth } from "../lib/db-types"; -import { useParams, useRouter, useSearchParams } from "next/navigation"; +import { useRouter, useSearchParams } from "next/navigation"; const getNextYearMonth = (yearMonth:YearMonth) => { const {year, month} = yearMonth; @@ -77,11 +77,15 @@ export const MonthLocationList:React.FC = ({ monthsArray.map(([monthKey, { yearMonth, locations, monthlyExpense }], monthIx) => { - locations.map((location, ix) => ) + yearMonth.month === expandedMonth ? + locations.map((location, ix) => ) + : null } { - // show AddLocationButton as a last item in the first month - monthIx === 0 ? : null + yearMonth.month === expandedMonth ? + // show AddLocationButton as a last item in the first month + (monthIx === 0 ? : null) + : null } )