Commit cd1e9170 authored by Juorder Antonio's avatar Juorder Antonio

fire event to finish loading bar, add json stringify to data to send ajax

parent 7806d752
...@@ -2,6 +2,7 @@ import React from 'react'; ...@@ -2,6 +2,7 @@ import React from 'react';
import PageInfo from '../page_info.jsx'; import PageInfo from '../page_info.jsx';
import Panel from '../panel.jsx'; import Panel from '../panel.jsx';
import UserStore from '../../stores/user_store.jsx'; import UserStore from '../../stores/user_store.jsx';
import * as GlobalActions from '../../action_creators/global_actions.jsx';
import * as Utils from '../../utils/utils.jsx'; import * as Utils from '../../utils/utils.jsx';
import * as Client from '../../utils/client.jsx'; import * as Client from '../../utils/client.jsx';
import sweetAlert from 'sweetalert'; import sweetAlert from 'sweetalert';
...@@ -12,6 +13,7 @@ export default class SalesForm extends React.Component { ...@@ -12,6 +13,7 @@ export default class SalesForm extends React.Component {
this.buildPurchase = this.buildPurchase.bind(this); this.buildPurchase = this.buildPurchase.bind(this);
this.confirmShipping = this.confirmShipping.bind(this); this.confirmShipping = this.confirmShipping.bind(this);
this.resetCounter = this.resetCounter.bind(this);
const {name, attrs} = UserStore.getCurrentUser(); const {name, attrs} = UserStore.getCurrentUser();
const {displayName, cn, sn} = attrs._attrs; const {displayName, cn, sn} = attrs._attrs;
...@@ -29,6 +31,7 @@ export default class SalesForm extends React.Component { ...@@ -29,6 +31,7 @@ export default class SalesForm extends React.Component {
this.avoidPlans = ['archiving', 'default']; this.avoidPlans = ['archiving', 'default'];
this.plans = window.manager_config.plans; this.plans = window.manager_config.plans;
this.messageCode = window.manager_config.messageCode; this.messageCode = window.manager_config.messageCode;
this.mailboxes = Object.keys(this.plans).filter((plan) => { this.mailboxes = Object.keys(this.plans).filter((plan) => {
const isValidPlan = !this.avoidPlans.includes(plan); const isValidPlan = !this.avoidPlans.includes(plan);
...@@ -42,12 +45,24 @@ export default class SalesForm extends React.Component { ...@@ -42,12 +45,24 @@ export default class SalesForm extends React.Component {
this.state = state; this.state = state;
} }
resetCounter() {
const purchase = {};
const reset = this.mailboxes.forEach((plan) => {
purchase[plan] = 0;
});
this.setState({
purchase: reset
});
}
componentDidMount() { componentDidMount() {
GlobalActions.emitEndLoading(); GlobalActions.emitEndLoading();
} }
onKeyupInput(event, label) { onKeyupInput(event, label) {
const value = event.target.value; const value = event.target.value;
this.checkAmount(label, value); this.checkAmount(label, value);
} }
...@@ -135,6 +150,7 @@ export default class SalesForm extends React.Component { ...@@ -135,6 +150,7 @@ export default class SalesForm extends React.Component {
data = JSON.stringify(data); data = JSON.stringify(data);
Client.requestMailboxes(data, (response) => { Client.requestMailboxes(data, (response) => {
const text = this.messageCode[response.messageCode]; const text = this.messageCode[response.messageCode];
this.resetCounter();
sweetAlert('Compra éxitosa', text, 'success'); sweetAlert('Compra éxitosa', text, 'success');
}, (error) => { }, (error) => {
const text = this.messageCode[error.messageCode]; const text = this.messageCode[error.messageCode];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment