mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-20 14:54:15 +01:00
(quality) improved error message
This commit is contained in:
parent
8504864c20
commit
0ac99e3b6b
@ -8,6 +8,8 @@ class API::LocalPaymentController < API::PaymentsController
|
||||
|
||||
authorize LocalPaymentContext.new(cart, price[:amount])
|
||||
|
||||
render json: cart.errors, status: :unprocessable_entity and return unless cart.valid?
|
||||
|
||||
render on_payment_success(nil, nil, cart)
|
||||
end
|
||||
|
||||
|
@ -55,7 +55,7 @@ class API::PayzenController < API::PaymentsController
|
||||
|
||||
def check_cart
|
||||
cart = shopping_cart
|
||||
render json: { error: cart.errors }, status: :unprocessable_entity and return unless cart.valid?
|
||||
render json: cart.errors, status: :unprocessable_entity and return unless cart.valid?
|
||||
|
||||
render json: { cart: 'ok' }, status: :ok
|
||||
end
|
||||
|
@ -19,7 +19,7 @@ class API::StripeController < API::PaymentsController
|
||||
res = nil # json of the API answer
|
||||
|
||||
cart = shopping_cart
|
||||
render json: { error: cart.errors }, status: :unprocessable_entity and return unless cart.valid?
|
||||
render json: cart.errors, status: :unprocessable_entity and return unless cart.valid?
|
||||
|
||||
begin
|
||||
amount = debit_amount(cart) # will contains the amount and the details of each invoice lines
|
||||
@ -73,7 +73,7 @@ class API::StripeController < API::PaymentsController
|
||||
|
||||
def setup_subscription
|
||||
cart = shopping_cart
|
||||
render json: { error: cart.errors }, status: :unprocessable_entity and return unless cart.valid?
|
||||
render json: cart.errors, status: :unprocessable_entity and return unless cart.valid?
|
||||
|
||||
service = Stripe::Service.new
|
||||
method = service.attach_method_as_default(
|
||||
|
@ -69,7 +69,7 @@ export const PlanLimitForm = <TContext extends object> ({ register, control, for
|
||||
update(edited.index, { ...limitation, id });
|
||||
setEdited(null);
|
||||
} else {
|
||||
append({ ...limitation });
|
||||
append({ ...limitation, id });
|
||||
}
|
||||
};
|
||||
|
||||
@ -97,7 +97,7 @@ export const PlanLimitForm = <TContext extends object> ({ register, control, for
|
||||
remove(index);
|
||||
// This have a little drowback: remove(index) will set the form as "dirty", and trigger the "unsaved form alert", even if clicking on save or not
|
||||
// won't change anything to the deleted item. To improve this we could do the following: do not destroy the limitation through the API and instead
|
||||
// set {_destroy: true} and destroy the limitation when saving the form but we need some UI for items about to be deleted
|
||||
// set {_destroy: true} and destroy the limitation when saving the form, but we need some UI for items about to be deleted
|
||||
// update(index, { ...getValues(`plan_limitations_attributes.${index}`), _destroy: true });
|
||||
};
|
||||
};
|
||||
|
@ -67,7 +67,10 @@ class CartItem::Reservation < CartItem::BaseItem
|
||||
reservation_deadline = reservation_deadline_minutes.minutes.since
|
||||
|
||||
unless ReservationLimitService.authorized?(plan, customer, self, all_items)
|
||||
errors.add(:reservation, I18n.t('cart_item_validation.limit_reached', { HOURS: ReservationLimitService.limit(plan, reservable) }))
|
||||
errors.add(:reservation, I18n.t('cart_item_validation.limit_reached', {
|
||||
HOURS: ReservationLimitService.limit(plan, reservable),
|
||||
RESERVABLE: reservable.name
|
||||
}))
|
||||
return false
|
||||
end
|
||||
|
||||
|
@ -160,6 +160,7 @@ class ShoppingCart
|
||||
|
||||
# Check if the current cart needs the user to have been validated, and if the condition is satisfied.
|
||||
# Return an array of errors, if any; false otherwise
|
||||
# @return [Array<String>,FalseClass]
|
||||
def check_user_validation(items)
|
||||
user_validation_required = Setting.get('user_validation_required')
|
||||
user_validation_required_list = Setting.get('user_validation_required_list')
|
||||
|
@ -6,10 +6,9 @@ class CartService
|
||||
@operator = operator
|
||||
end
|
||||
|
||||
##
|
||||
# For details about the expected hash format
|
||||
# @see app/frontend/src/javascript/models/payment.ts > interface ShoppingCart
|
||||
##
|
||||
# @return [ShoppingCart]
|
||||
def from_hash(cart_items)
|
||||
cart_items.permit! if cart_items.is_a? ActionController::Parameters
|
||||
|
||||
|
@ -519,7 +519,7 @@ en:
|
||||
availability: "The availaility doesn't exist"
|
||||
full: "The slot is already fully reserved"
|
||||
deadline: "You can't reserve a slot %{MINUTES} minutes prior to its start"
|
||||
limit_reached: "You have reached the booking limit of %{HOURS}H per day for your current subscription"
|
||||
limit_reached: "You have reached the booking limit of %{HOURS}H per day for the %{RESERVABLE}, for your current subscription"
|
||||
restricted: "This availability is restricted for subscribers"
|
||||
plan: "This subscription plan is disabled"
|
||||
plan_group: "This subscription plan is reserved for members of group %{GROUP}"
|
||||
|
Loading…
x
Reference in New Issue
Block a user