first commit

This commit is contained in:
Your NamebaishaliHolocron
2026-06-15 12:57:03 +05:30
commit b9ac5ae0b2
398 changed files with 49583 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
import { getUsersApi } from "../../api/projectApi";
import { User } from "../../api/projectManager/projectManager";
let userCache: Record<string, string> | null = null;
export async function buildUserMap(): Promise<Record<string, string>> {
if (userCache) return userCache;
const users = await getUsersApi();
const map: Record<string, string> = {};
users.forEach((user: User) => {
map[user.userId] = user.userName;
});
userCache = map;
return map;
}
export async function getUserNameById(userId: string): Promise<string> {
if (!userId) return "—";
const map = await buildUserMap();
return map[userId] || "Unknown User";
}
export async function getUserNamesByIds(ids: string[]): Promise<string[]> {
const map = await buildUserMap();
return ids.map(id => map[id] || "Unknown User");
}

View File

@@ -0,0 +1,16 @@
export function calculateDurationInDays(
startDate?: string | Date,
endDate?: string | Date
): number | null {
if (!startDate || !endDate) return null;
const start = new Date(startDate);
const end = new Date(endDate);
if (isNaN(start.getTime()) || isNaN(end.getTime())) return null;
const diffTime = end.getTime() - start.getTime();
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
return diffDays >= 0 ? diffDays : null;
}