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

[bug] unable to list user's payment schedules in the dashboard

This commit is contained in:
Sylvain 2021-06-14 14:40:54 +02:00
parent 645efa37f4
commit ec301ba07e
4 changed files with 61 additions and 59 deletions

View File

@ -3,6 +3,7 @@
- Updated user's manual for v5 - Updated user's manual for v5
- Fix a bug: unable to process stripe payments with 3DS authentication - Fix a bug: unable to process stripe payments with 3DS authentication
- Fix a bug: unable to book an event - Fix a bug: unable to book an event
- Fix a bug: unable to list user's payment schedules in the dashboard
## v5.0.2 2021 June 11 ## v5.0.2 2021 June 11

View File

@ -1,4 +1,4 @@
web: bundle exec rails server puma -p $PORT #web: bundle exec rails server puma -p $PORT
worker: bundle exec sidekiq -C ./config/sidekiq.yml worker: bundle exec sidekiq -C ./config/sidekiq.yml
wp-client: bin/webpack-dev-server wp-client: bin/webpack-dev-server
wp-server: SERVER_BUNDLE_ONLY=yes bin/webpack --watch wp-server: SERVER_BUNDLE_ONLY=yes bin/webpack --watch

View File

@ -8,7 +8,7 @@ class API::PaymentSchedulesController < API::ApiController
def index def index
@payment_schedules = PaymentSchedule.where('invoicing_profile_id = ?', current_user.invoicing_profile.id) @payment_schedules = PaymentSchedule.where('invoicing_profile_id = ?', current_user.invoicing_profile.id)
.includes(:invoicing_profile, :payment_schedule_items, :subscription) .includes(:invoicing_profile, :payment_schedule_items, :payment_schedule_objects)
.joins(:invoicing_profile) .joins(:invoicing_profile)
.order('payment_schedules.created_at DESC') .order('payment_schedules.created_at DESC')
.page(params[:page]) .page(params[:page])

View File

@ -12,72 +12,73 @@
*/ */
'use strict'; 'use strict';
Application.Controllers.controller('DashboardController', ['$scope', 'memberPromise', 'trainingsPromise', 'SocialNetworks', function ($scope, memberPromise, trainingsPromise, SocialNetworks) { Application.Controllers.controller('DashboardController', ['$scope', 'memberPromise', 'trainingsPromise', 'SocialNetworks', 'growl',
// Current user's profile function ($scope, memberPromise, trainingsPromise, SocialNetworks, growl) {
$scope.user = memberPromise; // Current user's profile
$scope.user = memberPromise;
// List of social networks associated with this user and toggle 'show all' state // List of social networks associated with this user and toggle 'show all' state
$scope.social = { $scope.social = {
showAllLinks: false, showAllLinks: false,
networks: SocialNetworks networks: SocialNetworks
}; };
/** /**
* Check if the member has used his training credits for the given credit * Check if the member has used his training credits for the given credit
* @param trainingCredits array of credits used by the member * @param trainingCredits array of credits used by the member
* @param trainingId id of the training to find * @param trainingId id of the training to find
*/ */
$scope.hasUsedTrainingCredit = function (trainingCredits, trainingId) { $scope.hasUsedTrainingCredit = function (trainingCredits, trainingId) {
return trainingCredits.find(tc => tc.training_id === trainingId); return trainingCredits.find(tc => tc.training_id === trainingId);
}; };
/** /**
* Return the name associated with the provided training ID * Return the name associated with the provided training ID
* @param trainingId training identifier * @param trainingId training identifier
* @return {string} * @return {string}
*/ */
$scope.getTrainingName = function (trainingId) { $scope.getTrainingName = function (trainingId) {
return trainingsPromise.find(t => t.id === trainingId).name; return trainingsPromise.find(t => t.id === trainingId).name;
}; };
/* PRIVATE SCOPE */ /* PRIVATE SCOPE */
/** /**
* Kind of constructor: these actions will be realized first when the controller is loaded * Kind of constructor: these actions will be realized first when the controller is loaded
*/ */
const initialize = () => $scope.social.networks = filterNetworks(); const initialize = () => $scope.social.networks = filterNetworks();
/** /**
* Filter the social networks or websites that are associated with the profile of the user provided in promise * Filter the social networks or websites that are associated with the profile of the user provided in promise
* and return the filtered networks * and return the filtered networks
* @return {Array} * @return {Array}
*/ */
const filterNetworks = function () { const filterNetworks = function () {
const networks = []; const networks = [];
for (const network of Array.from(SocialNetworks)) { for (const network of Array.from(SocialNetworks)) {
if ($scope.user.profile[network] && ($scope.user.profile[network].length > 0)) { if ($scope.user.profile[network] && ($scope.user.profile[network].length > 0)) {
networks.push(network); networks.push(network);
}
} }
} return networks;
return networks; };
};
/** /**
* Callback used in PaymentScheduleDashboard, in case of error * Callback used in PaymentScheduleDashboard, in case of error
*/ */
$scope.onError = function (message) { $scope.onError = function (message) {
growl.error(message); growl.error(message);
}; };
/** /**
* Callback triggered when the user has successfully updated his card * Callback triggered when the user has successfully updated his card
*/ */
$scope.onCardUpdateSuccess = function (message) { $scope.onCardUpdateSuccess = function (message) {
growl.success(message); growl.success(message);
}; };
// !!! MUST BE CALLED AT THE END of the controller // !!! MUST BE CALLED AT THE END of the controller
return initialize(); return initialize();
} }
]); ]);