From 0f02939f27417c8af4d863e3eff7892297d149ea Mon Sep 17 00:00:00 2001 From: myrmidex Date: Thu, 1 Jan 2026 03:18:40 +0100 Subject: [PATCH] UI test fixes --- app/Actions/CreateScenarioAction.php | 8 ++++---- app/Services/Streams/StatsService.php | 12 ++++++------ resources/js/pages/Scenarios/Show.tsx | 18 +++++++++--------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/app/Actions/CreateScenarioAction.php b/app/Actions/CreateScenarioAction.php index 4702689..b6c0085 100644 --- a/app/Actions/CreateScenarioAction.php +++ b/app/Actions/CreateScenarioAction.php @@ -2,7 +2,7 @@ namespace App\Actions; -use App\Models\Bucket; +use App\Enums\BucketAllocationTypeEnum; use App\Models\Scenario; use Illuminate\Support\Facades\DB; @@ -24,8 +24,8 @@ public function execute(array $data): Scenario private function createDefaultBuckets(Scenario $scenario): void { - $this->createBucketAction->execute($scenario, 'Monthly Expenses', Bucket::TYPE_FIXED_LIMIT, 0, 1); - $this->createBucketAction->execute($scenario, 'Emergency Fund', Bucket::TYPE_FIXED_LIMIT, 0, 2); - $this->createBucketAction->execute($scenario, 'Investments', Bucket::TYPE_UNLIMITED, null, 3); + $this->createBucketAction->execute($scenario, 'Monthly Expenses', BucketAllocationTypeEnum::FIXED_LIMIT, 0, 1); + $this->createBucketAction->execute($scenario, 'Emergency Fund', BucketAllocationTypeEnum::FIXED_LIMIT, 0, 2); + $this->createBucketAction->execute($scenario, 'Investments', BucketAllocationTypeEnum::UNLIMITED, null, 3); } } diff --git a/app/Services/Streams/StatsService.php b/app/Services/Streams/StatsService.php index 3970b97..0949ec1 100644 --- a/app/Services/Streams/StatsService.php +++ b/app/Services/Streams/StatsService.php @@ -2,7 +2,7 @@ namespace App\Services\Streams; -use App\Models\Stream; +use App\Enums\StreamTypeEnum; use App\Models\Scenario; readonly class StatsService @@ -14,21 +14,21 @@ public function getSummaryStats(Scenario $scenario): array ->get(); $totalMonthlyIncome = $streams - ->where('type', Stream::TYPE_INCOME) + ->where('type', StreamTypeEnum::INCOME) ->sum(fn($stream) => $stream->getMonthlyEquivalent()); $totalMonthlyExpenses = $streams - ->where('type', Stream::TYPE_EXPENSE) + ->where('type', StreamTypeEnum::EXPENSE) ->sum(fn($stream) => $stream->getMonthlyEquivalent()); return [ 'total_streams' => $streams->count(), 'active_streams' => $streams->where('is_active', true)->count(), - 'income_streams' => $streams->where('type', Stream::TYPE_INCOME)->count(), - 'expense_streams' => $streams->where('type', Stream::TYPE_EXPENSE)->count(), + 'income_streams' => $streams->where('type', StreamTypeEnum::INCOME)->count(), + 'expense_streams' => $streams->where('type', StreamTypeEnum::EXPENSE)->count(), 'monthly_income' => $totalMonthlyIncome, 'monthly_expenses' => $totalMonthlyExpenses, 'monthly_net' => $totalMonthlyIncome - $totalMonthlyExpenses, ]; } -} \ No newline at end of file +} diff --git a/resources/js/pages/Scenarios/Show.tsx b/resources/js/pages/Scenarios/Show.tsx index aa2bbef..38b6f59 100644 --- a/resources/js/pages/Scenarios/Show.tsx +++ b/resources/js/pages/Scenarios/Show.tsx @@ -51,12 +51,12 @@ interface StreamStats { interface Props { scenario: Scenario; - buckets: Bucket[]; - streams: Stream[]; + buckets: { data: Bucket[] }; + streams: { data: Stream[] }; streamStats?: StreamStats; } -export default function Show({ scenario, buckets, streams = [], streamStats }: Props) { +export default function Show({ scenario, buckets, streams = { data: [] }, streamStats }: Props) { const [isModalOpen, setIsModalOpen] = useState(false); const [isSubmitting, setIsSubmitting] = useState(false); const [editingBucket, setEditingBucket] = useState(null); @@ -141,13 +141,13 @@ export default function Show({ scenario, buckets, streams = [], streamStats }: P }; const handlePriorityChange = async (bucketId: number, direction: 'up' | 'down') => { - const bucket = buckets.find(b => b.id === bucketId); + const bucket = buckets.data.find(b => b.id === bucketId); if (!bucket) return; const newPriority = direction === 'up' ? bucket.priority - 1 : bucket.priority + 1; // Don't allow moving beyond bounds - if (newPriority < 1 || newPriority > buckets.length) return; + if (newPriority < 1 || newPriority > buckets.data.length) return; try { const response = await fetch(`/buckets/${bucketId}`, { @@ -218,7 +218,7 @@ export default function Show({ scenario, buckets, streams = [], streamStats }: P
- {buckets.map((bucket) => ( + {buckets.data.map((bucket) => (
)} - {streams.length === 0 ? ( + {streams.data.length === 0 ? (

No streams yet. Add income or expense streams to start tracking cash flow.

@@ -424,7 +424,7 @@ export default function Show({ scenario, buckets, streams = [], streamStats }: P - {streams.map((stream) => ( + {streams.data.map((stream) => ( {stream.name}