<?php

namespace App\Jobs;

use Filament\Notifications\Actions\Action as NotificationAction;
use Filament\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Foundation\Queue\Queueable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Storage;

class ExportCompleteJob implements ShouldQueue
{
    use Queueable;


    /**
     * Create a new job instance.
     */
    public function __construct(private $user)
    {
    }

    /**
     * Execute the job.
     */
    public function handle(): void
    {
        Notification::make()->success()
            ->title('Export Completed')
            ->actions([
                    NotificationAction::make('download_transmittal-export.xlsx')
                        ->label('Download File')
                        ->url(url: Storage::url('public/transmittal-export.xlsx') ,shouldOpenInNewTab: true)
                        ->markAsRead(),
                ]
            )
            ->sendToDatabase($this->user);
    }
}
