Prettier format pending files
This commit is contained in:
parent
9bbe6bb428
commit
658acb9340
1 changed files with 59 additions and 37 deletions
|
|
@ -4,7 +4,10 @@ import Layout from "@/components/Layout";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { useAuth } from "@/contexts/AuthContext";
|
import { useAuth } from "@/contexts/AuthContext";
|
||||||
import { aethexToast } from "@/lib/aethex-toast";
|
import { aethexToast } from "@/lib/aethex-toast";
|
||||||
import { aethexProjectService, aethexAchievementService } from "@/lib/aethex-database-adapter";
|
import {
|
||||||
|
aethexProjectService,
|
||||||
|
aethexAchievementService,
|
||||||
|
} from "@/lib/aethex-database-adapter";
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
CardContent,
|
CardContent,
|
||||||
|
|
@ -48,12 +51,12 @@ export default function Dashboard() {
|
||||||
activeProjects: 0,
|
activeProjects: 0,
|
||||||
completedTasks: 0,
|
completedTasks: 0,
|
||||||
teamMembers: 0,
|
teamMembers: 0,
|
||||||
performanceScore: '0%'
|
performanceScore: "0%",
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!authLoading && !user) {
|
if (!authLoading && !user) {
|
||||||
navigate('/login');
|
navigate("/login");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -71,25 +74,29 @@ export default function Dashboard() {
|
||||||
setProjects(userProjects);
|
setProjects(userProjects);
|
||||||
|
|
||||||
// Load user's achievements
|
// Load user's achievements
|
||||||
const userAchievements = await aethexAchievementService.getUserAchievements(user!.id);
|
const userAchievements =
|
||||||
|
await aethexAchievementService.getUserAchievements(user!.id);
|
||||||
setAchievements(userAchievements);
|
setAchievements(userAchievements);
|
||||||
|
|
||||||
// Calculate stats
|
// Calculate stats
|
||||||
const activeCount = userProjects.filter(p => p.status === 'in_progress').length;
|
const activeCount = userProjects.filter(
|
||||||
const completedCount = userProjects.filter(p => p.status === 'completed').length;
|
(p) => p.status === "in_progress",
|
||||||
|
).length;
|
||||||
|
const completedCount = userProjects.filter(
|
||||||
|
(p) => p.status === "completed",
|
||||||
|
).length;
|
||||||
|
|
||||||
setStats({
|
setStats({
|
||||||
activeProjects: activeCount,
|
activeProjects: activeCount,
|
||||||
completedTasks: completedCount,
|
completedTasks: completedCount,
|
||||||
teamMembers: 8, // Mock for now
|
teamMembers: 8, // Mock for now
|
||||||
performanceScore: `${Math.min(95, 70 + (completedCount * 5))}%`
|
performanceScore: `${Math.min(95, 70 + completedCount * 5)}%`,
|
||||||
});
|
});
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error loading dashboard data:', error);
|
console.error("Error loading dashboard data:", error);
|
||||||
aethexToast.error({
|
aethexToast.error({
|
||||||
title: 'Failed to load dashboard',
|
title: "Failed to load dashboard",
|
||||||
description: 'Please try refreshing the page'
|
description: "Please try refreshing the page",
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
|
|
@ -98,25 +105,25 @@ export default function Dashboard() {
|
||||||
|
|
||||||
const handleQuickAction = async (actionTitle: string) => {
|
const handleQuickAction = async (actionTitle: string) => {
|
||||||
switch (actionTitle) {
|
switch (actionTitle) {
|
||||||
case 'Start New Project':
|
case "Start New Project":
|
||||||
navigate('/projects/new');
|
navigate("/projects/new");
|
||||||
break;
|
break;
|
||||||
case 'Join Team':
|
case "Join Team":
|
||||||
navigate('/teams');
|
navigate("/teams");
|
||||||
break;
|
break;
|
||||||
case 'Access Labs':
|
case "Access Labs":
|
||||||
navigate('/research');
|
navigate("/research");
|
||||||
break;
|
break;
|
||||||
case 'View Analytics':
|
case "View Analytics":
|
||||||
aethexToast.info({
|
aethexToast.info({
|
||||||
title: 'Analytics',
|
title: "Analytics",
|
||||||
description: 'Analytics dashboard coming soon!'
|
description: "Analytics dashboard coming soon!",
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
aethexToast.info({
|
aethexToast.info({
|
||||||
title: actionTitle,
|
title: actionTitle,
|
||||||
description: 'Feature coming soon!'
|
description: "Feature coming soon!",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -159,33 +166,48 @@ export default function Dashboard() {
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const getProgressPercentage = (project: any) => {
|
const getProgressPercentage = (project: any) => {
|
||||||
switch (project.status) {
|
switch (project.status) {
|
||||||
case 'planning': return 20;
|
case "planning":
|
||||||
case 'in_progress': return 60;
|
return 20;
|
||||||
case 'completed': return 100;
|
case "in_progress":
|
||||||
default: return 0;
|
return 60;
|
||||||
|
case "completed":
|
||||||
|
return 100;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getPriorityFromTech = (technologies: string[]) => {
|
const getPriorityFromTech = (technologies: string[]) => {
|
||||||
if (technologies.some(tech => tech.toLowerCase().includes('ai') || tech.toLowerCase().includes('blockchain'))) {
|
if (
|
||||||
return 'High';
|
technologies.some(
|
||||||
|
(tech) =>
|
||||||
|
tech.toLowerCase().includes("ai") ||
|
||||||
|
tech.toLowerCase().includes("blockchain"),
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
return "High";
|
||||||
}
|
}
|
||||||
return 'Medium';
|
return "Medium";
|
||||||
};
|
};
|
||||||
|
|
||||||
const getAchievementIcon = (iconName: string) => {
|
const getAchievementIcon = (iconName: string) => {
|
||||||
switch (iconName.toLowerCase()) {
|
switch (iconName.toLowerCase()) {
|
||||||
case 'code': return Code;
|
case "code":
|
||||||
case 'users': return Users;
|
return Code;
|
||||||
case 'rocket': return Rocket;
|
case "users":
|
||||||
case 'database': return Database;
|
return Users;
|
||||||
case 'shield': return Shield;
|
case "rocket":
|
||||||
case 'trophy': return Trophy;
|
return Rocket;
|
||||||
default: return Star;
|
case "database":
|
||||||
|
return Database;
|
||||||
|
case "shield":
|
||||||
|
return Shield;
|
||||||
|
case "trophy":
|
||||||
|
return Trophy;
|
||||||
|
default:
|
||||||
|
return Star;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue