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

public class FooterManager : MonoBehaviour
{
    [SerializeField] private Button kitchenButton;
    [SerializeField] private Button fieldButton;
    [SerializeField] private Button stockButton;
    [SerializeField] private Button saleButton;
    [SerializeField] private Button productManagementButton;

    private void Start()
    {
        var currentSceneName = SceneManager.GetActiveScene().name;
        kitchenButton.interactable = currentSceneName != GameScenes.Main.ToString();
        fieldButton.interactable = currentSceneName != GameScenes.CornField.ToString();
        stockButton.interactable = currentSceneName != GameScenes.shopping.ToString();
        saleButton.interactable = currentSceneName != GameScenes.marketing.ToString();
        productManagementButton.interactable = currentSceneName != GameScenes.ProductManagement.ToString();
        kitchenButton.OnClickAsObservable()
            .ThrottleFirst(TimeSpan.FromSeconds(.5f))
            .Subscribe(_ =>
            {
                TransitionManager.Instance.LoadScene(GameScenes.Main);
            }).AddTo(this);
        fieldButton.OnClickAsObservable()
            .ThrottleFirst(TimeSpan.FromSeconds(.5f))
            .Subscribe(_ =>
            {
                TransitionManager.Instance.LoadScene(GameScenes.CornField);
            }).AddTo(this);
        stockButton.OnClickAsObservable()
            .ThrottleFirst(TimeSpan.FromSeconds(.5f))
            .Subscribe(_ =>
            {
                TransitionManager.Instance.LoadScene(GameScenes.shopping);
            }).AddTo(this);
        saleButton.OnClickAsObservable()
            .ThrottleFirst(TimeSpan.FromSeconds(.5f))
            .Subscribe(_ =>
            {
                TransitionManager.Instance.LoadScene(GameScenes.marketing);
            }).AddTo(this);
        productManagementButton.OnClickAsObservable()
            .ThrottleFirst(TimeSpan.FromSeconds(.5f))
            .Subscribe(_ =>
            {
                TransitionManager.Instance.LoadScene(GameScenes.ProductManagement);
            }).AddTo(this);
    }
}