1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-20 14:54:15 +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)
cart = cs.from_hash(params)
@amount = cart.total
# TODO, remove this when the cart is refactored
cart.valid?
@errors = cart.errors
end
private

View File

@ -687,6 +687,13 @@ Application.Directives.directive('cart', ['$rootScope', '$uibModal', 'dialogs',
$scope.amountTotal = res.price;
$scope.schedule.payment_schedule = res.schedule;
$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);
});
} else {

View File

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