feat: Add referral code generation with WhatsApp sharing, remove email verification UI, and introduce tierPoints accessor.
This commit is contained in:
parent
2c564f410e
commit
f107e99d64
@ -22,24 +22,13 @@ class Overview extends Component
|
||||
|
||||
public bool $hasMemberData = false;
|
||||
|
||||
public bool $isVerified = false;
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->hasMemberData = auth()->user()->customer()->exists();
|
||||
|
||||
$this->isVerified = auth()->user()->hasVerifiedEmail();
|
||||
|
||||
$this->form->user_id = request()->routeIs('member.overview') ? auth()->id() : null;
|
||||
}
|
||||
|
||||
public function checkEmailVerification(): void
|
||||
{
|
||||
auth()->user()->refresh();
|
||||
|
||||
$this->isVerified = auth()->user()->hasVerifiedEmail();
|
||||
}
|
||||
|
||||
public function save(): void
|
||||
{
|
||||
DB::transaction(function () {
|
||||
@ -60,6 +49,20 @@ public function save(): void
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.member.overview');
|
||||
$user = auth()->user();
|
||||
$referralCode = $user->referralCode;
|
||||
|
||||
if (! $referralCode && $this->hasMemberData) {
|
||||
$referralCode = $user->referralCode()->create([
|
||||
'code' => strtoupper(str()->random(8)),
|
||||
]);
|
||||
}
|
||||
|
||||
$message = 'Halo! Ayo bergabung di Yadi Parfum dan dapatkan keuntungan eksklusif. Gunakan kode referral saya: '.($referralCode?->code ?? '').' saat mendaftar! '.url('/auth/register');
|
||||
$whatsappUrl = 'https://wa.me/?text='.urlencode($message);
|
||||
|
||||
return view('livewire.member.overview', [
|
||||
'whatsappUrl' => $whatsappUrl,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,8 +17,8 @@
|
||||
</flux:callout.text>
|
||||
|
||||
<x-slot name="actions">
|
||||
<flux:button>Undang teman</flux:button>
|
||||
<flux:button>Ambil Hadiah</flux:button>
|
||||
<flux:button href="{{ $whatsappUrl }}" target="_blank">Undang teman</flux:button>
|
||||
<flux:button href="{{ route('member.redeem_point') }}">Ambil Hadiah</flux:button>
|
||||
</x-slot>
|
||||
</flux:callout>
|
||||
|
||||
@ -37,28 +37,6 @@
|
||||
</x-slot>
|
||||
</flux:callout>
|
||||
|
||||
@if (!$isVerified)
|
||||
<div wire:poll.3s="checkEmailVerification">
|
||||
<flux:callout icon="envelope" color="rose" inline>
|
||||
<flux:callout.heading> Silakan verifikasi email Anda agar bisa menikmati seluruh fitur kami.
|
||||
</flux:callout.heading>
|
||||
|
||||
<x-slot name="actions">
|
||||
<flux:button x-data
|
||||
x-on:click.prevent="
|
||||
if (/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)) {
|
||||
window.location.href = 'intent://mail.google.com/#Intent;scheme=https;package=com.google.android.gm;end';
|
||||
} else {
|
||||
window.open('https://mail.google.com', '_blank');
|
||||
}
|
||||
">
|
||||
Verifikasi →
|
||||
</flux:button>
|
||||
</x-slot>
|
||||
</flux:callout>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<flux:callout icon="star" color="purple" inline>
|
||||
<flux:callout.heading> Temukan keuntungan eksklusif dan manfaat spesial sebagai member.
|
||||
</flux:callout.heading>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user