<?php

namespace App\Services;

use Illuminate\Support\Facades\Mail;
use App\Repositories\Interfaces\VerificationCodeRepositoryInterface;

class EmailService
{
    /**
     * @var VerificationCodeRepositoryInterface
     */
    protected $verificationCodeRepository;

    /**
     * @param VerificationCodeRepositoryInterface $verificationCodeRepository
     */
    public function __construct(VerificationCodeRepositoryInterface $verificationCodeRepository)
    {
        $this->verificationCodeRepository = $verificationCodeRepository;
    }

    /**
     * @param string $emailPage
     * @param array $emailInfo
     * 
     * @return void
     */
    public function sendEmail(string $emailPage, array $emailInfo): void
    {
        if ($emailPage) {
            $name = $emailInfo['name'];
            $email = $emailInfo['email'];
            $subject = "";

            switch ($emailPage) {
                case 'account-activation':
                    $subject = 'Your account has been created! | DESXPERT';
                    break;
                case 'forgot-password':
                    $subject = 'Forgot Your Password? | DESXPERT';
                    break;
                case 'professional-approved':
                    $subject = 'Application Approved | DESXPERT';
                   break;
                case 'professional-declined':
                    $subject = 'Application Declined | DESXPERT';
                   break;
                case 'professional-application':
                    $subject = 'New Application | DESXPERT';
                   break;
                case 'professional-application-support':
                    $subject = 'New Professional Application | DESXPERT';
                    break;
                default:
                    break;
            }

            Mail::send('emails.' . $emailPage, $emailInfo, function ($message) use ($name, $email, $subject) {
                $message->to($email, $name)->subject($subject);
            });
        }
    }
}
