feat: update CORS configuration and enhance player profile with Minecraft stats and tab navigation

This commit is contained in:
Lars Behrends
2025-12-30 12:41:12 +01:00
parent 5fcd5dbdcb
commit 1dcac99e73
5 changed files with 231 additions and 167 deletions

View File

@@ -647,7 +647,7 @@ const EditNpcCompanyCard: React.FC<{ company: any; npcCitizens: any[]; onUpdate:
const AdminPage: React.FC<AdminPageProps> = ({ onBack }) => {
const [user, setUser] = useState(authService.getUser());
const [activeTab, setActiveTab] = useState<'overview' | 'npcs' | 'create-npc' | 'edit-npcs' | 'cities' | 'create-city' | 'manage-admins'>('overview');
const [activeTab, setActiveTab] = useState<'overview' | 'create-npc' | 'edit-npcs' | 'cities' | 'create-city' | 'manage-admins'>('overview');
const [npcs, setNpcs] = useState<any>({ citizens: [], companies: [] });
const [cities, setCities] = useState<any[]>([]);
const [loading, setLoading] = useState(false);
@@ -903,17 +903,11 @@ const AdminPage: React.FC<AdminPageProps> = ({ onBack }) => {
>
Übersicht
</button>
<button
onClick={() => setActiveTab('npcs')}
className={`px-6 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${activeTab === 'npcs' ? 'border-accentInfo text-white' : 'border-transparent text-textMuted hover:text-white'}`}
>
NPCs verwalten ({npcs.citizens.length + npcs.companies.length})
</button>
<button
onClick={() => setActiveTab('edit-npcs')}
className={`px-6 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${activeTab === 'edit-npcs' ? 'border-accentInfo text-white' : 'border-transparent text-textMuted hover:text-white'}`}
>
NPCs bearbeiten
NPCs verwalten ({npcs.citizens.length + npcs.companies.length})
</button>
<button
onClick={() => setActiveTab('create-npc')}
@@ -987,79 +981,6 @@ const AdminPage: React.FC<AdminPageProps> = ({ onBack }) => {
</div>
)}
{activeTab === 'npcs' && (
<div className="space-y-8">
{/* NPC Citizens */}
<div className="bg-surface border border-border rounded-xl p-6">
<h3 className="text-xl font-bold mb-4 flex items-center gap-2">
<Icons.Users className="w-5 h-5 text-blue-400" />
NPC-Bürger ({npcs.citizens.length})
</h3>
{loading ? (
<div className="flex justify-center py-8">
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-accentInfo"></div>
</div>
) : npcs.citizens.length === 0 ? (
<p className="text-textMuted">Keine NPC-Bürger vorhanden.</p>
) : (
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
{npcs.citizens.map((citizen: any) => (
<div key={citizen.uuid} className="bg-surfaceHighlight/30 border border-border rounded-lg p-4">
<div className="flex items-center gap-3 mb-2">
<div className="w-8 h-8 bg-purple-500/20 rounded flex items-center justify-center text-xs font-bold text-purple-400">
NPC
</div>
<div>
<h4 className="font-medium text-white">{citizen.username}</h4>
<p className="text-xs text-textMuted">{citizen.stats.role}</p>
</div>
</div>
<div className="text-xs text-textMuted">
Level {citizen.stats.level} {citizen.stats.playtimeHours}h Spielzeit
</div>
</div>
))}
</div>
)}
</div>
{/* NPC Companies */}
<div className="bg-surface border border-border rounded-xl p-6">
<h3 className="text-xl font-bold mb-4 flex items-center gap-2">
<Icons.ShoppingBag className="w-5 h-5 text-purple-400" />
NPC-Firmen ({npcs.companies.length})
</h3>
{npcs.companies.length === 0 ? (
<p className="text-textMuted">Keine NPC-Firmen vorhanden.</p>
) : (
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
{npcs.companies.map((company: any) => (
<div key={company.id} className="bg-surfaceHighlight/30 border border-border rounded-lg p-4">
<div className="flex justify-between items-start mb-2">
<h4 className="font-medium text-white">{company.title}</h4>
<span className="text-xs px-2 py-1 bg-purple-500/20 text-purple-400 rounded">
{company.category}
</span>
</div>
<p className="text-sm text-textMuted mb-2">{company.description}</p>
<div className="text-xs text-textMuted">
Eigentümer: {company.owner} Gegründet: {company.foundedDate}
</div>
{company.shopCatalog && company.shopCatalog.length > 0 && (
<div className="mt-2 text-xs text-accentInfo">
Shop: {company.shopCatalog.length} Artikel
</div>
)}
</div>
))}
</div>
)}
</div>
</div>
)}
{activeTab === 'edit-npcs' && (
<div className="space-y-8">
{/* Edit NPC Citizens */}