feat: implement person name utility functions and update related components for name handling

This commit is contained in:
Nati
2026-08-19 05:52:26 +00:00
parent d44977cbf3
commit 629b02fd26
6 changed files with 169 additions and 36 deletions

View File

@@ -23,3 +23,4 @@ export * from "./lib/feedback/use-error-handler";
export * from "./lib/data/useServerTable";
export * from "./lib/landing/LandingPage";
export * from "./lib/landing/landing-copy";
export * from "./lib/utils/person-name";

View File

@@ -0,0 +1,19 @@
/**
* Splits and joins a person's name between the account's single `name.en`
* string and the profile's separate `firstName`/`middleName`/`lastName`
* fields.
*
* The account has no first/middle/last columns of its own (that model lives
* only on the profile), so this is the one place that heuristic lives —
* reused everywhere a name crosses that boundary: the signup form joins into
* it, the Identity Details wizard step and the Profile page's Personal tab
* both split out of it.
*/
export function splitPersonName(fullName: string) {
const [firstName = '', middleName = '', ...rest] = fullName.trim().split(/\s+/);
return { firstName, middleName, lastName: rest.join(' ') };
}
export function joinPersonName(parts: { firstName: string; middleName?: string; lastName: string }) {
return [parts.firstName, parts.middleName, parts.lastName].filter(Boolean).join(' ');
}