using Knot.Shared.Kernel;
using System;

namespace Knot.Modules.Relations.Domain;

public enum ContactStatus
{
    Pending,
    Accepted,
    Declined,
    Blocked
}

public sealed class Contact : Entity<Guid>, IAggregateRoot
{
    public Guid UserId { get; private set; }
    public Guid ContactId { get; private set; }
    public ContactStatus Status { get; private set; }
    public DateTime CreatedAt { get; private set; }

    private Contact() : base(Guid.NewGuid()) { }

    private Contact(Guid id, Guid userId, Guid contactId, ContactStatus status) : base(id)
    {
        UserId = userId;
        ContactId = contactId;
        Status = status;
        CreatedAt = DateTime.UtcNow;
    }

    public static Contact CreateRequest(Guid userId, Guid contactId)
    {
        return new Contact(Guid.NewGuid(), userId, contactId, ContactStatus.Pending);
    }

    public void Accept() => Status = ContactStatus.Accepted;
    public void Decline() => Status = ContactStatus.Declined;
    public void Block() => Status = ContactStatus.Blocked;
    public void Unblock() => Status = ContactStatus.Accepted; // Or Pending if it was pending
}
