using Microsoft.AspNetCore.Components;
using SkiaSharp;
using System;
using System.Buffers.Text;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TIAMWebApp.Shared.Application.Interfaces;
using TIAMWebApp.Shared.Application.Models;

namespace TIAMSharedUI.Pages.User.Hotels
{
    public partial class HotelComponent : ComponentBase
    {

        [Parameter]
        public string? Id { get; set; }

        [Inject]
        ISupplierService SupplierService { get; set; }

        [Inject]
        IUserDataService UserDataService { get; set; }

        [Inject]
        IServiceProviderDataService ServiceProviderDataService { get; set; }

        object? OrderData { get; set; }
        object? AffiliateData { get; set; }

        object? Data { get; set; }

        public string ImageSource { get; set; } = "";

        protected override async Task OnInitializedAsync()
        {
            base.OnInitialized();

            OrderData = new object[]
            {
            new {
                Date = DateTime.Now.AddDays(3),
                Income = "$5",
                TransactionId = "POX987532582",
                Status = "Finished"
            },
            new {
                Date = DateTime.Today.AddDays(-2),
                Income = "$5",
                TransactionId = "POX645646382",
                Status = "Finished"
            },
            new {
                Date = DateTime.Today.AddDays(-6),
                Income = "$8",
                TransactionId = "POX645766311",
                Status = "Finished"
            },
            };

            AffiliateData = new object[]
            {
           new {
                AffiliateId = 1,
                IncomeThisMonth = "$5",
                IncomeAlltime = "9425",
                CompanyName = "Upgen Ltd.",
                Status = "Active"
            },
            new {
                AffiliateId = 2,
                IncomeThisMonth = "$538",
                IncomeAlltime = "13425",
                CompanyName = "Kovacs hotel Ltd.",
                Status = "Active"
            },
            new {
                AffiliateId = 3,
                IncomeThisMonth = "$0",
                IncomeAlltime = "134200",
                CompanyName = "Innosaurus Ltd.",
                Status = "Passive"
            },
            };


            var suppliers = await SupplierService.GetSuppliersAsync();
            Data = suppliers.Select(s =>
            {
                return new
                {
                    s.CompanyName,
                    s.ContactName,
                    s.ContactTitle,
                    s.Country,
                    s.City,
                    s.Address,
                    s.Phone
                };
            });

            //SKBitmap bitmap = await ServiceProviderDataService.GetQRCodeByProductIdAsync(Guid.NewGuid());
            ImageSource = await ServiceProviderDataService.GetQRCodeByProductIdAsync(Guid.NewGuid());
        }
        [Parameter] public bool ShowSeriesPointMarkers { get; set; }
        [Parameter] public bool ShowSeriesLabels { get; set; }
    }
}
