From fc6243f9b858ea9b39ccab945e058098ee3b5f5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Dere=C5=BEi=C4=87?= Date: Sat, 17 Feb 2024 10:14:46 +0100 Subject: [PATCH 1/3] i18n: minor fixes --- app/ui/AddLocationButton.tsx | 4 ++-- app/ui/AddMonthButton.tsx | 6 ++++-- app/ui/BillDeleteForm.tsx | 2 +- app/ui/LocationCard.tsx | 6 +++--- app/ui/LocationDeleteForm.tsx | 2 +- app/ui/SelectLanguage.tsx | 2 +- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/ui/AddLocationButton.tsx b/app/ui/AddLocationButton.tsx index a14f4f8..2f68524 100644 --- a/app/ui/AddLocationButton.tsx +++ b/app/ui/AddLocationButton.tsx @@ -11,11 +11,11 @@ export interface AddLocationButtonProps { export const AddLocationButton:React.FC = ({yearMonth}) => { - const t = useTranslations("home-page"); + const t = useTranslations("home-page.add-location-button"); return(
- + diff --git a/app/ui/AddMonthButton.tsx b/app/ui/AddMonthButton.tsx index 9e51c9f..8ba1484 100644 --- a/app/ui/AddMonthButton.tsx +++ b/app/ui/AddMonthButton.tsx @@ -1,3 +1,5 @@ +"use client"; + import { PlusCircleIcon, CalendarDaysIcon } from "@heroicons/react/24/outline"; import React from "react"; import { formatYearMonth } from "../lib/format"; @@ -11,12 +13,12 @@ export interface AddMonthButtonProps { export const AddMonthButton:React.FC = ({ yearMonth }) => { - const t = useTranslations("home-page"); + const t = useTranslations("home-page.add-month-button"); const locale = useLocale(); return(
- + diff --git a/app/ui/BillDeleteForm.tsx b/app/ui/BillDeleteForm.tsx index 3743c3b..b5d79b0 100644 --- a/app/ui/BillDeleteForm.tsx +++ b/app/ui/BillDeleteForm.tsx @@ -29,7 +29,7 @@ export const BillDeleteForm:FC = ({ bill, location }) => { t.rich("text", { bill_name:bill.name, location_name:location.name, - strong: (chunks:ReactNode) => ${chunks}, + strong: (chunks:ReactNode) => {chunks}, }) }

diff --git a/app/ui/LocationCard.tsx b/app/ui/LocationCard.tsx index 1510a30..ce257ca 100644 --- a/app/ui/LocationCard.tsx +++ b/app/ui/LocationCard.tsx @@ -1,7 +1,7 @@ -'client only'; +'use client'; import { Cog8ToothIcon, PlusCircleIcon } from "@heroicons/react/24/outline"; -import { FC, ReactNode } from "react"; +import { FC } from "react"; import { BillBadge } from "./BillBadge"; import { BillingLocation } from "../lib/db-types"; import { formatYearMonth } from "../lib/format"; @@ -38,7 +38,7 @@ export const LocationCard:FC = ({location: { _id, name, yearM { monthlyExpense > 0 ?

- { t("payed-total") } ${monthlyExpense} + { t("payed-total") } ${formatCurrency(monthlyExpense)}

: null } diff --git a/app/ui/LocationDeleteForm.tsx b/app/ui/LocationDeleteForm.tsx index d3b8c6e..0524aa9 100644 --- a/app/ui/LocationDeleteForm.tsx +++ b/app/ui/LocationDeleteForm.tsx @@ -32,7 +32,7 @@ export const LocationDeleteForm:FC = ({ location }) => { t.rich("text", { name:location.name, - strong: (chunks:ReactNode) => `${chunks}`, + strong: (chunks:ReactNode) => {chunks}, }) }

diff --git a/app/ui/SelectLanguage.tsx b/app/ui/SelectLanguage.tsx index 478eeba..28b2e3a 100644 --- a/app/ui/SelectLanguage.tsx +++ b/app/ui/SelectLanguage.tsx @@ -12,5 +12,5 @@ export const SelectLanguage: React.FC = () => { const secondLocale = locales.find((l) => l !== currentLocale) as string; const secondLocalePathname = defaultLocale === currentLocale ? `/${secondLocale}${currentPathname}` : currentPathname.replace(`/${currentLocale}`, `/${secondLocale}`); - return ({localeNames[secondLocale]}); + return ({localeNames[secondLocale]}); } \ No newline at end of file From f7b92931a985e9ec334c1abc9886c72c01d6bbfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Dere=C5=BEi=C4=87?= Date: Sat, 17 Feb 2024 10:17:17 +0100 Subject: [PATCH 2/3] i18n: fixing form validaton messages --- app/lib/actions/billActions.ts | 10 +++++----- app/lib/actions/locationActions.ts | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/lib/actions/billActions.ts b/app/lib/actions/billActions.ts index 97820ff..0db48ab 100644 --- a/app/lib/actions/billActions.ts +++ b/app/lib/actions/billActions.ts @@ -26,7 +26,7 @@ export type State = { */ const FormSchema = (t:IntlTemplateFn) => z.object({ _id: z.string(), - billName: z.coerce.string().min(1, t("validation.bill-name-required")), + billName: z.coerce.string().min(1, t("bill-name-required")), billNotes: z.string(), payedAmount: z.string().nullable().transform((val, ctx) => { @@ -39,7 +39,7 @@ const FormSchema = (t:IntlTemplateFn) => z.object({ if (isNaN(parsed)) { ctx.addIssue({ code: z.ZodIssueCode.custom, - message: t("validation.not-a-number"), + message: t("not-a-number"), }); // This is a special symbol you can use to @@ -52,7 +52,7 @@ const FormSchema = (t:IntlTemplateFn) => z.object({ if (parsed < 0) { ctx.addIssue({ code: z.ZodIssueCode.custom, - message: t("validation.negative-number") + message: t("negative-number") }); // This is a special symbol you can use to @@ -115,7 +115,7 @@ export const updateOrAddBill = withUser(async (user:AuthenticatedUser, locationI const { id: userId } = user; - const t = await getTranslations("bill-edit-form"); + const t = await getTranslations("bill-edit-form.validation"); // FormSchema const validatedFields = FormSchema(t) @@ -131,7 +131,7 @@ export const updateOrAddBill = withUser(async (user:AuthenticatedUser, locationI console.log("updateBill.validation-error"); return({ errors: validatedFields.error.flatten().fieldErrors, - message: t("validation.form-error-message"), + message: t("form-error-message"), }); } diff --git a/app/lib/actions/locationActions.ts b/app/lib/actions/locationActions.ts index b662c6a..635acfb 100644 --- a/app/lib/actions/locationActions.ts +++ b/app/lib/actions/locationActions.ts @@ -25,7 +25,7 @@ export type State = { */ const FormSchema = (t:IntlTemplateFn) => z.object({ _id: z.string(), - locationName: z.coerce.string().min(1, t("validation.location-name-required")), + locationName: z.coerce.string().min(1, t("location-name-required")), locationNotes: z.string(), }) // dont include the _id field in the response @@ -42,7 +42,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat noStore(); - const t = await getTranslations("location-edit-form"); + const t = await getTranslations("location-edit-form.validation"); const validatedFields = FormSchema(t).safeParse({ locationName: formData.get('locationName'), From 6146d8670f60e25b8c2ae8307ea844ac6ecd27ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Dere=C5=BEi=C4=87?= Date: Sat, 17 Feb 2024 10:18:08 +0100 Subject: [PATCH 3/3] updated version in compose file --- docker-compose-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose-deploy.yml b/docker-compose-deploy.yml index 5f32496..368336b 100644 --- a/docker-compose-deploy.yml +++ b/docker-compose-deploy.yml @@ -9,7 +9,7 @@ networks: services: web-app: - image: utility-bills-tracker:1.25.3 + image: utility-bills-tracker:1.25.4 networks: - traefik-network - mongo-network