* fix: multi lines and spaces issues * fix: eslint operator-linebreak issue * fix: eslint quotes issue * fix: remaining quotes issues * fix: eslint object curly newline issue * fix: eslint object curly spacing issue * fix: eslint brace-style issues * fix: react jsx indent and props issues * fix: eslint trailing spaces issues * fix: eslint linbreak style issue * fix: eslint space unary operator issue * fix: eslint line around directives issue * fix: void and typeof space unary ops issue
47 lines
1.5 KiB
JavaScript
47 lines
1.5 KiB
JavaScript
/**
|
|
* Student dashboard credit messaging.
|
|
*/
|
|
|
|
var edx = edx || {};
|
|
|
|
(function($, analytics) {
|
|
'use strict';
|
|
|
|
$(document).ready(function() {
|
|
var $errorContainer = $('.credit-error-msg'),
|
|
creditStatusError = $errorContainer.data('credit-error');
|
|
|
|
if (creditStatusError === 'True') {
|
|
$errorContainer.toggleClass('is-hidden');
|
|
}
|
|
|
|
// Fire analytics events when the "purchase credit" button is clicked
|
|
$('.purchase-credit-btn').on('click', function(event) {
|
|
var courseKey = $(event.target).data('course-key');
|
|
analytics.track(
|
|
'edx.bi.credit.clicked_purchase_credit',
|
|
{
|
|
category: 'credit',
|
|
label: courseKey
|
|
}
|
|
);
|
|
});
|
|
|
|
// This event invokes credit request endpoint. It will initiate
|
|
// a credit request for the credit course for the provided user.
|
|
$('.pending-credit-btn').on('click', function(event) {
|
|
var $target = $(event.target),
|
|
courseKey = $target.data('course-key'),
|
|
username = $target.data('user'),
|
|
providerId = $target.data('provider');
|
|
|
|
event.preventDefault();
|
|
|
|
edx.commerce.credit.createCreditRequest(providerId, courseKey, username).fail(function() {
|
|
$('.credit-action').hide();
|
|
$errorContainer.toggleClass('is-hidden');
|
|
});
|
|
});
|
|
});
|
|
}(jQuery, window.analytics));
|