package org.academiadecodigo.enuminatti.cadetregistry;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import org.academiadecodigo.enuminatti.cadetregistry.controllers.LoginController;
import org.academiadecodigo.enuminatti.cadetregistry.models.User;
import org.academiadecodigo.enuminatti.cadetregistry.services.MockUserService;
import org.academiadecodigo.enuminatti.cadetregistry.services.UserService;

public class Main extends Application {

    private Parent root;
    private LoginController controller;

    @Override
    public void init() throws Exception {

        FXMLLoader loader = new FXMLLoader(getClass().getResource("views/login.fxml"));
        root = loader.load();

        UserService userService = new MockUserService();
        userService.addUser(new User("ricardo", "cenas@email.com", "coisas"));

        controller = loader.getController();
        controller.setUserService(userService);

    }

    @Override
    public void start(Stage primaryStage) throws Exception {

        primaryStage.setTitle("Cadet Registry");
        primaryStage.setScene(new Scene(root));
        primaryStage.show();

    }


    public static void main(String[] args) {
        Application.launch(args);
    }
}
