{
- bills.map(bill =>
)
+ bills.map(bill =>
)
}
diff --git a/app/ui/LocationDeleteForm.tsx b/app/ui/LocationDeleteForm.tsx
new file mode 100644
index 0000000..47737d9
--- /dev/null
+++ b/app/ui/LocationDeleteForm.tsx
@@ -0,0 +1,41 @@
+"use client";
+
+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 { gotoHome } from "../lib/actions/navigationActions";
+
+export interface LocationDeleteFormProps {
+ /** location which should be deleted */
+ location: BillingLocation
+}
+
+export const LocationDeleteForm:FC
= ({ location }) =>
+{
+ const handleAction = deleteLocationById.bind(null, location._id, location.yearMonth);
+ const [ state, dispatch ] = useFormState(handleAction, null);
+
+ const handleCancel = () => {
+ gotoHome(`/location/${location._id}/edit/`);
+ };
+
+ return(
+
+
+
+ )
+}
diff --git a/app/ui/LocationEditForm.tsx b/app/ui/LocationEditForm.tsx
index da81eb1..1f236cd 100644
--- a/app/ui/LocationEditForm.tsx
+++ b/app/ui/LocationEditForm.tsx
@@ -5,9 +5,9 @@ import { FC } from "react";
import { BillingLocation, YearMonth } from "../lib/db-types";
import { updateOrAddLocation } from "../lib/actions/locationActions";
import { useFormState } from "react-dom";
-import { gotoHome } from "../lib/actions/billActions";
import { Main } from "./Main";
import Link from "next/link";
+import { gotoHome } from "../lib/actions/navigationActions";
export interface LocationEditFormProps {
/** location which should be edited */
@@ -25,7 +25,7 @@ export const LocationEditForm:FC = ({ location, yearMonth
// redirect to the main page
const handleCancel = () => {
console.log('handleCancel');
- gotoHome();
+ gotoHome(location ? `/?year=${location?.yearMonth?.year}` : undefined);
};
return(
diff --git a/app/ui/Pagination.tsx b/app/ui/Pagination.tsx
index 66b0e06..8316aa2 100644
--- a/app/ui/Pagination.tsx
+++ b/app/ui/Pagination.tsx
@@ -83,7 +83,7 @@ export default function Pagination({ availableYears } : { availableYears: number
return (