import React, { useState, useEffect, useRef } from 'react';
import { Bell, MessageSquare, Users, UserPlus, Calendar, Search, Menu, X, Home, User, Settings, LogOut, Moon, Sun, Heart, MessageCircle, Share2, Bookmark, MoreHorizontal, Smile, Image, Video, Send, ChevronDown, Hash, Zap, Globe, Lock, FileText, Clock, Book, Award, CheckSquare, PenTool, Paperclip, Coffee, ChevronRight, ExternalLink, Clipboard, AlignLeft, BarChart2, BookOpen, Edit3, Trash2, ThumbsUp, Flag, Layers, Folder, Download, MapPin } from 'lucide-react';
export default function App() {
const [darkMode, setDarkMode] = useState(false);
const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
const [activeTab, setActiveTab] = useState('home');
const [posts, setPosts] = useState([]);
const [newPostText, setNewPostText] = useState('');
const [notifications, setNotifications] = useState([]);
const [suggestedFriends, setSuggestedFriends] = useState([]);
const [trendingTopics, setTrendingTopics] = useState([]);
const [groups, setGroups] = useState([]);
const [events, setEvents] = useState([]);
const [currentUser, setCurrentUser] = useState(null);
const [activePostId, setActivePostId] = useState(null);
const [commentText, setCommentText] = useState('');
const [showShareModal, setShowShareModal] = useState(false);
const [sharePostId, setSharePostId] = useState(null);
const [courses, setCourses] = useState([]);
const [assignments, setAssignments] = useState([]);
const [studyTimer, setStudyTimer] = useState({ active: false, time: 25 * 60, type: 'focus' });
const [timerInterval, setTimerInterval] = useState(null);
const [showStudyTools, setShowStudyTools] = useState(false);
const [studyMaterials, setStudyMaterials] = useState([]);
const [showCreateGroupModal, setShowCreateGroupModal] = useState(false);
const [newGroupData, setNewGroupData] = useState({ name: '', description: '', privacy: 'public' });
const [activeSubTab, setActiveSubTab] = useState('feed');
const commentInputRef = useRef(null);
// Initialize with mock data
useEffect(() => {
// Mock current user
setCurrentUser({
id: 1,
name: "Alex Johnson",
username: "alexj",
avatar: "https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80",
bio: "Computer Science major at State University. Passionate about AI and web development.",
friends: 142,
school: "State University",
year: "Junior",
interests: ["Programming", "AI", "Basketball", "Photography"],
major: "Computer Science",
gpa: "3.8"
});
// Mock posts
setPosts([
{
id: 1,
user: {
id: 2,
name: "Emma Wilson",
avatar: "https://images.unsplash.com/photo-1494790108377-be9c29b29330?ixlib=rb-1.2.1&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80"
},
content: "Just finished my research paper on renewable energy! 🎉 #StudentLife #Science",
image: "https://images.unsplash.com/photo-1497435334941-8c899ee9e8e9?ixlib=rb-1.2.1&auto=format&fit=crop&w=1200&q=80",
timestamp: "2 hours ago",
likes: 24,
comments: [
{
id: 1,
user: {
id: 3,
name: "Marcus Chen",
avatar: "https://images.unsplash.com/photo-1500648767791-00dcc994a43e?ixlib=rb-1.2.1&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80"
},
content: "Congrats! What was your main finding?",
timestamp: "1 hour ago",
likes: 3
},
{
id: 2,
user: {
id: 4,
name: "Sophia Rodriguez",
avatar: "https://images.unsplash.com/photo-1438761681033-6461ffad8d80?ixlib=rb-1.2.1&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80"
},
content: "I'd love to read it when you have time!",
timestamp: "45 minutes ago",
likes: 2
}
],
shares: 2,
showComments: false
},
{
id: 2,
user: {
id: 3,
name: "Marcus Chen",
avatar: "https://images.unsplash.com/photo-1500648767791-00dcc994a43e?ixlib=rb-1.2.1&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80"
},
content: "Study group for Advanced Calculus tomorrow at the library, 5PM. Who's in? #StudyGroup #Math",
timestamp: "4 hours ago",
likes: 18,
comments: [
{
id: 3,
user: {
id: 5,
name: "Jordan Rivera",
avatar: "https://images.unsplash.com/photo-1506794778202-cad84cf45f1d?ixlib=rb-1.2.1&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80"
},
content: "I'll be there! Should we bring the textbooks?",
timestamp: "3 hours ago",
likes: 1
}
],
shares: 3,
showComments: false
},
{
id: 3,
user: {
id: 4,
name: "Sophia Rodriguez",
avatar: "https://images.unsplash.com/photo-1438761681033-6461ffad8d80?ixlib=rb-1.2.1&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80"
},
content: "Our team won the debate competition! So proud of everyone's hard work and dedication. #Debate #Championship",
image: "https://images.unsplash.com/photo-1515187029135-18ee286d815b?ixlib=rb-1.2.1&auto=format&fit=crop&w=1200&q=80",
timestamp: "Yesterday",
likes: 56,
comments: [
{
id: 4,
user: {
id: 1,
name: "Alex Johnson",
avatar: "https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80"
},
content: "Congratulations! What was the topic?",
timestamp: "Yesterday",
likes: 4
},
{
id: 5,
user: {
id: 6,
name: "Taylor Singh",
avatar: "https://images.unsplash.com/photo-1534528741775-53994a69daeb?ixlib=rb-1.2.1&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80"
},
content: "Amazing job! You all deserve it!",
timestamp: "Yesterday",
likes: 2
}
],
shares: 8,
showComments: false
}
]);
// Mock notifications
setNotifications([
{ id: 1, type: "friend_request", user: "Jamie Lee", timestamp: "5 min ago" },
{ id: 2, type: "like", user: "Taylor Kim", post: "your photo", timestamp: "20 min ago" },
{ id: 3, type: "comment", user: "Riley Smith", post: "your status", timestamp: "1 hour ago" },
{ id: 4, type: "group_invite", user: "Jordan Patel", group: "CS Study Group", timestamp: "3 hours ago" },
{ id: 5, type: "assignment", course: "CS 301", title: "Project Milestone", timestamp: "2 hours ago" },
{ id: 6, type: "grade", course: "MATH 201", grade: "A-", timestamp: "Yesterday" }
]);
// Mock suggested friends
setSuggestedFriends([
{ id: 5, name: "Casey Morgan", avatar: "https://images.unsplash.com/photo-1517841905240-472988babdf9?ixlib=rb-1.2.1&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80", mutualFriends: 5 },
{ id: 6, name: "Jordan Rivera", avatar: "https://images.unsplash.com/photo-1506794778202-cad84cf45f1d?ixlib=rb-1.2.1&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80", mutualFriends: 3 },
{ id: 7, name: "Taylor Singh", avatar: "https://images.unsplash.com/photo-1534528741775-53994a69daeb?ixlib=rb-1.2.1&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80", mutualFriends: 2 }
]);
// Mock trending topics
setTrendingTopics([
{ id: 1, tag: "FinalExams", posts: 1243 },
{ id: 2, tag: "CampusLife", posts: 856 },
{ id: 3, tag: "StudyAbroad", posts: 621 },
{ id: 4, tag: "Internships", posts: 542 }
]);
// Mock groups
setGroups([
{ id: 1, name: "Computer Science Club", members: 128, privacy: "public", avatar: "https://images.unsplash.com/photo-1515378791036-0648a3ef77b2?ixlib=rb-1.2.1&auto=format&fit=crop&w=100&h=100&q=80", description: "A community for CS enthusiasts to share knowledge and collaborate on projects." },
{ id: 2, name: "Photography Society", members: 94, privacy: "public", avatar: "https://images.unsplash.com/photo-1554080353-a576cf803bda?ixlib=rb-1.2.1&auto=format&fit=crop&w=100&h=100&q=80", description: "For students passionate about photography. We organize workshops, photo walks, and exhibitions." },
{ id: 3, name: "Business Case Study", members: 56, privacy: "private", avatar: "https://images.unsplash.com/photo-1507679799987-c73779587ccf?ixlib=rb-1.2.1&auto=format&fit=crop&w=100&h=100&q=80", description: "A group for business students to discuss and analyze real-world business cases." },
{ id: 4, name: "Math Study Group", members: 42, privacy: "public", avatar: "https://images.unsplash.com/photo-1635070041078-e363dbe005cb?ixlib=rb-1.2.1&auto=format&fit=crop&w=100&h=100&q=80", description: "Weekly study sessions for advanced mathematics courses." },
{ id: 5, name: "Campus Sustainability", members: 87, privacy: "public", avatar: "https://images.unsplash.com/photo-1542601906990-b4d3fb778b09?ixlib=rb-1.2.1&auto=format&fit=crop&w=100&h=100&q=80", description: "Working together to make our campus more environmentally friendly." }
]);
// Mock events
setEvents([
{ id: 1, title: "Campus Tech Fair", date: "May 15", attendees: 87, location: "Main Hall", description: "Connect with tech companies and explore internship opportunities." },
{ id: 2, title: "End of Semester Party", date: "June 2", attendees: 156, location: "Student Center", description: "Celebrate the end of the semester with food, music, and games!" },
{ id: 3, title: "Career Workshop", date: "May 20", attendees: 42, location: "Library, Room 305", description: "Learn how to build a strong resume and ace your interviews." },
{ id: 4, title: "Research Symposium", date: "May 25", attendees: 63, location: "Science Building", description: "Undergraduate and graduate students present their research projects." },
{ id: 5, title: "Hackathon", date: "June 10-12", attendees: 120, location: "Engineering Building", description: "48-hour coding competition with prizes for the best projects." }
]);
// Mock courses
setCourses([
{ id: 1, code: "CS 301", name: "Data Structures and Algorithms", instructor: "Dr. Sarah Chen", schedule: "MWF 10:00-11:15 AM", room: "Tech Hall 305", credits: 4 },
{ id: 2, code: "MATH 201", name: "Calculus III", instructor: "Prof. James Wilson", schedule: "TR 1:30-2:45 PM", room: "Math Building 210", credits: 3 },
{ id: 3, code: "PHYS 102", name: "Physics for Scientists", instructor: "Dr. Michael Rodriguez", schedule: "MWF 2:00-3:15 PM", room: "Science Center 110", credits: 4 },
{ id: 4, code: "ENG 215", name: "Technical Writing", instructor: "Prof. Emily Taylor", schedule: "TR 9:30-10:45 AM", room: "Humanities 405", credits: 3 }
]);
// Mock assignments
setAssignments([
{ id: 1, courseId: 1, title: "Project Milestone", dueDate: "May 18, 11:59 PM", description: "Submit your project proposal and initial design document.", status: "pending" },
{ id: 2, courseId: 2, title: "Problem Set 7", dueDate: "May 15, 5:00 PM", description: "Complete problems 7.1-7.15 in the textbook.", status: "completed" },
{ id: 3, courseId: 3, title: "Lab Report", dueDate: "May 20, 11:59 PM", description: "Write a report on the results of the pendulum experiment.", status: "pending" },
{ id: 4, courseId: 4, title: "Research Paper Draft", dueDate: "May 25, 11:59 PM", description: "Submit a draft of your research paper (minimum 5 pages).", status: "pending" },
{ id: 5, courseId: 1, title: "Algorithm Analysis", dueDate: "May 22, 11:59 PM", description: "Analyze the time and space complexity of the provided algorithms.", status: "pending" }
]);
// Mock study materials
setStudyMaterials([
{ id: 1, courseId: 1, title: "Lecture Notes - Week 8", type: "pdf", size: "2.4 MB", uploadedBy: "Dr. Sarah Chen", date: "May 5" },
{ id: 2, courseId: 1, title: "Sorting Algorithms Cheat Sheet", type: "pdf", size: "1.1 MB", uploadedBy: "Alex Johnson", date: "May 7" },
{ id: 3, courseId: 2, title: "Practice Exam Solutions", type: "pdf", size: "3.2 MB", uploadedBy: "Prof. James Wilson", date: "May 10" },
{ id: 4, courseId: 3, title: "Lab Experiment Guidelines", type: "docx", size: "1.8 MB", uploadedBy: "Dr. Michael Rodriguez", date: "May 8" },
{ id: 5, courseId: 4, title: "Citation Guide", type: "pdf", size: "0.9 MB", uploadedBy: "Prof. Emily Taylor", date: "May 3" }
]);
}, []);
// Toggle dark mode
useEffect(() => {
if (darkMode) {
document.documentElement.classList.add('dark');
} else {
document.documentElement.classList.remove('dark');
}
}, [darkMode]);
// Handle post submission
const handlePostSubmit = (e) => {
e.preventDefault();
if (!newPostText.trim()) return;
const newPost = {
id: posts.length + 1,
user: currentUser,
content: newPostText,
timestamp: "Just now",
likes: 0,
comments: [],
shares: 0,
showComments: false
};
setPosts([newPost, ...posts]);
setNewPostText('');
};
// Handle like action
const handleLike = (postId) => {
setPosts(posts.map(post =>
post.id === postId ? { ...post, likes: post.likes + 1 } : post
));
};
// Toggle comments visibility
const handleToggleComments = (postId) => {
setPosts(posts.map(post =>
post.id === postId ? { ...post, showComments: !post.showComments } : post
));
setActivePostId(postId);
// Focus the comment input when comments are shown
setTimeout(() => {
if (commentInputRef.current) {
commentInputRef.current.focus();
}
}, 100);
};
// Handle comment submission
const handleCommentSubmit = (postId) => {
if (!commentText.trim()) return;
const newComment = {
id: Math.max(0, ...posts.flatMap(post => post.comments.map(comment => comment.id))) + 1,
user: currentUser,
content: commentText,
timestamp: "Just now",
likes: 0
};
setPosts(posts.map(post =>
post.id === postId
? { ...post, comments: [...post.comments, newComment] }
: post
));
setCommentText('');
};
// Handle share action
const handleShare = (postId) => {
setSharePostId(postId);
setShowShareModal(true);
};
// Complete share action
const completeShare = (destination) => {
setPosts(posts.map(post =>
post.id === sharePostId ? { ...post, shares: post.shares + 1 } : post
));
// Add a notification about the share
const sharedPost = posts.find(post => post.id === sharePostId);
if (sharedPost) {
const newNotification = {
id: notifications.length + 1,
type: "share",
user: currentUser.name,
destination: destination,
timestamp: "Just now"
};
setNotifications([newNotification, ...notifications]);
}
setShowShareModal(false);
setSharePostId(null);
};
// Handle study timer
useEffect(() => {
if (studyTimer.active && !timerInterval) {
const interval = setInterval(() => {
setStudyTimer(prev => {
if (prev.time <= 1) {
clearInterval(interval);
// Switch between focus and break
const newType = prev.type === 'focus' ? 'break' : 'focus';
const newTime = newType === 'focus' ? 25 * 60 : 5 * 60;
// Create notification for timer completion
const newNotification = {
id: notifications.length + 1,
type: "timer",
timerType: prev.type,
timestamp: "Just now"
};
setNotifications([newNotification, ...notifications]);
return {
...prev,
time: newTime,
type: newType,
active: false
};
}
return {
...prev,
time: prev.time - 1
};
});
}, 1000);
setTimerInterval(interval);
} else if (!studyTimer.active && timerInterval) {
clearInterval(timerInterval);
setTimerInterval(null);
}
return () => {
if (timerInterval) {
clearInterval(timerInterval);
}
};
}, [studyTimer.active, timerInterval, notifications]);
// Format timer display
const formatTime = (seconds) => {
const mins = Math.floor(seconds / 60);
const secs = seconds % 60;
return `${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
};
// Toggle study timer
const toggleStudyTimer = () => {
setStudyTimer(prev => ({
...prev,
active: !prev.active
}));
};
// Reset study timer
const resetStudyTimer = () => {
setStudyTimer({
active: false,
time: studyTimer.type === 'focus' ? 25 * 60 : 5 * 60,
type: studyTimer.type
});
};
// Handle create group submission
const handleCreateGroup = () => {
if (!newGroupData.name.trim()) return;
const newGroup = {
id: groups.length + 1,
name: newGroupData.name,
description: newGroupData.description,
privacy: newGroupData.privacy,
members: 1,
avatar: "https://images.unsplash.com/photo-1522202176988-66273c2fd55f?ixlib=rb-1.2.1&auto=format&fit=crop&w=100&h=100&q=80"
};
setGroups([...groups, newGroup]);
setShowCreateGroupModal(false);
setNewGroupData({ name: '', description: '', privacy: 'public' });
// Create notification for new group
const newNotification = {
id: notifications.length + 1,
type: "group_created",
group: newGroupData.name,
timestamp: "Just now"
};
setNotifications([newNotification, ...notifications]);
};
// Toggle assignment status
const toggleAssignmentStatus = (assignmentId) => {
setAssignments(assignments.map(assignment =>
assignment.id === assignmentId
? { ...assignment, status: assignment.status === 'completed' ? 'pending' : 'completed' }
: assignment
));
};
return (
{/* Header/Navigation */}
CampusConnect
{/* Search */}
{/* Study Timer Button */}
{/* Notifications */}
{/* Dark mode toggle */}
{/* Profile dropdown */}
{/* Mobile menu button */}
{/* Mobile menu */}
{mobileMenuOpen && (
{currentUser?.name}
@{currentUser?.username}
)}
{/* Study Tools Popup */}
{showStudyTools && (
Study Tools
Pomodoro Timer
{formatTime(studyTimer.time)}
{studyTimer.type === 'focus' ? 'Focus Time' : 'Break Time'}
Upcoming Assignments
{assignments.filter(a => a.status === 'pending').slice(0, 3).map(assignment => (
{assignment.title}
Due: {assignment.dueDate}
))}
Quick Notes
)}
{/* Share Modal */}
{showShareModal && (
Share Post
)}
{/* Create Group Modal */}
{showCreateGroupModal && (
)}
{/* Main Content */}
{/* Home Page */}
{activeTab === 'home' && (
{/* Left Sidebar */}
Profile
{currentUser?.name}
@{currentUser?.username}
Friends
{currentUser?.friends}
School
{currentUser?.school}
Year
{currentUser?.year}
Major
{currentUser?.major}
{/* Main Feed */}
{/* Create Post */}
{/* Posts Feed */}
{posts.map((post) => (
{post.user.name}
{post.timestamp}
{post.content}
{post.image && (
)}
{/* Comments Section */}
{post.showComments && (
{/* Existing Comments */}
{post.comments.map((comment) => (
{comment.user.name}
{comment.content}
{comment.timestamp}
))}
{/* Add Comment */}
)}
))}
{/* Right Sidebar */}
{/* Notifications */}
{notifications.slice(0, 3).map((notification) => (
{notification.type === 'friend_request' &&
}
{notification.type === 'like' &&
}
{notification.type === 'comment' &&
}
{notification.type === 'group_invite' &&
}
{notification.type === 'assignment' &&
}
{notification.type === 'grade' &&
}
{notification.type === 'share' &&
}
{notification.type === 'timer' &&
}
{notification.type === 'group_created' &&
}
{notification.type === 'friend_request' && (
<>{notification.user} sent you a friend request>
)}
{notification.type === 'like' && (
<>{notification.user} liked {notification.post}>
)}
{notification.type === 'comment' && (
<>{notification.user} commented on {notification.post}>
)}
{notification.type === 'group_invite' && (
<>{notification.user} invited you to join {notification.group}>
)}
{notification.type === 'assignment' && (
<>New assignment in {notification.course}: {notification.title}>
)}
{notification.type === 'grade' && (
<>You received a {notification.grade} in {notification.course}>
)}
{notification.type === 'share' && (
<>You shared a post to {notification.destination}>
)}
{notification.type === 'timer' && (
<>Your {notification.timerType} timer is complete>
)}
{notification.type === 'group_created' && (
<>You created the group {notification.group}>
)}
{notification.timestamp}
))}
{/* Trending Topics */}
Trending Topics
{trendingTopics.map((topic) => (
#{topic.tag}
{topic.posts} posts
))}
{/* Upcoming Events */}
{events.slice(0, 2).map((event) => (
{event.title}
{event.date}
•
{event.location}
{event.attendees} attending
))}
{/* Suggested Friends */}
People You May Know
{suggestedFriends.map((friend) => (
{friend.name}
{friend.mutualFriends} mutual friends
))}
)}
{/* Academic Page */}
{activeTab === 'academic' && (
{/* Courses Tab */}
{activeSubTab === 'courses' && (
{courses.map((course) => (
{course.name}
{course.code}
{course.credits} Credits
{course.instructor}
{course.schedule}
{course.room}
))}
)}
{/* Assignments Tab */}
{activeSubTab === 'assignments' && (
Assignments
{assignments.map((assignment) => {
const course = courses.find(c => c.id === assignment.courseId);
return (
{assignment.status === 'completed' ? (
) : (
)}
{assignment.title}
{course?.code}
{assignment.status === 'completed' ? 'Completed' : 'Pending'}
{assignment.description}
Due: {assignment.dueDate}
);
})}
)}
{/* Study Materials Tab */}
{activeSubTab === 'materials' && (
Study Materials
|
Name
|
Course
|
Uploaded By
|
Date
|
Size
|
Actions
|
{studyMaterials.map((material) => {
const course = courses.find(c => c.id === material.courseId);
return (
{material.title}
.{material.type}
|
{course?.code}
|
{material.uploadedBy}
|
{material.date}
|
{material.size}
|
|
);
})}
)}
{/* Grades Tab */}
{activeSubTab === 'grades' && (
Grades
Current GPA
From previous semester
Credits Completed
64
Out of 120 required
Dean's List
Last achieved: Spring 2023
|
Course
|
Credits
|
Grade
|
Status
|
{courses.map((course) => (
{course.name}
{course.code}
|
{course.credits}
|
{course.code === 'MATH 201' ? 'A-' : course.code === 'CS 301' ? 'A' : 'In Progress'}
|
{course.code === 'MATH 201' || course.code === 'CS 301' ? 'Completed' : 'In Progress'}
|
))}
)}
)}
{/* Groups Page */}
{activeTab === 'groups' && (
Groups
{groups.map((group) => (
{group.name}
{group.privacy === 'private' && (
)}
{group.members} members
{group.description || "No description available."}
))}
)}
{/* Profile Page */}
{activeTab === 'profile' && (
{/* Cover Photo */}
{currentUser?.name}
@{currentUser?.username}
{/* Profile Navigation */}
{/* Profile Info */}
{/* Left Column - About */}
Education
{currentUser?.school}
{currentUser?.year} - {currentUser?.major}
GPA: {currentUser?.gpa}
Interests
{currentUser?.interests.map((interest, index) => (
{interest}
))}
{/* Right Column - Posts */}
{/* Create Post */}
{/* Posts */}
{posts.filter(post => post.user.id === currentUser?.id).length > 0 ? (
posts.filter(post => post.user.id === currentUser?.id).map((post) => (
{post.user.name}
{post.timestamp}
{post.content}
{post.image && (
)}
{/* Comments Section */}
{post.showComments && (
{/* Existing Comments */}
{post.comments.map((comment) => (
{comment.user.name}
{comment.content}
{comment.timestamp}
))}
{/* Add Comment */}
)}
))
) : (
No posts yet. Create your first post!
)}
)}
{/* Friends Page */}
{activeTab === 'friends' && (
Friends
import React, { useState, useEffect } from 'react';
import { Bell, MessageSquare, Users, UserPlus, Calendar, Search, Menu, X, Home, User, Settings, LogOut, Moon, Sun, Heart, MessageCircle, Share2, Bookmark, MoreHorizontal, Smile, Image, Video, Send, ChevronDown, Hash, Zap, Globe, Lock } from 'lucide-react';
export default function App() {
const [darkMode, setDarkMode] = useState(false);
const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
const [activeTab, setActiveTab] = useState('home');
const [posts, setPosts] = useState([]);
const [newPostText, setNewPostText] = useState('');
const [notifications, setNotifications] = useState([]);
const [suggestedFriends, setSuggestedFriends] = useState([]);
const [trendingTopics, setTrendingTopics] = useState([]);
const [groups, setGroups] = useState([]);
const [events, setEvents] = useState([]);
const [currentUser, setCurrentUser] = useState(null);
// Initialize with mock data
useEffect(() => {
// Mock current user
setCurrentUser({
id: 1,
name: "Alex Johnson",
username: "alexj",
avatar: "https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80",
bio: "Computer Science major at State University. Passionate about AI and web development.",
friends: 142,
school: "State University",
year: "Junior",
interests: ["Programming", "AI", "Basketball", "Photography"]
});
// Mock posts
setPosts([
{
id: 1,
user: {
id: 2,
name: "Emma Wilson",
avatar: "https://images.unsplash.com/photo-1494790108377-be9c29b29330?ixlib=rb-1.2.1&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80"
},
content: "Just finished my research paper on renewable energy! 🎉 #StudentLife #Science",
image: "https://images.unsplash.com/photo-1497435334941-8c899ee9e8e9?ixlib=rb-1.2.1&auto=format&fit=crop&w=1200&q=80",
timestamp: "2 hours ago",
likes: 24,
comments: 5,
shares: 2
},
{
id: 2,
user: {
id: 3,
name: "Marcus Chen",
avatar: "https://images.unsplash.com/photo-1500648767791-00dcc994a43e?ixlib=rb-1.2.1&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80"
},
content: "Study group for Advanced Calculus tomorrow at the library, 5PM. Who's in? #StudyGroup #Math",
timestamp: "4 hours ago",
likes: 18,
comments: 12,
shares: 3
},
{
id: 3,
user: {
id: 4,
name: "Sophia Rodriguez",
avatar: "https://images.unsplash.com/photo-1438761681033-6461ffad8d80?ixlib=rb-1.2.1&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80"
},
content: "Our team won the debate competition! So proud of everyone's hard work and dedication. #Debate #Championship",
image: "https://images.unsplash.com/photo-1515187029135-18ee286d815b?ixlib=rb-1.2.1&auto=format&fit=crop&w=1200&q=80",
timestamp: "Yesterday",
likes: 56,
comments: 14,
shares: 8
}
]);
// Mock notifications
setNotifications([
{ id: 1, type: "friend_request", user: "Jamie Lee", timestamp: "5 min ago" },
{ id: 2, type: "like", user: "Taylor Kim", post: "your photo", timestamp: "20 min ago" },
{ id: 3, type: "comment", user: "Riley Smith", post: "your status", timestamp: "1 hour ago" },
{ id: 4, type: "group_invite", user: "Jordan Patel", group: "CS Study Group", timestamp: "3 hours ago" }
]);
// Mock suggested friends
setSuggestedFriends([
{ id: 5, name: "Casey Morgan", avatar: "https://images.unsplash.com/photo-1517841905240-472988babdf9?ixlib=rb-1.2.1&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80", mutualFriends: 5 },
{ id: 6, name: "Jordan Rivera", avatar: "https://images.unsplash.com/photo-1506794778202-cad84cf45f1d?ixlib=rb-1.2.1&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80", mutualFriends: 3 },
{ id: 7, name: "Taylor Singh", avatar: "https://images.unsplash.com/photo-1534528741775-53994a69daeb?ixlib=rb-1.2.1&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80", mutualFriends: 2 }
]);
// Mock trending topics
setTrendingTopics([
{ id: 1, tag: "FinalExams", posts: 1243 },
{ id: 2, tag: "CampusLife", posts: 856 },
{ id: 3, tag: "StudyAbroad", posts: 621 },
{ id: 4, tag: "Internships", posts: 542 }
]);
// Mock groups
setGroups([
{ id: 1, name: "Computer Science Club", members: 128, privacy: "public", avatar: "https://images.unsplash.com/photo-1515378791036-0648a3ef77b2?ixlib=rb-1.2.1&auto=format&fit=crop&w=100&h=100&q=80" },
{ id: 2, name: "Photography Society", members: 94, privacy: "public", avatar: "https://images.unsplash.com/photo-1554080353-a576cf803bda?ixlib=rb-1.2.1&auto=format&fit=crop&w=100&h=100&q=80" },
{ id: 3, name: "Business Case Study", members: 56, privacy: "private", avatar: "https://images.unsplash.com/photo-1507679799987-c73779587ccf?ixlib=rb-1.2.1&auto=format&fit=crop&w=100&h=100&q=80" }
]);
// Mock events
setEvents([
{ id: 1, title: "Campus Tech Fair", date: "May 15", attendees: 87, location: "Main Hall" },
{ id: 2, title: "End of Semester Party", date: "June 2", attendees: 156, location: "Student Center" },
{ id: 3, title: "Career Workshop", date: "May 20", attendees: 42, location: "Library, Room 305" }
]);
}, []);
// Toggle dark mode
useEffect(() => {
if (darkMode) {
document.documentElement.classList.add('dark');
} else {
document.documentElement.classList.remove('dark');
}
}, [darkMode]);
// Handle post submission
const handlePostSubmit = (e) => {
e.preventDefault();
if (!newPostText.trim()) return;
const newPost = {
id: posts.length + 1,
user: currentUser,
content: newPostText,
timestamp: "Just now",
likes: 0,
comments: 0,
shares: 0
};
setPosts([newPost, ...posts]);
setNewPostText('');
};
// Handle like action
const handleLike = (postId) => {
setPosts(posts.map(post =>
post.id === postId ? { ...post, likes: post.likes + 1 } : post
));
};
return (
{/* Header/Navigation */}
CampusConnect
{/* Search */}
{/* Notifications */}
{/* Dark mode toggle */}
{/* Profile dropdown */}
{/* Mobile menu button */}
{/* Mobile menu */}
{mobileMenuOpen && (
{currentUser?.name}
@{currentUser?.username}
)}
{/* Main Content */}
{/* Home Page */}
{activeTab === 'home' && (
{/* Left Sidebar */}
Profile
{currentUser?.name}
@{currentUser?.username}
Friends
{currentUser?.friends}
School
{currentUser?.school}
Year
{currentUser?.year}
{/* Main Feed */}
{/* Create Post */}
{/* Posts Feed */}
{posts.map((post) => (
{post.user.name}
{post.timestamp}
{post.content}
{post.image && (
)}
))}
{/* Right Sidebar */}
{/* Notifications */}
{notifications.slice(0, 3).map((notification) => (
{notification.type === 'friend_request' && }
{notification.type === 'like' && }
{notification.type === 'comment' && }
{notification.type === 'group_invite' && }
{notification.user}
{notification.type === 'friend_request' && ' sent you a friend request'}
{notification.type === 'like' && ' liked '}
{notification.type === 'comment' && ' commented on '}
{notification.type === 'group_invite' && ' invited you to join '}
{(notification.type === 'like' || notification.type === 'comment') && notification.post}
{notification.type === 'group_invite' && notification.group}
{notification.timestamp}
))}
{/* Trending Topics */}
Trending Topics
{trendingTopics.map((topic) => (
#{topic.tag}
{topic.posts} posts
))}
{/* Suggested Friends */}
People You May Know
{suggestedFriends.map((friend) => (
{friend.name}
{friend.mutualFriends} mutual friends
))}
)}
{/* Profile Page */}
{activeTab === 'profile' && (
{/* Cover Photo */}
{currentUser?.name}
@{currentUser?.username}
{/* Profile Navigation */}
{/* Profile Info */}
{/* Left Column - About */}
Education
{currentUser?.school}
{currentUser?.year}
Interests
{currentUser?.interests.map((interest, index) => (
{interest}
))}
{/* Right Column - Posts */}
{/* Create Post */}
{/* Posts */}
{posts.filter(post => post.user.id === currentUser?.id).length > 0 ? (
posts.filter(post => post.user.id === currentUser?.id).map((post) => (
{post.user.name}
{post.timestamp}
{post.content}
{post.image && (
)}
))
) : (
No posts yet. Create your first post!
)}
)}
{/* Friends Page */}
{activeTab === 'friends' && (
{suggestedFriends.concat([
{ id: 8, name: "Alex Thompson", avatar: "https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?ixlib=rb-1.2.1&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80", mutualFriends: 8 },
{ id: 9, name: "Jamie Wilson", avatar: "https://images.unsplash.com/photo-1502378735452-bc7d86632805?ixlib=rb-1.2.1&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80", mutualFriends: 6 },
{ id: 10, name: "Riley Parker", avatar: "https://images.unsplash.com/photo-1519345182560-3f2917c472ef?ixlib=rb-1.2.1&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80", mutualFriends: 4 },
{ id: 11, name: "Morgan Lee", avatar: "https://images.unsplash.com/photo-1531427186611-ecfd6d936c79?ixlib=rb-1.2.1&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80", mutualFriends: 7 },
{ id: 12, name: "Jordan Taylor", avatar: "https://images.unsplash.com/photo-1500648767791-00dcc994a43e?ixlib=rb-1.2.1&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80", mutualFriends: 3 }
]).map((friend) => (
{friend.name}
{friend.mutualFriends} mutual friends
))}
)}
{/* Messages Page */}
{activeTab === 'messages' && (
{/* Conversations List */}
{[
{ id: 1, name: "Emma Wilson", avatar: "https://images.unsplash.com/photo-1494790108377-be9c29b29330?ixlib=rb-1.2.1&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80", lastMessage: "Hey, how's your project coming along?", time: "10:42 AM", unread: true, online: true },
{ id: 2, name: "Marcus Chen", avatar: "https://images.unsplash.com/photo-1500648767791-00dcc994a43e?ixlib=rb-1.2.1&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80", lastMessage: "Are we still meeting at the library tomorrow?", time: "Yesterday", unread: false, online: false },
{ id: 3, name: "Sophia Rodriguez", avatar: "https://images.unsplash.com/photo-1438761681033-6461ffad8d80?ixlib=rb-1.2.1&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80", lastMessage: "Thanks for the notes!", time: "Yesterday", unread: false, online: true },
{ id: 4, name: "Jamie Lee", avatar: "https://images.unsplash.com/photo-1517841905240-472988babdf9?ixlib=rb-1.2.1&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80", lastMessage: "Did you see the assignment for next week?", time: "Monday", unread: false, online: false },
{ id: 5, name: "Taylor Kim", avatar: "https://images.unsplash.com/photo-1534528741775-53994a69daeb?ixlib=rb-1.2.1&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80", lastMessage: "Let's grab coffee after class", time: "Monday", unread: false, online: true }
].map((conversation) => (
))}
{/* Chat Area */}
{/* Chat Header */}
{/* Messages */}
{/* Timestamp */}
Today, 10:30 AM
{/* Their message */}
Hey, how's your project coming along?
10:30 AM
{/* My message */}
It's going well! I'm almost done with the research part. How about yours?
10:35 AM
{/* Their message */}
I'm struggling a bit with the data analysis section. Do you think we could meet up to go over it?
10:38 AM
{/* Their message */}
Maybe tomorrow at the library?
10:39 AM
{/* My message */}
Sure, that works for me. How about 3PM?
10:40 AM
{/* Their message */}
Perfect! I'll see you then. Thanks!
10:42 AM
{/* Message Input */}
)}
{/* Footer */}
);
}