Merge branch 'release/1.8.0'

This commit is contained in:
2024-02-06 15:08:29 +01:00
8 changed files with 62 additions and 30 deletions

View File

@@ -0,0 +1,9 @@
import { notFound } from 'next/navigation';
import { LocationEditForm } from '@/app/ui/LocationEditForm';
import { fetchLocationById } from '@/app/lib/actions/locationActions';
import { YearMonth } from '@/app/lib/db-types';
import { Main } from '@/app/ui/Main';
export default async function LocationAddPage({ yearMonth }: { yearMonth:YearMonth }) {
return (<LocationEditForm yearMonth={yearMonth} />);
}

View File

@@ -1,6 +1,15 @@
import { parseYearMonth } from '@/app/lib/format';
import { LocationEditForm } from '@/app/ui/LocationEditForm';
import { LocationEditFormSkeleton } from '@/app/ui/LocationEditForm';
import LocationAddPage from './LocationAddPage';
import { Main } from '@/app/ui/Main';
import { Suspense } from 'react';
export default async function Page({ params:{ id } }: { params: { id:string } }) {
return (<LocationEditForm yearMonth={ parseYearMonth(id) } />);
return (
<Main>
<Suspense fallback={<LocationEditFormSkeleton />}>
<LocationAddPage yearMonth={ parseYearMonth(id) } />
</Suspense>
</Main>
);
}

View File

@@ -0,0 +1,14 @@
import { notFound } from 'next/navigation';
import { fetchLocationById } from '@/app/lib/actions/locationActions';
import { LocationDeleteForm } from '@/app/ui/LocationDeleteForm';
export const LocationDeletePage = async ({ locationId }: { locationId:string }) => {
const location = await fetchLocationById(locationId);
if (!location) {
return(notFound());
}
return (<LocationDeleteForm location={location} />);
}

View File

@@ -1,14 +1,17 @@
import { notFound } from 'next/navigation';
import { fetchLocationById } from '@/app/lib/actions/locationActions';
import { LocationDeleteForm } from '@/app/ui/LocationDeleteForm';
import { Main } from '@/app/ui/Main';
import { Suspense } from 'react';
import { LocationDeletePage } from './LocationDeletePage';
export default async function Page({ params:{ id } }: { params: { id:string } }) {
const location = await fetchLocationById(id);
if (!location) {
return(notFound());
}
return (<LocationDeleteForm location={location} />);
return (
<Main>
<Suspense fallback={<div>Loading...</div>}>
<LocationDeletePage locationId={id} />
</Suspense>
</Main>
);
}

View File

@@ -10,7 +10,7 @@ export default async function LocationEditPage({ locationId }: { locationId:stri
return(notFound());
}
const result = <LocationEditForm location={location} yearMonth={location.yearMonth} />;
const result = <LocationEditForm location={location} />;
return (result);
}

View File

@@ -4,7 +4,6 @@ import { FC } from "react";
import { BillingLocation } from "../lib/db-types";
import { deleteLocationById } from "../lib/actions/locationActions";
import { useFormState } from "react-dom";
import { Main } from "./Main";
import { gotoUrl } from "../lib/actions/navigationActions";
import Link from "next/link";
@@ -23,7 +22,6 @@ export const LocationDeleteForm:FC<LocationDeleteFormProps> = ({ location }) =>
};
return(
<Main>
<div className="card card-compact card-bordered min-w-[20em] max-w-[90em] bg-base-100 shadow-s my-1">
<div className="card-body">
<form action={dispatch}>
@@ -37,6 +35,5 @@ export const LocationDeleteForm:FC<LocationDeleteFormProps> = ({ location }) =>
</form>
</div>
</div>
</Main>
)
);
}

View File

@@ -12,10 +12,10 @@ export type LocationEditFormProps = {
/** location which should be edited */
location: BillingLocation,
/** year adn month at a new billing location should be assigned */
yearMonth: undefined
yearMonth?: undefined
} | {
/** location which should be edited */
location: undefined,
location?: undefined,
/** year adn month at a new billing location should be assigned */
yearMonth: YearMonth
}
@@ -23,7 +23,7 @@ export type LocationEditFormProps = {
export const LocationEditForm:FC<LocationEditFormProps> = ({ location, yearMonth }) =>
{
const initialState = { message: null, errors: {} };
const handleAction = updateOrAddLocation.bind(null, location?._id, yearMonth);
const handleAction = updateOrAddLocation.bind(null, location?._id, location?.yearMonth ?? yearMonth);
const [ state, dispatch ] = useFormState(handleAction, initialState);
let { year, month } = location ? location.yearMonth : yearMonth;

View File

@@ -9,7 +9,7 @@ networks:
services:
web-app:
image: utility-bills-tracker:1.7.0
image: utility-bills-tracker:1.8.0
networks:
- traefik-network
- mongo-network