using Offers;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.Events;


namespace UI.EmailWindow
{
    public class MessageRow : MonoBehaviour
    {
        [SerializeField] UnityEngine.UI.Button rowButton;
        [SerializeField] TextMeshProUGUI clientName;
        [SerializeField] TextMeshProUGUI messageText;
        [SerializeField] TextMeshProUGUI messageDate;

        UnityAction clickOnButtonAction;

        public void SetData(Offer offer, UnityAction clickOnButtonAction)
        {
            this.clickOnButtonAction = clickOnButtonAction;

            clientName.text = offer.ClientName;
            messageText.text = offer.Description;
            messageDate.text = NumbersFormatter.FormatNumber(offer.OfferCreatedTime.Day) + "."
                + NumbersFormatter.FormatNumber(offer.OfferCreatedTime.Month) + "."
                + NumbersFormatter.FormatNumber(offer.OfferCreatedTime.Year);

            rowButton.onClick.AddListener(clickOnButtonAction);
        }

        private void OnDisable()
        {
            rowButton.onClick.RemoveListener(clickOnButtonAction);
        }
    }
}