added suspense for home page

This commit is contained in:
2024-02-02 10:12:10 +01:00
parent e66958f6a3
commit 3cb93c53c4
4 changed files with 131 additions and 76 deletions

View File

@@ -18,8 +18,8 @@ const getNextYearMonth = (yearMonth:YearMonth) => {
}
export interface MonthLocationListProps {
availableYears: number[];
months: {
availableYears?: number[];
months?: {
[key: string]: {
yearMonth: YearMonth;
locations: BillingLocation[];
@@ -36,6 +36,20 @@ export const MonthLocationList:React.FC<MonthLocationListProps > = ({
const router = useRouter();
const params = useParams();
if(!availableYears || !months) {
const currentYearMonth:YearMonth = {
year: new Date().getFullYear(),
month: new Date().getMonth() + 1
};
return(
<>
<MonthCard yearMonth={currentYearMonth} key={`month-${currentYearMonth}`} monthlyExpense={0} onToggle={() => {}}>
<AddLocationButton yearMonth={currentYearMonth} />
</MonthCard>
</>)
};
const { month: initialMonth } = params;
const [expandedMonth, setExpandedMonth] = React.useState<number>(