Compare commits

...

2 Commits

Author SHA1 Message Date
kelly
782e6797d8 fix: pass brand hashid as query param to product create
Some checks are pending
ci/woodpecker/push/ci Pipeline is running
2025-12-18 09:33:40 -07:00
kelly
09ff7b27a5 feat: add New Product button with brand selector to Products page 2025-12-18 09:27:47 -07:00
2 changed files with 29 additions and 2 deletions

View File

@@ -29,10 +29,10 @@ class ProductController extends Controller
// Get brand IDs to filter by (respects brand context switcher)
$brandIds = BrandSwitcherController::getFilteredBrandIds();
// Get all brands for the business for the filter dropdown
// Get all brands for the business for the filter dropdown and new product button
$brands = \App\Models\Brand::where('business_id', $business->id)
->orderBy('name')
->get(['id', 'name']);
->get(['id', 'name', 'hashid', 'logo_path', 'slug', 'updated_at']);
// Calculate missing BOM count for health alert
$missingBomCount = Product::whereIn('brand_id', $brandIds)

View File

@@ -78,6 +78,33 @@
<h1 class="text-xl font-semibold text-base-content">Products</h1>
<p class="text-sm text-base-content/50">Manage your product catalog</p>
</div>
@if($brands->count() > 0)
<div class="dropdown dropdown-end" x-data="{ open: false }">
<button @click="open = !open" class="btn btn-primary btn-sm gap-2">
<span class="icon-[heroicons--plus] size-4"></span>
New Product
</button>
<div x-show="open" @click.away="open = false" x-cloak
class="dropdown-content mt-2 p-3 shadow-lg bg-base-100 rounded-lg w-64 border border-base-300 z-50">
<p class="text-xs font-medium text-base-content/50 mb-2">Select a brand</p>
<div class="space-y-1 max-h-64 overflow-y-auto">
@foreach($brands as $brandItem)
<a href="{{ route('seller.business.products.create', $business->slug) }}?brand={{ $brandItem->hashid }}"
class="flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-base-200 transition-colors">
@if($brandItem->getLogoUrl('thumb'))
<img src="{{ $brandItem->getLogoUrl('thumb') }}" alt="{{ $brandItem->name }}" class="w-6 h-6 rounded object-contain bg-base-200">
@else
<div class="w-6 h-6 rounded bg-base-200 flex items-center justify-center">
<span class="icon-[heroicons--building-storefront] size-3 text-base-content/30"></span>
</div>
@endif
<span class="text-sm text-base-content">{{ $brandItem->name }}</span>
</a>
@endforeach
</div>
</div>
</div>
@endif
</div>
{{-- Missing BOM Alert --}}