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

public class HasProductItemView : MonoBehaviour
{
    [SerializeField] private Text nameText;
    [SerializeField] private Text amountText;
    [SerializeField] private Transform productTarget;
    [SerializeField] private GameObject viewObject;
    [SerializeField] private GameObject noStockObject;

    public void SetData(ProductData productData, int amount)
    {
        amountText.text = $"{amount}{ScriptLocalization.Unit.Amount}";
        nameText.text = productData.Name;
        productTarget.DestroyAllChildrens();
        Instantiate(productData.GetIconPrefab(), productTarget);
    }

    public void SetNoStock(bool active)
    {
        viewObject.SetActive(!active);
        noStockObject.SetActive(active);
    }
}
