<?php

namespace App\Notification\Notifications;

use App\Browser\JobErrorScreenshot;
use App\Models\Job;
use App\Notification\Notification;
use App\Notification\NotificationBody\JobErrorNotificationBody;
use App\Notification\Stringifiable;
use App\Notification\Stringifiable\StringifiableSimpleText;
use Illuminate\Support\Facades\Log;

class JobErrorNotification extends Notification {

    public function __construct(int $jobId, string $error) {
        parent::__construct($jobId, isError:true);
        $this->setBody(new JobErrorNotificationBody($this->job, $error));
    }

    public function getTitle(): Stringifiable {
        return new StringifiableSimpleText("Le job {$this->job->name} a échoué");
    }

    /**
     * @inheritDoc
     */
    public function getImageProjectPath(): string|null {
        return JobErrorScreenshot::getImgFileProjectPath($this->job->id);
    }

    /**
     * @inheritDoc
     */
    public function getLinkURL(): string|null {
        return route('jobs.show', ['job' => $this->job->id]);
    }
}
