diff --git a/app/Http/Controllers/Auth/LoginWaController.php b/app/Http/Controllers/Auth/LoginWaController.php
index 3ea7de7..cf28252 100644
--- a/app/Http/Controllers/Auth/LoginWaController.php
+++ b/app/Http/Controllers/Auth/LoginWaController.php
@@ -62,6 +62,7 @@ class LoginWaController extends Controller
return response()->json([
'success' => true,
'message' => __('otp.sent'),
+
'redirect' => route('login-phone.otp.view', ['identity' => $identity]),
]);
} catch (\Exception $e) {
@@ -78,6 +79,7 @@ class LoginWaController extends Controller
{
return view('account.otp', [
'identity' => $identity,
+ 'type' => 'phone',
]);
}
diff --git a/app/Http/Controllers/ProductController.php b/app/Http/Controllers/ProductController.php
index 6bb7ece..a59d878 100644
--- a/app/Http/Controllers/ProductController.php
+++ b/app/Http/Controllers/ProductController.php
@@ -205,6 +205,31 @@ class ProductController extends Controller
]);
}
+ public function brandsWithImages(Request $request)
+ {
+ $brandRepository = new \App\Repositories\Catalog\BrandRepository;
+ $brands = $brandRepository->getList([]);
+
+ // Render brand links HTML with images as swiper slides
+ $brandHtml = '';
+ $currentBrandId = $request->input('current_brand');
+
+ foreach ($brands as $brand) {
+ $isActive = $currentBrandId == $brand->id;
+ // Only show brands that have images
+ if ($brand->image_url) {
+ $brandHtml .= '';
+ $brandHtml .= '
';
+ $brandHtml .= '';
+ }
+ }
+
+ return response()->json([
+ 'success' => true,
+ 'brands' => $brandHtml,
+ ]);
+ }
+
public function announcements(Request $request)
{
// Static announcements for now - can be moved to database later
@@ -388,6 +413,70 @@ class ProductController extends Controller
]);
}
+ public function populersJson(Request $request)
+ {
+ $type = $request->input('type', 'new');
+ $limit = 6;
+
+ $user = auth()->user();
+ $userId = $user ? $user->id : 0;
+ [$location_id, $is_consignment] = Cache::remember('employee_user_'.$userId, 60 * 60 * 24, function () use ($user) {
+
+ if ($user == null) {
+ return [10, false];
+ }
+
+ $employee = @$user->employee;
+ $location_id = @$employee->location_id;
+ $location = @$employee->location;
+ $is_consignment = (bool) @$location->is_consignment;
+
+ return [$location_id, $is_consignment];
+
+ });
+
+ $productRepository = new ProductRepository;
+
+ // Set parameters based on type
+ $params = [
+ 'limit' => $limit,
+ 'location_id' => $location_id,
+ 'is_consignment' => $is_consignment,
+ ];
+
+ switch ($type) {
+ case 'new':
+ $params['sort'] = 'new';
+ break;
+ case 'best_sellers':
+ $params['sort'] = 'best_sellers';
+ break;
+ case 'special-offer':
+ $params['event'] = 'special-offer';
+ break;
+ case 'top_rated':
+ $params['sort'] = 'random';
+ break;
+ default:
+ $params['sort'] = 'new';
+ break;
+ }
+
+ $params['limit'] = 10;
+
+ $products = $productRepository->getList($params);
+
+
+ $p = $products->map(function($row){
+ $row->image_url = $row->image_url;
+ return $row;
+ });
+
+ return response()->json([
+ 'data' =>$p,
+ ]);
+ }
+
public function detail($slug, Request $request, ProductRepository $productRepository)
{
diff --git a/resources/views/account/otp.blade.php b/resources/views/account/otp.blade.php
index 960cc32..bd2722e 100644
--- a/resources/views/account/otp.blade.php
+++ b/resources/views/account/otp.blade.php
@@ -37,7 +37,7 @@
diff --git a/resources/views/checkout/v1-cart.blade.php b/resources/views/checkout/v1-cart.blade.php
index 8e9c968..29d094a 100644
--- a/resources/views/checkout/v1-cart.blade.php
+++ b/resources/views/checkout/v1-cart.blade.php
@@ -660,7 +660,7 @@
- --}}
diff --git a/resources/views/components/home/brand-home-fashion-v1.blade.php b/resources/views/components/home/brand-home-fashion-v1.blade.php
index ee921c6..28c8ed4 100644
--- a/resources/views/components/home/brand-home-fashion-v1.blade.php
+++ b/resources/views/components/home/brand-home-fashion-v1.blade.php
@@ -71,8 +71,8 @@ document.addEventListener('DOMContentLoaded', function() {
// Show loading spinner
loadingSpinner.classList.remove('d-none');
- // Make AJAX request for brands
- fetch('{{ route("product.ajax.brands") }}')
+ // Make AJAX request for brands with images
+ fetch('{{ route("product.ajax.brands-with-images") }}')
.then(response => response.json())
.then(data => {
if (data.success && data.brands) {
diff --git a/resources/views/components/home/home-popular-products.blade.php b/resources/views/components/home/home-popular-products.blade.php
index d157481..0582e9f 100644
--- a/resources/views/components/home/home-popular-products.blade.php
+++ b/resources/views/components/home/home-popular-products.blade.php
@@ -113,16 +113,12 @@ document.addEventListener('DOMContentLoaded', function() {
}
// Make AJAX request for popular products
- fetch('{{ route("product.ajax.populers") }}?type=best_sellers&limit=6')
+ fetch('{{ route("product.ajax.populers-json") }}?type=best_sellers&limit=6')
.then(response => response.json())
.then(data => {
- if (data.success && data.products) {
- // Parse the HTML to extract individual product cards
- const tempDiv = document.createElement('div');
- tempDiv.innerHTML = data.products;
-
- const productCards = tempDiv.querySelectorAll('.col');
- const productsArray = Array.from(productCards);
+ if ( data.data) {
+ // Handle JSON response directly
+ const productsArray = data.data;
// Split products into two slides (3 products each)
const slide1 = productsArray.slice(0, 3);
@@ -139,16 +135,16 @@ document.addEventListener('DOMContentLoaded', function() {
listDiv.className = 'd-flex flex-column gap-3 gap-lg-4';
slide.forEach(product => {
- // Convert product card to list item format
- const productImg = product.querySelector('img');
- const productLink = product.querySelector('a');
- const productPrice = product.querySelector('.h6, .price');
+ // Convert product object to list item format
+ const productImg = product.image_url;
+ const productLink = product.name;
+ const productPrice = product.unit_price;
const listItem = document.createElement('div');
listItem.className = 'd-flex align-items-center position-relative bg-body-tertiary rounded overflow-hidden animate-underline';
const img = document.createElement('img');
- img.src = productImg ? productImg.src : '/img/shop/fashion/thumbs/0' + (index * 3 + slide.indexOf(product) + 1) + '.png';
+ img.src = productImg ? productImg : '/img/shop/fashion/thumbs/0' + (index * 3 + slide.indexOf(product) + 1) + '.png';
img.width = 110;
img.alt = 'Thumbnail';
@@ -157,23 +153,22 @@ document.addEventListener('DOMContentLoaded', function() {
const link = document.createElement('a');
link.className = 'nav-link text-dark-emphasis stretched-link w-100 min-w-0 p-0';
- link.href = productLink ? productLink.href : '#';
+ link.href = product.slug ? '/product/' + product.slug : '#';
const span = document.createElement('span');
span.className = 'animate-target text-truncate';
- span.textContent = productLink ? productLink.textContent.trim() : 'Product Name';
+ span.textContent = productLink ? productLink : 'Product Name';
const price = document.createElement('div');
price.className = 'h6 mb-0';
- price.textContent = productPrice ? productPrice.textContent : '$0.00';
+ price.textContent = productPrice ? Number(productPrice).toLocaleString('id-ID', { style: 'currency', currency: 'IDR', minimumFractionDigits: 0 }) : '$0.00';
const name = document.createElement('div');
name.className = 'text-truncate mb-1';
- name.textContent = productLink ? productLink.textContent.trim() : 'Product Name';
+ name.textContent = productLink ? productLink : 'Product Name';
link.appendChild(span);
navDiv.appendChild(link);
- navDiv.appendChild(name);
navDiv.appendChild(price);
listItem.appendChild(img);
listItem.appendChild(navDiv);
diff --git a/resources/views/components/home/product-card.blade.php b/resources/views/components/home/product-card.blade.php
index a53a00c..dee9213 100644
--- a/resources/views/components/home/product-card.blade.php
+++ b/resources/views/components/home/product-card.blade.php
@@ -16,20 +16,6 @@
- {{-- --}}
name('home');
Route::get('/products', [ProductController::class, 'index'])->name('product.index');
Route::get('/products/ajax', [ProductController::class, 'ajax'])->name('product.ajax');
Route::get('/products/ajax/populers', [ProductController::class, 'populers'])->name('product.ajax.populers');
+Route::get('/products/ajax/populers-json', [ProductController::class, 'populersJson'])->name('product.ajax.populers-json');
Route::get('/products/ajax/highlights', [ProductController::class, 'highlights'])->name('product.ajax.highlights');
Route::get('/products/ajax/brands', [ProductController::class, 'brands'])->name('product.ajax.brands');
+Route::get('/products/ajax/brands-with-images', [ProductController::class, 'brandsWithImages'])->name('product.ajax.brands-with-images');
Route::get('/products/ajax/categories', [ProductController::class, 'categories'])->name('product.ajax.categories');
Route::get('/products/ajax/genders', [ProductController::class, 'genders'])->name('product.ajax.genders');
Route::get('/products/ajax/announcements', [ProductController::class, 'announcements'])->name('product.ajax.announcements');