using FruitBank.Common.Entities;
using Microsoft.AspNetCore.Http;
using Nop.Web.Framework.Models;
using System.ComponentModel.DataAnnotations;

namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Models
{
    public record EditShippingModel : BaseNopModel
    {
        public int Id { get; set; }


        public string LicencePlate { get; set; }

        [Required]
        public DateTime ShippingDate { get; set; }

        public bool IsAllMeasured { get; set; }

        // List of existing documents associated with this Shipping
        public List<ShippingDocumentModel> ExistingDocuments { get; set; } = new();

        // For tracking newly uploaded files during the session
        public List<string> NewlyUploadedFiles { get; set; } = new();
    }

    public class ShippingDocumentModel
    {
        public int Id { get; set; }
        public int ShippingId { get; set; }
        public string FileName { get; set; }
        public string FilePath { get; set; }
        public int FileSize { get; set; }

        // Extracted data from PDF
        public DateTime? DocumentDate { get; set; }
        public string RecipientName { get; set; }
        public string SenderName { get; set; }
        public string InvoiceNumber { get; set; }
        public decimal? TotalAmount { get; set; }
        public int? ItemCount { get; set; }
        public string Notes { get; set; }
        public string RawAIAnalysis { get; set; }

        public ShippingDocument? ShippingDocument { get; set; }

    }

    // Result model for AJAX operations
    public class DocumentOperationResult
    {
        public bool Success { get; set; }
        public string Message { get; set; }
        public ShippingDocumentModel Document { get; set; }
        public int DocumentId { get; set; }
    }

    // Model for bulk operations
    public class BulkDocumentOperation
    {
        public List<int> DocumentIds { get; set; } = new();
        public string Operation { get; set; } // "delete", "activate", "deactivate"
    }
}
