Merge branch 'feature/add-realestate-button' into develop
This commit is contained in:
@@ -8,7 +8,7 @@ import { updateOrAddBill } from "../lib/actions/billActions";
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { formatYearMonth } from "../lib/format";
|
import { formatYearMonth } from "../lib/format";
|
||||||
import { findDecodePdf417 } from "../lib/pdf/barcodeDecoder";
|
import { findDecodePdf417 } from "../lib/pdf/barcodeDecoder";
|
||||||
import { useTranslations } from "next-intl";
|
import { useLocale, useTranslations } from "next-intl";
|
||||||
|
|
||||||
// Next.js does not encode an utf-8 file name correctly when sending a form with a file attachment
|
// Next.js does not encode an utf-8 file name correctly when sending a form with a file attachment
|
||||||
// This is a workaround for that
|
// This is a workaround for that
|
||||||
@@ -27,6 +27,7 @@ export interface BillEditFormProps {
|
|||||||
export const BillEditForm:FC<BillEditFormProps> = ({ location, bill }) => {
|
export const BillEditForm:FC<BillEditFormProps> = ({ location, bill }) => {
|
||||||
|
|
||||||
const t = useTranslations("bill-edit-form");
|
const t = useTranslations("bill-edit-form");
|
||||||
|
const locale = useLocale();
|
||||||
|
|
||||||
const { _id: billID, name, paid, attachment, notes, payedAmount: initialPayedAmount, barcodeImage: initialBarcodeImage } = bill ?? { _id:undefined, name:"", paid:false, notes:"" };
|
const { _id: billID, name, paid, attachment, notes, payedAmount: initialPayedAmount, barcodeImage: initialBarcodeImage } = bill ?? { _id:undefined, name:"", paid:false, notes:"" };
|
||||||
|
|
||||||
@@ -72,7 +73,7 @@ export const BillEditForm:FC<BillEditFormProps> = ({ location, bill }) => {
|
|||||||
{
|
{
|
||||||
// don't show the delete button if we are adding a new bill
|
// don't show the delete button if we are adding a new bill
|
||||||
bill ?
|
bill ?
|
||||||
<Link href={`/bill/${locationID}-${billID}/delete/`} data-tip={t("delete-tooltip")}>
|
<Link href={`/${locale}/bill/${locationID}-${billID}/delete/`} data-tip={t("delete-tooltip")}>
|
||||||
<TrashIcon className="h-[1em] w-[1em] absolute cursor-pointer text-error bottom-5 right-4 text-2xl" />
|
<TrashIcon className="h-[1em] w-[1em] absolute cursor-pointer text-error bottom-5 right-4 text-2xl" />
|
||||||
</Link> : null
|
</Link> : null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { BillingLocation, YearMonth } from "../lib/db-types";
|
|||||||
import { updateOrAddLocation } from "../lib/actions/locationActions";
|
import { updateOrAddLocation } from "../lib/actions/locationActions";
|
||||||
import { useFormState } from "react-dom";
|
import { useFormState } from "react-dom";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useTranslations } from "next-intl";
|
import { useLocale, useTranslations } from "next-intl";
|
||||||
|
|
||||||
export type LocationEditFormProps = {
|
export type LocationEditFormProps = {
|
||||||
/** location which should be edited */
|
/** location which should be edited */
|
||||||
@@ -26,6 +26,7 @@ export const LocationEditForm:FC<LocationEditFormProps> = ({ location, yearMonth
|
|||||||
const handleAction = updateOrAddLocation.bind(null, location?._id, location?.yearMonth ?? yearMonth);
|
const handleAction = updateOrAddLocation.bind(null, location?._id, location?.yearMonth ?? yearMonth);
|
||||||
const [ state, dispatch ] = useFormState(handleAction, initialState);
|
const [ state, dispatch ] = useFormState(handleAction, initialState);
|
||||||
const t = useTranslations("location-edit-form");
|
const t = useTranslations("location-edit-form");
|
||||||
|
const locale = useLocale();
|
||||||
|
|
||||||
let { year, month } = location ? location.yearMonth : yearMonth;
|
let { year, month } = location ? location.yearMonth : yearMonth;
|
||||||
|
|
||||||
@@ -35,7 +36,7 @@ export const LocationEditForm:FC<LocationEditFormProps> = ({ location, yearMonth
|
|||||||
<form action={dispatch}>
|
<form action={dispatch}>
|
||||||
{
|
{
|
||||||
location &&
|
location &&
|
||||||
<Link href={`/location/${location._id}/delete`} className="absolute bottom-5 right-4 tooltip" data-tip={t("delete-tooltip")}>
|
<Link href={`/${locale}/location/${location._id}/delete`} className="absolute bottom-5 right-4 tooltip" data-tip={t("delete-tooltip")}>
|
||||||
<TrashIcon className="h-[1em] w-[1em] text-error text-2xl" />
|
<TrashIcon className="h-[1em] w-[1em] text-error text-2xl" />
|
||||||
</Link>
|
</Link>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,12 +81,7 @@ export const MonthLocationList:React.FC<MonthLocationListProps > = ({
|
|||||||
locations.map((location, ix) => <LocationCard key={`location-${location._id}`} location={location} />)
|
locations.map((location, ix) => <LocationCard key={`location-${location._id}`} location={location} />)
|
||||||
: null
|
: null
|
||||||
}
|
}
|
||||||
{
|
<AddLocationButton yearMonth={yearMonth} />
|
||||||
yearMonth.month === expandedMonth ?
|
|
||||||
// show AddLocationButton as a last item in the first month
|
|
||||||
(monthIx === 0 ? <AddLocationButton yearMonth={yearMonth} /> : null)
|
|
||||||
: null
|
|
||||||
}
|
|
||||||
</MonthCard>
|
</MonthCard>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user