Repository URL to install this package:
|
Version:
0.0.15 ▾
|
import * as tslib_1 from "tslib";
import React from 'react';
import { observer } from 'xmobx/mobx-react';
import { StyledSwitchButton, PrivacyText, PrivacyWrap, StyledExportButton, FreezeAlert, } from './styled';
import { privacyContainer } from './privacyContainer';
import { PrivacyContext } from './PrivacyContext';
// & is like extends + extends + extends
let PrivacySwitch = class PrivacySwitch extends React.Component {
// & is like extends + extends + extends
constructor() {
super(...arguments);
this.renderExportOrSwitchButton = () => {
const { onClick, onToggle, switchLabel, toggleSwitch, label } = this.context;
// const hasPopUp = switchLabel === 'freeze' || switchLabel === 'delete'
const isSelected = privacyContainer.privacyState.profileData[switchLabel];
switch (toggleSwitch) {
case false: return React.createElement(StyledExportButton, { onClick: onClick });
case true: return React.createElement(StyledSwitchButton, { isSelected: isSelected, onToggle: onToggle, label: switchLabel });
default: return '';
}
};
this.renderPrivacyText = () => {
const { note, value } = this.context;
return (React.createElement(PrivacyText, null,
value,
" ",
note && React.createElement(FreezeAlert, null, note)));
};
}
// @todo - label here seems to be value and value seems to be label, so that is weir
render() {
const { qa } = this.context;
return (React.createElement(PrivacyWrap, { "data-qa": qa },
this.renderPrivacyText(),
this.renderExportOrSwitchButton()));
}
};
PrivacySwitch.contextType = PrivacyContext;
PrivacySwitch.defaultProps = {
onToggle: privacyContainer.handleOnSwitchClick,
onClick: privacyContainer.handleOnClick,
hasPopUp: false,
};
PrivacySwitch = tslib_1.__decorate([
observer
], PrivacySwitch);
export { PrivacySwitch };
export default PrivacySwitch;
//# sourceMappingURL=PrivacySwitch.js.map