form action redirects user to tjhe appropriate year

This commit is contained in:
2024-01-17 15:47:55 +01:00
parent 119d64344f
commit 0eb11e7d02
18 changed files with 158 additions and 86 deletions

View File

@@ -8,7 +8,7 @@ import { formatCurrency } from './lib/formatStrings';
import { fetchAvailableYears } from './lib/actions/monthActions';
import { YearMonth } from './lib/db-types';
import { formatYearMonth } from './lib/format';
import { FC } from 'react';
import { FC, Fragment } from 'react';
import Pagination from './ui/Pagination';
import { PageHeader } from './ui/PageHeader';
import { Main } from './ui/Main';
@@ -89,17 +89,17 @@ const Page:FC<PageProps> = async ({ searchParams }) => {
monthlyExpense += location.bills.reduce((acc, bill) => acc + (bill.payedAmount ?? 0), 0);
return (
<>
<Fragment key={`location-${location._id}`}>
{
// show month title above the first LocationCard in the month
isFirstLocationInMonth ?
<MonthTitle key={`${year}-${month}`} yearMonth={location.yearMonth} /> : null
<MonthTitle yearMonth={location.yearMonth} /> : null
}
<LocationCard key={`${location._id}`} location={location} />
<LocationCard location={location} />
{
// show AddLocationButton as a last item in the first month
isLastLocationOfLatestMonth && isLatestYear ?
<AddLocationButton key={`add-loc-${formatYearMonth(location.yearMonth)}`} yearMonth={location.yearMonth} /> : null
<AddLocationButton yearMonth={location.yearMonth} /> : null
}
{
isLastLocationInMonth && monthlyExpense>0 ?
@@ -111,7 +111,7 @@ const Page:FC<PageProps> = async ({ searchParams }) => {
</span>
</div> : null
}
</>
</Fragment>
)
})
}