optimizirano generiranje popisa lokacija
This commit is contained in:
@@ -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<MonthLocationListProps > = ({
|
||||
monthsArray.map(([monthKey, { yearMonth, locations, monthlyExpense }], monthIx) =>
|
||||
<MonthCard yearMonth={yearMonth} key={`month-${monthKey}`} monthlyExpense={monthlyExpense} expanded={ yearMonth.month === expandedMonth } onToggle={handleMonthToggle} >
|
||||
{
|
||||
locations.map((location, ix) => <LocationCard key={`location-${location._id}`} location={location} />)
|
||||
yearMonth.month === expandedMonth ?
|
||||
locations.map((location, ix) => <LocationCard key={`location-${location._id}`} location={location} />)
|
||||
: null
|
||||
}
|
||||
{
|
||||
// show AddLocationButton as a last item in the first month
|
||||
monthIx === 0 ? <AddLocationButton yearMonth={yearMonth} /> : null
|
||||
yearMonth.month === expandedMonth ?
|
||||
// show AddLocationButton as a last item in the first month
|
||||
(monthIx === 0 ? <AddLocationButton yearMonth={yearMonth} /> : null)
|
||||
: null
|
||||
}
|
||||
</MonthCard>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user