<?php

namespace App\Services;

use App\Mail\EmailReceipt;
use App\Mail\ProviderApprovedMail;
use App\Mail\SendCodeMail;
use Illuminate\Support\Facades\Mail;

class EmailService
{
    public function sendEmailReceipt(
        string $email,
        object $schedule,
        string $client_name,
        string $service_date,
        string $start_time,
        string $end_time,
        string $address,
        string $total_amount,
        string $service_fee,
        string $final_amount,
        string $payment_method): void
    {
        Mail::to($email)->send(new EmailReceipt($schedule, $client_name, $service_date, $start_time, $end_time, $address, $total_amount, $service_fee, $final_amount, $payment_method));
    }

    public function sendProviderApproved(string $email, string $recipientName = '', ?string $locale = null): void
    {
        $pendingMail = Mail::to($email);

        if (! empty($locale)) {
            $pendingMail->locale($locale);
        }

        $pendingMail->send(new ProviderApprovedMail($recipientName));
    }

    /**
     * Envia o e-mail com o código de verificação para o usuário.
     *
     * @param  string $email          Endereço de e-mail do destinatário.
     * @param  string $code           Código de 6 dígitos gerado.
     * @param  string $recipientName  Nome do destinatário (opcional).
     */
    public function sendVerificationCode(string $email, string $code, string $recipientName = ''): void
    {
        Mail::to($email)->send(new SendCodeMail($code, $recipientName));
    }
}
