From cf6f0c76c2635a0fe9d50b5a6e1f455d738eb605 Mon Sep 17 00:00:00 2001 From: myrmidex Date: Mon, 30 Mar 2026 00:01:05 +0200 Subject: [PATCH] 24 - Remove multi-scenario scaffolding --- app/Actions/DeleteScenarioAction.php | 13 -- app/Http/Controllers/ScenarioController.php | 43 ------ app/Http/Requests/StoreScenarioRequest.php | 42 ------ app/Repositories/ScenarioRepository.php | 16 -- resources/js/pages/Scenarios/Index.tsx | 153 -------------------- routes/web.php | 16 +- 6 files changed, 1 insertion(+), 282 deletions(-) delete mode 100644 app/Actions/DeleteScenarioAction.php delete mode 100644 app/Http/Requests/StoreScenarioRequest.php delete mode 100644 app/Repositories/ScenarioRepository.php delete mode 100644 resources/js/pages/Scenarios/Index.tsx diff --git a/app/Actions/DeleteScenarioAction.php b/app/Actions/DeleteScenarioAction.php deleted file mode 100644 index c8449bc..0000000 --- a/app/Actions/DeleteScenarioAction.php +++ /dev/null @@ -1,13 +0,0 @@ -delete(); - } -} diff --git a/app/Http/Controllers/ScenarioController.php b/app/Http/Controllers/ScenarioController.php index d2aa199..11fc3c5 100644 --- a/app/Http/Controllers/ScenarioController.php +++ b/app/Http/Controllers/ScenarioController.php @@ -2,36 +2,21 @@ namespace App\Http\Controllers; -use App\Actions\CreateScenarioAction; -use App\Actions\DeleteScenarioAction; use App\Actions\UpdateScenarioAction; -use App\Http\Requests\StoreScenarioRequest; use App\Http\Requests\UpdateScenarioRequest; use App\Http\Resources\BucketResource; use App\Http\Resources\ScenarioResource; use App\Models\Scenario; -use App\Repositories\ScenarioRepository; use Illuminate\Http\JsonResponse; -use Illuminate\Http\RedirectResponse; use Inertia\Inertia; use Inertia\Response; class ScenarioController extends Controller { public function __construct( - private readonly ScenarioRepository $scenarioRepository, - private readonly CreateScenarioAction $createScenarioAction, private readonly UpdateScenarioAction $updateScenarioAction, - private readonly DeleteScenarioAction $deleteScenarioAction, ) {} - public function index(): Response - { - return Inertia::render('Scenarios/Index', [ - 'scenarios' => ScenarioResource::collection($this->scenarioRepository->getAll()), - ]); - } - public function show(Scenario $scenario): Response { $scenario->load(['buckets' => function ($query) { @@ -44,38 +29,10 @@ public function show(Scenario $scenario): Response ]); } - public function create(): Response - { - return Inertia::render('Scenarios/Create'); - } - - public function store(StoreScenarioRequest $request): RedirectResponse - { - $scenario = $this->createScenarioAction->execute($request->validated()); - - return redirect()->route('scenarios.show', $scenario); - } - - public function edit(Scenario $scenario): Response - { - return Inertia::render('Scenarios/Edit', [ - 'scenario' => ScenarioResource::make($scenario)->resolve(), - ]); - } - public function update(UpdateScenarioRequest $request, Scenario $scenario): JsonResponse { $this->updateScenarioAction->execute($scenario, $request->validated()); return response()->json(['success' => true]); } - - public function destroy(Scenario $scenario): RedirectResponse - { - $this->deleteScenarioAction->execute($scenario); - - return redirect() - ->route('scenarios.index') - ->with('success', 'Scenario deleted successfully'); - } } diff --git a/app/Http/Requests/StoreScenarioRequest.php b/app/Http/Requests/StoreScenarioRequest.php deleted file mode 100644 index e1eed7f..0000000 --- a/app/Http/Requests/StoreScenarioRequest.php +++ /dev/null @@ -1,42 +0,0 @@ - ['required', 'string', 'max:255', 'min:1'], - 'description' => ['nullable', 'string', 'max:1000'], - ]; - } - - public function messages(): array - { - return [ - 'name.required' => 'A scenario name is required.', - 'name.min' => 'The scenario name must be at least 1 character.', - 'name.max' => 'The scenario name cannot exceed 255 characters.', - ]; - } - - protected function prepareForValidation(): void - { - // Trim the name - if ($this->has('name')) { - $this->merge([ - 'name' => trim($this->name), - ]); - } - } -} diff --git a/app/Repositories/ScenarioRepository.php b/app/Repositories/ScenarioRepository.php deleted file mode 100644 index d641552..0000000 --- a/app/Repositories/ScenarioRepository.php +++ /dev/null @@ -1,16 +0,0 @@ -orderBy('created_at', 'desc') - ->get(); - } -} diff --git a/resources/js/pages/Scenarios/Index.tsx b/resources/js/pages/Scenarios/Index.tsx deleted file mode 100644 index b5c1098..0000000 --- a/resources/js/pages/Scenarios/Index.tsx +++ /dev/null @@ -1,153 +0,0 @@ -import { Head, router } from '@inertiajs/react'; -import React, { useState } from 'react'; - -interface Scenario { - id: string; - name: string; - created_at: string; - updated_at: string; -} - -interface Props { - scenarios: { - data: Scenario[]; - }; -} - -export default function Index({ scenarios }: Props) { - const [showCreateForm, setShowCreateForm] = useState(false); - const [name, setName] = useState(''); - const [errors, setErrors] = useState<{ name?: string }>({}); - - const handleCreateScenario = (e: React.FormEvent) => { - e.preventDefault(); - - router.post('/scenarios', { name }, { - onSuccess: () => { - setShowCreateForm(false); - setName(''); - setErrors({}); - }, - onError: (errors) => { - setErrors(errors); - } - }); - }; - - const handleCancel = () => { - setShowCreateForm(false); - setName(''); - setErrors({}); - }; - - return ( - <> - - -
-
-
-

Budget Scenarios

-

- Manage your budget projections with water-themed scenarios -

-
- - {/* Create Scenario Form */} - {showCreateForm && ( -
-

Create New Scenario

-
-
- - setName(e.target.value)} - className="mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 text-sm text-gray-900 focus:border-blue-500 focus:outline-none focus:ring-blue-500" - placeholder="e.g., 2025 Budget" - /> - {errors.name && ( -

{errors.name}

- )} -
-
- - -
-
-
- )} - - {/* Create Button */} - {!showCreateForm && ( -
- -
- )} - - {/* Scenarios List */} - {scenarios.data.length === 0 ? ( -
-
- - - -
-

No scenarios yet

-

- Create your first budget scenario to get started -

-
- ) : ( -
- {scenarios.data.map((scenario) => ( -
router.visit(`/scenarios/${scenario.id}`)} - className="cursor-pointer rounded-lg bg-white p-6 shadow transition-shadow hover:shadow-lg" - > -

- {scenario.name} -

-

- Created {new Date(scenario.created_at).toLocaleDateString()} -

-
- View Details - - - -
-
- ))} -
- )} -
-
- - ); -} diff --git a/routes/web.php b/routes/web.php index b69e1a0..4edae11 100644 --- a/routes/web.php +++ b/routes/web.php @@ -7,20 +7,13 @@ use App\Models\Scenario; use Illuminate\Support\Facades\Route; -// Single-scenario MVP: redirect root to the default scenario +// Single scenario: redirect to default Route::get('/', function () { return redirect()->route('scenarios.show', Scenario::firstOrFail()); })->name('home'); Route::get('/scenarios/{scenario}', [ScenarioController::class, 'show'])->name('scenarios.show'); - -// Scenario CRUD routes (hidden for single-scenario MVP, re-enable later) -// Route::get('/scenarios', [ScenarioController::class, 'index'])->name('scenarios.index'); -// Route::get('/scenarios/create', [ScenarioController::class, 'create'])->name('scenarios.create'); -// Route::post('/scenarios', [ScenarioController::class, 'store'])->name('scenarios.store'); -// Route::get('/scenarios/{scenario}/edit', [ScenarioController::class, 'edit'])->name('scenarios.edit'); Route::patch('/scenarios/{scenario}', [ScenarioController::class, 'update'])->name('scenarios.update'); -// Route::delete('/scenarios/{scenario}', [ScenarioController::class, 'destroy'])->name('scenarios.destroy'); // Bucket routes (no auth required for MVP) Route::get('/scenarios/{scenario}/buckets', [BucketController::class, 'index'])->name('buckets.index'); @@ -41,11 +34,4 @@ Route::post('/scenarios/{scenario}/projections/preview', [ProjectionController::class, 'preview'])->name('projections.preview'); Route::post('/scenarios/{scenario}/projections/apply', [ProjectionController::class, 'apply'])->name('projections.apply'); -// Auth dashboard (hidden for single-scenario MVP, re-enable later) -// Route::middleware(['auth', 'verified'])->group(function () { -// Route::get('dashboard', function () { -// return Inertia::render('dashboard'); -// })->name('dashboard'); -// }); - require __DIR__.'/settings.php';