Initial commit device-management
tests / ci (push) Has been cancelled

This commit is contained in:
Wian Drs
2026-08-25 09:42:00 +07:00
commit 1e80be180e
1159 changed files with 149545 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
import { useCallback } from 'react';
export type GetInitialsFn = (fullName: string) => string;
function getInitial(name: string): string {
return Array.from(name)[0] ?? '';
}
export function useInitials(): GetInitialsFn {
return useCallback((fullName: string): string => {
const names = fullName.trim().split(/\s+/u).filter(Boolean);
if (names.length === 0) {
return '';
}
if (names.length === 1) {
return getInitial(names[0]).toUpperCase();
}
const firstInitial = getInitial(names[0]);
const lastInitial = getInitial(names[names.length - 1]);
return `${firstInitial}${lastInitial}`.toUpperCase();
}, []);
}