<?php

namespace App\Http\Controllers\ClaudeCode;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\View\View;
use Symfony\Component\HttpFoundation\BinaryFileResponse;

class UsagePlanController extends Controller
{
    public function index(Request $request): View|Response
    {
        if ($request->header('HX-Request')) {
            return response('', 200)->header('HX-Redirect', route('claude-code.usage-plan.index'));
        }

        return view('claude-code.usage-plan.index');
    }

    public function download(): BinaryFileResponse
    {
        $path = public_path('downloads/sam-usage-plan.pptx');
        abort_unless(file_exists($path), 404, 'PPTX 파일을 찾을 수 없습니다.');

        return response()->download($path, 'SAM_활용방안.pptx');
    }
}
