package dev.ui;

import dev.model.User;
import dev.service.AuthService;

import java.util.Scanner;

public class ConsoleMenu {

    private final Scanner scanner = new Scanner(System.in);
    private final AuthService authService = new AuthService();
    private User user;


    public void start() {

        while (true) {

            System.out.println();
            System.out.println("===== JAVA PIZZERIA =====");
            System.out.println("1. Login");
            System.out.println("2. Register");
            System.out.println("3. Exit");
            System.out.println("======================================= \n" +
                    "Choose an option: ");

            int choice = scanner.nextInt();

            switch (choice) {

                case 1:
                {
                    System.out.println("Enter username:");
                    String username =scanner.next();
                    System.out.println("Enter password:");
                    String password = scanner.next();

                    user = authService.login(username,password);

                    if(user == null){
                        System.out.println("Try again");
                    }
                    else {
                        System.out.println("Login success");

                    }

                    break;
                }

                case 2:
                {
                    System.out.println("Enter username:");
                    String username =scanner.next();
                    System.out.println("Enter password:");
                    String password = scanner.next();
                    System.out.println("Enter email:");
                    String email = scanner.next();


                    authService.register(username,password,email);
                    break;
                }

                case 3:
                    return;

                default:
                    System.out.println("Invalid choice");

            }

        }

    }

    public void menu(){

        while (true){
            System.out.println();
            System.out.println("========\uD83C\uDF7D\uFE0F MAIN MENU \uD83C\uDF7D\uFE0F========");
            System.out.println("1. View Menu");
            System.out.println("2. Place a New Order");
            System.out.println("3. View Order History ");
            System.out.println("4. Logout");
            System.out.println("======================================= \n" +
                    "Choose an option: ");

            int choice = scanner.nextInt();



        }








    }

}