using Books.Api.Domain.UserAccess;
using Books.Api.GraphQL.Types;
using GraphQL.Types;

namespace Books.Api.GraphQL.InputTypes;

public class GrantUserAccessInputType : InputObjectGraphType<GrantUserAccessInput>
{
    public GrantUserAccessInputType()
    {
        Name = "GrantUserAccessInput";
        Description = "Input for granting a user access to a company";

        Field(x => x.UserId).Description("User ID (Keycloak ID or email)");
        Field(x => x.CompanyId).Description("Company ID to grant access to");
        Field<NonNullGraphType<CompanyRoleEnumType>>("role")
            .Description("Role to grant (OWNER, ACCOUNTANT, VIEWER)");
    }
}

public class GrantUserAccessInput
{
    public string UserId { get; set; } = string.Empty;
    public string CompanyId { get; set; } = string.Empty;
    public CompanyRole Role { get; set; }
}

public class ChangeUserAccessRoleInputType : InputObjectGraphType<ChangeUserAccessRoleInput>
{
    public ChangeUserAccessRoleInputType()
    {
        Name = "ChangeUserAccessRoleInput";
        Description = "Input for changing a user's role for a company";

        Field(x => x.UserId).Description("User ID");
        Field(x => x.CompanyId).Description("Company ID");
        Field<NonNullGraphType<CompanyRoleEnumType>>("newRole")
            .Description("New role to assign");
    }
}

public class ChangeUserAccessRoleInput
{
    public string UserId { get; set; } = string.Empty;
    public string CompanyId { get; set; } = string.Empty;
    public CompanyRole NewRole { get; set; }
}

public class RevokeUserAccessInputType : InputObjectGraphType<RevokeUserAccessInput>
{
    public RevokeUserAccessInputType()
    {
        Name = "RevokeUserAccessInput";
        Description = "Input for revoking a user's access to a company";

        Field(x => x.UserId).Description("User ID");
        Field(x => x.CompanyId).Description("Company ID");
    }
}

public class RevokeUserAccessInput
{
    public string UserId { get; set; } = string.Empty;
    public string CompanyId { get; set; } = string.Empty;
}
