diff --git a/app/[locale]/location/[id]/add/LocationAddPage.tsx b/app/[locale]/location/[id]/add/LocationAddPage.tsx new file mode 100644 index 0000000..9556980 --- /dev/null +++ b/app/[locale]/location/[id]/add/LocationAddPage.tsx @@ -0,0 +1,6 @@ +import { LocationEditForm } from '@/app/ui/LocationEditForm'; +import { YearMonth } from '@/app/lib/db-types'; + +export default async function LocationAddPage({ yearMonth }: { yearMonth:YearMonth }) { + return (); +} \ No newline at end of file diff --git a/app/[locale]/location/[id]/add/page.tsx b/app/[locale]/location/[id]/add/page.tsx new file mode 100644 index 0000000..3f032fc --- /dev/null +++ b/app/[locale]/location/[id]/add/page.tsx @@ -0,0 +1,11 @@ +import { parseYearMonth } from '@/app/lib/format'; +import LocationAddPage from './LocationAddPage'; +import { Main } from '@/app/ui/Main'; + +export default async function Page({ params:{ id } }: { params: { id:string } }) { + return ( +
+ +
+ ); +} \ No newline at end of file diff --git a/app/[locale]/location/[id]/delete/LocationDeletePage.tsx b/app/[locale]/location/[id]/delete/LocationDeletePage.tsx new file mode 100644 index 0000000..7377733 --- /dev/null +++ b/app/[locale]/location/[id]/delete/LocationDeletePage.tsx @@ -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 (); +} \ No newline at end of file diff --git a/app/[locale]/location/[id]/delete/not-found.tsx b/app/[locale]/location/[id]/delete/not-found.tsx new file mode 100644 index 0000000..1587224 --- /dev/null +++ b/app/[locale]/location/[id]/delete/not-found.tsx @@ -0,0 +1,6 @@ +import { NotFoundPage } from '@/app/ui/NotFoundPage'; + +const BillingLocationNotFound = () => +; + +export default BillingLocationNotFound; \ No newline at end of file diff --git a/app/[locale]/location/[id]/delete/page.tsx b/app/[locale]/location/[id]/delete/page.tsx new file mode 100644 index 0000000..40c7b8e --- /dev/null +++ b/app/[locale]/location/[id]/delete/page.tsx @@ -0,0 +1,19 @@ +import { notFound } from 'next/navigation'; +import { fetchLocationById } from '@/app/lib/actions/locationActions'; +import { LocationDeleteForm } from '@/app/ui/LocationDeleteForm'; +import { Main } from '@/app/ui/Main'; + +export default async function Page({ params:{ id } }: { params: { id:string } }) { + + const location = await fetchLocationById(id); + + if (!location) { + return(notFound()); + } + + return ( +
+ +
+ ); +} \ No newline at end of file diff --git a/app/[locale]/location/[id]/edit/LocationEditPage.tsx b/app/[locale]/location/[id]/edit/LocationEditPage.tsx new file mode 100644 index 0000000..505f634 --- /dev/null +++ b/app/[locale]/location/[id]/edit/LocationEditPage.tsx @@ -0,0 +1,16 @@ +import { notFound } from 'next/navigation'; +import { LocationEditForm } from '@/app/ui/LocationEditForm'; +import { fetchLocationById } from '@/app/lib/actions/locationActions'; + +export default async function LocationEditPage({ locationId }: { locationId:string }) { + + const location = await fetchLocationById(locationId); + + if (!location) { + return(notFound()); + } + + const result = ; + + return (result); +} \ No newline at end of file diff --git a/app/[locale]/location/[id]/edit/not-found.tsx b/app/[locale]/location/[id]/edit/not-found.tsx new file mode 100644 index 0000000..54c9f60 --- /dev/null +++ b/app/[locale]/location/[id]/edit/not-found.tsx @@ -0,0 +1,6 @@ +import { NotFoundPage } from '@/app/ui/NotFoundPage'; + +const BillingLocationNotFound = () => +; + +export default BillingLocationNotFound; \ No newline at end of file diff --git a/app/[locale]/location/[id]/edit/page.tsx b/app/[locale]/location/[id]/edit/page.tsx new file mode 100644 index 0000000..251f944 --- /dev/null +++ b/app/[locale]/location/[id]/edit/page.tsx @@ -0,0 +1,15 @@ +import { Suspense } from 'react'; +import LocationEditPage from './LocationEditPage'; +import { Main } from '@/app/ui/Main'; +import { LocationEditFormSkeleton } from '@/app/ui/LocationEditForm'; + +export default async function Page({ params:{ id } }: { params: { id:string } }) { + + return ( +
+ }> + + +
+ ); +} \ No newline at end of file diff --git a/app/lib/actions/billActions.ts b/app/lib/actions/billActions.ts index 0db48ab..97820ff 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("bill-name-required")), + billName: z.coerce.string().min(1, t("validation.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("not-a-number"), + message: t("validation.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("negative-number") + message: t("validation.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.validation"); + const t = await getTranslations("bill-edit-form"); // 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("form-error-message"), + message: t("validation.form-error-message"), }); } diff --git a/app/lib/actions/locationActions.ts b/app/lib/actions/locationActions.ts index 635acfb..b662c6a 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("location-name-required")), + locationName: z.coerce.string().min(1, t("validation.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.validation"); + const t = await getTranslations("location-edit-form"); const validatedFields = FormSchema(t).safeParse({ locationName: formData.get('locationName'), diff --git a/app/ui/AddLocationButton.tsx b/app/ui/AddLocationButton.tsx index 2f68524..a14f4f8 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.add-location-button"); + const t = useTranslations("home-page"); return(
- + diff --git a/app/ui/AddMonthButton.tsx b/app/ui/AddMonthButton.tsx index ae9f1a5..9e51c9f 100644 --- a/app/ui/AddMonthButton.tsx +++ b/app/ui/AddMonthButton.tsx @@ -11,12 +11,12 @@ export interface AddMonthButtonProps { export const AddMonthButton:React.FC = ({ yearMonth }) => { - const t = useTranslations("home-page.add-month-button"); + const t = useTranslations("home-page"); const locale = useLocale(); return(
- + diff --git a/app/ui/BillDeleteForm.tsx b/app/ui/BillDeleteForm.tsx index fcb39d9..3743c3b 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 1f1120d..1510a30 100644 --- a/app/ui/LocationCard.tsx +++ b/app/ui/LocationCard.tsx @@ -38,11 +38,7 @@ export const LocationCard:FC = ({location: { _id, name, yearM { monthlyExpense > 0 ?

- { - t.rich("payed-total", { - amount: formatCurrency(monthlyExpense), - strong: (chunks:ReactNode) => `${chunks}` - })} + { t("payed-total") } ${monthlyExpense}

: null } diff --git a/app/ui/SelectLanguage.tsx b/app/ui/SelectLanguage.tsx index 623aaa6..478eeba 100644 --- a/app/ui/SelectLanguage.tsx +++ b/app/ui/SelectLanguage.tsx @@ -8,9 +8,9 @@ import { defaultLocale, localeNames, locales } from "../i18n"; export const SelectLanguage: React.FC = () => { const currentPathname = usePathname(); - const locale = useLocale(); - const secondLocale = locales.find((l) => l !== locale) as string; - const secondLocalePathname = defaultLocale === locale ? `/${secondLocale}${currentPathname}` : currentPathname.replace(`/${locale}/`, `/${secondLocale}/`); + const currentLocale = useLocale(); + const secondLocale = locales.find((l) => l !== currentLocale) as string; + const secondLocalePathname = defaultLocale === currentLocale ? `/${secondLocale}${currentPathname}` : currentPathname.replace(`/${currentLocale}`, `/${secondLocale}`); return ({localeNames[secondLocale]}); } \ No newline at end of file diff --git a/docker-compose-deploy.yml b/docker-compose-deploy.yml index 575ba13..5f32496 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.2 + image: utility-bills-tracker:1.25.3 networks: - traefik-network - mongo-network diff --git a/messages/en.json b/messages/en.json index 08d78b5..14a8549 100644 --- a/messages/en.json +++ b/messages/en.json @@ -53,7 +53,7 @@ "location-card": { "edit-card-tooltip": "Edit realestate", "add-bill-button-tooltip": "Add a new bill", - "payed-total": "Payed total: {amount}" + "payed-total": "Payed total:" }, "month-card": { "payed-total-label": "Total monthly expenditure:"