diff --git a/client/src/components/NotificationDropdown.jsx b/client/src/components/NotificationDropdown.jsx
index 920f8d9..9f7f5dd 100644
--- a/client/src/components/NotificationDropdown.jsx
+++ b/client/src/components/NotificationDropdown.jsx
@@ -24,245 +24,4 @@ const NotificationDropdown = () => {
const { data: notificationsData, isLoading } = useQuery(
['notifications'],
() => api.get('api/notifications?limit=10').then(res => res.data),
- {
- refetchInterval: 10000, // Poll every 10 seconds
- enabled: !!user,
- }
- );
-
- // Fetch unread count
- const { data: unreadData } = useQuery(
- ['notifications', 'unread'],
- () => api.get('api/notifications/unread-count').then(res => res.data),
- {
- refetchInterval: 5000, // Poll every 5 seconds
- enabled: !!user,
- }
- );
-
- const unreadCount = unreadData?.unreadCount || 0;
- const notifications = notificationsData?.notifications || [];
-
- // Mark notification as read
- const markAsReadMutation = useMutation(
- notificationId => api.put(`api/notifications/${notificationId}/read`),
- {
- onSuccess: () => {
- queryClient.invalidateQueries(['notifications']);
- queryClient.invalidateQueries(['notifications', 'unread']);
- },
- }
- );
-
- // Mark all as read
- const markAllAsReadMutation = useMutation(
- () => api.put('api/notifications/read-all'),
- {
- onSuccess: () => {
- queryClient.invalidateQueries(['notifications']);
- queryClient.invalidateQueries(['notifications', 'unread']);
- toast.success('All notifications marked as read');
- },
- onError: error => {
- toast.error(
- error.response?.data?.message || 'Failed to mark all as read'
- );
- },
- }
- );
-
- // Delete notification
- const deleteNotificationMutation = useMutation(
- notificationId => api.delete(`api/notifications/${notificationId}`),
- {
- onSuccess: () => {
- queryClient.invalidateQueries(['notifications']);
- queryClient.invalidateQueries(['notifications', 'unread']);
- toast.success('Notification deleted');
- },
- onError: error => {
- toast.error(
- error.response?.data?.message || 'Failed to delete notification'
- );
- },
- }
- );
-
- const handleNotificationClick = notification => {
- if (!notification.read) {
- markAsReadMutation.mutate(notification._id);
- }
- setIsOpen(false);
- };
-
- const handleMarkAllAsRead = () => {
- markAllAsReadMutation.mutate();
- };
-
- const handleDeleteNotification = (e, notificationId) => {
- e.stopPropagation();
- deleteNotificationMutation.mutate(notificationId);
- };
-
- const getNotificationIcon = type => {
- switch (type) {
- case 'comment':
- return ;
- case 'upvote':
- return ;
- case 'downvote':
- return ;
- case 'accepted':
- return ;
- default:
- return ;
- }
- };
-
- const getNotificationLink = notification => {
- if (notification.questionId) {
- return `/questions/${notification.questionId}`;
- }
- return '/notifications';
- };
-
- const formatTimeAgo = date => {
- const now = new Date();
- const diff = now - new Date(date);
- const minutes = Math.floor(diff / 60000);
- const hours = Math.floor(diff / 3600000);
- const days = Math.floor(diff / 86400000);
-
- if (minutes < 1) return 'Just now';
- if (minutes < 60) return `${minutes}m ago`;
- if (hours < 24) return `${hours}h ago`;
- return `${days}d ago`;
- };
-
- if (!user) return null;
-
- return (
-
- {/* Notification Bell */}
-
-
- {/* Dropdown */}
-
- {isOpen && (
-
- {/* Header */}
-
-
- Notifications
-
-
- {unreadCount > 0 && (
-
- )}
-
-
-
-
- {/* Notifications List */}
-
- {isLoading ? (
-
- Loading notifications...
-
- ) : notifications.length === 0 ? (
-
- No notifications yet
-
- ) : (
- notifications.map(notification => (
-
handleNotificationClick(notification)}
- >
-
-
- {getNotificationIcon(notification.type)}
-
-
-
-
- {notification.sender?.username || 'Unknown User'}
-
-
-
- {formatTimeAgo(notification.createdAt)}
-
-
-
-
-
- {notification.content}
-
- {!notification.read && (
-
- )}
-
-
-
- ))
- )}
-
-
- {/* Footer */}
- {notifications.length > 0 && (
-
- setIsOpen(false)}
- >
- View all notifications
-
-
- )}
-
- )}
-
-
- );
-};
-
-export default NotificationDropdown;
+ .catch(err => console.error(err))
\ No newline at end of file
diff --git a/client/src/pages/AdminDashboard.jsx b/client/src/pages/AdminDashboard.jsx
index 30e3e6a..6803523 100644
--- a/client/src/pages/AdminDashboard.jsx
+++ b/client/src/pages/AdminDashboard.jsx
@@ -39,679 +39,4 @@ const AdminDashboard = () => {
} = useQuery(
['admin-dashboard'],
() => api.get('api/admin/dashboard').then(res => res.data),
- {
- staleTime: 60000, // 1 minute
- refetchOnWindowFocus: false,
- }
- );
-
- // Mutations
- const approveContentMutation = useMutation(
- ({ contentType, contentId }) =>
- api.post(`api/admin/${contentType}/${contentId}/approve`),
- {
- onSuccess: () => {
- queryClient.invalidateQueries(['admin-dashboard']);
- toast.success('Content approved successfully!');
- },
- onError: error => {
- toast.error(
- error.response?.data?.message || 'Failed to approve content'
- );
- },
- }
- );
-
- const rejectContentMutation = useMutation(
- ({ contentType, contentId, reason }) =>
- api.post(`api/admin/${contentType}/${contentId}/reject`, { reason }),
- {
- onSuccess: () => {
- queryClient.invalidateQueries(['admin-dashboard']);
- toast.success('Content rejected successfully!');
- },
- onError: error => {
- toast.error(
- error.response?.data?.message || 'Failed to reject content'
- );
- },
- }
- );
-
- const banUserMutation = useMutation(
- ({ userId, reason, duration }) =>
- api.post(`api/admin/users/${userId}/ban`, { reason, duration }),
- {
- onSuccess: () => {
- queryClient.invalidateQueries(['admin-dashboard']);
- toast.success('User banned successfully!');
- },
- onError: error => {
- toast.error(error.response?.data?.message || 'Failed to ban user');
- },
- }
- );
-
- const deleteContentMutation = useMutation(
- ({ contentType, contentId }) =>
- api.delete(`api/admin/${contentType}/${contentId}`),
- {
- onSuccess: () => {
- queryClient.invalidateQueries(['admin-dashboard']);
- toast.success('Content deleted successfully!');
- },
- onError: error => {
- toast.error(
- error.response?.data?.message || 'Failed to delete content'
- );
- },
- }
- );
-
- // Check if user is admin
- if (!user || user.role !== 'admin') {
- return (
-
-
-
- Access Denied
-
-
- You don't have permission to access the admin dashboard.
-
-
- );
- }
-
- if (isLoading) {
- return (
-
-
-
-
- {[...Array(4)].map((_, i) => (
-
- ))}
-
-
-
- );
- }
-
- if (error) {
- return (
-
-
- Error loading admin data: {error.message}
-
-
- );
- }
-
- const {
- stats,
- pendingContent,
- reportedContent,
- recentUsers,
- recentActivity,
- } = adminData;
-
- const tabs = [
- { id: 'overview', label: 'Overview', icon: FiBarChart2 },
- { id: 'moderation', label: 'Content Moderation', icon: FiShield },
- { id: 'users', label: 'User Management', icon: FiUsers },
- { id: 'reports', label: 'Reports', icon: FiFlag },
- { id: 'activity', label: 'Recent Activity', icon: FiActivity },
- ];
-
- const handleApprove = (contentType, contentId) => {
- approveContentMutation.mutate({ contentType, contentId });
- };
-
- const handleReject = (contentType, contentId, reason) => {
- rejectContentMutation.mutate({ contentType, contentId, reason });
- };
-
- const handleBanUser = (userId, reason, duration) => {
- banUserMutation.mutate({ userId, reason, duration });
- };
-
- const handleDeleteContent = (contentType, contentId) => {
- if (
- window.confirm(
- 'Are you sure you want to delete this content? This action cannot be undone.'
- )
- ) {
- deleteContentMutation.mutate({ contentType, contentId });
- }
- };
-
- const formatDate = date => {
- return new Date(date).toLocaleDateString('en-US', {
- year: 'numeric',
- month: 'short',
- day: 'numeric',
- hour: '2-digit',
- minute: '2-digit',
- });
- };
-
- return (
-
- {/* Header */}
-
-
- Admin Dashboard
-
-
- Manage users, moderate content, and monitor platform activity
-
-
-
- {/* Stats Overview */}
-
-
-
-
-
-
-
-
- Total Users
-
-
- {stats.totalUsers}
-
-
-
-
-
-
-
-
-
-
-
-
- Total Questions
-
-
- {stats.totalQuestions}
-
-
-
-
-
-
-
-
-
-
-
-
- Pending Review
-
-
- {pendingContent.length}
-
-
-
-
-
-
-
-
-
-
-
-
- Reports
-
-
- {reportedContent.length}
-
-
-
-
-
-
- {/* Tabs */}
-
-
-
-
-
-
- {/* Tab Content */}
-
- {activeTab === 'overview' && (
-
- {/* Recent Users */}
-
-
- Recent Users
-
-
- {recentUsers.map(user => (
-
-
-
-
-
-
-
- {user.username}
-
-
- {user.email}
-
-
-
-
-
- {user.reputation}
-
-
- reputation
-
-
-
- ))}
-
-
-
- {/* Recent Activity */}
-
-
- Recent Activity
-
-
- {recentActivity.map((activity, index) => (
-
-
-
-
-
-
- {activity.description}
-
-
- {formatDate(activity.date)}
-
-
-
- ))}
-
-
-
- )}
-
- {activeTab === 'moderation' && (
-
-
- Pending Content Review
-
- {pendingContent.length > 0 ? (
- pendingContent.map(content => (
-
-
-
-
-
- {content.type}
-
-
- by {content.author.username}
-
-
- {formatDate(content.createdAt)}
-
-
-
- {content.type === 'question' && (
-
-
- {content.title}
-
-
-
- )}
-
- {content.type === 'answer' && (
-
-
- Answer to: {content.question.title}
-
-
-
- )}
-
-
-
-
-
-
-
-
-
- ))
- ) : (
-
-
-
- No pending content
-
-
- All content has been reviewed and approved.
-
-
- )}
-
- )}
-
- {activeTab === 'users' && (
-
-
- User Management
-
-
-
-
-
- |
- User
- |
-
- Email
- |
-
- Reputation
- |
-
- Joined
- |
-
- Status
- |
-
- Actions
- |
-
-
-
- {recentUsers.map(user => (
-
-
-
-
-
-
-
- {user.username}
-
-
- |
-
- {user.email}
- |
-
- {user.reputation}
- |
-
- {formatDate(user.createdAt)}
- |
-
-
- {user.isBanned ? 'Banned' : 'Active'}
-
- |
-
-
-
- {!user.isBanned && (
-
- )}
-
- |
-
- ))}
-
-
-
-
- )}
-
- {activeTab === 'reports' && (
-
-
- Reported Content
-
- {reportedContent.length > 0 ? (
- reportedContent.map(report => (
-
-
-
-
-
- Reported
-
-
- by {report.reporter.username}
-
-
- {formatDate(report.createdAt)}
-
-
-
-
- Reason: {report.reason}
-
-
-
-
- Reported Content:
-
-
-
-
-
-
-
-
-
-
-
- ))
- ) : (
-
-
-
- No reported content
-
-
- All content is following community guidelines.
-
-
- )}
-
- )}
-
- {activeTab === 'activity' && (
-
-
- Recent Activity
-
-
- {recentActivity.map((activity, index) => (
-
-
-
-
-
-
-
- {activity.description}
-
-
- {formatDate(activity.date)}
-
-
-
-
- {activity.type}
-
-
-
-
- ))}
-
-
- )}
-
-
- );
-};
-
-export default AdminDashboard;
+ .catch(err => console.error(err))
\ No newline at end of file
diff --git a/client/src/pages/SettingsPage.jsx b/client/src/pages/SettingsPage.jsx
index e8dfc4d..349bcf0 100644
--- a/client/src/pages/SettingsPage.jsx
+++ b/client/src/pages/SettingsPage.jsx
@@ -60,709 +60,4 @@ const SettingsPage = () => {
const { data: userData, isLoading } = useQuery(
['user-settings'],
() => api.get('api/users/profile').then(res => res.data),
- {
- enabled: !!user,
- staleTime: 300000, // 5 minutes
- }
- );
-
- // Initialize form data when user data is loaded
- useEffect(() => {
- if (userData) {
- setProfileData({
- username: userData.username || '',
- email: userData.email || '',
- bio: userData.bio || '',
- avatar: null,
- });
- setPreferences({
- emailNotifications: userData.preferences?.emailNotifications ?? true,
- pushNotifications: userData.preferences?.pushNotifications ?? true,
- weeklyDigest: userData.preferences?.weeklyDigest ?? false,
- mentionNotifications:
- userData.preferences?.mentionNotifications ?? true,
- answerNotifications: userData.preferences?.answerNotifications ?? true,
- voteNotifications: userData.preferences?.voteNotifications ?? true,
- });
- }
- }, [userData]);
-
- // Mutations
- const updateProfileMutation = useMutation(
- data => api.put('api/users/profile', data),
- {
- onSuccess: data => {
- queryClient.invalidateQueries(['user-settings']);
- updateUser(data.user);
- toast.success('Profile updated successfully!');
- },
- onError: error => {
- toast.error(
- error.response?.data?.message || 'Failed to update profile'
- );
- },
- }
- );
-
- const changePasswordMutation = useMutation(
- data => api.put('api/users/change-password', data),
- {
- onSuccess: () => {
- setPasswordData({
- currentPassword: '',
- newPassword: '',
- confirmPassword: '',
- });
- setShowPasswordForm(false);
- toast.success('Password changed successfully!');
- },
- onError: error => {
- toast.error(
- error.response?.data?.message || 'Failed to change password'
- );
- },
- }
- );
-
- const updatePreferencesMutation = useMutation(
- data => api.put('api/users/preferences', data),
- {
- onSuccess: () => {
- queryClient.invalidateQueries(['user-settings']);
- toast.success('Preferences updated successfully!');
- },
- onError: error => {
- toast.error(
- error.response?.data?.message || 'Failed to update preferences'
- );
- },
- }
- );
-
- const deleteAccountMutation = useMutation(
- () => api.delete('api/users/account'),
- {
- onSuccess: () => {
- toast.success('Account deleted successfully');
- // Redirect to logout
- window.location.href = '/logout';
- },
- onError: error => {
- toast.error(
- error.response?.data?.message || 'Failed to delete account'
- );
- },
- }
- );
-
- const tabs = [
- { id: 'profile', label: 'Profile', icon: FiUser },
- { id: 'security', label: 'Security', icon: FiShield },
- { id: 'notifications', label: 'Notifications', icon: FiBell },
- {
- id: 'appearance',
- label: 'Appearance',
- icon: theme === 'dark' ? FiMoon : FiSun,
- },
- { id: 'danger', label: 'Danger Zone', icon: FiTrash2 },
- ];
-
- const handleProfileSubmit = e => {
- e.preventDefault();
- if (!profileData.username.trim()) {
- toast.error('Username is required');
- return;
- }
-
- const formData = new FormData();
- formData.append('username', profileData.username);
- formData.append('email', profileData.email);
- formData.append('bio', profileData.bio);
- if (profileData.avatar) {
- formData.append('avatar', profileData.avatar);
- }
-
- updateProfileMutation.mutate(formData);
- };
-
- const handlePasswordSubmit = e => {
- e.preventDefault();
- if (passwordData.newPassword !== passwordData.confirmPassword) {
- toast.error('New passwords do not match');
- return;
- }
- if (passwordData.newPassword.length < 6) {
- toast.error('Password must be at least 6 characters long');
- return;
- }
-
- changePasswordMutation.mutate({
- currentPassword: passwordData.currentPassword,
- newPassword: passwordData.newPassword,
- });
- };
-
- const handlePreferencesChange = (key, value) => {
- const newPreferences = { ...preferences, [key]: value };
- setPreferences(newPreferences);
- updatePreferencesMutation.mutate(newPreferences);
- };
-
- const handleDeleteAccount = () => {
- if (
- window.confirm(
- 'Are you absolutely sure? This action cannot be undone and will permanently delete your account and all associated data.'
- )
- ) {
- deleteAccountMutation.mutate();
- }
- };
-
- const handleAvatarChange = e => {
- const file = e.target.files[0];
- if (file) {
- if (file.size > 5 * 1024 * 1024) {
- // 5MB limit
- toast.error('Avatar file size must be less than 5MB');
- return;
- }
- setProfileData({ ...profileData, avatar: file });
- }
- };
-
- if (isLoading) {
- return (
-
- );
- }
-
- return (
-
- {/* Header */}
-
-
- Settings
-
-
- Manage your account settings and preferences
-
-
-
-
- {/* Sidebar */}
-
-
-
-
- {/* Content */}
-
- {activeTab === 'profile' && (
-
-
- Profile Information
-
-
-
-
- )}
-
- {activeTab === 'security' && (
-
-
- Security Settings
-
-
-
- {/* Change Password */}
-
-
-
-
- Change Password
-
-
- Update your password to keep your account secure
-
-
-
-
-
- {showPasswordForm && (
-
- )}
-
-
- {/* Two-Factor Authentication */}
-
-
-
-
- Two-Factor Authentication
-
-
- Add an extra layer of security to your account
-
-
-
-
-
-
-
- )}
-
- {activeTab === 'notifications' && (
-
-
- Notification Preferences
-
-
-
-
-
-
-
- Email Notifications
-
-
- Receive notifications via email
-
-
-
-
-
-
-
-
- Push Notifications
-
-
- Receive browser push notifications
-
-
-
-
-
-
-
-
- Weekly Digest
-
-
- Receive a weekly summary of activity
-
-
-
-
-
-
-
-
- Mention Notifications
-
-
- When someone mentions you
-
-
-
-
-
-
-
-
- Answer Notifications
-
-
- When someone answers your question
-
-
-
-
-
-
-
-
- Vote Notifications
-
-
- When someone votes on your content
-
-
-
-
-
-
-
- )}
-
- {activeTab === 'appearance' && (
-
-
- Appearance Settings
-
-
-
-
-
-
- Theme
-
-
- Choose your preferred theme
-
-
-
-
-
-
-
-
-
- Language
-
-
- Choose your preferred language
-
-
-
-
-
-
-
- )}
-
- {activeTab === 'danger' && (
-
-
- Danger Zone
-
-
-
-
-
- Delete Account
-
-
- Once you delete your account, there is no going back. Please
- be certain.
-
-
-
-
-
- )}
-
-
-
- );
-};
-
-export default SettingsPage;
+ .catch(err => console.error(err))
\ No newline at end of file
diff --git a/client/src/pages/TagManagementPage.jsx b/client/src/pages/TagManagementPage.jsx
index 42f29d0..9eedca3 100644
--- a/client/src/pages/TagManagementPage.jsx
+++ b/client/src/pages/TagManagementPage.jsx
@@ -38,465 +38,4 @@ const TagManagementPage = () => {
} = useQuery(
['tags-management'],
() => api.get('api/admin/tags').then(res => res.data),
- {
- staleTime: 300000, // 5 minutes
- refetchOnWindowFocus: false,
- }
- );
-
- // Mutations
- const createTagMutation = useMutation(
- tagData => api.post('api/admin/tags', tagData),
- {
- onSuccess: () => {
- queryClient.invalidateQueries(['tags-management']);
- setFormData({ name: '', description: '', color: '#3B82F6' });
- setShowCreateForm(false);
- toast.success('Tag created successfully!');
- },
- onError: error => {
- toast.error(error.response?.data?.message || 'Failed to create tag');
- },
- }
- );
-
- const updateTagMutation = useMutation(
- ({ tagId, tagData }) => api.put(`api/admin/tags/${tagId}`, tagData),
- {
- onSuccess: () => {
- queryClient.invalidateQueries(['tags-management']);
- setEditingTag(null);
- setFormData({ name: '', description: '', color: '#3B82F6' });
- toast.success('Tag updated successfully!');
- },
- onError: error => {
- toast.error(error.response?.data?.message || 'Failed to update tag');
- },
- }
- );
-
- const deleteTagMutation = useMutation(
- tagId => api.delete(`api/admin/tags/${tagId}`),
- {
- onSuccess: () => {
- queryClient.invalidateQueries(['tags-management']);
- toast.success('Tag deleted successfully!');
- },
- onError: error => {
- toast.error(error.response?.data?.message || 'Failed to delete tag');
- },
- }
- );
-
- // Check if user is admin
- if (!user || user.role !== 'admin') {
- return (
-
-
-
- Access Denied
-
-
- You don't have permission to access tag management.
-
-
- );
- }
-
- if (isLoading) {
- return (
-
-
-
-
- {[...Array(6)].map((_, i) => (
-
- ))}
-
-
-
- );
- }
-
- if (error) {
- return (
-
-
- Error loading tags: {error.message}
-
-
- );
- }
-
- const { tags, stats } = tagsData;
-
- const filteredTags = tags.filter(
- tag =>
- tag.name.toLowerCase().includes(searchTerm.toLowerCase()) ||
- tag.description.toLowerCase().includes(searchTerm.toLowerCase())
- );
-
- const handleSubmit = e => {
- e.preventDefault();
- if (!formData.name.trim()) {
- toast.error('Tag name is required');
- return;
- }
-
- if (editingTag) {
- updateTagMutation.mutate({ tagId: editingTag._id, tagData: formData });
- } else {
- createTagMutation.mutate(formData);
- }
- };
-
- const handleEdit = tag => {
- setEditingTag(tag);
- setFormData({
- name: tag.name,
- description: tag.description,
- color: tag.color,
- });
- setShowCreateForm(true);
- };
-
- const handleDelete = tagId => {
- if (
- window.confirm(
- 'Are you sure you want to delete this tag? This action cannot be undone.'
- )
- ) {
- deleteTagMutation.mutate(tagId);
- }
- };
-
- const handleCancel = () => {
- setShowCreateForm(false);
- setEditingTag(null);
- setFormData({ name: '', description: '', color: '#3B82F6' });
- };
-
- const colorOptions = [
- '#3B82F6',
- '#10B981',
- '#F59E0B',
- '#EF4444',
- '#8B5CF6',
- '#06B6D4',
- '#84CC16',
- '#F97316',
- '#EC4899',
- '#6B7280',
- ];
-
- return (
-
- {/* Header */}
-
-
- Tag Management
-
-
- Create, edit, and manage tags for organizing questions
-
-
-
- {/* Stats */}
-
-
-
-
-
-
-
-
- Total Tags
-
-
- {stats.totalTags}
-
-
-
-
-
-
-
-
-
-
-
-
- Tagged Questions
-
-
- {stats.taggedQuestions}
-
-
-
-
-
-
-
-
-
-
-
-
- Most Popular
-
-
- {stats.mostPopularTag}
-
-
-
-
-
-
-
-
-
-
-
-
- Active Tags
-
-
- {stats.activeTags}
-
-
-
-
-
-
- {/* Search and Create */}
-
-
-
- setSearchTerm(e.target.value)}
- className="w-full pl-10 pr-4 py-2 border border-navy-300 dark:border-navy-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white dark:bg-navy-800 text-navy-900 dark:text-white"
- />
-
-
-
-
-
- {/* Create/Edit Form */}
- {showCreateForm && (
-
-
- {editingTag ? 'Edit Tag' : 'Create New Tag'}
-
-
-
-
- )}
-
- {/* Tags Grid */}
-
- {filteredTags.map((tag, index) => (
-
-
-
-
-
-
-
-
-
-
- {tag.description && (
-
- {tag.description}
-
- )}
-
-
-
-
-
- {tag.questionCount} questions
-
-
-
- {tag.viewCount} views
-
-
-
-
-
- {tag.trendingScore}
-
-
-
-
-
-
- Created {new Date(tag.createdAt).toLocaleDateString()}
-
-
- {tag.isActive ? 'Active' : 'Inactive'}
-
-
-
-
- ))}
-
-
- {filteredTags.length === 0 && (
-
-
-
- {searchTerm ? 'No tags found' : 'No tags yet'}
-
-
- {searchTerm
- ? 'Try adjusting your search terms'
- : 'Create your first tag to get started'}
-
-
- )}
-
- );
-};
-
-export default TagManagementPage;
+ .catch(err => console.error(err))
\ No newline at end of file
diff --git a/client/src/pages/UserProfilePage.jsx b/client/src/pages/UserProfilePage.jsx
index 9ef1de5..28fb0c1 100644
--- a/client/src/pages/UserProfilePage.jsx
+++ b/client/src/pages/UserProfilePage.jsx
@@ -37,444 +37,4 @@ const UserProfilePage = () => {
} = useQuery(
['user-profile', username],
() => api.get(`api/users/profile/${username}`).then(res => res.data),
- {
- staleTime: 300000, // 5 minutes
- refetchOnWindowFocus: false,
- }
- );
-
- if (isLoading) {
- return (
-
- );
- }
-
- if (error) {
- return (
-
-
- Error loading profile: {error.message}
-
-
-
- );
- }
-
- const { user, questions, answers, stats } = profileData;
- const isOwnProfile = currentUser && currentUser._id === user._id;
-
- const tabs = [
- {
- id: 'questions',
- label: 'Questions',
- count: questions.length,
- icon: FiMessageSquare,
- },
- { id: 'answers', label: 'Answers', count: answers.length, icon: FiCheck },
- {
- id: 'activity',
- label: 'Activity',
- count: stats.totalActivity,
- icon: FiTrendingUp,
- },
- ];
-
- const formatDate = date => {
- return new Date(date).toLocaleDateString('en-US', {
- year: 'numeric',
- month: 'long',
- day: 'numeric',
- });
- };
-
- const getReputationColor = reputation => {
- if (reputation >= 1000) return 'text-yellow-600 dark:text-yellow-400';
- if (reputation >= 500) return 'text-green-600 dark:text-green-400';
- if (reputation >= 100) return 'text-blue-600 dark:text-blue-400';
- return 'text-navy-600 dark:text-navy-400';
- };
-
- const getReputationBadge = reputation => {
- if (reputation >= 1000)
- return {
- text: 'Expert',
- color:
- 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200',
- };
- if (reputation >= 500)
- return {
- text: 'Contributor',
- color:
- 'bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200',
- };
- if (reputation >= 100)
- return {
- text: 'Member',
- color: 'bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200',
- };
- return {
- text: 'New User',
- color: 'bg-navy-100 text-navy-800 dark:bg-navy-900 dark:text-navy-200',
- };
- };
-
- return (
-
- {/* Back button */}
-
-
- {/* Profile header */}
-
-
- {/* Avatar and basic info */}
-
-
-
-
-
-
-
- {user.username}
-
-
- {getReputationBadge(user.reputation).text}
-
-
-
-
- {/* Stats and details */}
-
-
-
-
- {user.reputation}
-
-
- Reputation
-
-
-
-
-
- {questions.length}
-
-
- Questions
-
-
-
-
-
- {answers.length}
-
-
- Answers
-
-
-
-
- {/* User details */}
-
- {user.email && (
-
-
- {user.email}
-
- )}
-
-
-
- Joined {formatDate(user.createdAt)}
-
-
- {user.bio && (
-
- {user.bio}
-
- )}
-
-
- {/* Action buttons */}
- {isOwnProfile && (
-
-
-
- )}
-
-
-
-
- {/* Stats overview */}
-
-
-
- {stats.totalViews}
-
-
- Total Views
-
-
-
-
-
- {stats.acceptedAnswers}
-
-
- Accepted Answers
-
-
-
-
-
- {stats.totalVotes}
-
-
- Total Votes
-
-
-
-
-
- {stats.questionsThisMonth}
-
-
- This Month
-
-
-
-
- {/* Tabs */}
-
-
-
-
-
-
- {/* Tab content */}
-
- {activeTab === 'questions' && (
-
- {questions.length > 0 ? (
- questions.map(question => (
-
- ))
- ) : (
-
-
-
- No questions yet
-
-
- {isOwnProfile
- ? "You haven't asked any questions yet. Start contributing to the community!"
- : "This user hasn't asked any questions yet."}
-
- {isOwnProfile && (
-
- )}
-
- )}
-
- )}
-
- {activeTab === 'answers' && (
-
- {answers.length > 0 ? (
- answers.map(answer => (
-
-
-
-
-
- {answer.votes.upvotes.length -
- answer.votes.downvotes.length}
-
-
-
-
-
-
-
- {answer.isAccepted && (
-
-
-
- Accepted
-
-
- )}
-
-
-
-
-
-
-
-
- {answer.question.viewCount} views
-
-
-
- {answer.question.tags.length} tags
-
-
-
{formatDate(answer.createdAt)}
-
-
-
-
- ))
- ) : (
-
-
-
- No answers yet
-
-
- {isOwnProfile
- ? "You haven't answered any questions yet. Start helping others!"
- : "This user hasn't answered any questions yet."}
-
- {isOwnProfile && (
-
- )}
-
- )}
-
- )}
-
- {activeTab === 'activity' && (
-
-
-
- Recent Activity
-
-
- {stats.recentActivity?.map((activity, index) => (
-
-
- {activity.type === 'question' && (
-
- )}
- {activity.type === 'answer' && (
-
- )}
- {activity.type === 'vote' && (
-
- )}
-
-
-
- {activity.description}
-
-
- {formatDate(activity.date)}
-
-
-
- ))}
-
-
-
- )}
-
-
- );
-};
-
-export default UserProfilePage;
+ .catch(err => console.error(err))
\ No newline at end of file