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 {
    private final MenuItemDao menuItemDao;
    private Scanner scanner = new Scanner(System.in);
    private User currentUsers;

    public MenuService(MenuItemDao menuItemDao) {
        this.menuItemDao = menuItemDao;
        this.scanner = scanner;
    }

    public void setCurrentUsers(User user){
        this.currentUsers = user;
    }

    public void logout(){
        this.currentUsers = null;
    }

    public void showMenuItems() {
        if (currentUsers == null) {
            System.out.println(" Please login first!");
            return;
        }

        List<MenuItem> items = menuItemDao.findAll();
        if (items.isEmpty()) {
            System.out.println("No menu items available.");
            return;
        }

        System.out.println("\n--- 🍴 RESTAURANT MENU ---");
        for (MenuItem item : items) {
            System.out.println(item.toString());
            System.out.println("   " + item.getDescription());
        }
        System.out.println("---------------------------");
    }
}