From 1aa8f3da42c09afbd529a2dc4aa67895123cc87f Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Fri, 5 Dec 2025 14:20:56 +0700 Subject: [PATCH] refactor(home): membuat layouting - memperbaiki custom js - menyimpan menu untuk header di view service dan di foreach - menghapus file yang tidak berguna - membuat halaman outlet --- app/Livewire/Home/Index.php | 10 +- app/Livewire/Home/Outlet.php | 17 ++ app/Livewire/Home/Product/Index.php | 1 - app/Providers/ViewServiceProvider.php | 60 +++++- .../views/components/layouts/home.blade.php | 183 ++++++++++++++-- .../components/partials/home/_css.blade.php | 6 - .../partials/home/_header.blade.php | 199 +++--------------- .../components/partials/home/_js.blade.php | 2 - .../components/partials/home/_meta.blade.php | 8 - .../views/livewire/home/faq/index.blade.php | 66 ++---- resources/views/livewire/home/index.blade.php | 101 +++++++++ .../views/livewire/home/outlets.blade.php | 3 + .../livewire/home/partials/benefits.blade.php | 76 ++----- .../home/partials/categories.blade.php | 48 ----- .../livewire/home/partials/partners.blade.php | 57 +---- routes/pages/home.php | 38 +++- 16 files changed, 457 insertions(+), 418 deletions(-) create mode 100644 app/Livewire/Home/Outlet.php delete mode 100644 resources/views/components/partials/home/_css.blade.php delete mode 100644 resources/views/components/partials/home/_js.blade.php delete mode 100644 resources/views/components/partials/home/_meta.blade.php create mode 100644 resources/views/livewire/home/outlets.blade.php diff --git a/app/Livewire/Home/Index.php b/app/Livewire/Home/Index.php index 6534aaf..6dabc84 100644 --- a/app/Livewire/Home/Index.php +++ b/app/Livewire/Home/Index.php @@ -27,7 +27,7 @@ public function mount() { $this->brands = Brand::orderBy('sort_order') ->get() - ->map(fn(Brand $brand) => [ + ->map(fn (Brand $brand) => [ 'name' => $brand->name, 'image' => $brand->getFirstMediaUrl('image') ? Storage::url($brand->getFirstMediaUrl('image')) : asset('assets/images/logo.png'), ]) @@ -35,7 +35,7 @@ public function mount() $this->perfumeFeatures = PerfumeFeature::orderBy('sort_order') ->get() - ->map(fn(PerfumeFeature $perfumeFeature) => [ + ->map(fn (PerfumeFeature $perfumeFeature) => [ 'name' => $perfumeFeature->name, 'description' => $perfumeFeature->description, ]) @@ -43,7 +43,7 @@ public function mount() $this->faqs = Faq::orderBy('sort_order') ->get() - ->map(fn(Faq $faq) => [ + ->map(fn (Faq $faq) => [ 'question' => $faq->question, 'answer' => $faq->answer, ]) @@ -51,7 +51,7 @@ public function mount() $this->whyChooseUs = ChooseUs::orderBy('sort_order') ->get() - ->map(fn(ChooseUs $chooseUs) => [ + ->map(fn (ChooseUs $chooseUs) => [ 'name' => $chooseUs->name, 'description' => $chooseUs->description, ]) @@ -64,7 +64,7 @@ public function render() 'pageTitle' => 'Beranda', ]); } - + public function goToProduct() { return redirect('/product'); diff --git a/app/Livewire/Home/Outlet.php b/app/Livewire/Home/Outlet.php new file mode 100644 index 0000000..2ce56cc --- /dev/null +++ b/app/Livewire/Home/Outlet.php @@ -0,0 +1,17 @@ + 'Outlet', +])] +class Outlet extends Component +{ + public function render() + { + return view('livewire.home.outlets'); + } +} diff --git a/app/Livewire/Home/Product/Index.php b/app/Livewire/Home/Product/Index.php index ceb685a..c0713a1 100644 --- a/app/Livewire/Home/Product/Index.php +++ b/app/Livewire/Home/Product/Index.php @@ -10,7 +10,6 @@ ])] class Index extends Component { - public function render() { return view('livewire.home.product.index'); diff --git a/app/Providers/ViewServiceProvider.php b/app/Providers/ViewServiceProvider.php index 9b1a7df..8a84d39 100644 --- a/app/Providers/ViewServiceProvider.php +++ b/app/Providers/ViewServiceProvider.php @@ -262,7 +262,65 @@ public function boot(): void ], ]; - $view->with('sidebar', $sidebar); + $header = [ + [ + 'title' => 'Beranda', + 'type' => 'link', + 'route' => 'homepage', + 'match' => 'homepage', + ], + [ + 'title' => 'Outlet', + 'type' => 'link', + 'route' => 'outlet', + 'match' => 'outlet', + ], + [ + 'title' => 'Produk', + 'type' => 'dropdown', + 'action' => 'goToProduct', + 'items' => [ + [ + 'title' => 'Parfum', + 'route' => 'product.perfume.index', + 'match' => 'product.perfume.*', + ], + [ + 'title' => 'Botol', + 'route' => 'product.bottle.index', + 'match' => 'product.bottle.*', + ], + [ + 'title' => 'Arabian', + 'route' => 'product.arabian.index', + 'match' => 'product.arabian.*', + ], + ], + ], + [ + 'title' => 'Voucher', + 'type' => 'link', + 'route' => 'voucher.index', + 'match' => 'voucher.*', + ], + [ + 'title' => 'Artikel', + 'type' => 'link', + 'route' => 'article.index', + 'match' => 'article.*', + ], + [ + 'title' => 'FAQ', + 'type' => 'link', + 'route' => 'faq', + 'match' => 'faq', + ], + ]; + + $view->with([ + 'sidebar' => $sidebar, + 'header' => $header, + ]); }); } } diff --git a/resources/views/components/layouts/home.blade.php b/resources/views/components/layouts/home.blade.php index 993be2b..a64934a 100644 --- a/resources/views/components/layouts/home.blade.php +++ b/resources/views/components/layouts/home.blade.php @@ -1,20 +1,175 @@ - + - - @include('components.partials.home._meta') - @include('components.partials.home._css') - + + + + {{ $title }} | {{ config('app.name') }} + @vite(['resources/css/app.css', 'resources/js/app.js']) + @fluxAppearance + + + + - + + @include('components.partials.home._header') - @include("components.partials.home._header") - - {{ $slot }} - - @include("components.partials.home._footer") - - @include('components.partials.home._js') - + @persist('toast') + + @endpersist + + {{ $slot }} + @fluxScripts + + + + diff --git a/resources/views/components/partials/home/_css.blade.php b/resources/views/components/partials/home/_css.blade.php deleted file mode 100644 index bbc4350..0000000 --- a/resources/views/components/partials/home/_css.blade.php +++ /dev/null @@ -1,6 +0,0 @@ -{{-- - - - - --}} -@vite(['resources/css/app.css', 'resources/js/app.js']) \ No newline at end of file diff --git a/resources/views/components/partials/home/_header.blade.php b/resources/views/components/partials/home/_header.blade.php index de28c05..7fd754b 100644 --- a/resources/views/components/partials/home/_header.blade.php +++ b/resources/views/components/partials/home/_header.blade.php @@ -26,27 +26,38 @@ class="w-10 h-8 lg:w-16 lg:h-12 transition-all duration-500">
@@ -110,151 +121,3 @@ class="mt-8 px-8 py-3 bg-white text-black font-bold rounded-full hover:bg-gray-1 - - diff --git a/resources/views/components/partials/home/_js.blade.php b/resources/views/components/partials/home/_js.blade.php deleted file mode 100644 index c2b9f3e..0000000 --- a/resources/views/components/partials/home/_js.blade.php +++ /dev/null @@ -1,2 +0,0 @@ -{{-- - --}} diff --git a/resources/views/components/partials/home/_meta.blade.php b/resources/views/components/partials/home/_meta.blade.php deleted file mode 100644 index 72879d0..0000000 --- a/resources/views/components/partials/home/_meta.blade.php +++ /dev/null @@ -1,8 +0,0 @@ - - - - - -{{ $title }} - {{ config('app.name') }} diff --git a/resources/views/livewire/home/faq/index.blade.php b/resources/views/livewire/home/faq/index.blade.php index 6570855..9fa2cb9 100644 --- a/resources/views/livewire/home/faq/index.blade.php +++ b/resources/views/livewire/home/faq/index.blade.php @@ -15,32 +15,39 @@ ['id' => 4, 'q' => 'Bagaimana kebijakan pengembalian barang?', 'a' => 'Pengembalian dalam 30 hari dengan syarat barang belum digunakan, segel utuh, dan menyertakan video unboxing.'], ['id' => 5, 'q' => 'Metode pembayaran apa saja yang tersedia?', 'a' => 'Kami menerima Transfer bank (BCA, Mandiri), Kartu Kredit, E-wallet (GoPay, OVO), dan cicilan 0%.'], ['id' => 6, 'q' => 'Bagaimana cara menggunakan voucher?', 'a' => 'Masukkan kode voucher pada halaman checkout di kolom "Kode Promo", diskon akan otomatis terpotong.'], - ] as $faq) -
$faq) +
- -
@endforeach +
@@ -53,38 +60,3 @@ class="bg-home-foreground text-white font-bold px-8 py-3 rounded-lg hover:opacit
- - diff --git a/resources/views/livewire/home/index.blade.php b/resources/views/livewire/home/index.blade.php index ab0d2a2..4419ecf 100644 --- a/resources/views/livewire/home/index.blade.php +++ b/resources/views/livewire/home/index.blade.php @@ -6,3 +6,104 @@ @include('livewire.home.partials.benefits') @include('livewire.home.partials.cta') + +@assets + +@endassets + +@script + +@endscript diff --git a/resources/views/livewire/home/outlets.blade.php b/resources/views/livewire/home/outlets.blade.php new file mode 100644 index 0000000..81108e5 --- /dev/null +++ b/resources/views/livewire/home/outlets.blade.php @@ -0,0 +1,3 @@ +
+ Outlet +
diff --git a/resources/views/livewire/home/partials/benefits.blade.php b/resources/views/livewire/home/partials/benefits.blade.php index b5aef4b..29ad950 100644 --- a/resources/views/livewire/home/partials/benefits.blade.php +++ b/resources/views/livewire/home/partials/benefits.blade.php @@ -23,74 +23,42 @@ ]; @endphp -
-
-
-
- -
+
+
Parfum Premium + class="w-full h-[500px] object-cover rounded-2xl shadow">
- -
-

- Keunggulan Produk Kami. -

+
+

Keunggulan Produk Kami.

Setiap parfum dibuat dengan standar tinggi agar kamu mendapatkan kualitas terbaik. - Dan kalau kamu ingin pengalaman yang lebih eksklusif, ada paket membership yang bikin kamu jauh lebih - hemat dan leluasa mencoba banyak aroma.

- @foreach ($accordions as $acc) -
- -
-
{{ $acc['content'] }}
+
+
+ {{ $acc['content'] }} +
@endforeach
- - diff --git a/resources/views/livewire/home/partials/categories.blade.php b/resources/views/livewire/home/partials/categories.blade.php index dc78493..12a9f10 100644 --- a/resources/views/livewire/home/partials/categories.blade.php +++ b/resources/views/livewire/home/partials/categories.blade.php @@ -95,51 +95,3 @@ class="w-[3px] h-10 rounded-full pagination-link transition duration-300 {{ $i =
- - - - diff --git a/resources/views/livewire/home/partials/partners.blade.php b/resources/views/livewire/home/partials/partners.blade.php index 99bceef..8a02c3c 100644 --- a/resources/views/livewire/home/partials/partners.blade.php +++ b/resources/views/livewire/home/partials/partners.blade.php @@ -1,6 +1,5 @@ -
+
- Next.js Laravel class="w-32 h-32 object-contain rounded-xl flex-shrink-0"> Tailwind CSS -
- - - - diff --git a/routes/pages/home.php b/routes/pages/home.php index a8fe961..8839d22 100644 --- a/routes/pages/home.php +++ b/routes/pages/home.php @@ -1,15 +1,37 @@ name('homepage'); -Route::get('/product', ProductComponent::class)->name('product'); -Route::get('/voucher', VoucherComponent::class)->name('voucher'); -Route::get('/article', ArticleComponent::class)->name('article'); + +Route::get('/outlets', OutletComponent::class)->name('outlet'); + +Route::prefix('products') + ->name('product.') + ->group(function () { + Route::prefix('perfumes') + ->name('perfume.') + ->group(function () { + Route::get('/', ProductComponent::class)->name('index'); + }); + }); + +Route::prefix('vouchers') + ->name('voucher.') + ->group(function () { + Route::get('/', VoucherIndex::class)->name('index'); + }); + +Route::prefix('articles') + ->name('article.') + ->group(function () { + Route::get('/', ArticleIndex::class)->name('index'); + }); + Route::get('/faq', FaqComponent::class)->name('faq'); -// Route::get('/', HomeComponent::class)->name('produk');