feat(tier): menambahkan counting total hadiah
- updated data tiers saat action reward - menyesuaikan kueri tiers nya
This commit is contained in:
parent
99bb26924b
commit
54a7fcec5a
@ -31,6 +31,12 @@ class Tier extends Component
|
||||
public string $modalTitle = '';
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->loadTiers();
|
||||
}
|
||||
|
||||
#[On('data:tiersUpdated')]
|
||||
public function loadTiers()
|
||||
{
|
||||
$this->tiers = TierModel::with(['memberships.user.customer.orders.items'])
|
||||
->withCount('memberships')
|
||||
@ -82,6 +88,7 @@ public function mount()
|
||||
'min_points' => currency($tier->min_points),
|
||||
'max_points' => currency($tier->max_points),
|
||||
'total_members' => currency($tier->memberships_count),
|
||||
'total_rewards' => $tier->rewards->count(),
|
||||
'top_member' => $topMemberStats,
|
||||
];
|
||||
})
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
namespace App\Livewire\Studio\Loyalty\Tier;
|
||||
|
||||
use App\Livewire\Forms\Studio\Loyalty\Tier\RewardForm;
|
||||
use App\Livewire\Studio\Loyalty\Tier;
|
||||
use App\Models\TierReward;
|
||||
use App\Traits\WithAuthorization;
|
||||
use App\Traits\WithCloseModal;
|
||||
@ -59,6 +60,8 @@ public function create()
|
||||
|
||||
$this->form->store();
|
||||
|
||||
$this->dispatch('data:tiersUpdated')->to(Tier::class);
|
||||
|
||||
$this->toast('Hadiah berhasil ditambahkan.');
|
||||
|
||||
Flux::modals()->close();
|
||||
@ -81,6 +84,8 @@ public function delete(TierReward $reward)
|
||||
|
||||
$this->toast('Hadiah berhasil dihapus.');
|
||||
|
||||
$this->dispatch('data:tiersUpdated')->to(Tier::class);
|
||||
|
||||
Flux::modal('delete')->close();
|
||||
|
||||
$this->rewards = array_values(array_filter($this->rewards, fn ($item) => $item['hash'] !== $reward->hash));
|
||||
|
||||
@ -42,6 +42,11 @@ class="hover:shadow-lg transition-shadow duration-200 bg-white dark:bg-gray-900
|
||||
<span class="font-medium">{{ $tier['total_members'] }}</span>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-between text-sm">
|
||||
<span class="text-gray-500 dark:text-gray-400">Total Hadiah:</span>
|
||||
<span class="font-medium">{{ $tier['total_rewards'] }}</span>
|
||||
</div>
|
||||
|
||||
@if ($tier['top_member'])
|
||||
<div class="text-sm">
|
||||
<span class="text-gray-500 dark:text-gray-400 font-semibold">Member Dengan Poin
|
||||
|
||||
Loading…
Reference in New Issue
Block a user