mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-17 06:52:27 +01:00
apply coupon in payment modal + fix update user w/o organization
This commit is contained in:
parent
a679bc1638
commit
b4e28b94f3
@ -635,16 +635,27 @@ Application.Controllers.controller "ReserveMachineController", ["$scope", "$stat
|
||||
|
||||
|
||||
|
||||
##
|
||||
# Format the parameters expected by /api/prices/compute and return the resulting object
|
||||
# @param reservation {Object} as returned by mkReservation()
|
||||
# @param coupon {Object} Coupon as returned from the API
|
||||
# @return {{reservation:Object, coupon_id:number}}
|
||||
##
|
||||
mkComputePriceParams = (reservation, coupon) ->
|
||||
params = {reservation: reservation}
|
||||
if coupon
|
||||
params['coupon_id'] = coupon.id
|
||||
params
|
||||
|
||||
|
||||
|
||||
##
|
||||
# Update the total price of the current selection/reservation
|
||||
##
|
||||
updateCartPrice = ->
|
||||
if Object.keys($scope.ctrl.member).length > 0
|
||||
r = mkReservation($scope.ctrl.member, $scope.eventsReserved, $scope.selectedPlan)
|
||||
params = {reservation: r}
|
||||
if $scope.coupon.applied
|
||||
params['coupon_id'] = $scope.coupon.applied.id
|
||||
Price.compute params, (res) ->
|
||||
Price.compute mkComputePriceParams(r, $scope.coupon.applied), (res) ->
|
||||
$scope.amountTotal = res.price
|
||||
setSlotsDetails(res.details)
|
||||
else
|
||||
@ -759,7 +770,7 @@ Application.Controllers.controller "ReserveMachineController", ["$scope", "$stat
|
||||
reservation: ->
|
||||
reservation
|
||||
price: ->
|
||||
Price.compute({reservation: reservation}).$promise
|
||||
Price.compute(mkComputePriceParams(reservation, $scope.coupon.applied)).$promise
|
||||
wallet: ->
|
||||
Wallet.getWalletByUser({user_id: reservation.user_id}).$promise
|
||||
cgv: ->
|
||||
@ -816,7 +827,7 @@ Application.Controllers.controller "ReserveMachineController", ["$scope", "$stat
|
||||
reservation: ->
|
||||
reservation
|
||||
price: ->
|
||||
Price.compute({reservation: reservation}).$promise
|
||||
Price.compute(mkComputePriceParams(reservation, $scope.coupon.applied)).$promise
|
||||
wallet: ->
|
||||
Wallet.getWalletByUser({user_id: reservation.user_id}).$promise
|
||||
controller: ['$scope', '$uibModalInstance', '$state', 'reservation', 'price', 'Auth', 'Reservation', 'wallet', 'helpers', '$filter', '$locale', ($scope, $uibModalInstance, $state, reservation, price, Auth, Reservation, wallet, helpers, $filter, $locale) ->
|
||||
|
@ -162,7 +162,7 @@
|
||||
<span class="help-block" ng-show="userForm['user[password_confirmation]'].$error.match" translate>{{ 'confirmation_mismatch_with_password' }}</span>
|
||||
</div>
|
||||
|
||||
<div class="form-group" ng-show="user.profile.organization" ng-class="{'has-error': userForm['user[profile_attributes][organization_attributes][name]'].$dirty && userForm['user[profile_attributes][organization_attributes][name]'].$invalid}">
|
||||
<div class="form-group" ng-if="user.profile.organization" ng-class="{'has-error': userForm['user[profile_attributes][organization_attributes][name]'].$dirty && userForm['user[profile_attributes][organization_attributes][name]'].$invalid}">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><i class="fa fa-building-o"></i></span>
|
||||
<input type="hidden"
|
||||
@ -179,7 +179,7 @@
|
||||
<span class="help-block" ng-show="userForm['user[profile_attributes][organization_attributes][name]'].$dirty && userForm['user[profile_attributes][organization_attributes][name]'].$error.required" translate>{{ 'organization_name_is_required' }}</span>
|
||||
</div>
|
||||
|
||||
<div class="form-group" ng-show="user.profile.organization" ng-class="{'has-error': userForm['user[profile_attributes][organization_attributes][address_attributes][address]'].$dirty && userForm['user[profile_attributes][organization_attributes][address_attributes][address]'].$invalid}">
|
||||
<div class="form-group" ng-if="user.profile.organization" ng-class="{'has-error': userForm['user[profile_attributes][organization_attributes][address_attributes][address]'].$dirty && userForm['user[profile_attributes][organization_attributes][address_attributes][address]'].$invalid}">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><i class="fa fa-map-marker"></i></span>
|
||||
<input type="hidden"
|
||||
|
Loading…
x
Reference in New Issue
Block a user