using Android.DeviceLock;
using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.MAUI.Pages.Security;
using WorkFlowCheck.MAUI.Services.Interfaces;

namespace WorkFlowCheck.MAUI.Pages.BaseStock;

public partial class BaseStockPage : ContentPage
{
    private IUserService _userService;
    private UserDTO _currentUser;
    
    public BaseStockPage()
    {
        InitializeComponent();
        _userService = MauiProgram.ServiceProvider.GetRequiredService<IUserService>();
    }
    private void SetInfo()
    {
        _currentUser = _userService.GetCurrentUser();
        DeviceId.Text = _userService.DeviceId;
        UserInfo.Text = $"{_currentUser?.LastName} {_currentUser?.FirstName}";
    }

    override protected async void OnAppearing()
    {
        base.OnAppearing();
        SetInfo();
    }
    private async void OnButtonGetCheckPoints(object sender, EventArgs e)
    {
        //await Shell.Current.GoToAsync("//CheckPointsPage");
        await Navigation.PushAsync(new CheckPointsPage());
    }
    private async void OnButtonGetEquipments(object sender, EventArgs e)
    {
        //await Shell.Current.GoToAsync("//EquipmentsPage");
        await Navigation.PushAsync(new EquipmentsPage());
    }
    private async void OnButtonGetLocations(object sender, EventArgs e)
    {
        //await Shell.Current.GoToAsync("//LocationsPage");
        await Navigation.PushAsync(new LocationsPage());
    }
    private async void OnButtonGetUsers(object sender, EventArgs e)
    {
        //await Shell.Current.GoToAsync("//LocationsPage");
        await Navigation.PushAsync(new UsersPage());
    }

    protected override bool OnBackButtonPressed()
    {
        Shell.Current.GoToAsync("//MainPage");
        return true;
    }
}