Skip to content

Commit

Permalink
Redirect with status
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvints committed Mar 23, 2020
1 parent 7f38371 commit 8d3761a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions resources/views/payment.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ class="inline-block w-full px-4 py-3 mb-4 text-white rounded-lg hover:bg-blue-50
</div>
@endif

<a href="{{ $redirect ?? url('/') }}"
<button @click="goBack" ref="goBackButton" data-redirect="{{ $redirect ?? url('/') }}"
class="inline-block w-full px-4 py-3 bg-gray-200 hover:bg-gray-300 text-center text-gray-700 rounded-lg">
{{ __('Go back') }}
</a>
</button>
</div>

<p class="text-center text-gray-500 text-sm">
Expand Down Expand Up @@ -149,6 +149,18 @@ class="inline-block w-full px-4 py-3 bg-gray-200 hover:bg-gray-300 text-center t
}
});
},
goBack: function () {
var self = this;
var button = this.$refs.goBackButton;
var redirect = new URL(button.dataset.redirect);
if (self.successMessage || self.errorMessage) {
redirect.searchParams.append('message', self.successMessage ? self.successMessage : self.errorMessage);
redirect.searchParams.append('success', !! self.successMessage);
}
window.location.href = redirect;
},
},
})
</script>
Expand Down

0 comments on commit 8d3761a

Please sign in to comment.