AddNewStaff.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import React, { Component, Fragment } from 'react';
  2. import { connect } from 'react-redux';
  3. import { AddNewStaffAction, closeModal, pushPhoto, base64, base641, base642, base643 } from "../actions/addNewStaffAction";
  4. import { getUsersDataById } from "../actions/getUserById"
  5. import { bindActionCreators } from "redux";
  6. import FormAddNewStaff from '../components/FormsAdd/FormAddNewStaff';
  7. import EditModal from "../components/Modal/addNewStaffModal";
  8. class AddNewStaff extends Component {
  9. componentDidMount() {
  10. const { getUsersDataById } = this.props
  11. let localS = JSON.parse(localStorage.getItem("login"));
  12. if(localS===null){
  13. }
  14. else{
  15. getUsersDataById(localS)
  16. }
  17. }
  18. closeEditModal = () => {
  19. const { closeModal } = this.props;
  20. closeModal();
  21. }
  22. render() {
  23. const { showModal, error } = this.props
  24. const str = "Ваше объявление успешно добавлено"
  25. return (
  26. <Fragment>
  27. <Fragment>
  28. <FormAddNewStaff {...this.props}
  29. />
  30. </Fragment>
  31. <EditModal visible={showModal}
  32. onOk={this.closeEditModal}
  33. onCancel={this.closeEditModal}
  34. error={error}
  35. str={ str }
  36. />
  37. </Fragment>
  38. );
  39. }
  40. }
  41. const mapStateToProps = state => ({
  42. staffData: state.addStaff.staffData,
  43. photo: state.addStaff.photo,
  44. isFetching: state.addStaff.isFetching,
  45. showModal: state.addStaff.showModal,
  46. error: state.addStaff.error,
  47. getUser: state.getUserById.getUser,
  48. base64Photo: state.addStaff.base64Photo,
  49. base64Photo1: state.addStaff.base64Photo1,
  50. base64Photo2: state.addStaff.base64Photo2,
  51. base64Photo3: state.addStaff.base64Photo3,
  52. addOrnot: state.addStaff.addOrnot,
  53. addOrnot1: state.addStaff.addOrnot1,
  54. addOrnot2: state.addStaff.addOrnot2,
  55. addOrnot3: state.addStaff.addOrnot3
  56. });
  57. const mapDispatchToProps = dispatch => bindActionCreators({ AddNewStaffAction, getUsersDataById, closeModal, pushPhoto, base64, base641, base642,base643 }, dispatch);
  58. export default AddNewStaff = connect(
  59. mapStateToProps,
  60. mapDispatchToProps
  61. )(AddNewStaff);