569d887d1e
Renaming the package so any further PRs directed to the website are targeted to the reworked code instead of diverging. Once merged, I will start preparing this for deployment to dev to test before releasing to prod. Any improvements will also be applied to this package. I avoided making significant changes to API routes so nothing breaks, but will test it thoroughly today to confirm. That said, everything is ported - double checked. Big diff PR, impossible to review, but last one! No more rebuilds.
14 lines
470 B
TypeScript
14 lines
470 B
TypeScript
// The form collects one "name" field; the webhook payload wants first/last.
|
|
// First token is the first name, the rest join as the last name.
|
|
export function splitFullName(fullName: string): {
|
|
firstName: string;
|
|
lastName: string;
|
|
} {
|
|
const tokens = fullName.trim().split(/\s+/).filter(Boolean);
|
|
if (tokens.length === 0) {
|
|
return { firstName: '', lastName: '' };
|
|
}
|
|
const [firstName, ...rest] = tokens;
|
|
return { firstName, lastName: rest.join(' ') };
|
|
}
|