mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-21 15:54:22 +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])
|
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)
|
render on_payment_success(nil, nil, cart)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ class API::PayzenController < API::PaymentsController
|
|||||||
|
|
||||||
def check_cart
|
def check_cart
|
||||||
cart = shopping_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
|
render json: { cart: 'ok' }, status: :ok
|
||||||
end
|
end
|
||||||
|
@ -19,7 +19,7 @@ class API::StripeController < API::PaymentsController
|
|||||||
res = nil # json of the API answer
|
res = nil # json of the API answer
|
||||||
|
|
||||||
cart = shopping_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?
|
||||||
|
|
||||||
begin
|
begin
|
||||||
amount = debit_amount(cart) # will contains the amount and the details of each invoice lines
|
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
|
def setup_subscription
|
||||||
cart = shopping_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?
|
||||||
|
|
||||||
service = Stripe::Service.new
|
service = Stripe::Service.new
|
||||||
method = service.attach_method_as_default(
|
method = service.attach_method_as_default(
|
||||||
|
@ -69,7 +69,7 @@ export const PlanLimitForm = <TContext extends object> ({ register, control, for
|
|||||||
update(edited.index, { ...limitation, id });
|
update(edited.index, { ...limitation, id });
|
||||||
setEdited(null);
|
setEdited(null);
|
||||||
} else {
|
} else {
|
||||||
append({ ...limitation });
|
append({ ...limitation, id });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ export const PlanLimitForm = <TContext extends object> ({ register, control, for
|
|||||||
remove(index);
|
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
|
// 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
|
// 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 });
|
// 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
|
reservation_deadline = reservation_deadline_minutes.minutes.since
|
||||||
|
|
||||||
unless ReservationLimitService.authorized?(plan, customer, self, all_items)
|
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
|
return false
|
||||||
end
|
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.
|
# 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 an array of errors, if any; false otherwise
|
||||||
|
# @return [Array<String>,FalseClass]
|
||||||
def check_user_validation(items)
|
def check_user_validation(items)
|
||||||
user_validation_required = Setting.get('user_validation_required')
|
user_validation_required = Setting.get('user_validation_required')
|
||||||
user_validation_required_list = Setting.get('user_validation_required_list')
|
user_validation_required_list = Setting.get('user_validation_required_list')
|
||||||
|
@ -6,10 +6,9 @@ class CartService
|
|||||||
@operator = operator
|
@operator = operator
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
|
||||||
# For details about the expected hash format
|
# For details about the expected hash format
|
||||||
# @see app/frontend/src/javascript/models/payment.ts > interface ShoppingCart
|
# @see app/frontend/src/javascript/models/payment.ts > interface ShoppingCart
|
||||||
##
|
# @return [ShoppingCart]
|
||||||
def from_hash(cart_items)
|
def from_hash(cart_items)
|
||||||
cart_items.permit! if cart_items.is_a? ActionController::Parameters
|
cart_items.permit! if cart_items.is_a? ActionController::Parameters
|
||||||
|
|
||||||
|
@ -519,7 +519,7 @@ en:
|
|||||||
availability: "The availaility doesn't exist"
|
availability: "The availaility doesn't exist"
|
||||||
full: "The slot is already fully reserved"
|
full: "The slot is already fully reserved"
|
||||||
deadline: "You can't reserve a slot %{MINUTES} minutes prior to its start"
|
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"
|
restricted: "This availability is restricted for subscribers"
|
||||||
plan: "This subscription plan is disabled"
|
plan: "This subscription plan is disabled"
|
||||||
plan_group: "This subscription plan is reserved for members of group %{GROUP}"
|
plan_group: "This subscription plan is reserved for members of group %{GROUP}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user