click to copy Ref URL // Badge Color on Profile

This commit is contained in:
1Day 2022-06-08 11:01:28 +02:00
parent 2bc5e91c25
commit 0071c2218b
2 changed files with 46 additions and 4 deletions

View file

@ -16,11 +16,26 @@ class ProfileController extends Controller
/** Display a listing of the resource. */ /** Display a listing of the resource. */
public function index() public function index()
{ {
switch (Auth::user()->role) {
case 'admin':
$badgeColor = 'badge-danger';
break;
case 'mod':
$badgeColor = 'badge-info';
break;
case 'client':
$badgeColor = 'badge-success';
break;
default:
$badgeColor = 'badge-secondary';
break;
}
return view('profile.index')->with([ return view('profile.index')->with([
'user' => Auth::user(), 'user' => Auth::user(),
'credits_reward_after_verify_discord' => config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD'), 'credits_reward_after_verify_discord' => config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD'),
'force_email_verification' => config('SETTINGS::USER:FORCE_EMAIL_VERIFICATION'), 'force_email_verification' => config('SETTINGS::USER:FORCE_EMAIL_VERIFICATION'),
'force_discord_verification' => config('SETTINGS::USER:FORCE_DISCORD_VERIFICATION'), 'force_discord_verification' => config('SETTINGS::USER:FORCE_DISCORD_VERIFICATION'),
'badgeColor' => $badgeColor,
]); ]);
} }

View file

@ -105,7 +105,10 @@
<div class="mt-1"> <div class="mt-1">
<span class="badge badge-success"><i <span class="badge badge-success"><i
class="fa fa-user-check mr-2"></i> class="fa fa-user-check mr-2"></i>
{{_("Referral URL")}} : {{route("register")}}?ref={{$user->referral_code}}</span> {{_("Referral URL")}} :
<span onclick="onClickCopy()" id="RefLink" style="cursor: pointer;">
{{route("register")}}?ref={{$user->referral_code}}</span>
</span>
@else @else
<span class="badge badge-warning"><i <span class="badge badge-warning"><i
class="fa fa-user-check mr-2"></i> class="fa fa-user-check mr-2"></i>
@ -115,9 +118,8 @@
@endif @endif
</div> </div>
<div class="text-center text-sm-right"><span <div class="text-center text-sm-right"><span
class="badge badge-secondary">{{ $user->role }}</span> class="badge {{$badgeColor}}">{{ $user->role }}</span>
<div class="text-muted"> <div class="text-muted">
<small>{{ $user->created_at->isoFormat('LL') }}</small> <small>{{ $user->created_at->isoFormat('LL') }}</small>
</div> </div>
@ -304,5 +306,30 @@
</div> </div>
</section> </section>
<!-- END CONTENT --> <!-- END CONTENT -->
<script>
function onClickCopy() {
let textToCopy = document.getElementById('RefLink').innerText;
if(navigator.clipboard) {
navigator.clipboard.writeText(textToCopy).then(() => {
Swal.fire({
icon: 'success',
title: '{{ __("URL copied to clipboard")}}',
position: 'top-middle',
showConfirmButton: false,
background: '#343a40',
toast: false,
timer: 1000,
timerProgressBar: true,
didOpen: (toast) => {
toast.addEventListener('mouseenter', Swal.stopTimer)
toast.addEventListener('mouseleave', Swal.resumeTimer)
}
})
})
} else {
console.log('Browser Not compatible')
}
}
</script>
@endsection @endsection