JSFiddle - React, Tailwind, and code Playground
by alexrom7
JavaScript
function bookMember( payLater ){
$scope.paymentLoading = true;
var paymentMethod = (typeof $scope.paymentMethod != 'undefined') ? $scope.paymentMethod.value : null;
var postData = {
"branch_id" : $scope.branchId,
"user_id" : $scope.selectedMember._id,
"event_id" : $scope.eventEntity._id,
"pay_gym" : payLater,
"is_free" : isFree(),
"payment_method": paymentMethod,
"price": ($scope.charge.numPay > 0) ? ($scope.charge.price / $scope.charge.numPay) : 0,
"guest_bookings": $scope.booking.guestBookings
};
var url = _FULL_BASE_URL+'bookings/add_web_admin';
$http.post( url, postData).
success(function(data, status, headers, config) {
if ( data.success ){
toastr.success( data.message );
location.reload();
} else {
toastr.error( data.message );
}
$scope.paymentLoading = false;
}).
error(function(data, status, headers, config) {
$scope.paymentLoading = false
toastr.error( "Ocurred an error while booking the member.");
});
}