Refactor Summary component to remove unnecessary code and add product notes

This commit is contained in:
Benjamin Beganović 2024-02-16 17:42:38 +01:00
parent 5d9da26970
commit e8eca033eb

View File

@ -25,19 +25,6 @@ class Summary extends Component
public array $context;
#[On('purchase.context')]
public function handleContext(string $property, $value): self
{
data_set($this->context, $property, $value);
// The following may not be needed, as we can pass arround $context.
// cache()->set($this->hash, $this->context);
// $this->dispatch('purchase.context', property: 'products', value: $products);
return $this;
}
public function mount()
{
$bundle = $this->context['bundle'] ?? [
@ -59,6 +46,7 @@ class Summary extends Component
$bundle['one_time_products'][$product->hashed_id] = [
'product' => $product,
'quantity' => 1,
'notes' => $product->markdownNotes(),
];
}
@ -66,6 +54,7 @@ class Summary extends Component
$bundle['optional_recurring_products'][$product->hashed_id] = [
'product' => $product,
'quantity' => 0,
'notes' => $product->markdownNotes(),
];
}
@ -73,6 +62,7 @@ class Summary extends Component
$bundle['optional_one_time_products'][$product->hashed_id] = [
'product' => $product,
'quantity' => 0,
'notes' => $product->markdownNotes(),
];
}
@ -180,6 +170,8 @@ class Summary extends Component
];
}
$this->dispatch('purchase.context', property: 'products', value: $products);
return $products;
}