refactor: rename remaining recipient references to person/people

This commit is contained in:
2026-06-16 13:34:15 +02:00
parent 29c7c19cd8
commit cf6820a7aa
33 changed files with 225 additions and 213 deletions
+1 -1
View File
@@ -77,7 +77,7 @@ export default async function Home() {
viewBox="0 0 24 24"
stroke="currentColor"
role="img"
aria-label="total-recipients"
aria-label="total-people"
>
<path
strokeLinecap="round"
@@ -1,5 +1,4 @@
import { getI18n } from "@/i18n/server"
import type { UpdateAssignmentFormType } from "@/schemas/assignment.schema"
import { AssetService } from "@/services/asset.service"
import { AssignmentService } from "@/services/assignment.service"
import { ItemService } from "@/services/item.service"
@@ -37,10 +36,19 @@ export default async function EditAssignmentPage({
<h1 className="text-2xl font-bold">{copy.edit.title}</h1>
</div>
<AssignmentForm
recipients={people}
people={people}
items={items}
assets={assets}
initialData={assignment as UpdateAssignmentFormType}
initialData={{
...assignment,
id: assignment.id,
personId: assignment.recipientId ?? "",
itemId: assignment.itemId ?? undefined,
assetId: assignment.assetId ?? undefined,
quantity: assignment.quantity ?? undefined,
notes: assignment.notes ?? undefined,
assignmentDate: assignment.assignmentDate ?? undefined,
}}
formCopy={copy.form}
schemaCopy={copy.schema}
submitButtonCopy={dictionary.common.submitButton}
@@ -21,7 +21,7 @@ type AssignmentFormCopy = Dictionary["inventory"]["assignments"]["form"]
type AssignmentSchemaCopy = Dictionary["inventory"]["assignments"]["schema"]
interface Props {
recipients: Person[]
people: Person[]
items: Item[]
assets: Asset[]
initialData: UpdateAssignmentFormType
@@ -31,7 +31,7 @@ interface Props {
}
export default function EditAssignmentForm({
recipients,
people,
items,
assets,
initialData,
@@ -84,24 +84,24 @@ export default function EditAssignmentForm({
<form className="flex flex-col gap-4" onSubmit={handleSubmit(onSubmit)}>
<input type="hidden" {...register("id")} />
<div className="flex flex-col gap-2">
<label htmlFor="recipientId" className="mb-2 block text-lg">
{formCopy.recipientLabel}
<label htmlFor="personId" className="mb-2 block text-lg">
{formCopy.personLabel}
</label>
<select
id="recipientId"
{...register("recipientId")}
id="personId"
{...register("personId")}
className={`w-full rounded-lg border px-4 py-2 ${
errors.recipientId ? "border-error" : ""
errors.personId ? "border-error" : ""
}`}
>
{recipients.map((recipient) => (
<option key={recipient.id} value={recipient.id}>
{recipient.firstName} {recipient.lastName}
{people.map((person) => (
<option key={person.id} value={person.id}>
{person.firstName} {person.lastName}
</option>
))}
</select>
{errors.recipientId && (
<p className="text-error">{errors.recipientId.message}</p>
{errors.personId && (
<p className="text-error">{errors.personId.message}</p>
)}
</div>
<div className="flex flex-col gap-2">
@@ -21,7 +21,7 @@ type AssignmentFormCopy = Dictionary["inventory"]["assignments"]["form"]
type AssignmentSchemaCopy = Dictionary["inventory"]["assignments"]["schema"]
interface Props {
recipients: Person[]
people: Person[]
items: Item[]
assets: Asset[]
formCopy: AssignmentFormCopy
@@ -30,7 +30,7 @@ interface Props {
}
export default function CreateAssignmentForm({
recipients,
people,
items,
assets,
formCopy,
@@ -81,25 +81,25 @@ export default function CreateAssignmentForm({
return (
<form className="flex flex-col gap-4" onSubmit={handleSubmit(onSubmit)}>
<div className="flex flex-col gap-2">
<label htmlFor="recipientId" className="mb-2 block text-lg">
{formCopy.recipientLabel}
<label htmlFor="personId" className="mb-2 block text-lg">
{formCopy.personLabel}
</label>
<select
id="recipientId"
{...register("recipientId")}
id="personId"
{...register("personId")}
className={`w-full rounded-lg border px-4 py-2 ${
errors.recipientId ? "border-error" : ""
errors.personId ? "border-error" : ""
}`}
>
<option value="">{formCopy.recipientPlaceholder}</option>
{recipients.map((recipient) => (
<option key={recipient.id} value={recipient.id}>
{recipient.firstName} {recipient.lastName}
<option value="">{formCopy.personPlaceholder}</option>
{people.map((person) => (
<option key={person.id} value={person.id}>
{person.firstName} {person.lastName}
</option>
))}
</select>
{errors.recipientId && (
<p className="text-error">{errors.recipientId.message}</p>
{errors.personId && (
<p className="text-error">{errors.personId.message}</p>
)}
</div>
<div className="flex flex-col gap-2">
+1 -1
View File
@@ -18,7 +18,7 @@ export default async function NewAssignmentPage() {
<h1 className="text-2xl font-bold">{copy.new.title}</h1>
</div>
<AssignmentForm
recipients={people}
people={people}
items={items}
assets={assets}
formCopy={copy.form}
+5 -5
View File
@@ -19,7 +19,7 @@ export default async function AssignmentsPage(props: {
const currentPage = searchParams?.page ? parseInt(searchParams.page, 10) : 1
const search = searchParams?.search || ""
const { data: assignments, totalPages } =
await AssignmentService.findAllWithRecipientPaginated({
await AssignmentService.findAllWithPersonPaginated({
page: currentPage,
search,
})
@@ -42,7 +42,7 @@ export default async function AssignmentsPage(props: {
<thead className="border-b">
<tr>
<th scope="col" className="p-4">
{copy.list.columns.recipient}
{copy.list.columns.person}
</th>
<th scope="col" className="p-4">
{copy.list.columns.item}
@@ -63,11 +63,11 @@ export default async function AssignmentsPage(props: {
<tr key={assignment.id} className="border-b">
<td className="p-4">
<Link
href={`/people/${assignment?.recipient?.id}`}
href={`/people/${assignment?.person?.id}`}
className="hover:underline"
>
{assignment?.recipient?.firstName}{" "}
{assignment?.recipient?.lastName}
{assignment?.person?.firstName}{" "}
{assignment?.person?.lastName}
</Link>
</td>
<td className="p-4">
@@ -31,7 +31,7 @@ export default async function EditAssetPage({
</div>
<EditAssetForm
items={items}
recipients={people}
people={people}
asset={asset as unknown as AssetWithAssignment}
formCopy={copy.form}
schemaCopy={copy.schema}
@@ -31,7 +31,7 @@ import type {
interface EditAssetFormProps {
asset: AssetWithAssignment
items: Item[]
recipients: Person[]
people: Person[]
formCopy: AssetFormCopy
schemaCopy: AssetSchemaCopy
statusCopy: AssetStatusCopy
@@ -41,7 +41,7 @@ interface EditAssetFormProps {
export default function EditAssetForm({
asset,
items,
recipients,
people,
formCopy,
schemaCopy,
statusCopy,
@@ -64,7 +64,7 @@ export default function EditAssetForm({
serialNumber: asset.serialNumber,
deliveryNote: asset.deliveryNote ?? undefined,
status: asset.status as UpdateAssetStatus,
recipientId: asset.assignment?.recipientId ?? undefined,
personId: asset.assignment?.recipientId ?? undefined,
},
shouldFocusError: true,
mode: "onSubmit",
@@ -168,23 +168,23 @@ export default function EditAssetForm({
</div>
{status === "ASSIGNED" && (
<div>
<label htmlFor="recipientId" className="mb-2 block text-lg">
{formCopy.recipientLabel}
<label htmlFor="personId" className="mb-2 block text-lg">
{formCopy.personLabel}
</label>
<select
id="recipientId"
{...register("recipientId")}
id="personId"
{...register("personId")}
className="w-full rounded-lg border px-4 py-2"
>
<option value="">{formCopy.recipientPlaceholder}</option>
{recipients?.map((recipient) => (
<option key={recipient.id} value={recipient.id}>
{recipient.firstName} {recipient.lastName}
<option value="">{formCopy.personPlaceholder}</option>
{people?.map((person) => (
<option key={person.id} value={person.id}>
{person.firstName} {person.lastName}
</option>
))}
</select>
{errors?.recipientId && (
<p className="text-error">{errors.recipientId.message}</p>
{errors?.personId && (
<p className="text-error">{errors.personId.message}</p>
)}
</div>
)}
@@ -25,7 +25,7 @@ import type {
interface NewAssetFormProps {
items: ItemWithoutStock[]
recipients: Person[]
people: Person[]
formCopy: AssetFormCopy
schemaCopy: AssetSchemaCopy
statusCopy: AssetStatusCopy
@@ -34,7 +34,7 @@ interface NewAssetFormProps {
export default function NewAssetForm({
items,
recipients,
people,
formCopy,
schemaCopy,
statusCopy,
@@ -156,23 +156,23 @@ export default function NewAssetForm({
</div>
{status === "ASSIGNED" && (
<div>
<label htmlFor="recipientId" className="mb-2 block text-lg">
{formCopy.recipientLabel}
<label htmlFor="personId" className="mb-2 block text-lg">
{formCopy.personLabel}
</label>
<select
id="recipientId"
{...register("recipientId")}
id="personId"
{...register("personId")}
className="w-full rounded-lg border px-4 py-2"
>
<option value="">{formCopy.recipientPlaceholder}</option>
{recipients?.map((recipient) => (
<option key={recipient.id} value={recipient.id}>
{recipient.firstName} {recipient.lastName}
<option value="">{formCopy.personPlaceholder}</option>
{people?.map((person) => (
<option key={person.id} value={person.id}>
{person.firstName} {person.lastName}
</option>
))}
</select>
{errors?.recipientId && (
<p className="text-error">{errors.recipientId.message}</p>
{errors?.personId && (
<p className="text-error">{errors.personId.message}</p>
)}
</div>
)}
@@ -19,7 +19,7 @@ export default async function NewAssetPage() {
</div>
<NewAssetForm
items={items}
recipients={people}
people={people}
formCopy={copy.form}
schemaCopy={copy.schema}
statusCopy={copy.status}
+3 -3
View File
@@ -43,7 +43,7 @@ export default async function MovementsPage(props: {
{copy.list.columns.quantity}
</th>
<th scope="col" className="p-4">
{copy.list.columns.recipient}
{copy.list.columns.person}
</th>
<th scope="col" className="p-4">
{copy.list.columns.date}
@@ -69,8 +69,8 @@ export default async function MovementsPage(props: {
</td>
<td className="p-4">{movement.quantity}</td>
<td className="p-4">
{movement?.recipient
? `${movement.recipient.firstName} ${movement.recipient.lastName}`
{movement?.person
? `${movement.person.firstName} ${movement.person.lastName}`
: copy.fallback.missingValue}
</td>
<td className="p-4">{formatDate(movement.createdAt)}</td>