// Copyright © Selmo Technology GmbH. All Rights Reserved

using Microsoft.AspNetCore.Components;
using SelmoStudio.Hmi.Server.SelmoHmi.Shared.Helpers;

namespace SelmoStudio.Hmi.Server.Shared.Components.BaseComponents
{
    public partial class DatePickerComponent : ComponentBase
    {
        [Parameter]
        public DateTime? SelectedDate { get; set; }

        [Parameter]
        public EventCallback<DateTime?> SelectedDateChanged { get; set; }

        private async Task OnDateChanged(DateTime? value)
        {
            if (SelectedDateChanged.HasDelegate)
            {
                await SelectedDateChanged.InvokeAsync(value);
            }
        }

        private string CurrentUICultureDateFormat => DateTimeFormatter.CurrentUICultureDateFormat;
    }
}