initial commit
This commit is contained in:
commit
2e0cbc254c
174 changed files with 27742 additions and 0 deletions
15
resources/js/hooks/use-initials.tsx
Normal file
15
resources/js/hooks/use-initials.tsx
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import { useCallback } from 'react';
|
||||
|
||||
export function useInitials() {
|
||||
return useCallback((fullName: string): string => {
|
||||
const names = fullName.trim().split(' ');
|
||||
|
||||
if (names.length === 0) return '';
|
||||
if (names.length === 1) return names[0].charAt(0).toUpperCase();
|
||||
|
||||
const firstInitial = names[0].charAt(0);
|
||||
const lastInitial = names[names.length - 1].charAt(0);
|
||||
|
||||
return `${firstInitial}${lastInitial}`.toUpperCase();
|
||||
}, []);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue