<?php

declare(strict_types=1);

namespace App\Filament\Auth;

use Filament\Auth\Http\Responses\Contracts\LoginResponse as LoginResponseContract;
use Filament\Facades\Filament;
use Illuminate\Http\RedirectResponse;
use Livewire\Features\SupportRedirects\Redirector;

/**
 * 登录页在「/」时 Filament::getUrl() 会回到根路径导致重定向死循环，
 * 登录成功应进入工作台（见 AdminPanelProvider 的 homeUrl）。
 */
final class DberpLoginResponse implements LoginResponseContract
{
    public function toResponse($request): RedirectResponse|Redirector
    {
        return redirect()->intended(Filament::getHomeUrl());
    }
}
