Comprehensive design sweep across the rest of the app following the shipped Liquid Glass + corner-border-light system (#116). ## Three classes of finding ### 1. Broken Tailwind token classes (HIGH — pages were unstyled) The decks / deck-builder / deck-detail cluster relied on Tailwind classes that don't exist in `tailwind.config.js` (no `bg-bg-*`, `text-text-*`, `border-border`, `bg-accent-ember`, `focus:ring-accent-ember`, `hover:bg-accent-ember-dark`). Those classes produced ZERO CSS — backgrounds were transparent, borders invisible, hover states absent. Rewrote with inline `style={{ ... CSS vars ... }}` + the `<Button>` / `<SearchBar>` primitives + `glass-panel` surfaces: - `pages/decks.js` (full page) - `pages/deck/[id].js` (header, stats sidebar, group-by controls, card list) - `pages/deck-builder.js` (loading spinner) - `components/DeckBuilderView.js` (toolbar + main panel) - `components/DeckBuilderCardBrowser.js` (full rewrite; integrated `<SearchBar>` for the card-picker input) - `components/DeckBuilderDeckList.js` (full rewrite) - `components/DeckBuilderStatsBar.js` - `components/ManaSymbolSettings.js` - `components/ManaSymbols.js` (single `text-text-secondary`) - `pages/admin/card-editor.js` cluster was already clean ### 2. Duplicative / stale page searches Replaced raw `<input>` search controls with the `<SearchBar>` primitive (adds clear button, ember focus ring, system-consistent rounded corners). Kept page-specific filter searches (they filter the visible list — distinct from the global TopSearchBar command palette): - `pages/my-cards.js` - `pages/community/collections.js` - `components/CardsPageView.js` - `components/CollectionPageView.js` - `components/DeckBuilderCardBrowser.js` `pages/my-cards.js` filter wrapper also lifted into a `glass-panel` chip instead of a solid `var(--bg-primary)` band. ### 3. Square corners + stale palette in shared views - `components/CollectionPageView.js`: 10 action buttons (`rounded-lg` + `hover:bg-gray-50`) → `rounded-xl` + `nav-item-hover`; 4 filter selects (`focus:ring-purple-500 rounded-lg`) → `.input-field`; view-mode toggle (`bg-white text-gray-900` — invisible in dark mode) → tokenised; SYSTEM badge gradient (`from-blue-500 to-purple-600`) → ember↔flame; tooltip (`bg-gray-900`) → `glass-panel-strong`; search-results dropdown (`bg-white border-gray-200` — invisible in dark mode) → `glass-panel-strong`; Activity / game-count / TCG-game badges palette-aligned. - `components/CardsPageView.js`: "Load More Cards" button (`bg-gradient-to-r from-blue-500 to-purple-600 rounded-lg`) → `<Button variant="primary" size="lg">`. - `components/CollectionsPageView.js`: matching SYSTEM badge + tooltip cleanup. - `components/ShareModal.js`: user-search dropdown (`border-gray-200 hover:bg-gray-50`) and email-invite card moved onto `glass-panel` + `nav-item-hover`; social-share buttons `rounded-lg hover:bg-gray-50` → `rounded-xl nav-item-hover`. - `components/Layout.js`: profile-menu dropdown row (`hover:bg-gray-50 dark:hover:bg-gray-700`) → `nav-item-hover`. - `components/CardItem.js`: bulk-select checkbox `focus:ring-purple-500` → ember. ### 4. `dark:` modifier classes (broken with `[data-theme]` theming) This app uses `[data-theme="dark"]` CSS selector theming, not Tailwind's `class` strategy, so `dark:bg-green-900/20` etc. produced no CSS in dark mode. Affected alerts on `pages/settings.js` and `pages/profile.js` — replaced with `glass-panel` + semantic border colour (flame for success, #dc2626 for error). `pages/settings.js` sidebar nav also moved off its hardcoded full-ember fill onto the system `nav-item` / `nav-item-active` / `nav-item-hover` pattern for consistency with the global sidebar. ## Verification - `npm run build` — green (Next 16 + Turbopack) - `npm run lint` — 0 errors, 1 unrelated pre-existing warning - `npm run test:run` — 113/113 pass (no test changes needed) Co-authored-by: Cursor <cursoragent@cursor.com>
626 lines
No EOL
23 KiB
JavaScript
626 lines
No EOL
23 KiB
JavaScript
/* eslint-disable @next/next/no-img-element -- External or generated image URLs; next/image migration is out of scope. */
|
|
import { useState, useEffect, useRef } from 'react';
|
|
import { useRouter } from 'next/router';
|
|
import Layout from '../components/Layout';
|
|
|
|
export default function Profile() {
|
|
const router = useRouter();
|
|
const fileInputRef = useRef(null);
|
|
|
|
// User state
|
|
const [user, setUser] = useState(null);
|
|
|
|
// UI state
|
|
const [loading, setLoading] = useState(true);
|
|
const [saving, setSaving] = useState(false);
|
|
const [editMode, setEditMode] = useState(false);
|
|
const [message, setMessage] = useState({ type: '', text: '' });
|
|
const [stats, setStats] = useState({
|
|
totalCards: 0,
|
|
totalCollections: 0,
|
|
totalDecks: 0,
|
|
totalValue: 0
|
|
});
|
|
|
|
// Form state
|
|
const [formData, setFormData] = useState({
|
|
first_name: '',
|
|
last_name: '',
|
|
username: '',
|
|
bio: '',
|
|
favorite_games: []
|
|
});
|
|
|
|
const loadUserProfile = async () => {
|
|
try {
|
|
const token = localStorage.getItem('auth_token');
|
|
if (!token) {
|
|
router.push('/login');
|
|
return;
|
|
}
|
|
|
|
const response = await fetch('/api/user/profile', {
|
|
headers: {
|
|
'Authorization': `Bearer ${token}`
|
|
}
|
|
});
|
|
|
|
if (response.ok) {
|
|
const userData = await response.json();
|
|
setUser(userData);
|
|
setFormData({
|
|
first_name: userData.first_name || '',
|
|
last_name: userData.last_name || '',
|
|
username: userData.username || '',
|
|
bio: userData.bio || '',
|
|
favorite_games: userData.favorite_games || []
|
|
});
|
|
} else if (response.status === 401) {
|
|
router.push('/login');
|
|
}
|
|
} catch (error) {
|
|
console.error('Error loading profile:', error);
|
|
setMessage({ type: 'error', text: 'Failed to load profile' });
|
|
} finally {
|
|
setLoading(false);
|
|
}
|
|
};
|
|
|
|
const loadUserStats = async () => {
|
|
try {
|
|
const token = localStorage.getItem('auth_token');
|
|
if (!token) return;
|
|
|
|
const response = await fetch('/api/user/stats', {
|
|
headers: {
|
|
'Authorization': `Bearer ${token}`
|
|
}
|
|
});
|
|
|
|
if (response.ok) {
|
|
const statsData = await response.json();
|
|
setStats(statsData);
|
|
}
|
|
} catch (error) {
|
|
console.error('Error loading stats:', error);
|
|
}
|
|
};
|
|
|
|
useEffect(() => {
|
|
// eslint-disable-next-line react-hooks/set-state-in-effect -- mount profile and stats load
|
|
loadUserProfile();
|
|
loadUserStats();
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- mount-only profile and stats load
|
|
}, []);
|
|
|
|
const handleInputChange = (field, value) => {
|
|
setFormData(prev => ({
|
|
...prev,
|
|
[field]: value
|
|
}));
|
|
};
|
|
|
|
const handleGameToggle = (game) => {
|
|
setFormData(prev => ({
|
|
...prev,
|
|
favorite_games: prev.favorite_games.includes(game)
|
|
? prev.favorite_games.filter(g => g !== game)
|
|
: [...prev.favorite_games, game]
|
|
}));
|
|
};
|
|
|
|
const handleSave = async () => {
|
|
setSaving(true);
|
|
setMessage({ type: '', text: '' });
|
|
|
|
try {
|
|
const token = localStorage.getItem('auth_token');
|
|
const response = await fetch('/api/user/profile', {
|
|
method: 'PUT',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'Authorization': `Bearer ${token}`
|
|
},
|
|
body: JSON.stringify(formData)
|
|
});
|
|
|
|
if (response.ok) {
|
|
const updatedUser = await response.json();
|
|
setUser(updatedUser);
|
|
setEditMode(false);
|
|
setMessage({ type: 'success', text: 'Profile updated successfully!' });
|
|
} else {
|
|
const error = await response.json();
|
|
setMessage({ type: 'error', text: error.message || 'Failed to update profile' });
|
|
}
|
|
} catch (error) {
|
|
console.error('Error updating profile:', error);
|
|
setMessage({ type: 'error', text: 'Failed to update profile' });
|
|
} finally {
|
|
setSaving(false);
|
|
}
|
|
};
|
|
|
|
const handleAvatarUpload = async (event) => {
|
|
const file = event.target.files[0];
|
|
if (!file) return;
|
|
|
|
// Validate file type and size
|
|
if (!file.type.startsWith('image/')) {
|
|
setMessage({ type: 'error', text: 'Please select an image file' });
|
|
return;
|
|
}
|
|
|
|
if (file.size > 5 * 1024 * 1024) { // 5MB limit
|
|
setMessage({ type: 'error', text: 'Image must be less than 5MB' });
|
|
return;
|
|
}
|
|
|
|
const formData = new FormData();
|
|
formData.append('avatar', file);
|
|
|
|
try {
|
|
setSaving(true);
|
|
const token = localStorage.getItem('auth_token');
|
|
const response = await fetch('/api/user/avatar', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Authorization': `Bearer ${token}`
|
|
},
|
|
body: formData
|
|
});
|
|
|
|
if (response.ok) {
|
|
const result = await response.json();
|
|
setUser(prev => ({ ...prev, avatar_url: result.avatar_url }));
|
|
setMessage({ type: 'success', text: 'Avatar updated successfully!' });
|
|
} else {
|
|
const error = await response.json();
|
|
setMessage({ type: 'error', text: error.message || 'Failed to upload avatar' });
|
|
}
|
|
} catch (error) {
|
|
console.error('Error uploading avatar:', error);
|
|
setMessage({ type: 'error', text: 'Failed to upload avatar' });
|
|
} finally {
|
|
setSaving(false);
|
|
}
|
|
};
|
|
|
|
const generateAvatar = async () => {
|
|
try {
|
|
setSaving(true);
|
|
const token = localStorage.getItem('auth_token');
|
|
const response = await fetch('/api/user/avatar/generate', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Authorization': `Bearer ${token}`
|
|
}
|
|
});
|
|
|
|
if (response.ok) {
|
|
const result = await response.json();
|
|
setUser(prev => ({ ...prev, avatar_url: result.avatar_url }));
|
|
setMessage({ type: 'success', text: 'Avatar generated successfully!' });
|
|
} else {
|
|
const error = await response.json();
|
|
setMessage({ type: 'error', text: error.message || 'Failed to generate avatar' });
|
|
}
|
|
} catch (error) {
|
|
console.error('Error generating avatar:', error);
|
|
setMessage({ type: 'error', text: 'Failed to generate avatar' });
|
|
} finally {
|
|
setSaving(false);
|
|
}
|
|
};
|
|
|
|
const formatCurrency = (amount) => {
|
|
return new Intl.NumberFormat('en-US', {
|
|
style: 'currency',
|
|
currency: 'USD'
|
|
}).format(amount);
|
|
};
|
|
|
|
const formatDate = (dateString) => {
|
|
return new Date(dateString).toLocaleDateString('en-US', {
|
|
year: 'numeric',
|
|
month: 'long',
|
|
day: 'numeric'
|
|
});
|
|
};
|
|
|
|
const getDisplayName = () => {
|
|
if (!user) return '';
|
|
if (user.first_name || user.last_name) {
|
|
return `${user.first_name} ${user.last_name}`.trim();
|
|
}
|
|
return user.username || user.email;
|
|
};
|
|
|
|
const getInitials = () => {
|
|
if (!user) return '';
|
|
if (user.first_name || user.last_name) {
|
|
return `${user.first_name?.charAt(0) || ''}${user.last_name?.charAt(0) || ''}`.toUpperCase();
|
|
}
|
|
return user.email?.charAt(0).toUpperCase() || 'U';
|
|
};
|
|
|
|
const gameOptions = [
|
|
{ value: 'MTG', label: 'Magic: The Gathering', color: 'purple', icon: '🔮' },
|
|
{ value: 'Pokemon', label: 'Pokemon', color: 'blue', icon: '⚡' },
|
|
{ value: 'Lorcana', label: 'Disney Lorcana', color: 'pink', icon: '✨' }
|
|
];
|
|
|
|
if (loading) {
|
|
return (
|
|
<Layout user={user}>
|
|
<div className="flex items-center justify-center min-h-screen">
|
|
<div className="animate-spin rounded-full h-32 w-32 border-b-2" style={{ borderColor: 'var(--accent-ember)' }}></div>
|
|
</div>
|
|
</Layout>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<Layout user={user}>
|
|
<div className="max-w-4xl mx-auto p-6">
|
|
{/* Header */}
|
|
<div className="mb-8">
|
|
<h1 className="text-3xl font-bold mb-2" style={{ color: 'var(--text-primary)' }}>
|
|
Profile
|
|
</h1>
|
|
<p className="text-lg" style={{ color: 'var(--text-secondary)' }}>
|
|
Manage your account information and preferences
|
|
</p>
|
|
</div>
|
|
|
|
{/* Message */}
|
|
{message.text && (
|
|
<div
|
|
className="mb-6 p-4 rounded-xl glass-panel"
|
|
style={{
|
|
color:
|
|
message.type === 'success' ? 'var(--accent-flame)' : '#dc2626',
|
|
borderColor:
|
|
message.type === 'success' ? 'var(--accent-flame)' : '#dc2626',
|
|
}}
|
|
>
|
|
{message.text}
|
|
</div>
|
|
)}
|
|
|
|
<div className="grid grid-cols-1 lg:grid-cols-3 gap-8">
|
|
{/* Profile Card */}
|
|
<div className="lg:col-span-1">
|
|
<div className="card p-6 text-center">
|
|
{/* Avatar */}
|
|
<div className="mb-6">
|
|
<div className="relative inline-block">
|
|
{user?.avatar_url ? (
|
|
<img
|
|
src={user.avatar_url}
|
|
alt="Profile"
|
|
className="w-32 h-32 rounded-full object-cover mx-auto border-4"
|
|
style={{ borderColor: 'var(--accent-ember)' }}
|
|
/>
|
|
) : (
|
|
<div
|
|
className="w-32 h-32 rounded-full flex items-center justify-center mx-auto text-4xl font-bold text-white border-4"
|
|
style={{
|
|
backgroundColor: 'var(--accent-ember)',
|
|
borderColor: 'var(--accent-flame)'
|
|
}}
|
|
>
|
|
{getInitials()}
|
|
</div>
|
|
)}
|
|
|
|
{/* Avatar Upload Button */}
|
|
<button
|
|
onClick={() => fileInputRef.current?.click()}
|
|
disabled={saving}
|
|
className="absolute bottom-0 right-0 p-2 rounded-full shadow-lg transition-all duration-200 hover:scale-110"
|
|
style={{ backgroundColor: 'var(--accent-flame)', color: 'white' }}
|
|
title="Upload new avatar"
|
|
>
|
|
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M3 9a2 2 0 012-2h.93a2 2 0 001.664-.89l.812-1.22A2 2 0 0110.07 4h3.86a2 2 0 011.664.89l.812 1.22A2 2 0 0018.07 7H19a2 2 0 012 2v9a2 2 0 01-2 2H5a2 2 0 01-2-2V9z" />
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 13a3 3 0 11-6 0 3 3 0 016 0z" />
|
|
</svg>
|
|
</button>
|
|
|
|
<input
|
|
ref={fileInputRef}
|
|
type="file"
|
|
accept="image/*"
|
|
onChange={handleAvatarUpload}
|
|
className="hidden"
|
|
/>
|
|
</div>
|
|
|
|
{/* Generate Avatar Button */}
|
|
<button
|
|
onClick={generateAvatar}
|
|
disabled={saving}
|
|
className="mt-4 px-4 py-2 rounded-xl font-medium transition-all duration-200 hover:shadow-md"
|
|
style={{
|
|
backgroundColor: 'var(--bg-tertiary)',
|
|
color: 'var(--text-primary)',
|
|
border: '1px solid var(--border)'
|
|
}}
|
|
>
|
|
Generate Avatar
|
|
</button>
|
|
</div>
|
|
|
|
{/* Basic Info */}
|
|
<div className="mb-6">
|
|
<h2 className="text-2xl font-bold mb-1" style={{ color: 'var(--text-primary)' }}>
|
|
{getDisplayName()}
|
|
</h2>
|
|
{user?.username && (
|
|
<p className="text-lg mb-2" style={{ color: 'var(--text-secondary)' }}>
|
|
@{user.username}
|
|
</p>
|
|
)}
|
|
<p className="text-sm" style={{ color: 'var(--text-secondary)' }}>
|
|
{user?.email}
|
|
</p>
|
|
<div className="flex items-center justify-center mt-2">
|
|
<span
|
|
className="px-3 py-1 text-xs rounded-full font-medium"
|
|
style={{
|
|
backgroundColor: user?.role === 'admin' ? 'var(--accent-ember)' : 'var(--accent-gold)',
|
|
color: 'white'
|
|
}}
|
|
>
|
|
{user?.role?.toUpperCase()}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
|
|
{/* Bio */}
|
|
{user?.bio && (
|
|
<div className="mb-6">
|
|
<p className="text-sm leading-relaxed" style={{ color: 'var(--text-secondary)' }}>
|
|
{user.bio}
|
|
</p>
|
|
</div>
|
|
)}
|
|
|
|
{/* Member Since */}
|
|
{user?.created_at && (
|
|
<div className="text-center">
|
|
<p className="text-sm" style={{ color: 'var(--text-secondary)' }}>
|
|
Member since {formatDate(user.created_at)}
|
|
</p>
|
|
</div>
|
|
)}
|
|
</div>
|
|
|
|
{/* Stats Card */}
|
|
<div className="card p-6 mt-6">
|
|
<h3 className="text-lg font-semibold mb-4" style={{ color: 'var(--text-primary)' }}>
|
|
List Stats
|
|
</h3>
|
|
<div className="space-y-4">
|
|
<div className="flex justify-between items-center">
|
|
<span style={{ color: 'var(--text-secondary)' }}>Total Cards</span>
|
|
<span className="font-semibold" style={{ color: 'var(--text-primary)' }}>
|
|
{stats.totalCards.toLocaleString()}
|
|
</span>
|
|
</div>
|
|
<div className="flex justify-between items-center">
|
|
<span style={{ color: 'var(--text-secondary)' }}>Lists</span>
|
|
<span className="font-semibold" style={{ color: 'var(--text-primary)' }}>
|
|
{stats.totalCollections}
|
|
</span>
|
|
</div>
|
|
<div className="flex justify-between items-center">
|
|
<span style={{ color: 'var(--text-secondary)' }}>Decks</span>
|
|
<span className="font-semibold" style={{ color: 'var(--text-primary)' }}>
|
|
{stats.totalDecks}
|
|
</span>
|
|
</div>
|
|
<div className="flex justify-between items-center pt-2 border-t" style={{ borderColor: 'var(--border)' }}>
|
|
<span style={{ color: 'var(--text-secondary)' }}>Total Value</span>
|
|
<span className="font-bold text-lg" style={{ color: 'var(--accent-ember)' }}>
|
|
{formatCurrency(stats.totalValue)}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{/* Profile Form */}
|
|
<div className="lg:col-span-2">
|
|
<div className="card p-6">
|
|
<div className="flex justify-between items-center mb-6">
|
|
<h3 className="text-xl font-semibold" style={{ color: 'var(--text-primary)' }}>
|
|
Profile Information
|
|
</h3>
|
|
<button
|
|
onClick={() => editMode ? handleSave() : setEditMode(true)}
|
|
disabled={saving}
|
|
className="px-4 py-2 rounded-xl font-medium transition-all duration-200 hover:shadow-md"
|
|
style={{
|
|
backgroundColor: editMode ? 'var(--accent-ember)' : 'var(--bg-tertiary)',
|
|
color: editMode ? 'white' : 'var(--text-primary)',
|
|
border: `1px solid ${editMode ? 'var(--accent-ember)' : 'var(--border)'}`
|
|
}}
|
|
>
|
|
{saving ? 'Saving...' : editMode ? 'Save Changes' : 'Edit Profile'}
|
|
</button>
|
|
</div>
|
|
|
|
<div className="space-y-6">
|
|
{/* Name Fields */}
|
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
|
<div>
|
|
<label className="block text-sm font-medium mb-2" style={{ color: 'var(--text-primary)' }}>
|
|
First Name
|
|
</label>
|
|
{editMode ? (
|
|
<input
|
|
type="text"
|
|
value={formData.first_name}
|
|
onChange={(e) => handleInputChange('first_name', e.target.value)}
|
|
className="input-field w-full"
|
|
placeholder="Enter your first name"
|
|
/>
|
|
) : (
|
|
<p className="py-2 text-sm" style={{ color: 'var(--text-secondary)' }}>
|
|
{user?.first_name || 'Not set'}
|
|
</p>
|
|
)}
|
|
</div>
|
|
<div>
|
|
<label className="block text-sm font-medium mb-2" style={{ color: 'var(--text-primary)' }}>
|
|
Last Name
|
|
</label>
|
|
{editMode ? (
|
|
<input
|
|
type="text"
|
|
value={formData.last_name}
|
|
onChange={(e) => handleInputChange('last_name', e.target.value)}
|
|
className="input-field w-full"
|
|
placeholder="Enter your last name"
|
|
/>
|
|
) : (
|
|
<p className="py-2 text-sm" style={{ color: 'var(--text-secondary)' }}>
|
|
{user?.last_name || 'Not set'}
|
|
</p>
|
|
)}
|
|
</div>
|
|
</div>
|
|
|
|
{/* Username */}
|
|
<div>
|
|
<label className="block text-sm font-medium mb-2" style={{ color: 'var(--text-primary)' }}>
|
|
Username
|
|
</label>
|
|
{editMode ? (
|
|
<input
|
|
type="text"
|
|
value={formData.username}
|
|
onChange={(e) => handleInputChange('username', e.target.value)}
|
|
className="input-field w-full"
|
|
placeholder="Choose a unique username"
|
|
/>
|
|
) : (
|
|
<p className="py-2 text-sm" style={{ color: 'var(--text-secondary)' }}>
|
|
{user?.username || 'Not set'}
|
|
</p>
|
|
)}
|
|
</div>
|
|
|
|
{/* Bio */}
|
|
<div>
|
|
<label className="block text-sm font-medium mb-2" style={{ color: 'var(--text-primary)' }}>
|
|
Bio
|
|
</label>
|
|
{editMode ? (
|
|
<textarea
|
|
value={formData.bio}
|
|
onChange={(e) => handleInputChange('bio', e.target.value)}
|
|
className="input-field w-full h-24 resize-none"
|
|
placeholder="Tell us about yourself..."
|
|
maxLength={500}
|
|
/>
|
|
) : (
|
|
<p className="py-2 text-sm leading-relaxed" style={{ color: 'var(--text-secondary)' }}>
|
|
{user?.bio || 'No bio set'}
|
|
</p>
|
|
)}
|
|
</div>
|
|
|
|
{/* Favorite Games */}
|
|
<div>
|
|
<label className="block text-sm font-medium mb-3" style={{ color: 'var(--text-primary)' }}>
|
|
Favorite Games
|
|
</label>
|
|
<div className="flex flex-wrap gap-3">
|
|
{gameOptions.map(game => (
|
|
<button
|
|
key={game.value}
|
|
onClick={() => editMode && handleGameToggle(game.value)}
|
|
disabled={!editMode}
|
|
className={`px-4 py-2 rounded-xl font-medium transition-all duration-200 flex items-center gap-2 ${
|
|
editMode ? 'cursor-pointer hover:shadow-md' : 'cursor-default'
|
|
} ${
|
|
(editMode ? formData.favorite_games : user?.favorite_games)?.includes(game.value)
|
|
? 'shadow-lg'
|
|
: 'hover:shadow-md'
|
|
}`}
|
|
style={{
|
|
backgroundColor: (editMode ? formData.favorite_games : user?.favorite_games)?.includes(game.value)
|
|
? 'var(--accent-ember)'
|
|
: 'var(--bg-tertiary)',
|
|
color: (editMode ? formData.favorite_games : user?.favorite_games)?.includes(game.value)
|
|
? 'white'
|
|
: 'var(--text-primary)',
|
|
border: `1px solid ${
|
|
(editMode ? formData.favorite_games : user?.favorite_games)?.includes(game.value)
|
|
? 'var(--accent-ember)'
|
|
: 'var(--border)'
|
|
}`
|
|
}}
|
|
>
|
|
<span>{game.icon}</span>
|
|
{game.label}
|
|
</button>
|
|
))}
|
|
</div>
|
|
</div>
|
|
|
|
{/* Email (Read-only) */}
|
|
<div>
|
|
<label className="block text-sm font-medium mb-2" style={{ color: 'var(--text-primary)' }}>
|
|
Email Address
|
|
</label>
|
|
<div className="flex items-center gap-3">
|
|
<p className="py-2 text-sm" style={{ color: 'var(--text-secondary)' }}>
|
|
{user?.email}
|
|
</p>
|
|
<span className="px-2 py-1 text-xs rounded-full bg-green-100 dark:bg-green-900/20 text-green-800 dark:text-green-200">
|
|
Verified
|
|
</span>
|
|
</div>
|
|
<p className="text-xs mt-1" style={{ color: 'var(--text-secondary)' }}>
|
|
To change your email, please contact support
|
|
</p>
|
|
</div>
|
|
|
|
{/* Cancel Button (only in edit mode) */}
|
|
{editMode && (
|
|
<div className="flex justify-end pt-4">
|
|
<button
|
|
onClick={() => {
|
|
setEditMode(false);
|
|
setFormData({
|
|
first_name: user?.first_name || '',
|
|
last_name: user?.last_name || '',
|
|
username: user?.username || '',
|
|
bio: user?.bio || '',
|
|
favorite_games: user?.favorite_games || []
|
|
});
|
|
setMessage({ type: '', text: '' });
|
|
}}
|
|
className="px-4 py-2 rounded-xl font-medium transition-all duration-200 hover:shadow-md"
|
|
style={{
|
|
backgroundColor: 'var(--bg-tertiary)',
|
|
color: 'var(--text-secondary)',
|
|
border: '1px solid var(--border)'
|
|
}}
|
|
>
|
|
Cancel
|
|
</button>
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</Layout>
|
|
);
|
|
}
|