Spaces:
Paused
Paused
Download apps/web/src/utils.js from nenbuj/we-superapp: direct link, hf CLI and curl.
- Browser
- Download file 1.32 kB
-
https://huggingface.co/spaces/nenbuj/we-superapp/resolve/main/apps/web/src/utils.js
- Command line
-
hf download hf://spaces/nenbuj/we-superapp/apps/web/src/utils.js
-
curl -L -o utils.js https://huggingface.co/spaces/nenbuj/we-superapp/resolve/main/apps/web/src/utils.js
1.32 kB
| export const getInitials = (name) => { | |
| if (!name) return 'МЫ'; | |
| const parts = name.trim().split(/\s+/); | |
| if (parts.length >= 2) { | |
| return (parts[0][0] + parts[1][0]).toUpperCase(); | |
| } | |
| return name.slice(0, 2).toUpperCase(); | |
| }; | |
| export const getAvatarColorClass = (name) => { | |
| if (!name) return 'avatar-color-0'; | |
| let hash = 0; | |
| for (let i = 0; i < name.length; i++) { | |
| hash = name.charCodeAt(i) + ((hash << 5) - hash); | |
| } | |
| const colorIndex = Math.abs(hash) % 6; // 6 pre-defined gradients | |
| return `avatar-color-${colorIndex}`; | |
| }; | |
| export const formatDueDate = (timestamp) => { | |
| if (!timestamp) return null; | |
| const date = new Date(timestamp); | |
| const today = new Date(); | |
| today.setHours(0, 0, 0, 0); | |
| const tomorrow = new Date(today); | |
| tomorrow.setDate(tomorrow.getDate() + 1); | |
| const checkDate = new Date(date); | |
| checkDate.setHours(0, 0, 0, 0); | |
| const timeString = date.toLocaleTimeString('ru-RU', { | |
| hour: '2-digit', | |
| minute: '2-digit', | |
| }); | |
| if (checkDate.getTime() === today.getTime()) { | |
| return `Сегодня в ${timeString}`; | |
| } else if (checkDate.getTime() === tomorrow.getTime()) { | |
| return `Завтра в ${timeString}`; | |
| } | |
| return ( | |
| date.toLocaleDateString('ru-RU', { | |
| day: 'numeric', | |
| month: 'short', | |
| }) + ` в ${timeString}` | |
| ); | |
| }; | |