Repository URL to install this package:
|
Version:
2.0.17 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const tslib_1 = require("tslib");
const mobx_1 = require("xmobx/mobx");
const exotic_1 = require("exotic");
const inviteUserState = mobx_1.observable({
shouldValidateForm: false,
isAllFormsValid: true,
savedList: exotic_1.EMPTY_ARRAY
});
exports.inviteUserState = inviteUserState;
class UserInviteStorage {
constructor() {
this.userInviteList = [];
}
handleAddUser(SERIALIZED_DATA_ON_FORM_SUBMIT) {
this.userInviteList.push(SERIALIZED_DATA_ON_FORM_SUBMIT);
}
handleRemoveUser(index) {
// console.log('handleRemoveUser list Before', this.userInviteList)
this.userInviteList.splice(index, 1); // console.log('handleRemoveUser list After', this.userInviteList)
}
handleSendInvite(onSendInviteClick) {
inviteUserState.shouldValidateForm = true;
if (inviteUserState.isAllFormsValid === true) {
if (inviteUserState.savedList.length > 0 && exotic_1.isFunction(onSendInviteClick)) {
onSendInviteClick(inviteUserState.savedList);
}
this.userInviteList = [];
} else if (inviteUserState.isAllFormsValid === false) {
inviteUserState.isAllFormsValid = true;
}
inviteUserState.shouldValidateForm = false;
}
}
tslib_1.__decorate([mobx_1.observable], UserInviteStorage.prototype, "userInviteList", void 0);
tslib_1.__decorate([mobx_1.action.bound], UserInviteStorage.prototype, "handleAddUser", null);
tslib_1.__decorate([mobx_1.action.bound], UserInviteStorage.prototype, "handleRemoveUser", null);
tslib_1.__decorate([mobx_1.action.bound], UserInviteStorage.prototype, "handleSendInvite", null);
exports.UserInviteStorage = UserInviteStorage;
exports.default = UserInviteStorage;