lml-main
Version:
This is now a mono repository published into many standalone packages.
64 lines • 2.84 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const React = require("react");
const react_redux_1 = require("react-redux");
const cosmo_redux_api_1 = require("@lml/cosmo-redux-api");
const cosmoui_1 = require("cosmoui");
const constants_1 = require("../../constants");
const _1 = require("../");
const _2 = require("../../");
class PlacesByPartnerComponent extends cosmoui_1.StylableComponent {
constructor() {
super(...arguments);
this.showPlaceForm = () => {
this.props.openPlaceFormDrawer();
};
this.submitPartnerForm = (value) => {
this.props.fetchPlaces(value);
};
this.dividerStyle = () => ({
height: '40px',
borderColor: '#dedede',
margin: '0 15px',
});
this.headerStyle = () => ({
minHeight: 'max-content',
marginBottom: this.margin(200),
backgroundColor: 'white',
paddingBottom: 0,
});
this.bodyStyle = () => ({
backgroundColor: 'white',
overflow: 'auto',
});
}
componentDidMount() {
this.props.fetchPlaces(this.props.partners[0].value);
}
render() {
return (React.createElement(cosmoui_1.Column, null,
React.createElement(cosmoui_1.Paper, { style: this.headerStyle() },
React.createElement(cosmoui_1.Row, { justify: "space-between" },
React.createElement(cosmoui_1.Header, { primary: true }, "Places"),
React.createElement(cosmoui_1.Row, null,
React.createElement(_1.SearchPlaceForm, { submitForm: this.submitPartnerForm }),
React.createElement(cosmoui_1.Divider, { vertical: true, style: this.dividerStyle() }),
React.createElement(cosmoui_1.Button, { id: 'add-new-place-button', onClick: this.showPlaceForm, style: { marginBottom: '10px' } }, "Add New Place")))),
React.createElement(cosmoui_1.Paper, { style: this.bodyStyle() },
React.createElement(_1.PlaceTable, { places: this.props.places }))));
}
}
const mapStateToProps = (state) => {
const formField = cosmoui_1.getFormField(state, constants_1.SEARCH_PLACE_BY_PARTNER_FORM_KEY, constants_1.SEARCH_PLACE_PARTNER_SELECT_KEY);
const searchValue = formField && formField.value ? formField.value.value : '';
return {
partners: _2.getPartners(),
places: _2.getPlacesByPartner(state, searchValue),
};
};
const mapDispatchToProps = {
openPlaceFormDrawer: _2.openPlaceFormDrawer,
fetchPlaces: cosmo_redux_api_1.fetchPlaces,
};
exports.PlacesByPartner = react_redux_1.connect(mapStateToProps, mapDispatchToProps)(PlacesByPartnerComponent);
//# sourceMappingURL=places-by-partner.js.map