using System;
using I2.Loc;
using UnityEngine;
using UnityEngine.UI;

public class HasMaterialItemView : MonoBehaviour
{
    [SerializeField] private Text nameText;
    [SerializeField] private Text amountText;
    [SerializeField] private Transform materialTarget;
    [SerializeField] private GameObject viewObject;
    [SerializeField] private GameObject noStockObject;
    
    public void SetData(ShopData shopData, int amount)
    {
        amountText.text = $"{amount}{ScriptLocalization.Unit.Amount}";
        nameText.text = shopData.Name;
        materialTarget.DestroyAllChildrens();
        Instantiate(shopData.GetIconPrefab(), materialTarget);
    }
    
    public void SetNoStock(bool active)
    {
        viewObject.SetActive(!active);
        noStockObject.SetActive(active);
    }
}
