<?php

declare(strict_types=1);

namespace App\Command\Import;

use App\Entity\ShippingCompany;
use App\Entity\Vessel;
use App\Factory\MediaObjectFactory;
use App\Factory\UserFactory;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

#[AsCommand(
    name: 'app:create-user',
    description: 'Creates users'
)]
class CreateUserCommand extends Command
{

    public function __construct(
        private readonly EntityManagerInterface $entityManager
    ) {
        parent::__construct();
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $system = UserFactory::createOne(
            [
                'email' => 'jakob@spawntree.de',
                'firstName' => 'Jakob',
                'lastName' => 'Nordstrøm',
                'password' => '12spawntree345',
                'referenceId' => 'ABC123',
                'roles' => ['ROLE_ADMIN']
            ]
        );
        $system->_set('image', MediaObjectFactory::createOne()->_real());
        $system->_save();

        $adminD = UserFactory::createOne(
            [
                'email' => 'd.knudsen@spawntree.de',
                'firstName' => 'Daniel',
                'lastName' => 'Knudsen',
                'password' => '12spawntree345',
                'referenceId' => 'DEF456',
                'roles' => ['ROLE_ADMIN']
            ]
        );
        $system->_set('image', MediaObjectFactory::createOne()->_real());
        $adminD->_save();

        UserFactory::createOne(
            [
                'email' => 'f.eisenmenger@spawntree.de',
                'firstName' => 'Florian',
                'lastName' => 'Eisenmenger',
                'password' => '12spawntree345',
                'image' => MediaObjectFactory::createOne(),
                'referenceId' => 'GHI789',
                'roles' => ['ROLE_ADMIN']
            ]
        );
        $system->_set('image', MediaObjectFactory::createOne()->_real());
        $adminD->_save();


        return Command::SUCCESS;
    }
}