<?php

namespace App\Notifications;

use App\Models\Application;

class DeadlineReminder extends ApplicationNotification
{
    public function __construct(Application $application, public int $daysLeft)
    {
        parent::__construct($application);
    }

    protected function subject(): string
    {
        return $this->daysLeft === 1
            ? 'Last day to submit your application'
            : "{$this->daysLeft} days left to submit your application";
    }

    protected function heading(): string
    {
        return 'Your application is not finished yet';
    }

    protected function lines(): array
    {
        $intake = $this->application->intake;

        return [
            "Application {$this->application->application_number} is still a draft.",
            "Applications for {$intake->name} close on {$intake->deadlineLabel()} — that is "
                .($this->daysLeft === 1 ? 'today' : "in {$this->daysLeft} days").".",
            'Sign in to finish and submit it. Everything you have entered so far has been saved.',
        ];
    }

    protected function actionLabel(): ?string
    {
        return 'Continue Application';
    }

    protected function actionUrl(): ?string
    {
        return route('applicant.dashboard');
    }

    public function toSms(): ?string
    {
        return sprintf(
            'KCU: Your application %s is not yet submitted. Applications close %s.',
            $this->application->application_number,
            $this->application->intake->deadlineLabel(),
        );
    }
}
