using AyCode.Core.Interfaces;
using DevExpress.Blazor;
using FruitBank.Common.Entities;
using FruitBank.Common.Interfaces;
using FruitBank.Common.SignalRs;
using FruitBankHybrid.Shared.Pages;
using Microsoft.AspNetCore.Components;

namespace FruitBankHybrid.Shared.Components.Grids.StockTakingItems;

public class GridStockTakingItemBase: FruitBankGridBase<StockTakingItem>, IGrid
{
    private bool _isFirstInitializeParameterCore;
    private bool _isFirstInitializeParameters;

    public GridStockTakingItemBase() : base()
    {
        GetAllMessageTag = SignalRTags.GetStockTakingItems;
        //AddMessageTag = SignalRTags.AddPartner;
        //UpdateMessageTag = SignalRTags.UpdatePartner;

        //RemoveMessageTag = SignalRTags.;
    }

    protected override async Task OnInitializedAsync()
    {
        await base.OnInitializedAsync();
    }

    protected override void OnParametersSet()
    {
        base.OnParametersSet();

        if (!_isFirstInitializeParameters)
        {
            //if (!IsMasterGrid && (ContextIds == null || ContextIds.Length == 0))
            //{
            //    ContextIds = [ParentDataItem!.Id];
            //    GetAllMessageTag = SignalRTags.GetShippingItemsByDocumentId;
            //}

            _isFirstInitializeParameters = false;
        }
    }

    protected override async Task SetParametersAsyncCore(ParameterView parameters)
    {
        await base.SetParametersAsyncCore(parameters);

        if (!_isFirstInitializeParameterCore)
        {
            //if (!IsMasterGrid && (ContextIds == null || ContextIds.Length == 0))
            //{
            //    ContextIds = [ParentDataItem!.Id];
            //    GetAllMessageTag = SignalRTags.GetShippingItemsByDocumentId;
            //}

            //ShowFilterRow = true;
            //ShowGroupPanel = true;
            //AllowSort = false;

            //etc...

            _isFirstInitializeParameterCore = false;
        }
    }
}