package com.utopiaindustries.controller;

import com.utopiaindustries.service.InventoryArtifactService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping( "/inventory-artifacts" )
public class InventoryArtifactController {


    private final InventoryArtifactService inventoryArtifactService;

    public InventoryArtifactController(InventoryArtifactService inventoryArtifactService) {
        this.inventoryArtifactService = inventoryArtifactService;
    }

    @GetMapping( "/bundle/{id}" )
    public String getBundleViewId( @PathVariable( "id") long id,
                                   Model model ){
        model.addAttribute("bundle", inventoryArtifactService.findBundleById( id) );
        return "bundle-view";
    }

//    @GetMapping( "/master-bundle/{id}" )
//    public String getMasterBundleById( @PathVariable( "id") long id,
//                                       Model model ){
//        model.addAttribute("masterBundle", inventoryArtifactService.findMasterBundleById( id ) );
//        return "master-bundle-view";
//    }

    @GetMapping( "/finished-item/{id}" )
    public String getFinishItemById( @PathVariable( "id" ) long id,
                                     Model model ){
        model.addAttribute("finishedItem", inventoryArtifactService.findFinishedItemById( id ) );
        return "finished-item-view";
    }
}
