using System;
using UniRx;
using UnityEngine;
using UnityEngine.UI;

namespace MyGame.Scenes.marketing.Scripts
{
    public class IncreaseCustomerButtonView : MonoBehaviour
    {
        private static readonly string remainTimeFormat = "{0:D2}:{1:D2}";
        [SerializeField] private Button rewardButton;
        [SerializeField] private GameObject DisableObject;
        [SerializeField] private Text remainTimeText;
        public IObservable<Unit> RewardButton => rewardButton.OnClickAsObservable().TakeUntilDestroy(this);

        public void SetButtonActive(bool active)
        {
            rewardButton.gameObject.SetActive(active);
            DisableObject.SetActive(!active);
        }

        public void SetTime(int seconds)
        {
            seconds = Mathf.Max(0, seconds);
            remainTimeText.text = string.Format(remainTimeFormat, seconds / 60, seconds % 60);
        }
    }
}