1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-21 15:54:22 +01:00

(feat) display validation before payment

This commit is contained in:
Sylvain 2023-03-16 12:25:27 +01:00
parent 328529809d
commit 940ee06e58
3 changed files with 11 additions and 0 deletions

View File

@ -46,6 +46,9 @@ class API::PricesController < API::ApiController
cs = CartService.new(current_user) cs = CartService.new(current_user)
cart = cs.from_hash(params) cart = cs.from_hash(params)
@amount = cart.total @amount = cart.total
# TODO, remove this when the cart is refactored
cart.valid?
@errors = cart.errors
end end
private private

View File

@ -687,6 +687,13 @@ Application.Directives.directive('cart', ['$rootScope', '$uibModal', 'dialogs',
$scope.amountTotal = res.price; $scope.amountTotal = res.price;
$scope.schedule.payment_schedule = res.schedule; $scope.schedule.payment_schedule = res.schedule;
$scope.totalNoCoupon = res.price_without_coupon; $scope.totalNoCoupon = res.price_without_coupon;
if (res.errors && Object.keys(res.errors).length > 0) {
for (const error in res.errors) {
for (const message of res.errors[error]) {
growl.error(message);
}
}
}
setSlotsDetails(res.details); setSlotsDetails(res.details);
}); });
} else { } else {

View File

@ -21,3 +21,4 @@ if @amount[:schedule]
end end
end end
end end
json.errors @errors