package dev.service;

import dev.dao.MenuItemDao;
import dev.model.MenuItem;
import dev.model.User;

import java.util.List;
import java.util.Scanner;

public class MenuService {

    public static final MenuItemDao menuItemDao = new MenuItemDao();

    public void showMenu() {
        List<MenuItem> items = menuItemDao.findAll();
        for (MenuItem item : items){
            System.out.println(item.toString());
        }
    }

    public void userPanel(User user) {

        OrderService orderService;

        while (true) {
            System.out.println();
            System.out.println("===== " + user.getUsername().toUpperCase() + " =====");
            System.out.println("1. Place Order");
            System.out.println("2. Order History");
            System.out.println("3. Logout");

            Scanner scanner = new Scanner(System.in);
            int choice = scanner.nextInt();
            scanner.nextLine();

            switch (choice) {

                case 1:
                {
                    OrderService.placeOrder(user.getId());
                    break;
                }

                case 2: {
                    OrderService.showOrderHistory(user.getId());
                    break;
                }

                case 3:
                    System.out.println("Goodbye, " + user.getUsername() + "!");
                    return;

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

}