From bfea2b77ab43c9e3cd918174c06ed4fbd2a90f3c Mon Sep 17 00:00:00 2001 From: Asis Ferrer Date: Mon, 15 Jun 2026 00:47:25 +0200 Subject: [PATCH] feat(i18n): localize inventory assignments UI --- .../assignments/[assignmentId]/edit/page.tsx | 9 +- .../_components/edit.assignment.form.tsx | 18 +- .../_components/new.assignment.form.tsx | 22 ++- .../assignments/_components/return.button.tsx | 3 + src/app/(dashboard)/assignments/new/page.tsx | 19 +- src/app/(dashboard)/assignments/page.tsx | 31 ++- .../recipients/[recipientId]/page.tsx | 3 +- src/i18n/dictionaries/en.ts | 40 ++++ src/i18n/dictionaries/es.ts | 40 ++++ .../assignments/assignment-form-pages.test.ts | 177 ++++++++++++++++++ .../app/assignments/assignment-pages.test.ts | 124 ++++++++++++ .../app/recipients/recipient-pages.test.ts | 6 +- tests/unit/i18n/dictionaries.test.ts | 84 +++++++++ 13 files changed, 540 insertions(+), 36 deletions(-) create mode 100644 tests/unit/app/assignments/assignment-form-pages.test.ts create mode 100644 tests/unit/app/assignments/assignment-pages.test.ts diff --git a/src/app/(dashboard)/assignments/[assignmentId]/edit/page.tsx b/src/app/(dashboard)/assignments/[assignmentId]/edit/page.tsx index 9549158..15fc87b 100644 --- a/src/app/(dashboard)/assignments/[assignmentId]/edit/page.tsx +++ b/src/app/(dashboard)/assignments/[assignmentId]/edit/page.tsx @@ -18,9 +18,10 @@ export default async function EditAssignmentPage({ const items = await ItemService.findAllWithStock() const assets = await AssetService.findAll() const { dictionary } = await getI18n() + const copy = dictionary.inventory.assignments if (!assignment) { - return
Assignment not found
+ return
{copy.edit.notFound}
} let assignmentItem: Item = {} as Item @@ -31,12 +32,16 @@ export default async function EditAssignmentPage({ } return ( -
+
+
+

{copy.edit.title}

+
diff --git a/src/app/(dashboard)/assignments/_components/edit.assignment.form.tsx b/src/app/(dashboard)/assignments/_components/edit.assignment.form.tsx index 3c4f841..b8f38f6 100644 --- a/src/app/(dashboard)/assignments/_components/edit.assignment.form.tsx +++ b/src/app/(dashboard)/assignments/_components/edit.assignment.form.tsx @@ -9,17 +9,21 @@ import { SubmitButton, type SubmitButtonCopy, } from "@/components/forms/submitButton" +import type { Dictionary } from "@/i18n/dictionaries" import { type UpdateAssignmentFormType, updateAssignmentSchema, } from "@/schemas/assignment.schema" import type { Asset, Item, Recipient } from "@/types" +type AssignmentFormCopy = Dictionary["inventory"]["assignments"]["form"] + interface Props { recipients: Recipient[] items: Item[] assets: Asset[] initialData: UpdateAssignmentFormType + formCopy: AssignmentFormCopy submitButtonCopy: SubmitButtonCopy } @@ -28,6 +32,7 @@ export default function EditAssignmentForm({ items, assets, initialData, + formCopy, submitButtonCopy, }: Props) { const router = useRouter() @@ -71,7 +76,7 @@ export default function EditAssignmentForm({
0} min={1} max={itemId ? items.find((item) => item.id === itemId)?.stock : 0} + placeholder={formCopy.quantityPlaceholder} defaultValue={1} {...register("quantity")} className={`w-full rounded-lg border px-4 py-2 ${ @@ -159,7 +165,7 @@ export default function EditAssignmentForm({ isSubmitSuccessful={isSubmitSuccessful} disabled={!itemId || (assets.length > 0 && !assetId)} > - Update Assignment + {formCopy.updateSubmit} ) diff --git a/src/app/(dashboard)/assignments/_components/new.assignment.form.tsx b/src/app/(dashboard)/assignments/_components/new.assignment.form.tsx index dee973e..da0d5c0 100644 --- a/src/app/(dashboard)/assignments/_components/new.assignment.form.tsx +++ b/src/app/(dashboard)/assignments/_components/new.assignment.form.tsx @@ -10,16 +10,20 @@ import { SubmitButton, type SubmitButtonCopy, } from "@/components/forms/submitButton" +import type { Dictionary } from "@/i18n/dictionaries" import { type CreateAssignmentFormType, createAssignmentSchema, } from "@/schemas/assignment.schema" import type { Asset, Item, Recipient } from "@/types" +type AssignmentFormCopy = Dictionary["inventory"]["assignments"]["form"] + interface Props { recipients: Recipient[] items: Item[] assets: Asset[] + formCopy: AssignmentFormCopy submitButtonCopy: SubmitButtonCopy } @@ -27,6 +31,7 @@ export default function CreateAssignmentForm({ recipients, items, assets, + formCopy, submitButtonCopy, }: Props) { const router = useRouter() @@ -69,7 +74,7 @@ export default function CreateAssignmentForm({
- + {items.map((item) => (