mirror of
https://github.com/ceratic/project_vollidioten_website.git
synced 2026-05-14 00:16:47 +02:00
feat: enhance player model with organizationId and update related API handling
This commit is contained in:
@@ -22,7 +22,7 @@ const PlayerProfile: React.FC = () => {
|
||||
|
||||
// Is this the logged-in user's profile?
|
||||
const isOwner = currentUser?.linkedPlayerUuid === player?.uuid;
|
||||
const playerOrg = player ? dbService.getOrg(player.stats?.organizationId || '') : null;
|
||||
const playerOrg = player ? dbService.getOrg(player.organizationId || '') : null;
|
||||
|
||||
// Check if player is already linked to anyone in our mock/real DB logic
|
||||
// Since the Player object doesn't expose 'discordId' publicly in types yet (it's hidden in DB),
|
||||
@@ -44,12 +44,15 @@ const PlayerProfile: React.FC = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(playerData);
|
||||
setLoading(false);
|
||||
}, [id, navigate]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!player) return;
|
||||
|
||||
console.log(player);
|
||||
|
||||
// Load owned projects
|
||||
const allProjects = dbService.getProjects();
|
||||
const playerProjects = allProjects.filter(p => p.owner === player.username);
|
||||
@@ -105,7 +108,7 @@ const PlayerProfile: React.FC = () => {
|
||||
|
||||
if (response.ok) {
|
||||
// Update local state
|
||||
setPlayer(prev => ({ ...prev, stats: { ...prev.stats, organizationId: orgId || undefined } }));
|
||||
setPlayer(prev => ({ ...prev, organizationId: orgId || undefined }));
|
||||
} else {
|
||||
alert('Fehler beim Aktualisieren der Zugehörigkeit');
|
||||
}
|
||||
@@ -135,6 +138,7 @@ const PlayerProfile: React.FC = () => {
|
||||
});
|
||||
};
|
||||
|
||||
console.log(player);
|
||||
return (
|
||||
<div className="max-w-4xl mx-auto animate-in slide-in-from-right-4 duration-300">
|
||||
<div className="flex justify-between items-center mb-6">
|
||||
@@ -201,8 +205,8 @@ const PlayerProfile: React.FC = () => {
|
||||
<div className="flex items-center gap-2 text-textMuted">
|
||||
<Icons.Terminal className="w-4 h-4" />
|
||||
<span className="font-mono text-textMain">
|
||||
{player.minecraftStats?.statistics?.general?.["minecraft:play_time"]
|
||||
? `${Math.round((player.minecraftStats.statistics.general["minecraft:play_time"] || 0) / 20 / 3600)}h`
|
||||
{player.stats?.statistics?.general?.["minecraft:play_time"]
|
||||
? `${Math.round((player.stats.statistics.general["minecraft:play_time"] || 0) / 20 / 3600)}h`
|
||||
: `${player.stats?.playtimeHours || 0}h`
|
||||
}
|
||||
</span>
|
||||
@@ -210,27 +214,27 @@ const PlayerProfile: React.FC = () => {
|
||||
<div className="flex items-center gap-2 text-textMuted">
|
||||
<Icons.Box className="w-4 h-4" />
|
||||
<span className="font-mono text-textMain">
|
||||
Lvl {player.minecraftStats?.char?.xpLevel || player.stats?.level || 1}
|
||||
Lvl {player.stats?.char?.xpLevel || player.stats?.level || 1}
|
||||
</span>
|
||||
</div>
|
||||
{player.minecraftStats && player.minecraftStats.char && player.minecraftStats.statistics && (
|
||||
{player.stats && player.stats.char && player.stats.statistics && (
|
||||
<>
|
||||
<div className="flex items-center gap-2 text-textMuted">
|
||||
<Icons.Shield className="w-4 h-4" />
|
||||
<span className="font-mono text-textMain">
|
||||
{player.minecraftStats.char.health}/{player.minecraftStats.char.maxHealth} HP
|
||||
{player.stats.char.health}/{player.stats.char.maxHealth} HP
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 text-textMuted">
|
||||
<Icons.Coins className="w-4 h-4" />
|
||||
<span className="font-mono text-textMain">
|
||||
{player.minecraftStats.char.foodLevel}/20 Food
|
||||
{player.stats.char.foodLevel}/20 Food
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 text-textMuted">
|
||||
<Icons.Hammer className="w-4 h-4" />
|
||||
<span className="font-mono text-textMain">
|
||||
{player.minecraftStats.statistics.general?.["minecraft:mob_kills"] || 0} Kills
|
||||
{player.stats.statistics.general?.["minecraft:mob_kills"] || 0} Kills
|
||||
</span>
|
||||
</div>
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user