Repository URL to install this package:
|
Version:
2.8.4 ▾
|
@skava/ui
/
dist
/
components
/
presets
/
B2B
/
UserProfile
/
SmsNotifications
/
SmsNotifications.js
|
|---|
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const mobx_react_1 = require("xmobx/mobx-react");
const exotic_1 = require("exotic");
const utils_1 = require("@skava/utils");
const forms_1 = require("../../../../../forms");
const words_1 = require("../../../../../words");
const fixture_1 = require("../fixture");
const styled_1 = require("../styled");
const styled_2 = require("./styled");
class FormStateCard extends forms_1.FormState {
constructor() {
super(...arguments);
this.inputsList = fixture_1.smsNotificationInputList;
}
}
const formStateCard = new FormStateCard();
class FormButton extends react_1.default.PureComponent {
render() {
const passThroughProps = utils_1.omit(this.props, ['children']);
return react_1.default.createElement(styled_1.StyledButton, Object.assign({}, passThroughProps, {
text: words_1.wording.saveChanges,
"data-qa": 'qa-save-changes'
}));
}
}
let FormCard = class FormCard extends forms_1.ObserverForm {
constructor() {
super(...arguments);
this.SubmitButton = FormButton;
this.handleSubmit = event => {
const {
onSaveChanges
} = this.props;
event.preventDefault();
console.log('[On save changes] data: ', this.state.toSerialized());
if (exotic_1.isFunction(onSaveChanges)) {
onSaveChanges(this.state);
}
};
}
doPrefillForm(props, state) {
const {
item,
shouldDisablePropsList
} = props;
const toList = state => exotic_1.isArray(state.inputsList[0].elementList) && state.inputsList[0].elementList;
const list = toList(state);
list.map(inputState => {
if (exotic_1.isObj(item) && exotic_1.isSafe(item.phoneNumber) && inputState.name === 'phoneNumber' && inputState.value !== item.phoneNumber) {
inputState.setValue(item.phoneNumber);
}
inputState.isDisabled = exotic_1.isArray(shouldDisablePropsList) && shouldDisablePropsList.includes(inputState.name);
});
}
componentDidMount() {
this.doPrefillForm(this.props, this.state);
}
componentWillReceiveProps() {
this.doPrefillForm(this.props, this.state);
}
};
FormCard.FormCard = formStateCard;
FormCard.defaultProps = {
state: formStateCard
};
FormCard = tslib_1.__decorate([mobx_react_1.observer], FormCard);
class SmsNotifications extends react_1.default.PureComponent {
render() {
return react_1.default.createElement(styled_2.Wrapper, null, react_1.default.createElement(styled_2.Heading, {
breedType: "h2",
content: words_1.wording.smsNotifications
}), react_1.default.createElement(FormCard, Object.assign({}, this.props)));
}
}
exports.SmsNotifications = SmsNotifications;
exports.default = SmsNotifications; //# sourceMappingURL=SmsNotifications.js.map