23 lines
807 B
TypeScript
23 lines
807 B
TypeScript
import type { Dictionary } from "@/i18n/dictionaries"
|
|
|
|
export type PersonListCopy = Dictionary["inventory"]["people"]["list"]
|
|
export type PersonDetailCopy = Dictionary["inventory"]["people"]["detail"]
|
|
export type PersonFormCopy = Dictionary["inventory"]["people"]["form"]
|
|
export type PersonDepartmentCopy =
|
|
Dictionary["inventory"]["people"]["departments"]
|
|
export type PersonFallbackCopy = Dictionary["inventory"]["people"]["fallback"]
|
|
|
|
export function formatPersonDepartment(
|
|
department: string | null | undefined,
|
|
departmentCopy: PersonDepartmentCopy,
|
|
fallbackCopy: PersonFallbackCopy,
|
|
) {
|
|
if (!department) {
|
|
return fallbackCopy.unknownDepartment
|
|
}
|
|
|
|
return department in departmentCopy
|
|
? departmentCopy[department as keyof PersonDepartmentCopy]
|
|
: fallbackCopy.unknownDepartment
|
|
}
|