<?php

namespace App\Factory;

use App\Entity\MemberCase;
use App\Entity\Messages;
use App\Entity\User;
use App\Enums\MessageType;
use DateTimeImmutable;

class MessageFactory
{
    public static function createGeneral(User $sender, User $recipient, string $title, string $message): Messages
    {
        $msg = new Messages();
        $msg->setSent(new DateTimeImmutable())
            ->setType(MessageType::GENERAL)
            ->setSender($sender)
            ->setRecipient($recipient)
            ->setMessage($message)
            ->setTitle($title)
        ;

        return $msg;
    }

    public static function createCase(User $sender, User $recipient): Messages
    {
        $msg = new Messages();
        $msg->setSent(new DateTimeImmutable())
            ->setType(MessageType::CASE)
            ->setSender($sender)
            ->setRecipient($recipient)
            ->setTitle('Case')
            ->setMessage("{$sender->getName()} has updated a case")
        ;

        return $msg;
    }

    public static function createNewCase(User $sender, User $recipient, string $link): Messages
    {
        $msg = new Messages();
        $msg->setSent(new DateTimeImmutable())
            ->setType(MessageType::NEW_CASE)
            ->setSender($sender)
            ->setRecipient($recipient)
            ->setTitle('New Case')
            ->setLink($link)
            ->setMessage("You've been assigned a new case")
        ;

        return $msg;
    }

    public static function createStaffing(User $sender, User $recipient): Messages
    {
        $msg = new Messages();
        $msg->setSent(new DateTimeImmutable())
            ->setType(MessageType::STAFFING)
            ->setSender($sender)
            ->setRecipient($recipient)
            ->setTitle('Staff Notes')
            ->setMessage("Staff notes from {$sender->getName()} are ready for your review")
        ;

        return $msg;
    }

    public static function createBilling(User $sender, User $recipient): Messages
    {
        $msg = new Messages();
        $msg->setSent(new DateTimeImmutable())
            ->setType(MessageType::BILLING)
            ->setSender($sender)
            ->setRecipient($recipient)
            ->setTitle('New Billing')
            ->setMessage("{$sender->getName()} has published their timesheet")
        ;

        return $msg;
    }

    public static function createReminder(User $sender, User $recipient, string $title, string $message): Messages
    {
        $msg = new Messages();
        $msg->setSent(new DateTimeImmutable())
            ->setType(MessageType::REMINDER)
            ->setSender($sender)
            ->setRecipient($recipient)
            ->setTitle($title)
            ->setMessage($message)
        ;

        return $msg;
    }

    public static function createUser(User $sender, User $recipient, string $title, string $message): Messages
    {
        $msg = new Messages();
        $msg->setSent(new DateTimeImmutable())
            ->setType(MessageType::USER)
            ->setSender($sender)
            ->setRecipient($recipient)
            ->setTitle($title)
            ->setMessage($message)
        ;

        return $msg;
    }

    public static function createReferral(User $sender, User $recipient, MemberCase $case): Messages
    {
        $msg = new Messages();
        $msg->setSender($sender)
            ->setRecipient($recipient)
            ->setSent(new DateTimeImmutable())
            ->setType(MessageType::NEW_REFERRAL)
            ->setTitle('New Referral')
            ->setMessage("A referral has been added/updated to case {$case->getCaseName()}")
        ;

        return $msg;
    }

    public static function createSupervisorSignStaffNote(User $sender, User $recipient, MemberCase $case): Messages
    {
        $msg = new Messages();
        $msg->setSender($sender)
            ->setRecipient($recipient)
            ->setSent(new DateTimeImmutable())
            ->setType(MessageType::STAFFING)
            ->setTitle('Staff Note Signed')
            ->setMessage("Supervisor signed note for {$case->getCaseName()}")
        ;

        return $msg;
    }
}
