<?php

namespace App\Actions\Profile;

use App\Enums\PlayerLevel;
use App\Enums\ProfileVisibility;
use App\Models\PlayerProfile;
use App\Models\User;
use App\Support\PublicId;

class CreatePlayerProfileOnRegistration
{
    public function execute(User $user, array $data): PlayerProfile
    {
        return PlayerProfile::create([
            'public_id' => PublicId::generate(),
            'user_id' => $user->id,
            'display_name' => $data['display_name'],
            'country_code' => $data['country_code'] ?? null,
            'timezone' => $data['timezone'] ?? 'UTC',
            'player_level' => PlayerLevel::Amateur,
            'profile_visibility' => ProfileVisibility::Public,
            'profile_completion_percentage' => 0,
            'status' => 'active',
        ]);
    }
}
