package dev.service;

import dev.dao.MenuItemDao;
import dev.model.MenuItem;
import dev.ui.ConsoleStyle;
import java.util.List;

public class MenuService
{

    private final MenuItemDao menuItemDao = new MenuItemDao();

    public void showMenu()
    {
        List<MenuItem> menuItems = menuItemDao.findAll();

        if (menuItems == null || menuItems.isEmpty())
        {
            ConsoleStyle.printError("No menu items available.");
            return;
        }

        ConsoleStyle.printHeader("📋 MENU ITEMS");
        System.out.printf("%-5s %-25s %-10s %-15s%n", "ID", "Name", "Price", "Category");
        ConsoleStyle.printLine();

        for (MenuItem item : menuItems)
        {
            System.out.printf(
                    "%-5d %-25s $%-9.2f %-15s%n",
                    item.getId(),
                    item.getName(),
                    item.getPrice(),
                    item.getCategory() == null ? "-" : item.getCategory()
            );
        }
    }
}