fix(cart): hide Edit when there is nothing to configure

Drops the mount() change and its test, as suggested in review.
This commit is contained in:
dualfroz committed 2026-10-08 12:13:18 +02:00
1 parent 21685acdc9
commit 0b257a4761
3 files changed
+3 -23

No files matched your search

+1 -1
View File
@@ -92,7 +92,7 @@ class Checkout extends Component
// As there is only one plan, config options and checkout config, we can directly call the checkout method to avoid confusion
// This is only done when the user is not editing the cart item
if ($this->product->plans->count() === 1 && empty($this->configOptions) && empty($this->checkoutConfig) && !$this->cartProductKey) {
if ($this->product->plans->count() === 1 && empty($this->configOptions) && empty($this->checkoutConfig)) {
$this->checkout();
}
}
-22
View File
@@ -72,28 +72,6 @@ class CheckoutTest extends TestCase
]);
}
public function test_checkout_page_does_not_redirect_if_one_plan_when_editing_cart_item(): void
{
$this->get(route('products.checkout', [
$this->product->product->category->slug,
$this->product->product->slug,
]))->assertRedirect(route('cart'));
$cart = Cart::where('currency_code', 'USD')->firstOrFail();
$item = $cart->items()->firstOrFail();
Once::flush();
$response = $this->withCookie('cart', $cart->ulid)->get(route('products.checkout', [
$this->product->product->category->slug,
$this->product->product->slug,
'edit' => $item->id,
]));
$response->assertStatus(200);
$response->assertSee($this->product->product->name);
}
public function test_checkout_page_with_multiple_plans(): void
{
// Add plan
+2
View File
@@ -40,12 +40,14 @@
</x-button.secondary>
</div>
@endif
@if ($item->product->plans->count() > 1 || $item->product->configOptions->isNotEmpty() || !empty($item->checkout_config))
<a href="{{ route('products.checkout', [$item->product->category, $item->product, 'edit' => $item->id]) }}"
wire:navigate>
<x-button.primary class="h-fit w-fit">
{{ __('product.edit') }}
</x-button.primary>
</a>
@endif
<x-button.danger wire:click="removeProduct({{ $item->id }})" class="h-fit !w-fit">
<x-loading target="removeProduct({{ $item->id }})" />
<div wire:loading.remove wire:target="removeProduct({{ $item->id }})">