#include "apiform.h"
#include "ui_apiform.h"
#include "utils.h"

ApiForm::ApiForm(QDialog *parent)
    : QDialog(parent)
    , ui(new Ui::ApiForm)
{
    ui->setupUi(this);

    connect(ui->loginButton, &QPushButton::clicked, this, [this]() {
        const QString adres = ui->adres->text();
        const QString port = ui->port->text();
        if (!adres.isEmpty() && !port.isEmpty()) {
            utils::API_URL = QString("http://%1:%2").arg(adres).arg(port);
            this->accept();
        }
        this->accept();
    });
}

ApiForm::~ApiForm()
{
    delete ui;
}
