16 lines
570 B
TypeScript
16 lines
570 B
TypeScript
export function fieldNameToLabel(fieldName: string): string {
|
|
const withoutId = fieldName.replace(/Id$/, '');
|
|
const spaced = withoutId.replace(/([a-z])([A-Z])/g, '$1 $2');
|
|
return spaced.charAt(0).toUpperCase() + spaced.slice(1);
|
|
}
|
|
|
|
export function resolveFieldValue(record: Record<string, unknown>, path: string): unknown {
|
|
const parts = path.split('.');
|
|
let current: unknown = record;
|
|
for (const part of parts) {
|
|
if (current == null || typeof current !== 'object') return undefined;
|
|
current = (current as Record<string, unknown>)[part];
|
|
}
|
|
return current;
|
|
}
|