Refactor home navigation and fix dashboard calculations

- Replace interactive buttons with anchor tags in Jumbotron and Category sections to improve navigation and SEO.
- Fix SQL calculation for gross profit in OrdersTable to ensure correct aggregation.
- Remove unused `selectedOutletIds` property from Studio Dashboard Analysis and Overview components.
- Adjust padding in the right Jumbotron section for better responsiveness.
This commit is contained in:
Yoga Pangestu 2026-01-15 22:23:13 +07:00
parent bdd793343f
commit 4ec293449c
7 changed files with 55 additions and 27 deletions

View File

@ -3,7 +3,6 @@
namespace App\Livewire\Auth; namespace App\Livewire\Auth;
use App\Traits\Components\WithToast; use App\Traits\Components\WithToast;
use Illuminate\Support\Facades\Auth;
use Illuminate\View\View; use Illuminate\View\View;
use Livewire\Attributes\Layout; use Livewire\Attributes\Layout;
use Livewire\Component; use Livewire\Component;
@ -15,18 +14,29 @@ class VerifyEmail extends Component
{ {
use WithToast; use WithToast;
public function mount(): void
{
$user = auth()->user();
if ($user?->hasVerifiedEmail()) {
$this->redirectIntended(route('member.overview'), navigate: true);
}
}
/** /**
* Send email verification notification to the user. * Send email verification notification to the user.
*/ */
public function resend(): void public function resend(): void
{ {
if (Auth::user()->hasVerifiedEmail()) { $user = auth()->user();
if ($user?->hasVerifiedEmail()) {
$this->redirectIntended(route('member.overview'), navigate: true); $this->redirectIntended(route('member.overview'), navigate: true);
return; return;
} }
Auth::user()->sendEmailVerificationNotification(); $user?->sendEmailVerificationNotification();
$this->toast('Tautan verifikasi baru telah dikirim ke alamat email Anda.'); $this->toast('Tautan verifikasi baru telah dikirim ke alamat email Anda.');
} }
@ -36,7 +46,7 @@ public function resend(): void
*/ */
public function logout(): void public function logout(): void
{ {
Auth::logout(); auth()->logout();
$this->redirect(route('login'), navigate: true); $this->redirect(route('login'), navigate: true);
} }

View File

@ -21,9 +21,16 @@ class OrdersTable extends DataTableComponent
public function columns(): array public function columns(): array
{ {
return [ return [
Column::make('Pegawai', 'user.employee.full_name')->searchable(), Column::make('Outlet', 'outlet.name')->searchable(),
Column::make('Voucher', 'voucher.name')->searchable(), Column::make('Pegawai', 'user.employee.full_name')
->searchable(function (Builder $query, $searchTerm) {
$query->orWhereHas('user', function (Builder $query) use ($searchTerm) {
$query->whereHas('employee', function (Builder $query) use ($searchTerm) {
$query->where('full_name', 'like', "%{$searchTerm}%");
});
});
}),
Column::make('Nomor Invoice') Column::make('Nomor Invoice')
->label(function ($row) { ->label(function ($row) {
@ -35,7 +42,7 @@ public function columns(): array
HTML; HTML;
}) })
->searchable(function ($query, $searchTerm) { ->searchable(function ($query, $searchTerm) {
$query->where('invoice_number', 'like', "%{$searchTerm}%") $query->orWhere('invoice_number', 'like', "%{$searchTerm}%")
->orWhereHas('customer', function (Builder $query) use ($searchTerm) { ->orWhereHas('customer', function (Builder $query) use ($searchTerm) {
$query->where('name', 'like', "%{$searchTerm}%"); $query->where('name', 'like', "%{$searchTerm}%");
}); });
@ -43,12 +50,13 @@ public function columns(): array
->html(), ->html(),
Column::make('Tanggal', 'ordered_at') Column::make('Tanggal', 'ordered_at')
->format(fn ($value) => formatDateLocalized($value)) ->format(fn ($value) => formatDateTimeLocalized($value))
->searchable(), ->searchable(),
Column::make('HPP', 'cogs') Column::make('HPP', 'cogs')
->format(fn ($value) => formatCurrencyNumber($value, 'Rp')) ->format(fn ($value) => formatCurrencyNumber($value, 'Rp'))
->searchable(), ->searchable()
->hideIf(! auth()->user()->hasRole(['Developer', 'Owner'])),
ArrayColumn::make('Item') ArrayColumn::make('Item')
->data( ->data(
@ -70,7 +78,16 @@ public function columns(): array
<div class='text-gray-400 text-[12px]'>{$value['total_price']}</div> <div class='text-gray-400 text-[12px]'>{$value['total_price']}</div>
</div> </div>
") ")
->flexCol(['class' => 'flex-col gap-3']), ->flexCol(['class' => 'flex-col gap-3'])
->searchable(function ($query, $searchTerm) {
$query->orWhereHas('items', function (Builder $query) use ($searchTerm) {
$query->whereHas('orderable', function (Builder $query) use ($searchTerm) {
$query->where('name', 'like', "%{$searchTerm}%");
});
});
}),
Column::make('Voucher', 'voucher.name')->searchable(),
Column::make('Ringkasan') Column::make('Ringkasan')
->label(function ($value) { ->label(function ($value) {
@ -148,6 +165,7 @@ public function builder(): Builder
return Order::select( return Order::select(
'orders.id', 'orders.id',
'orders.user_id', 'orders.user_id',
'orders.outlet_id',
'invoice_number', 'invoice_number',
'customer_id', 'customer_id',
'orders.ordered_at', 'orders.ordered_at',
@ -161,7 +179,7 @@ public function builder(): Builder
'orders.voucher_id', 'orders.voucher_id',
'orders.created_at' 'orders.created_at'
) )
->with(['user', 'user.employee', 'customer', 'voucher']) ->with(['outlet', 'user', 'user.employee', 'customer', 'voucher'])
->whereHas( ->whereHas(
'outlet', 'outlet',
fn ($q) => $q->whereIn('outlets.id', auth()->user()->outlets()->pluck('outlets.id')) fn ($q) => $q->whereIn('outlets.id', auth()->user()->outlets()->pluck('outlets.id'))

View File

@ -84,8 +84,6 @@ class Analysis extends Component
public function mount(): void public function mount(): void
{ {
$this->outlets = auth()->user()->outlets()->get()->pluck('name', 'id')->toArray(); $this->outlets = auth()->user()->outlets()->get()->pluck('name', 'id')->toArray();
$this->selectedOutletIds = auth()->user()->outlets()->pluck('outlets.id')->toArray();
} }
public function render(): View public function render(): View
@ -389,7 +387,7 @@ public function render(): View
$ordersTrend = Order::query() $ordersTrend = Order::query()
->when(! empty($outletIds), fn ($q) => $q->whereIn('outlet_id', $outletIds)) ->when(! empty($outletIds), fn ($q) => $q->whereIn('outlet_id', $outletIds))
->where('created_at', '>=', now()->subDays(30)->startOfDay()) ->where('created_at', '>=', now()->subDays(30)->startOfDay())
->select(DB::raw('DATE(created_at) as date'), DB::raw('SUM(total) as revenue'), DB::raw('SUM(total - cogs - discount - COALESCE(voucher_discount,0)) as gross_profit'), DB::raw('count(*) as count')) ->select(DB::raw('DATE(created_at) as date'), DB::raw('SUM(total) as revenue'), DB::raw('SUM(total) - SUM(cogs) - SUM(discount) - SUM(COALESCE(voucher_discount,0)) as gross_profit'), DB::raw('count(*) as count'))
->groupBy('date') ->groupBy('date')
->get() ->get()
->keyBy('date'); ->keyBy('date');

View File

@ -45,8 +45,6 @@ class Overview extends Component
public function mount(): void public function mount(): void
{ {
$this->outlets = auth()->user()->outlets()->get()->pluck('name', 'id')->toArray(); $this->outlets = auth()->user()->outlets()->get()->pluck('name', 'id')->toArray();
$this->selectedOutletIds = auth()->user()->outlets()->pluck('outlets.id')->toArray();
} }
public function render(): View public function render(): View

View File

@ -18,13 +18,16 @@
<div class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 gap-6"> <div class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 gap-6">
@foreach ($categories as $category) @foreach ($categories as $category)
<article <article
class="category-item group flex flex-col items-center justify-center py-10 px-4 bg-white rounded-2xl border border-gray-100 hover:border-home-primary hover:shadow-xl hover:shadow-home-primary/5 hover:-translate-y-1 transition-all duration-300 cursor-pointer h-full" class="category-item group flex flex-col items-center justify-center py-10 px-4 bg-white rounded-2xl border border-gray-100 hover:border-home-primary hover:shadow-xl hover:shadow-home-primary/5 hover:-translate-y-1 transition-all duration-300 h-full"
wire:key="category-{{ $category['id'] }}"> wire:key="category-{{ $category['id'] }}">
<div <div
class="w-24 h-24 mb-4 rounded-full bg-gray-50 flex items-center justify-center group-hover:bg-home-primary transition-colors duration-300 overflow-hidden"> class="w-24 h-24 mb-4 rounded-full bg-gray-50 flex items-center justify-center group-hover:bg-home-primary transition-colors duration-300 overflow-hidden">
<img src="{{ $category['image'] }}" alt="{{ $category['name'] }}" <a href="{{ route('product.index', ['categories' => [$category['slug']]]) }}"
class="w-full h-full object-cover transition-transform duration-300 group-hover:scale-110"> wire:navigate>
<img src="{{ $category['image'] }}" alt="{{ $category['name'] }}"
class="w-full h-full object-cover transition-transform duration-300 group-hover:scale-110">
</a>
</div> </div>
<h3 <h3

View File

@ -36,13 +36,13 @@ class="bg-home-primary text-home-background py-3 px-6 rounded-full hover:shadow-
Jelajahi Toko Jelajahi Toko
</a> </a>
<span class="w-8 h-[2px] bg-home-primary/20"></span> <span class="w-8 h-[2px] bg-home-primary/20"></span>
<button <a href="{{ route('product.index') }}" wire:navigate
class="flex items-center justify-center w-12 h-12 border border-home-primary rounded-full hover:bg-home-background transition-colors group bg-transparent"> class="flex items-center justify-center w-12 h-12 border border-home-primary rounded-full hover:bg-home-background transition-colors group bg-transparent">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2"
stroke="currentColor" class="w-5 h-5 text-home-primary"> stroke="currentColor" class="w-5 h-5 text-home-primary">
<path stroke-linecap="round" stroke-linejoin="round" d="m4.5 19.5 15-15m0 0H8.25m11.25 0v11.25" /> <path stroke-linecap="round" stroke-linejoin="round" d="m4.5 19.5 15-15m0 0H8.25m11.25 0v11.25" />
</svg> </svg>
</button> </a>
</div> </div>
</div> </div>
@include('livewire.home.partials.jumbotron.testimonial') @include('livewire.home.partials.jumbotron.testimonial')

View File

@ -1,5 +1,5 @@
<section <section
class="relative w-full lg:w-[65%] min-h-[600px] lg:min-h-screen hidden lg:flex flex-col lg:flex-row justify-end items-end pb-8 pr-0 lg:pr-10 z-10"> class="relative w-full lg:w-[65%] min-h-[600px] lg:min-h-screen hidden lg:flex flex-col lg:flex-row justify-end items-end pb-8 pr-0 lg:px-10 z-10">
<div <div
class="absolute inset-0 bg-[url('https://images.unsplash.com/photo-1591925463023-1ca6b0636780?q=80&w=1632&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D')] bg-cover bg-center bg-no-repeat"> class="absolute inset-0 bg-[url('https://images.unsplash.com/photo-1591925463023-1ca6b0636780?q=80&w=1632&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D')] bg-cover bg-center bg-no-repeat">
@ -22,7 +22,8 @@ class="w-full h-full object-cover group-hover:scale-105 transition-transform dur
<div class="flex-1 ml-4 lg:ml-6 flex flex-col justify-center space-y-2 lg:space-y-3"> <div class="flex-1 ml-4 lg:ml-6 flex flex-col justify-center space-y-2 lg:space-y-3">
<div> <div>
<h3 class="text-base lg:text-xl text-black font-bold line-clamp-1">{{ $perfume['name'] }}</h3> <h3 class="text-base lg:text-xl text-black font-bold line-clamp-1">{{ $perfume['name'] }}
</h3>
<div class="flex items-center gap-2 mt-1"> <div class="flex items-center gap-2 mt-1">
<span class="text-home-primary font-bold text-sm lg:text-lg"> <span class="text-home-primary font-bold text-sm lg:text-lg">
Rp {{ number_format($perfume['sale_price'], 0, ',', '.') }} Rp {{ number_format($perfume['sale_price'], 0, ',', '.') }}
@ -36,18 +37,18 @@ class="w-full h-full object-cover group-hover:scale-105 transition-transform dur
</div> </div>
<div class="flex items-center gap-2 mt-auto"> <div class="flex items-center gap-2 mt-auto">
<button wire:click="goToProduct" <a href="{{ route('product.show', ['slug' => $perfume['slug']]) }}" wire:navigate
class="flex-1 justify-center items-center border border-gray-200 py-2 px-3 bg-home-primary rounded-full text-xs lg:text-sm font-medium hover:bg-home-primary/80 transition-colors text-home-background"> class="flex-1 justify-center items-center border border-gray-200 py-2 px-3 bg-home-primary rounded-full text-xs lg:text-sm font-medium hover:bg-home-primary/80 transition-colors text-home-background">
Belanja Sekarang Belanja Sekarang
</button> </a>
<button wire:click="goToProduct" <a href="{{ route('product.show', ['slug' => $perfume['slug']]) }}" wire:navigate
class="w-8 h-8 lg:w-10 lg:h-10 bg-home-primary flex justify-center items-center rounded-full hover:bg-home-primary/80 transition-colors"> class="w-8 h-8 lg:w-10 lg:h-10 bg-home-primary flex justify-center items-center rounded-full hover:bg-home-primary/80 transition-colors">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
stroke-width="1.5" stroke="currentColor" class="size-4 lg:size-5 text-home-background"> stroke-width="1.5" stroke="currentColor" class="size-4 lg:size-5 text-home-background">
<path stroke-linecap="round" stroke-linejoin="round" <path stroke-linecap="round" stroke-linejoin="round"
d="m4.5 19.5 15-15m0 0H8.25m11.25 0v11.25" /> d="m4.5 19.5 15-15m0 0H8.25m11.25 0v11.25" />
</svg> </svg>
</button> </a>
</div> </div>
</div> </div>
</article> </article>