From 160c4f00f51708a30dbc5bff736e9daebff35d62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Dere=C5=BEi=C4=87?= Date: Mon, 19 Feb 2024 10:21:25 +0100 Subject: [PATCH] BugFix: delete button did not use locale path prefix --- app/ui/BillEditForm.tsx | 5 +++-- app/ui/LocationEditForm.tsx | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/ui/BillEditForm.tsx b/app/ui/BillEditForm.tsx index d27ba87..03f1d10 100644 --- a/app/ui/BillEditForm.tsx +++ b/app/ui/BillEditForm.tsx @@ -8,7 +8,7 @@ import { updateOrAddBill } from "../lib/actions/billActions"; import Link from "next/link"; import { formatYearMonth } from "../lib/format"; 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 // This is a workaround for that @@ -27,6 +27,7 @@ export interface BillEditFormProps { export const BillEditForm:FC = ({ location, bill }) => { 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:"" }; @@ -72,7 +73,7 @@ export const BillEditForm:FC = ({ location, bill }) => { { // don't show the delete button if we are adding a new bill bill ? - + : null } diff --git a/app/ui/LocationEditForm.tsx b/app/ui/LocationEditForm.tsx index ae8e144..a64ea24 100644 --- a/app/ui/LocationEditForm.tsx +++ b/app/ui/LocationEditForm.tsx @@ -6,7 +6,7 @@ import { BillingLocation, YearMonth } from "../lib/db-types"; import { updateOrAddLocation } from "../lib/actions/locationActions"; import { useFormState } from "react-dom"; import Link from "next/link"; -import { useTranslations } from "next-intl"; +import { useLocale, useTranslations } from "next-intl"; export type LocationEditFormProps = { /** location which should be edited */ @@ -26,6 +26,7 @@ export const LocationEditForm:FC = ({ location, yearMonth const handleAction = updateOrAddLocation.bind(null, location?._id, location?.yearMonth ?? yearMonth); const [ state, dispatch ] = useFormState(handleAction, initialState); const t = useTranslations("location-edit-form"); + const locale = useLocale(); let { year, month } = location ? location.yearMonth : yearMonth; @@ -35,7 +36,7 @@ export const LocationEditForm:FC = ({ location, yearMonth
{ location && - + }