diff --git a/client/pages/Dashboard.tsx b/client/pages/Dashboard.tsx index c175174e..e00b3552 100644 --- a/client/pages/Dashboard.tsx +++ b/client/pages/Dashboard.tsx @@ -9,6 +9,8 @@ import { aethexProjectService, aethexAchievementService, } from "@/lib/aethex-database-adapter"; +import { communityService } from "@/lib/supabase-service"; +import PostComposer from "@/components/social/PostComposer"; import { Card, CardContent, @@ -68,6 +70,8 @@ export default function Dashboard() { teamMembers: 0, performanceScore: "0%", }); + const [userPosts, setUserPosts] = useState([]); + const [applications, setApplications] = useState([]); useEffect(() => { console.log("Dashboard useEffect:", { @@ -108,6 +112,7 @@ export default function Dashboard() { setLinkedin(profile?.linkedin_url || ""); setGithub(profile?.github_url || ""); setTwitter(profile?.twitter_url || ""); + if (profile) computeProfileCompletion(profile); }, [profile]); const saveProfile = async () => { @@ -157,6 +162,32 @@ export default function Dashboard() { setProjects([]); } + // Load user's recent posts + try { + const posts = await communityService.getUserPosts(user!.id); + setUserPosts(posts.slice(0, 5)); + } catch (e) { + console.warn("Could not load user posts:", e); + setUserPosts([]); + } + + // Load project applications (if table exists) + try { + const { data, error } = await supabase + .from("project_applications") + .select( + `*, projects!inner(id, title, user_id)` + ) + .eq("projects.user_id", user!.id) + .order("created_at", { ascending: false }) + .limit(10); + if (!error && Array.isArray(data)) setApplications(data); + else setApplications([]); + } catch (e) { + console.warn("Applications fetch skipped or failed:", e); + setApplications([]); + } + // Check and award project-related achievements, then load achievements try { await aethexAchievementService.checkAndAwardProjectAchievements( @@ -548,6 +579,17 @@ export default function Dashboard() { })} + {/* Central Post Composer */} + + + Create a Post + Share updates, images, or videos + + + + + + {/* Settings Section */} + {/* Your Recent Posts */} + + +
+
+ Your Recent Posts + Your latest activity +
+ +
+
+ + {userPosts.length === 0 ? ( +
No posts yet. Share something above.
+ ) : ( + userPosts.map((p: any) => { + let text = ""; + try { const obj = JSON.parse(p.content||"{}"); text = obj.text || p.content; } catch { text = p.content; } + return ( +
+
{p.title}
+ {text &&
{text}
} +
{new Date(p.created_at).toLocaleString()}
+
+ ); + }) + )} +
+
+ {/* Recent Projects */} @@ -900,6 +972,36 @@ export default function Dashboard() { + {/* Applications to Your Projects */} + + +
+
+ Project Applications + People who applied to your projects +
+
+
+ + {applications.length === 0 ? ( +
No applications yet.
+ ) : ( + applications.map((a: any) => ( +
+
+
+
{a.applicant_name || a.applicant_email || "Applicant"}
+
Applied to: {a.projects?.title || a.project_title || "Project"}
+
+
{new Date(a.created_at).toLocaleDateString()}
+
+ {a.message &&
{a.message}
} +
+ )) + )} +
+
+ {/* Achievements */}