UNPKG

lml-main

Version:

This is now a mono repository published into many standalone packages.

44 lines 2.74 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const React = require("react"); const react_redux_1 = require("react-redux"); const lodash_1 = require("lodash"); const actions_1 = require("../../../frequencies/actions"); const selectors_1 = require("../../../frequencies/selectors"); const cosmoui_1 = require("cosmoui"); const frequency_item_1 = require("./frequency-item"); const styles = require('./frequency-item.scss'); class FrequencyServiceCentreItemListComponent extends React.Component { constructor() { super(...arguments); this.renderList = () => { const { serviceCentre } = this.props; if (!serviceCentre) return null; const frequencies = this.props.getFrequenciesByServiceCentreCode(serviceCentre.code); return (React.createElement(cosmoui_1.Column, { key: `${serviceCentre.code}_all`, className: styles.list, justify: "flex-start" }, this.renderSelectAllCheckbox(), frequencies.map((frequency, idx) => React.createElement(frequency_item_1.FrequencyItem, { key: `frequency-item-${idx}`, frequency: frequency })))); }; this.renderSelectAllCheckbox = () => (React.createElement(cosmoui_1.Row, { className: styles.item }, React.createElement("input", { type: "checkbox", className: styles.input, id: `${this.props.serviceCentre.code}_all`, onChange: this.toggleAll, checked: this.props.allChecked }), React.createElement("label", { htmlFor: `${this.props.serviceCentre.code}_all`, className: styles.label }, this.props.serviceCentre.name, " all"))); this.toggleAll = () => this.props.setAllPendingFrequenciesInServiceCentreSelected(!this.props.allChecked); } render() { console.log('RENDER FrequencyServiceCentreItemListComponent', this.props); return (React.createElement(cosmoui_1.Column, { className: styles.container }, this.renderList())); } } const mapStateToProps = (state, ownProps) => ({ serviceCentre: selectors_1.getSelectedServiceCentre(state), allChecked: selectors_1.areAllPendingFrequenceisInServiceCentreSelected(state, lodash_1.get(selectors_1.getSelectedServiceCentre(state), 'code', '')), getFrequenciesByServiceCentreCode: (code) => selectors_1.getFrequenciesByServiceCentreCode(state, code), }); const mapDispatchToProps = { setAllPendingFrequenciesInServiceCentreSelected: actions_1.setAllPendingFrequenciesInServiceCentreSelected, }; exports.FrequencyServiceCentreItemList = react_redux_1.connect(mapStateToProps, mapDispatchToProps)(FrequencyServiceCentreItemListComponent); //# sourceMappingURL=frequency-service-centre-item-list.js.map