using FluentValidation;
using Meezi.API.Models.Public;

namespace Meezi.API.Validators;

public class GuestCreateOrderRequestValidator : AbstractValidator<GuestCreateOrderRequest>
{
    public GuestCreateOrderRequestValidator()
    {
        RuleFor(x => x.Items).NotEmpty();
        RuleForEach(x => x.Items).ChildRules(item =>
        {
            item.RuleFor(i => i.MenuItemId).NotEmpty();
            item.RuleFor(i => i.Quantity).GreaterThan(0);
        });
    }
}

public class PlaceGuestOrderRequestValidator : AbstractValidator<PlaceGuestOrderRequest>
{
    public PlaceGuestOrderRequestValidator()
    {
        RuleFor(x => x.TableId).NotEmpty();
        RuleFor(x => x.Items).NotEmpty();
        RuleForEach(x => x.Items).ChildRules(item =>
        {
            item.RuleFor(i => i.MenuItemId).NotEmpty();
            item.RuleFor(i => i.Quantity).GreaterThan(0);
        });
    }
}

public class CreateReservationRequestValidator : AbstractValidator<CreateReservationRequest>
{
    public CreateReservationRequestValidator()
    {
        RuleFor(x => x.GuestName).NotEmpty().MaximumLength(200);
        RuleFor(x => x.GuestPhone).NotEmpty().Matches(@"^09\d{9}$");
        RuleFor(x => x.PartySize).InclusiveBetween(1, 20);
        RuleFor(x => x.Date).Must(d => d >= DateOnly.FromDateTime(DateTime.UtcNow.Date));
    }
}
