using GraphQL.Types;

namespace Books.Api.GraphQL.InputTypes;

public class CreateProductInputType : InputObjectGraphType<CreateProductInput>
{
    public CreateProductInputType()
    {
        Name = "CreateProductInput";
        Description = "Input for creating a new product";

        Field(x => x.CompanyId).Description("Company ID (required)");
        Field(x => x.ProductNumber, nullable: true).Description("Product number/SKU (optional, must be unique if provided)");
        Field(x => x.Name).Description("Product name (required)");
        Field(x => x.Description, nullable: true).Description("Product description");
        Field(x => x.UnitPrice).Description("Unit price excl. VAT (required)");
        Field(x => x.VatCode).Description("VAT code (required, e.g., U25, IEUV)");
        Field(x => x.Unit, nullable: true).Description("Unit of measure (e.g., stk, time, kg)");
        Field(x => x.DefaultAccountId, nullable: true).Description("Default revenue account for this product");
        Field(x => x.Ean, nullable: true).Description("EAN/barcode number");
        Field(x => x.Manufacturer, nullable: true).Description("Manufacturer/brand name");
    }
}

public class CreateProductInput
{
    public string CompanyId { get; set; } = string.Empty;
    public string? ProductNumber { get; set; }
    public string Name { get; set; } = string.Empty;
    public string? Description { get; set; }
    public decimal UnitPrice { get; set; }
    public string VatCode { get; set; } = "U25";
    public string? Unit { get; set; }
    public string? DefaultAccountId { get; set; }
    public string? Ean { get; set; }
    public string? Manufacturer { get; set; }
}

public class UpdateProductInputType : InputObjectGraphType<UpdateProductInput>
{
    public UpdateProductInputType()
    {
        Name = "UpdateProductInput";
        Description = "Input for updating a product";

        Field(x => x.Id).Description("Product ID (required)");
        Field(x => x.ProductNumber, nullable: true).Description("Product number/SKU (optional, must be unique if provided)");
        Field(x => x.Name).Description("Product name (required)");
        Field(x => x.Description, nullable: true).Description("Product description");
        Field(x => x.UnitPrice).Description("Unit price excl. VAT (required)");
        Field(x => x.VatCode).Description("VAT code (required, e.g., U25, IEUV)");
        Field(x => x.Unit, nullable: true).Description("Unit of measure (e.g., stk, time, kg)");
        Field(x => x.DefaultAccountId, nullable: true).Description("Default revenue account for this product");
        Field(x => x.Ean, nullable: true).Description("EAN/barcode number");
        Field(x => x.Manufacturer, nullable: true).Description("Manufacturer/brand name");
    }
}

public class UpdateProductInput
{
    public string Id { get; set; } = string.Empty;
    public string? ProductNumber { get; set; }
    public string Name { get; set; } = string.Empty;
    public string? Description { get; set; }
    public decimal UnitPrice { get; set; }
    public string VatCode { get; set; } = "U25";
    public string? Unit { get; set; }
    public string? DefaultAccountId { get; set; }
    public string? Ean { get; set; }
    public string? Manufacturer { get; set; }
}
