import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { UserStatus } from "@/generated/prisma/client" import { getI18n } from "@/i18n/server" import { AssignmentService } from "@/services/assignment.service" import { PersonService } from "@/services/person.service" import { formatPersonDepartment } from "../_components/person.copy" import { formatUserRole, type UserFallbackCopy, type UserRoleCopy, } from "../_components/user.copy" export default async function PersonInfoPage({ params, }: { params: Promise<{ personId: string }> }) { const { personId } = await params const { dictionary } = await getI18n() const copy = dictionary.inventory.people const assignmentCopy = dictionary.inventory.assignments const userCopy = dictionary.admin.users const person = await PersonService.findByIdWithUser(personId) const assignments = await AssignmentService.findAllByPerson(personId) if (!person) { return
{copy.detail.notFound}
} return (
{`${person.firstName} ${person.lastName}`}
{copy.detail.labels.email} {person.email}
{copy.detail.labels.phone} {person.phone}
{copy.detail.labels.department} {formatPersonDepartment( person.department, copy.departments, copy.fallback, )}
{person.user ? ( <>
{copy.detail.labels.role} {formatUserRole( person.user.role, userCopy.roles as UserRoleCopy, userCopy.fallback as UserFallbackCopy, )}
{copy.detail.labels.status} {person.user.status === UserStatus.ACTIVE ? userCopy.status.active : userCopy.status.inactive}
) : (
{copy.detail.labels.role} {copy.detail.labels.noUser}
)}
{assignments.length > 0 && ( {assignmentCopy.list.title}
{assignments.map((assignment) => (
{assignment.item?.name} {assignment.asset?.serialNumber} {assignment.quantity || 1}
))}
)}
) }