Skip to content

Commit 980a720

Browse files
committed
Fix "Uncaught TypeError: Cannot read properties of null (reading 'addEventListener')"
1 parent 9806afe commit 980a720

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

resources/views/linkstack/modules/admin-bar.blade.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,18 +131,20 @@ function submitForm() {
131131
document.getElementById('logoutForm').submit();
132132
}
133133
</script>
134-
<script>
135-
function showConfirmation() {
136-
var isConfirmed = confirm("{{__('messages.confirm.delete.user')}}");
137-
if (isConfirmed) {
138-
window.location.href = document.getElementById("confirmationLink").getAttribute("href");
139-
}
134+
@if(auth()->user()->role != 'admin')
135+
<script>
136+
function showConfirmation() {
137+
var isConfirmed = confirm("{{__('messages.confirm.delete.user')}}");
138+
if (isConfirmed) {
139+
window.location.href = document.getElementById("confirmationLink").getAttribute("href");
140140
}
141-
document.getElementById("confirmationLink").addEventListener("click", function(event) {
142-
event.preventDefault();
143-
showConfirmation();
144-
});
145-
</script>
141+
}
142+
document.getElementById("confirmationLink").addEventListener("click", function(event) {
143+
event.preventDefault();
144+
showConfirmation();
145+
});
146+
</script>
147+
@endif
146148
<form id="logoutForm" action="{{ route('logout') }}" method="post">
147149
<input type="hidden" name="_token" value="{{ csrf_token() }}">
148150
</form>

0 commit comments

Comments
 (0)