@plusscommunities/pluss-maintenance-web 1.0.23 → 1.0.27-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -9,13 +9,13 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty';
9
9
  import _regeneratorRuntime from '@babel/runtime/regenerator';
10
10
  import React, { Component } from 'react';
11
11
  import { connect } from 'react-redux';
12
+ import { withRouter } from 'react-router';
12
13
  import _ from 'lodash';
13
14
  import moment from 'moment';
14
15
  import FontAwesome from 'react-fontawesome';
15
16
  import * as PlussCore from '@plusscommunities/pluss-core-web';
16
17
  import Cookies from 'js-cookie';
17
18
  import { Table, MenuItem, DropdownButton } from 'react-bootstrap';
18
- import { withRouter } from 'react-router';
19
19
  import { Link } from 'react-router-dom';
20
20
  import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
21
21
  import Textarea from 'react-textarea-autosize';
@@ -277,13 +277,14 @@ var maintenanceActions = {
277
277
  var Helper$3 = PlussCore.Helper,
278
278
  Session$5 = PlussCore.Session;
279
279
  var reactionActions = {
280
- addComment: function addComment(entityId, entityType, entityName, site, comment, image) {
280
+ addComment: function addComment(entityId, entityType, entityName, site, comment, image, parentId) {
281
281
  var data = {
282
282
  entityId: entityId,
283
283
  entityType: entityType,
284
284
  entityName: entityName,
285
285
  site: site,
286
- comment: comment
286
+ comment: comment,
287
+ parentId: parentId
287
288
  };
288
289
 
289
290
  if (!_.isEmpty(image)) {
@@ -424,8 +425,7 @@ var StatusTypes = {
424
425
  function _createSuper$a(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$a(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
425
426
 
426
427
  function _isNativeReflectConstruct$a() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
427
- var Session$4 = PlussCore.Session,
428
- Components$4 = PlussCore.Components;
428
+ var Session$4 = PlussCore.Session;
429
429
 
430
430
  var JobList = /*#__PURE__*/function (_Component) {
431
431
  _inherits(JobList, _Component);
@@ -533,10 +533,6 @@ var JobList = /*#__PURE__*/function (_Component) {
533
533
  };
534
534
  }());
535
535
 
536
- _defineProperty(_assertThisInitialized(_this), "onOpenJobTypes", function () {
537
- _this.props.history.push('/requestTypes');
538
- });
539
-
540
536
  _this.state = {
541
537
  showCompleted: false,
542
538
  sortColumn: 'createdUnix',
@@ -676,27 +672,6 @@ var JobList = /*#__PURE__*/function (_Component) {
676
672
  }
677
673
  }, "Example might be; Fix my light bulb, hand rail is broken, or please send flowers to Mum."));
678
674
  }
679
- }, {
680
- key: "renderButtons",
681
- value: function renderButtons() {
682
- if (!Session$4.validateAccess(this.props.auth.site, 'maintenanceTypes', this.props.auth)) return null;
683
- return /*#__PURE__*/React.createElement("div", {
684
- className: "flex-reverse"
685
- }, /*#__PURE__*/React.createElement(Components$4.Button, {
686
- inline: true,
687
- buttonType: "primaryAction",
688
- onClick: this.onOpenJobTypes,
689
- isActive: true
690
- }, /*#__PURE__*/React.createElement("div", {
691
- className: "flex flex-row flex-center"
692
- }, /*#__PURE__*/React.createElement(Components$4.SVGIcon, {
693
- colour: '#fff',
694
- icon: "maintenance2",
695
- height: "17px"
696
- }), /*#__PURE__*/React.createElement("div", {
697
- className: "marginLeft-10"
698
- }, "Request Types"))));
699
- }
700
675
  }, {
701
676
  key: "renderContent",
702
677
  value: function renderContent() {
@@ -768,7 +743,9 @@ var JobList = /*#__PURE__*/function (_Component) {
768
743
  style: {
769
744
  minWidth: '100%'
770
745
  }
771
- }, this.renderButtons(), this.renderContent());
746
+ }, this.renderContent(), /*#__PURE__*/React.createElement("div", {
747
+ className: "hub_tidioPadding"
748
+ }));
772
749
  }
773
750
  }]);
774
751
 
@@ -792,1308 +769,1235 @@ var JobList$1 = connect(mapStateToProps$4, {
792
769
  function _createSuper$9(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$9(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
793
770
 
794
771
  function _isNativeReflectConstruct$9() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
795
- var Components$3 = PlussCore.Components,
796
- Session$3 = PlussCore.Session;
772
+ var Session$3 = PlussCore.Session,
773
+ Components$3 = PlussCore.Components,
774
+ Helper$2 = PlussCore.Helper;
797
775
 
798
- var RequestsHub = /*#__PURE__*/function (_Component) {
799
- _inherits(RequestsHub, _Component);
776
+ var JobTypes = /*#__PURE__*/function (_Component) {
777
+ _inherits(JobTypes, _Component);
800
778
 
801
- var _super = _createSuper$9(RequestsHub);
779
+ var _super = _createSuper$9(JobTypes);
802
780
 
803
- function RequestsHub(props) {
781
+ function JobTypes(props) {
804
782
  var _this;
805
783
 
806
- _classCallCheck(this, RequestsHub);
784
+ _classCallCheck(this, JobTypes);
807
785
 
808
786
  _this = _super.call(this, props);
809
787
 
810
- _defineProperty(_assertThisInitialized(_this), "setData", function () {
811
- var allList = [];
788
+ _defineProperty(_assertThisInitialized(_this), "getJobTypes", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
789
+ var res;
790
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
791
+ while (1) {
792
+ switch (_context.prev = _context.next) {
793
+ case 0:
794
+ _context.prev = 0;
795
+ _context.next = 3;
796
+ return maintenanceActions.getJobTypes(_this.props.auth.site);
812
797
 
813
- _this.state.allList.forEach(function (ev) {
814
- if (ev != null && !ev.Deleted) allList.push(ev);
815
- });
798
+ case 3:
799
+ res = _context.sent;
800
+ if (res.data != null) _this.props.jobTypesLoaded(res.data);
801
+ _context.next = 10;
802
+ break;
816
803
 
817
- var upcoming = _.filter(allList, function (ev) {
818
- if (!ev) return false;
819
- if (ev.status && ev.status === 'Completed') return false;
820
- return true;
821
- });
804
+ case 7:
805
+ _context.prev = 7;
806
+ _context.t0 = _context["catch"](0);
807
+ console.error('getJobTypes', _context.t0);
822
808
 
823
- var completed = _.filter(allList, function (ev) {
824
- if (!ev) return false;
825
- if (ev.status && ev.status === 'Completed') return true;
826
- return false;
827
- }); // console.log('setData', upcoming, completed);
809
+ case 10:
810
+ _context.prev = 10;
828
811
 
812
+ _this.setState({
813
+ loading: false
814
+ });
829
815
 
830
- _this.setState({
831
- allList: allList,
832
- upcoming: upcoming,
833
- completed: completed
834
- });
816
+ return _context.finish(10);
817
+
818
+ case 13:
819
+ case "end":
820
+ return _context.stop();
821
+ }
822
+ }
823
+ }, _callee, null, [[0, 7, 10, 13]]);
824
+ })));
825
+
826
+ _defineProperty(_assertThisInitialized(_this), "sortByCol", function (col) {
827
+ if (_this.state.sortColumn === col) {
828
+ _this.setState({
829
+ sortDesc: !_this.state.sortDesc
830
+ });
831
+ } else {
832
+ _this.setState({
833
+ sortColumn: col,
834
+ sortDesc: false
835
+ });
836
+ }
835
837
  });
836
838
 
837
- _defineProperty(_assertThisInitialized(_this), "getData", function () {
838
- var auth = _this.props.auth;
839
+ _defineProperty(_assertThisInitialized(_this), "validateEmail", function () {
840
+ var jobTypeEmail = _this.state.jobTypeEmail;
841
+ return !_.isEmpty(jobTypeEmail) && Helper$2.isEmail(jobTypeEmail);
842
+ });
839
843
 
840
- _this.setState({
841
- loadingAll: true
842
- }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
843
- var res;
844
- return _regeneratorRuntime.wrap(function _callee$(_context) {
844
+ _defineProperty(_assertThisInitialized(_this), "isJobTypeValid", function () {
845
+ var _this$state = _this.state,
846
+ jobTypeName = _this$state.jobTypeName,
847
+ jobTypeDescription = _this$state.jobTypeDescription;
848
+ if (_.isEmpty(jobTypeName)) return false;
849
+ if (!_this.validateEmail()) return false;
850
+ if (_.isEmpty(jobTypeDescription)) return false;
851
+ return true;
852
+ });
853
+
854
+ _defineProperty(_assertThisInitialized(_this), "onRemoveJobType", /*#__PURE__*/function () {
855
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(ev) {
856
+ var index, newJobTypes;
857
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
845
858
  while (1) {
846
- switch (_context.prev = _context.next) {
859
+ switch (_context2.prev = _context2.next) {
847
860
  case 0:
848
- _context.prev = 0;
849
- _context.next = 3;
850
- return maintenanceActions.getJobs(auth.site);
861
+ if (window.confirm("Are you sure you want to delete ".concat(ev.typeName, "?"))) {
862
+ _context2.next = 2;
863
+ break;
864
+ }
851
865
 
852
- case 3:
853
- res = _context.sent;
866
+ return _context2.abrupt("return");
854
867
 
855
- // console.log('getData', res.data);
856
- _this.setState({
857
- loadingAll: false
868
+ case 2:
869
+ _context2.prev = 2;
870
+ _context2.next = 5;
871
+ return maintenanceActions.deleteJobType(_this.props.auth.site, ev.id);
872
+
873
+ case 5:
874
+ index = _.findIndex(_this.state.jobList, function (job) {
875
+ return job != null && job.id === ev.id;
858
876
  });
859
877
 
860
- if (res.data != null && !_.isEmpty(res.data) && res.data[0].site === auth.site) {
861
- _this.props.jobsLoaded(res.data);
878
+ if (index > -1) {
879
+ newJobTypes = _toConsumableArray(_this.state.jobList);
880
+ newJobTypes[index].Deleted = true;
881
+
882
+ _this.props.jobTypesLoaded(newJobTypes);
862
883
  }
863
884
 
864
- _context.next = 12;
885
+ _context2.next = 13;
865
886
  break;
866
887
 
867
- case 8:
868
- _context.prev = 8;
869
- _context.t0 = _context["catch"](0);
870
- console.error('getData', _context.t0);
871
-
872
- _this.setState({
873
- loadingAll: false
874
- });
888
+ case 9:
889
+ _context2.prev = 9;
890
+ _context2.t0 = _context2["catch"](2);
891
+ console.error('onRemoveJobType', _context2.t0);
892
+ alert('Something went wrong with the request. Please try again.');
875
893
 
876
- case 12:
894
+ case 13:
877
895
  case "end":
878
- return _context.stop();
896
+ return _context2.stop();
879
897
  }
880
898
  }
881
- }, _callee, null, [[0, 8]]);
882
- })));
883
- });
899
+ }, _callee2, null, [[2, 9]]);
900
+ }));
884
901
 
885
- _defineProperty(_assertThisInitialized(_this), "onAddNew", function () {
886
- var auth = _this.props.auth;
902
+ return function (_x) {
903
+ return _ref2.apply(this, arguments);
904
+ };
905
+ }());
887
906
 
888
- if (Session$3.validateAccess(auth.site, 'maintenanceTracking', auth)) {
889
- _this.props.history.push("/requestsHub/job");
890
- }
891
- });
907
+ _defineProperty(_assertThisInitialized(_this), "onShowJobType", function () {
908
+ var job = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
892
909
 
893
- _defineProperty(_assertThisInitialized(_this), "canAddNew", function (isClass) {
894
- var auth = _this.props.auth;
895
- if (Session$3.validateAccess(auth.site, 'maintenanceTracking', auth)) return isClass ? '' : true;
896
- return isClass ? ' hub-sideContent-topButton--hide' : false;
910
+ _this.setState({
911
+ showJobType: true,
912
+ jobTypeId: job ? job.id : null,
913
+ jobTypeName: job ? job.typeName : '',
914
+ jobTypeEmail: job ? job.email : '',
915
+ jobTypeDescription: job ? job.description : '',
916
+ jobTypeLevel: job ? job.level : 1
917
+ });
897
918
  });
898
919
 
899
- _defineProperty(_assertThisInitialized(_this), "getSideBarSectionColour", function (id) {
900
- return _this.state.selectedSection === id ? {
901
- backgroundColor: '#fff'
902
- } : {};
903
- });
920
+ _defineProperty(_assertThisInitialized(_this), "onHideJobType", function () {
921
+ if (_this.state.submitting) return;
904
922
 
905
- _defineProperty(_assertThisInitialized(_this), "renderStats", function (stat, loading) {
906
- return loading ? /*#__PURE__*/React.createElement(FontAwesome, {
907
- style: styles$4.spinner,
908
- name: "spinner fa-pulse fa-fw"
909
- }) : stat;
923
+ _this.setState({
924
+ showWarnings: false,
925
+ showJobType: false,
926
+ jobTypeId: null,
927
+ jobTypeName: '',
928
+ jobTypeEmail: '',
929
+ jobTypeDescription: '',
930
+ jobTypeLevel: 1
931
+ });
910
932
  });
911
933
 
912
- _this.state = {
913
- selectedSection: 'upcoming',
914
- location: '',
915
- loadingAll: false,
916
- loadingSubmissions: false,
917
- submissionEntries: [],
918
- allList: [],
919
- completed: [],
920
- upcoming: [],
921
- now: moment.utc(),
922
- onlyFuture: true,
923
- search: ''
924
- };
925
- return _this;
926
- }
934
+ _defineProperty(_assertThisInitialized(_this), "onHandleChange", function (event) {
935
+ var stateChange = {};
936
+ stateChange[event.target.getAttribute('id')] = event.target.value;
927
937
 
928
- _createClass(RequestsHub, [{
929
- key: "UNSAFE_componentWillMount",
930
- value: function UNSAFE_componentWillMount() {
931
- this.updateProps(this.props);
932
- }
933
- }, {
934
- key: "componentDidMount",
935
- value: function componentDidMount() {
936
- this.getData();
937
- }
938
- }, {
939
- key: "UNSAFE_componentWillReceiveProps",
940
- value: function UNSAFE_componentWillReceiveProps(nextProps) {
941
- if (!_.isEqual(this.props.jobs, nextProps.jobs)) this.updateProps(nextProps);
942
- }
943
- }, {
944
- key: "updateProps",
945
- value: function updateProps(props) {
946
- this.setState({
947
- allList: props.jobs
948
- }, this.setData);
949
- }
950
- }, {
951
- key: "renderLeftBar",
952
- value: function renderLeftBar() {
953
- var _this2 = this;
938
+ _this.setState(stateChange);
939
+ });
954
940
 
955
- return /*#__PURE__*/React.createElement("div", {
956
- className: "hub-sideContent"
957
- }, /*#__PURE__*/React.createElement("div", {
958
- className: "hub-sideContent-topButton"
959
- }), /*#__PURE__*/React.createElement("div", {
960
- style: {
961
- paddingLeft: 15,
962
- width: '100%'
963
- }
964
- }, /*#__PURE__*/React.createElement("div", {
965
- className: "fontMedium fontSize-32 text-dark",
966
- style: styles$4.sideBarTitleSection
967
- }, "Maintenance requests"), /*#__PURE__*/React.createElement("div", {
968
- onClick: function onClick() {
969
- _this2.setState({
970
- selectedSection: 'completed'
971
- });
972
- },
973
- className: "sideBarSection",
974
- style: this.getSideBarSectionColour('completed')
975
- }, /*#__PURE__*/React.createElement("div", {
976
- className: "fontMedium fontSize-36 text-dark",
977
- style: {
978
- lineHeight: '50px'
979
- }
980
- }, this.renderStats(this.state.completed.length, this.state.loadingAll)), /*#__PURE__*/React.createElement("div", {
981
- className: "fontRegular fontSize-16 text-light lineHeight-22"
982
- }, "Complete")), /*#__PURE__*/React.createElement("div", {
983
- onClick: function onClick() {
984
- _this2.setState({
985
- selectedSection: 'upcoming'
986
- });
987
- },
988
- className: "sideBarSection",
989
- style: this.getSideBarSectionColour('upcoming')
990
- }, /*#__PURE__*/React.createElement("div", {
991
- className: "fontMedium fontSize-36 text-dark",
992
- style: {
993
- lineHeight: '50px'
994
- }
995
- }, this.renderStats(this.state.upcoming.length, this.state.loadingAll)), /*#__PURE__*/React.createElement("div", {
996
- className: "fontRegular fontSize-16 text-light lineHeight-22"
997
- }, "Incomplete"))));
998
- }
999
- }, {
1000
- key: "renderRight",
1001
- value: function renderRight() {
1002
- return /*#__PURE__*/React.createElement(JobList$1, {
1003
- source: this.state.selectedSection === 'completed' ? this.state.completed : this.state.upcoming
1004
- });
1005
- }
1006
- }, {
1007
- key: "render",
1008
- value: function render() {
1009
- return /*#__PURE__*/React.createElement("div", {
1010
- className: "hub-wrapperContainer"
1011
- }, this.renderLeftBar(), /*#__PURE__*/React.createElement("div", {
1012
- className: "hub-headerContentWrapper"
1013
- }, /*#__PURE__*/React.createElement(Components$3.Header, null, this.canAddNew() && /*#__PURE__*/React.createElement(Components$3.AddButton, {
1014
- onClick: this.onAddNew,
1015
- text: "NEW REQUEST"
1016
- })), /*#__PURE__*/React.createElement("div", {
1017
- className: "hub-contentWrapper"
1018
- }, this.renderRight())));
1019
- }
1020
- }]);
1021
-
1022
- return RequestsHub;
1023
- }(Component);
1024
-
1025
- var styles$4 = {
1026
- sideBarTitleSection: {
1027
- lineHeight: '40px',
1028
- marginTop: 30,
1029
- marginBottom: 30,
1030
- paddingLeft: 24,
1031
- paddingRight: 24
1032
- },
1033
- sideBarSection: {
1034
- weight: '100%',
1035
- minWidth: 200,
1036
- padding: 32,
1037
- paddingLeft: 24,
1038
- cursor: 'pointer',
1039
- display: 'flex',
1040
- flexDirection: 'column',
1041
- justifyContent: 'center'
1042
- },
1043
- spinner: {
1044
- fontSize: 32,
1045
- color: FeatureConfig.env.colourBrandingOff
1046
- }
1047
- };
1048
-
1049
- var mapStateToProps$3 = function mapStateToProps(state) {
1050
- var jobs = state.maintenance.jobs;
1051
- var auth = state.auth;
1052
- return {
1053
- jobs: jobs,
1054
- auth: auth
1055
- };
1056
- };
1057
-
1058
- var RequestsHub$1 = connect(mapStateToProps$3, {
1059
- jobsLoaded: jobsLoaded
1060
- })(RequestsHub);
1061
-
1062
- function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
1063
-
1064
- function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$3(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
1065
-
1066
- function _createSuper$8(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$8(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
941
+ _defineProperty(_assertThisInitialized(_this), "onSave", function () {
942
+ var site = _this.props.auth.site;
943
+ var _this$state2 = _this.state,
944
+ submitting = _this$state2.submitting,
945
+ jobTypeId = _this$state2.jobTypeId,
946
+ jobTypeName = _this$state2.jobTypeName,
947
+ jobTypeEmail = _this$state2.jobTypeEmail,
948
+ jobTypeDescription = _this$state2.jobTypeDescription,
949
+ jobTypeLevel = _this$state2.jobTypeLevel;
950
+ if (submitting) return;
1067
951
 
1068
- function _isNativeReflectConstruct$8() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
1069
- var Apis = PlussCore.Apis,
1070
- Helper$2 = PlussCore.Helper,
1071
- Session$2 = PlussCore.Session,
1072
- Colours = PlussCore.Colours,
1073
- Components$2 = PlussCore.Components;
952
+ if (!_this.isJobTypeValid()) {
953
+ _this.setState({
954
+ showWarnings: true
955
+ });
1074
956
 
1075
- var Job = /*#__PURE__*/function (_Component) {
1076
- _inherits(Job, _Component);
957
+ return;
958
+ }
1077
959
 
1078
- var _super = _createSuper$8(Job);
960
+ _this.setState({
961
+ submitting: true
962
+ }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
963
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
964
+ while (1) {
965
+ switch (_context3.prev = _context3.next) {
966
+ case 0:
967
+ _context3.prev = 0;
1079
968
 
1080
- function Job(props) {
1081
- var _this;
969
+ if (!jobTypeId) {
970
+ _context3.next = 6;
971
+ break;
972
+ }
1082
973
 
1083
- _classCallCheck(this, Job);
974
+ _context3.next = 4;
975
+ return maintenanceActions.editJobType(site, jobTypeId, jobTypeName, jobTypeEmail, jobTypeDescription, jobTypeLevel);
1084
976
 
1085
- _this = _super.call(this, props);
977
+ case 4:
978
+ _context3.next = 8;
979
+ break;
1086
980
 
1087
- _defineProperty(_assertThisInitialized(_this), "getJob", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
1088
- var res;
1089
- return _regeneratorRuntime.wrap(function _callee$(_context) {
1090
- while (1) {
1091
- switch (_context.prev = _context.next) {
1092
- case 0:
1093
- _context.prev = 0;
1094
- _context.next = 3;
1095
- return maintenanceActions.getJob(_this.props.auth.site, _this.state.jobId);
981
+ case 6:
982
+ _context3.next = 8;
983
+ return maintenanceActions.addJobType(site, jobTypeName, jobTypeEmail, jobTypeDescription, jobTypeLevel);
1096
984
 
1097
- case 3:
1098
- res = _context.sent;
985
+ case 8:
986
+ _this.props.jobTypesUpdate(site);
1099
987
 
1100
- _this.setState({
1101
- updating: false
1102
- });
988
+ _this.setState({
989
+ submitting: false
990
+ }, _this.onHideJobType);
1103
991
 
1104
- res.data.location = res.data.site;
992
+ _context3.next = 17;
993
+ break;
1105
994
 
1106
- _this.setJob(res.data);
995
+ case 12:
996
+ _context3.prev = 12;
997
+ _context3.t0 = _context3["catch"](0);
998
+ console.error('onSave', _context3.t0);
1107
999
 
1108
- _context.next = 12;
1109
- break;
1000
+ _this.setState({
1001
+ submitting: false
1002
+ });
1110
1003
 
1111
- case 9:
1112
- _context.prev = 9;
1113
- _context.t0 = _context["catch"](0);
1114
- console.error('getJob', _context.t0);
1004
+ alert('Something went wrong with the request. Please try again.');
1115
1005
 
1116
- case 12:
1117
- case "end":
1118
- return _context.stop();
1006
+ case 17:
1007
+ case "end":
1008
+ return _context3.stop();
1009
+ }
1119
1010
  }
1120
- }
1121
- }, _callee, null, [[0, 9]]);
1122
- })));
1123
-
1124
- _defineProperty(_assertThisInitialized(_this), "setJob", function (job) {
1125
- job.typeIcon = job.type === 'General' ? 'wrench' : 'tree';
1126
- job.typeColour = job.type === 'General' ? '#666' : 'green';
1127
-
1128
- if (_.isEmpty(job.lastActivity)) {
1129
- job.lastActivity = '-- --';
1130
- job.noActivity = true;
1131
- }
1132
-
1133
- if (_.isEmpty(job.status)) {
1134
- job.status = 'Unassigned';
1135
- job.notStatus = true;
1136
- }
1137
-
1138
- if (_.isEmpty(job.audience)) {
1139
- job.audience = [{
1140
- displayName: 'Unassigned',
1141
- isEmpty: true
1142
- }];
1143
- }
1144
-
1145
- var needToMarkSeen = false;
1011
+ }, _callee3, null, [[0, 12]]);
1012
+ })));
1013
+ });
1146
1014
 
1147
- if (!job.seen) {
1148
- job.seen = true;
1149
- needToMarkSeen = true;
1150
- }
1015
+ _this.state = {
1016
+ jobList: [],
1017
+ showCompleted: false,
1018
+ sortColumn: 'name',
1019
+ sortDesc: false,
1020
+ loading: true,
1021
+ showJobType: false,
1022
+ jobTypeId: null,
1023
+ jobTypeName: '',
1024
+ jobTypeEmail: '',
1025
+ jobTypeDescription: '',
1026
+ jobTypeLevel: 1,
1027
+ showWarnings: false,
1028
+ submitting: false
1029
+ };
1030
+ return _this;
1031
+ }
1151
1032
 
1152
- _this.setState({
1153
- job: job
1154
- }, function () {
1155
- if (needToMarkSeen) _this.markSeen();
1033
+ _createClass(JobTypes, [{
1034
+ key: "componentWillMount",
1035
+ value: function componentWillMount() {
1036
+ this.updateProps(this.props);
1037
+ Session$3.checkLoggedIn(this, this.props.auth);
1038
+ }
1039
+ }, {
1040
+ key: "componentDidMount",
1041
+ value: function componentDidMount() {
1042
+ this.getJobTypes();
1043
+ }
1044
+ }, {
1045
+ key: "componentWillReceiveProps",
1046
+ value: function componentWillReceiveProps(nextProps) {
1047
+ this.updateProps(nextProps);
1048
+ }
1049
+ }, {
1050
+ key: "updateProps",
1051
+ value: function updateProps(props) {
1052
+ this.setState({
1053
+ jobList: props.jobtypes
1156
1054
  });
1055
+ }
1056
+ }, {
1057
+ key: "renderList",
1058
+ value: function renderList() {
1059
+ var _this2 = this;
1157
1060
 
1158
- _this.props.jobsLoaded([job]);
1159
- });
1160
-
1161
- _defineProperty(_assertThisInitialized(_this), "editJob", function () {});
1061
+ var source = _.sortBy(this.state.jobList, this.state.sortColumn);
1162
1062
 
1163
- _defineProperty(_assertThisInitialized(_this), "isReadyToSaveNote", function () {
1164
- var _this$state = _this.state,
1165
- noteAttachments = _this$state.noteAttachments,
1166
- noteInput = _this$state.noteInput;
1167
- if (_.some(noteAttachments, function (n) {
1168
- return n.Uploading;
1169
- })) return false;
1170
- return !_.isEmpty(noteInput) || !_.isEmpty(noteAttachments);
1171
- });
1172
-
1173
- _defineProperty(_assertThisInitialized(_this), "onOpenAddNote", function () {
1174
- _this.setState({
1175
- addNoteOpen: true,
1176
- editingNote: null
1177
- });
1178
- });
1179
-
1180
- _defineProperty(_assertThisInitialized(_this), "onCloseAddNote", function () {
1181
- var newState = {
1182
- addNoteOpen: false,
1183
- editingNote: null
1184
- };
1185
-
1186
- if (!!_this.state.editingNote) {
1187
- newState.noteInput = '';
1188
- newState.noteAttachments = [];
1189
- }
1190
-
1191
- _this.setState(newState);
1192
- });
1193
-
1194
- _defineProperty(_assertThisInitialized(_this), "onOpenNoteMenu", function (index) {
1195
- if (_this.state.noteMenuOpen === index) {
1196
- _this.setState({
1197
- noteMenuOpen: null
1198
- });
1199
- } else {
1200
- _this.setState({
1201
- noteMenuOpen: index
1202
- });
1203
- }
1204
- });
1205
-
1206
- _defineProperty(_assertThisInitialized(_this), "onHandlePDFFileChange", function (event) {
1207
- var file = event.target.files[0];
1208
- if (!file || _this.state.uploadingNoteAttachment) return;
1209
-
1210
- var noteAttachments = _toConsumableArray(_this.state.noteAttachments);
1211
-
1212
- var newAttachment = {
1213
- Uploading: true,
1214
- Title: file.name
1215
- };
1216
- noteAttachments.push(newAttachment);
1217
-
1218
- _this.setState({
1219
- noteAttachments: noteAttachments
1063
+ if (this.state.sortDesc) source.reverse();
1064
+ source = _.filter(source, function (ev) {
1065
+ if (!ev) return false;
1066
+ if (ev.Deleted) return false;
1067
+ return true;
1220
1068
  });
1069
+ return source.map(function (ev, index) {
1070
+ if (ev != null) {
1071
+ return /*#__PURE__*/React.createElement("tr", {
1072
+ key: index
1073
+ }, /*#__PURE__*/React.createElement("td", {
1074
+ className: "table-TitleColumn"
1075
+ }, /*#__PURE__*/React.createElement("a", {
1076
+ onClick: function onClick() {
1077
+ return _this2.onShowJobType(ev);
1078
+ }
1079
+ }, ev.typeName)), /*#__PURE__*/React.createElement("td", null, ev.description), /*#__PURE__*/React.createElement("td", null, ev.email), /*#__PURE__*/React.createElement("td", {
1080
+ className: "table-options"
1081
+ }, /*#__PURE__*/React.createElement("div", {
1082
+ style: {
1083
+ display: 'flex',
1084
+ alignItems: 'center'
1085
+ }
1086
+ }, Session$3.validateAccess(_this2.props.auth.site, 'maintenanceTypes', _this2.props.auth) && /*#__PURE__*/React.createElement("a", {
1087
+ onClick: function onClick() {
1088
+ return _this2.onShowJobType(ev);
1089
+ }
1090
+ }, /*#__PURE__*/React.createElement(FontAwesome, {
1091
+ style: {
1092
+ fontSize: 20,
1093
+ padding: 5,
1094
+ marginLeft: 12,
1095
+ cursor: 'pointer'
1096
+ },
1097
+ name: "pencil"
1098
+ })), Session$3.validateAccess(_this2.props.auth.site, 'maintenanceTypes', _this2.props.auth) && /*#__PURE__*/React.createElement("a", {
1099
+ onClick: function onClick() {
1100
+ return _this2.onRemoveJobType(ev);
1101
+ }
1102
+ }, /*#__PURE__*/React.createElement(FontAwesome, {
1103
+ style: {
1104
+ fontSize: 20,
1105
+ padding: 5,
1106
+ marginLeft: 8,
1107
+ cursor: 'pointer'
1108
+ },
1109
+ name: "minus-circle"
1110
+ })))));
1111
+ }
1221
1112
 
1222
- Apis.fileActions.uploadMediaAsync(file, file.name).then(function (fileRes) {
1223
- newAttachment.Source = fileRes;
1224
- newAttachment.Uploading = false;
1225
-
1226
- _this.setState({
1227
- noteAttachments: _toConsumableArray(_this.state.noteAttachments)
1228
- });
1229
- }).catch(function (uploadErrorRes) {
1230
- console.log(uploadErrorRes);
1231
- newAttachment.Uploading = false;
1232
-
1233
- _this.setState({
1234
- noteAttachments: _toConsumableArray(_this.state.noteAttachments)
1235
- });
1113
+ return null;
1236
1114
  });
1237
- event.target.value = '';
1238
- });
1239
-
1240
- _defineProperty(_assertThisInitialized(_this), "onRemoveAttachment", function (a) {
1241
- var index = _this.state.noteAttachments.indexOf(a);
1115
+ }
1116
+ }, {
1117
+ key: "renderView",
1118
+ value: function renderView() {
1119
+ var _this3 = this;
1242
1120
 
1243
- if (index > -1) {
1244
- var newAttachments = _toConsumableArray(_this.state.noteAttachments);
1121
+ return /*#__PURE__*/React.createElement(Table, {
1122
+ className: "plussTable",
1123
+ striped: true,
1124
+ bordered: true,
1125
+ condensed: true,
1126
+ hover: true,
1127
+ style: {
1128
+ minWidth: '100%'
1129
+ }
1130
+ }, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
1131
+ style: {
1132
+ cursor: 'pointer'
1133
+ },
1134
+ onClick: function onClick() {
1135
+ return _this3.sortByCol('name');
1136
+ }
1137
+ }, "Request type"), /*#__PURE__*/React.createElement("th", {
1138
+ style: {
1139
+ cursor: 'pointer'
1140
+ },
1141
+ onClick: function onClick() {
1142
+ return _this3.sortByCol('name');
1143
+ }
1144
+ }, "Type Description"), /*#__PURE__*/React.createElement("th", {
1145
+ style: {
1146
+ cursor: 'pointer'
1147
+ },
1148
+ onClick: function onClick() {
1149
+ return _this3.sortByCol('email');
1150
+ }
1151
+ }, "Email"), /*#__PURE__*/React.createElement("th", {
1152
+ style: {
1153
+ width: 70
1154
+ }
1155
+ }))), /*#__PURE__*/React.createElement("tbody", null, this.renderList()));
1156
+ }
1157
+ }, {
1158
+ key: "renderEmpty",
1159
+ value: function renderEmpty() {
1160
+ return /*#__PURE__*/React.createElement("div", {
1161
+ style: {
1162
+ display: 'flex',
1163
+ flexDirection: 'column',
1164
+ flex: 1,
1165
+ justifyContent: 'center',
1166
+ alignItems: 'center',
1167
+ marginTop: 32
1168
+ }
1169
+ }, /*#__PURE__*/React.createElement("div", {
1170
+ className: "emptyState"
1171
+ }), /*#__PURE__*/React.createElement("div", {
1172
+ className: "marginTop-32",
1173
+ style: {
1174
+ maxWidth: 500,
1175
+ textAlign: 'center'
1176
+ }
1177
+ }, /*#__PURE__*/React.createElement("span", {
1178
+ className: "fontRegular fontSize-13"
1179
+ }, "Please add the many categories of request types that exist in your village which work alongside the Maintenance area.")), /*#__PURE__*/React.createElement("div", {
1180
+ className: "marginTop-8 fontRegular fontSize-13",
1181
+ style: {
1182
+ maxWidth: 500,
1183
+ textAlign: 'center'
1184
+ }
1185
+ }, "Examples might be; OH&S, Electrical, General. Remember to add a description too."));
1186
+ }
1187
+ }, {
1188
+ key: "renderContent",
1189
+ value: function renderContent() {
1190
+ if (_.isEmpty(this.state.jobList)) return this.renderEmpty();
1191
+ return this.renderView();
1192
+ }
1193
+ }, {
1194
+ key: "renderJobTypes",
1195
+ value: function renderJobTypes() {
1196
+ var _this4 = this;
1245
1197
 
1246
- newAttachments.splice(index, 1);
1198
+ var _this$state3 = this.state,
1199
+ jobList = _this$state3.jobList,
1200
+ loading = _this$state3.loading;
1247
1201
 
1248
- _this.setState({
1249
- noteAttachments: newAttachments
1250
- });
1202
+ if (jobList.length === 0 && loading) {
1203
+ return /*#__PURE__*/React.createElement("div", {
1204
+ style: {
1205
+ minWidth: '100%'
1206
+ }
1207
+ }, /*#__PURE__*/React.createElement("div", {
1208
+ className: "padding-60 paddingVertical-40",
1209
+ style: {
1210
+ textAlign: 'center'
1211
+ }
1212
+ }, /*#__PURE__*/React.createElement(FontAwesome, {
1213
+ style: {
1214
+ fontSize: 30,
1215
+ color: FeatureConfig.env.colourBrandingOff
1216
+ },
1217
+ name: "spinner fa-pulse fa-fw"
1218
+ })));
1251
1219
  }
1252
- });
1253
-
1254
- _defineProperty(_assertThisInitialized(_this), "onConfirmAddNote", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
1255
- var res;
1256
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
1257
- while (1) {
1258
- switch (_context2.prev = _context2.next) {
1259
- case 0:
1260
- if (_this.isReadyToSaveNote()) {
1261
- _context2.next = 2;
1262
- break;
1263
- }
1264
-
1265
- return _context2.abrupt("return");
1266
1220
 
1267
- case 2:
1268
- _context2.prev = 2;
1221
+ return /*#__PURE__*/React.createElement("div", {
1222
+ style: {
1223
+ minWidth: '100%'
1224
+ }
1225
+ }, /*#__PURE__*/React.createElement("div", {
1226
+ className: "marginBottom-32"
1227
+ }, /*#__PURE__*/React.createElement(Components$3.AddButton, {
1228
+ onClick: function onClick() {
1229
+ return _this4.onShowJobType();
1230
+ },
1231
+ text: "NEW REQUEST TYPE"
1232
+ })), this.renderContent());
1233
+ }
1234
+ }, {
1235
+ key: "renderNewUserTypePopup",
1236
+ value: function renderNewUserTypePopup() {
1237
+ var _this5 = this;
1269
1238
 
1270
- _this.setState({
1271
- submittingNote: true
1272
- });
1239
+ var _this$state4 = this.state,
1240
+ submitting = _this$state4.submitting,
1241
+ showJobType = _this$state4.showJobType,
1242
+ jobTypeId = _this$state4.jobTypeId,
1243
+ showWarnings = _this$state4.showWarnings,
1244
+ jobTypeName = _this$state4.jobTypeName,
1245
+ jobTypeEmail = _this$state4.jobTypeEmail,
1246
+ jobTypeDescription = _this$state4.jobTypeDescription;
1247
+ if (!showJobType) return null;
1248
+ return /*#__PURE__*/React.createElement(Components$3.Popup, {
1249
+ maxWidth: 800,
1250
+ hasPadding: true,
1251
+ buttons: [{
1252
+ type: 'primaryAction',
1253
+ onClick: this.onSave,
1254
+ isActive: !submitting && this.isJobTypeValid(),
1255
+ text: submitting ? 'Saving...' : 'Save',
1256
+ className: 'popupButton'
1257
+ }, {
1258
+ type: 'outlinedAction',
1259
+ onClick: this.onHideJobType,
1260
+ isActive: !submitting,
1261
+ text: 'Cancel',
1262
+ className: 'popupButton'
1263
+ }],
1264
+ onClose: this.onHideJobType,
1265
+ title: jobTypeId ? 'Edit Request Type' : 'Create New Request Type'
1266
+ }, /*#__PURE__*/React.createElement(Components$3.GenericInput, {
1267
+ id: "jobTypeName",
1268
+ type: "text",
1269
+ label: "Request type title",
1270
+ placeholder: "Request type title",
1271
+ value: jobTypeName,
1272
+ onChange: this.onHandleChange,
1273
+ isRequired: true,
1274
+ isValid: function isValid() {
1275
+ return !_.isEmpty(jobTypeName);
1276
+ },
1277
+ showError: function showError() {
1278
+ return showWarnings && _.isEmpty(jobTypeName);
1279
+ },
1280
+ alwaysShowLabel: true
1281
+ }), /*#__PURE__*/React.createElement(Components$3.GenericInput, {
1282
+ id: "jobTypeEmail",
1283
+ type: "text",
1284
+ label: "Email",
1285
+ placeholder: "Request email",
1286
+ help: "This is the email address that'll receive service requests of this type",
1287
+ value: jobTypeEmail,
1288
+ onChange: this.onHandleChange,
1289
+ isRequired: true,
1290
+ isValid: this.validateEmail,
1291
+ showError: function showError() {
1292
+ return showWarnings && !_this5.validateEmail();
1293
+ },
1294
+ alwaysShowLabel: true
1295
+ }), /*#__PURE__*/React.createElement(Components$3.GenericInput, {
1296
+ id: "jobTypeDescription",
1297
+ type: "text",
1298
+ label: "Description",
1299
+ placeholder: "Add a description. ",
1300
+ help: "This description will be visible to the people to help them select the correct request type.",
1301
+ value: jobTypeDescription,
1302
+ onChange: this.onHandleChange,
1303
+ isRequired: true,
1304
+ isValid: function isValid() {
1305
+ return !_.isEmpty(jobTypeDescription);
1306
+ },
1307
+ showError: function showError() {
1308
+ return showWarnings && _.isEmpty(jobTypeDescription);
1309
+ },
1310
+ alwaysShowLabel: true
1311
+ }));
1312
+ }
1313
+ }, {
1314
+ key: "render",
1315
+ value: function render() {
1316
+ return /*#__PURE__*/React.createElement("div", {
1317
+ style: {
1318
+ minWidth: '100%'
1319
+ }
1320
+ }, /*#__PURE__*/React.createElement("div", null, this.renderJobTypes()), this.renderNewUserTypePopup(), /*#__PURE__*/React.createElement("div", {
1321
+ className: "hub_tidioPadding"
1322
+ }));
1323
+ }
1324
+ }]);
1273
1325
 
1274
- _context2.next = 6;
1275
- return _this.state.editingNote ? maintenanceActions.editNote(_this.state.jobId, _this.state.editingNote, _this.state.noteInput, _this.state.noteAttachments.map(function (a) {
1276
- return {
1277
- Title: a.Title,
1278
- Source: a.Source
1279
- };
1280
- })) : maintenanceActions.addNote(_this.state.jobId, _this.state.noteInput, _this.state.noteAttachments.map(function (a) {
1281
- return {
1282
- Title: a.Title,
1283
- Source: a.Source
1284
- };
1285
- }));
1326
+ return JobTypes;
1327
+ }(Component);
1286
1328
 
1287
- case 6:
1288
- res = _context2.sent;
1329
+ var mapStateToProps$3 = function mapStateToProps(state) {
1330
+ var jobtypes = state.maintenance.jobtypes;
1331
+ var auth = state.auth;
1332
+ return {
1333
+ jobtypes: jobtypes,
1334
+ auth: auth
1335
+ };
1336
+ };
1289
1337
 
1290
- _this.setState({
1291
- job: res.data.job,
1292
- submittingNote: false,
1293
- addNoteOpen: false,
1294
- noteInput: '',
1295
- noteAttachments: [],
1296
- editingNote: null
1297
- }, function () {
1298
- _this.props.jobsLoaded([_this.state.job]);
1299
- });
1338
+ var JobTypes$1 = connect(mapStateToProps$3, {
1339
+ jobTypesLoaded: jobTypesLoaded,
1340
+ jobTypesUpdate: jobTypesUpdate
1341
+ })(withRouter(JobTypes));
1300
1342
 
1301
- _context2.next = 13;
1302
- break;
1343
+ function _createSuper$8(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$8(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
1303
1344
 
1304
- case 10:
1305
- _context2.prev = 10;
1306
- _context2.t0 = _context2["catch"](2);
1307
- console.error('onConfirmAddNote', _context2.t0);
1345
+ function _isNativeReflectConstruct$8() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
1346
+ var Components$2 = PlussCore.Components,
1347
+ Session$2 = PlussCore.Session;
1308
1348
 
1309
- case 13:
1310
- case "end":
1311
- return _context2.stop();
1312
- }
1313
- }
1314
- }, _callee2, null, [[2, 10]]);
1315
- })));
1349
+ var RequestsHub = /*#__PURE__*/function (_Component) {
1350
+ _inherits(RequestsHub, _Component);
1316
1351
 
1317
- _defineProperty(_assertThisInitialized(_this), "onDeleteNote", function (n) {
1318
- if (!window.confirm('Are you sure you want to delete that note?')) {
1319
- _this.setState({
1320
- noteMenuOpen: null
1321
- });
1352
+ var _super = _createSuper$8(RequestsHub);
1322
1353
 
1323
- return;
1324
- }
1354
+ function RequestsHub(props) {
1355
+ var _this;
1325
1356
 
1326
- maintenanceActions.deleteNote(_this.state.jobId, n.Id);
1357
+ _classCallCheck(this, RequestsHub);
1327
1358
 
1328
- var newNotes = _.filter(_this.state.job.Notes, function (note) {
1329
- return note.Id !== n.Id;
1330
- });
1359
+ _this = _super.call(this, props);
1331
1360
 
1332
- var newJob = _objectSpread$3({}, _this.state.job);
1361
+ _defineProperty(_assertThisInitialized(_this), "setData", function () {
1362
+ var allList = [];
1333
1363
 
1334
- newJob.Notes = newNotes;
1364
+ _this.state.allList.forEach(function (ev) {
1365
+ if (ev != null && !ev.Deleted) allList.push(ev);
1366
+ });
1335
1367
 
1336
- _this.setState({
1337
- job: newJob,
1338
- noteMenuOpen: null
1368
+ var upcoming = _.filter(allList, function (ev) {
1369
+ if (!ev) return false;
1370
+ if (ev.status && ev.status === 'Completed') return false;
1371
+ return true;
1339
1372
  });
1340
- });
1341
1373
 
1342
- _defineProperty(_assertThisInitialized(_this), "onOpenEditNote", function (n) {
1374
+ var completed = _.filter(allList, function (ev) {
1375
+ if (!ev) return false;
1376
+ if (ev.status && ev.status === 'Completed') return true;
1377
+ return false;
1378
+ }); // console.log('setData', upcoming, completed);
1379
+
1380
+
1343
1381
  _this.setState({
1344
- noteAttachments: n.Attachments || [],
1345
- noteInput: n.Note || '',
1346
- addNoteOpen: true,
1347
- editingNote: n.Id,
1348
- noteMenuOpen: null
1382
+ allList: allList,
1383
+ upcoming: upcoming,
1384
+ completed: completed
1349
1385
  });
1350
1386
  });
1351
1387
 
1352
- _defineProperty(_assertThisInitialized(_this), "markSeen", function () {
1353
- var job = _this.state.job;
1354
- var auth = _this.props.auth; // Must have maintenance permission and not the requester
1355
-
1356
- if (!Session$2.validateAccess(auth.site, 'maintenanceTracking', auth)) return;
1357
- if (auth.user.Id === job.userID) return;
1388
+ _defineProperty(_assertThisInitialized(_this), "getData", function () {
1389
+ var auth = _this.props.auth;
1358
1390
 
1359
1391
  _this.setState({
1360
- updating: true
1361
- }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
1362
- var update;
1363
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
1392
+ loadingAll: true
1393
+ }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
1394
+ var res;
1395
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
1364
1396
  while (1) {
1365
- switch (_context3.prev = _context3.next) {
1397
+ switch (_context.prev = _context.next) {
1366
1398
  case 0:
1367
- _context3.prev = 0;
1368
- update = {
1369
- id: job.id,
1370
- seen: true,
1371
- status: job.status || 'Unassigned'
1372
- };
1373
- _context3.next = 4;
1374
- return maintenanceActions.editJob(update, auth.site);
1399
+ _context.prev = 0;
1400
+ _context.next = 3;
1401
+ return maintenanceActions.getJobs(auth.site);
1375
1402
 
1376
- case 4:
1377
- _context3.next = 11;
1403
+ case 3:
1404
+ res = _context.sent;
1405
+
1406
+ // console.log('getData', res.data);
1407
+ _this.setState({
1408
+ loadingAll: false
1409
+ });
1410
+
1411
+ if (res.data != null && !_.isEmpty(res.data) && res.data[0].site === auth.site) {
1412
+ _this.props.jobsLoaded(res.data);
1413
+ }
1414
+
1415
+ _context.next = 12;
1378
1416
  break;
1379
1417
 
1380
- case 6:
1381
- _context3.prev = 6;
1382
- _context3.t0 = _context3["catch"](0);
1418
+ case 8:
1419
+ _context.prev = 8;
1420
+ _context.t0 = _context["catch"](0);
1421
+ console.error('getData', _context.t0);
1383
1422
 
1384
1423
  _this.setState({
1385
- updating: false
1424
+ loadingAll: false
1386
1425
  });
1387
1426
 
1388
- console.log('markSeen error', _context3.t0);
1389
- alert('Something went wrong with the request. Please try again.');
1390
-
1391
- case 11:
1427
+ case 12:
1392
1428
  case "end":
1393
- return _context3.stop();
1429
+ return _context.stop();
1394
1430
  }
1395
1431
  }
1396
- }, _callee3, null, [[0, 6]]);
1432
+ }, _callee, null, [[0, 8]]);
1397
1433
  })));
1398
1434
  });
1399
1435
 
1400
- _defineProperty(_assertThisInitialized(_this), "getComments", function () {
1401
- reactionActions.getComments(_this.state.jobId, 'maintenancerequest', 0).then(function (res) {
1402
- _this.setState({
1403
- comments: res.data
1404
- });
1405
- });
1436
+ _defineProperty(_assertThisInitialized(_this), "onAddNew", function () {
1437
+ var auth = _this.props.auth;
1438
+
1439
+ if (Session$2.validateAccess(auth.site, 'maintenanceTracking', auth)) {
1440
+ _this.props.history.push("/requestsHub/job");
1441
+ }
1406
1442
  });
1407
1443
 
1408
- _defineProperty(_assertThisInitialized(_this), "onAddComment", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
1409
- var _this$state2, commentInput, jobId, job, comments, res;
1410
-
1411
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
1412
- while (1) {
1413
- switch (_context4.prev = _context4.next) {
1414
- case 0:
1415
- _this$state2 = _this.state, commentInput = _this$state2.commentInput, jobId = _this$state2.jobId, job = _this$state2.job, comments = _this$state2.comments;
1416
- _context4.prev = 1;
1417
-
1418
- _this.setState({
1419
- commentInput: ''
1420
- });
1421
-
1422
- _context4.next = 5;
1423
- return reactionActions.addComment(jobId, 'maintenancerequest', job.title, job.site, commentInput);
1424
-
1425
- case 5:
1426
- res = _context4.sent;
1427
-
1428
- _this.setState({
1429
- comments: [].concat(_toConsumableArray(comments), [res.data])
1430
- });
1431
-
1432
- _context4.next = 12;
1433
- break;
1434
-
1435
- case 9:
1436
- _context4.prev = 9;
1437
- _context4.t0 = _context4["catch"](1);
1438
- console.error('onAddComment', _context4.t0);
1439
-
1440
- case 12:
1441
- case "end":
1442
- return _context4.stop();
1443
- }
1444
- }
1445
- }, _callee4, null, [[1, 9]]);
1446
- })));
1447
-
1448
- _defineProperty(_assertThisInitialized(_this), "onHandleChange", function (event) {
1449
- var stateChange = {};
1450
- stateChange[event.target.getAttribute('id')] = event.target.value;
1451
-
1452
- _this.setState(stateChange);
1444
+ _defineProperty(_assertThisInitialized(_this), "canAddNew", function (isClass) {
1445
+ var auth = _this.props.auth;
1446
+ if (Session$2.validateAccess(auth.site, 'maintenanceTracking', auth)) return isClass ? '' : true;
1447
+ return isClass ? ' hub-sideContent-topButton--hide' : false;
1453
1448
  });
1454
1449
 
1455
- _defineProperty(_assertThisInitialized(_this), "onToggleStatusChanger", function () {
1456
- _this.setState({
1457
- statusChangerOpen: !_this.state.statusChangerOpen
1458
- });
1450
+ _defineProperty(_assertThisInitialized(_this), "getSideBarSectionColour", function (id) {
1451
+ return _this.state.selectedSection === id ? {
1452
+ backgroundColor: '#fff'
1453
+ } : {};
1459
1454
  });
1460
1455
 
1461
- _defineProperty(_assertThisInitialized(_this), "onSelectStatus", /*#__PURE__*/function () {
1462
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(status) {
1463
- var res;
1464
- return _regeneratorRuntime.wrap(function _callee5$(_context5) {
1465
- while (1) {
1466
- switch (_context5.prev = _context5.next) {
1467
- case 0:
1468
- _this.setState({
1469
- job: _objectSpread$3(_objectSpread$3({}, _this.state.job), {}, {
1470
- status: status
1471
- }),
1472
- statusChangerOpen: false
1473
- });
1474
-
1475
- _context5.prev = 1;
1476
- _context5.next = 4;
1477
- return maintenanceActions.editJobStatus(_this.state.job.id, status);
1478
-
1479
- case 4:
1480
- res = _context5.sent;
1481
-
1482
- _this.setState({
1483
- job: res.data.job
1484
- }, function () {
1485
- _this.props.jobsLoaded([_this.state.job]);
1486
- });
1487
-
1488
- _context5.next = 11;
1489
- break;
1490
-
1491
- case 8:
1492
- _context5.prev = 8;
1493
- _context5.t0 = _context5["catch"](1);
1494
- console.error('onSelectStatus', _context5.t0);
1495
-
1496
- case 11:
1497
- case "end":
1498
- return _context5.stop();
1499
- }
1500
- }
1501
- }, _callee5, null, [[1, 8]]);
1502
- }));
1503
-
1504
- return function (_x) {
1505
- return _ref5.apply(this, arguments);
1506
- };
1507
- }());
1456
+ _defineProperty(_assertThisInitialized(_this), "renderStats", function (stat, loading) {
1457
+ return loading ? /*#__PURE__*/React.createElement(FontAwesome, {
1458
+ style: styles$4.spinner,
1459
+ name: "spinner fa-pulse fa-fw"
1460
+ }) : stat;
1461
+ });
1508
1462
 
1509
1463
  _this.state = {
1510
- jobId: Helper$2.safeReadParams(props, 'jobId') ? props.match.params.jobId : null,
1511
- job: null,
1512
- showingSelector: false,
1513
- updating: false,
1514
- comments: [],
1515
- commentInput: '',
1516
- loadingComments: false,
1517
- statusChangerOpen: false,
1518
- addNoteOpen: false,
1519
- noteAttachments: [],
1520
- noteInput: ''
1464
+ selectedSection: 'all',
1465
+ location: '',
1466
+ loadingAll: false,
1467
+ loadingSubmissions: false,
1468
+ submissionEntries: [],
1469
+ allList: [],
1470
+ completed: [],
1471
+ upcoming: [],
1472
+ now: moment.utc(),
1473
+ onlyFuture: true,
1474
+ search: ''
1521
1475
  };
1522
1476
  return _this;
1523
1477
  }
1524
1478
 
1525
- _createClass(Job, [{
1526
- key: "UNSAFE_componentWillReceiveProps",
1527
- value: function UNSAFE_componentWillReceiveProps(nextProps) {
1528
- Session$2.checkLoggedIn(this, this.props.auth);
1479
+ _createClass(RequestsHub, [{
1480
+ key: "UNSAFE_componentWillMount",
1481
+ value: function UNSAFE_componentWillMount() {
1482
+ this.updateProps(this.props);
1529
1483
  }
1530
1484
  }, {
1531
1485
  key: "componentDidMount",
1532
1486
  value: function componentDidMount() {
1533
- if (this.state.jobId) {
1534
- this.getJob();
1535
- this.getComments();
1536
- }
1487
+ this.getData();
1537
1488
  }
1538
1489
  }, {
1539
- key: "renderStatusLabel",
1540
- value: function renderStatusLabel() {
1541
- if (!this.state.job.status) return null;
1542
- var auth = this.props.auth;
1543
-
1544
- if (Session$2.validateAccess(auth.site, 'maintenanceTracking', auth)) {
1545
- return /*#__PURE__*/React.createElement("div", {
1546
- className: "statusLabel pointer",
1547
- onClick: this.onToggleStatusChanger,
1548
- style: {
1549
- backgroundColor: StatusTypes[this.state.job.status].color
1550
- }
1551
- }, /*#__PURE__*/React.createElement("span", {
1552
- className: "statusLabel_text"
1553
- }, StatusTypes[this.state.job.status].text), this.renderStatusChanger());
1554
- }
1555
-
1556
- return /*#__PURE__*/React.createElement("div", {
1557
- className: "statusLabel",
1558
- style: {
1559
- backgroundColor: StatusTypes[this.state.job.status].color
1560
- }
1561
- }, /*#__PURE__*/React.createElement("span", {
1562
- className: "statusLabel_text"
1563
- }, StatusTypes[this.state.job.status].text));
1490
+ key: "UNSAFE_componentWillReceiveProps",
1491
+ value: function UNSAFE_componentWillReceiveProps(nextProps) {
1492
+ if (!_.isEqual(this.props.jobs, nextProps.jobs)) this.updateProps(nextProps);
1564
1493
  }
1565
1494
  }, {
1566
- key: "renderNotesButton",
1567
- value: function renderNotesButton() {
1568
- var auth = this.props.auth;
1569
- if (!Session$2.validateAccess(auth.site, 'maintenanceTracking', auth)) return null;
1570
- return /*#__PURE__*/React.createElement("div", {
1571
- className: "statusLabel pointer",
1572
- onClick: this.onOpenAddNote,
1573
- style: {
1574
- backgroundColor: FeatureConfig.env.colourBrandingMain,
1575
- marginLeft: 8
1576
- }
1577
- }, /*#__PURE__*/React.createElement("span", {
1578
- className: "statusLabel_text"
1579
- }, "Add Note"));
1495
+ key: "updateProps",
1496
+ value: function updateProps(props) {
1497
+ this.setState({
1498
+ allList: props.jobs
1499
+ }, this.setData);
1580
1500
  }
1581
1501
  }, {
1582
- key: "renderStatusChanger",
1583
- value: function renderStatusChanger() {
1502
+ key: "renderLeftBar",
1503
+ value: function renderLeftBar() {
1584
1504
  var _this2 = this;
1585
1505
 
1586
- if (!this.state.statusChangerOpen) return null;
1587
- return /*#__PURE__*/React.createElement("div", {
1588
- className: "statusChanger statusChanger-maintenance"
1589
- }, Object.keys(StatusTypes).map(function (statusKey) {
1590
- return /*#__PURE__*/React.createElement("div", {
1591
- key: statusKey,
1592
- className: "statusLabel",
1506
+ var sectionItems = [];
1507
+
1508
+ if (this.canAddNew()) {
1509
+ sectionItems.push({
1510
+ type: 'newButton',
1511
+ text: 'New Request',
1512
+ onClick: this.onAddNew
1513
+ });
1514
+ }
1515
+
1516
+ sectionItems.push({
1517
+ type: 'navItem',
1518
+ text: 'View Requests',
1519
+ icon: 'eye',
1520
+ isFontAwesome: true,
1521
+ selected: this.state.selectedSection === 'all',
1522
+ onClick: function onClick() {
1523
+ _this2.setState({
1524
+ selectedSection: 'all'
1525
+ });
1526
+ }
1527
+ });
1528
+
1529
+ if (Session$2.validateAccess(this.props.auth.site, 'maintenanceTypes', this.props.auth)) {
1530
+ sectionItems.push({
1531
+ type: 'navItem',
1532
+ text: 'Request Types',
1533
+ // icon: 'maintenance2',
1534
+ // isSVG: true,
1535
+ selected: this.state.selectedSection === 'requestTypes',
1593
1536
  onClick: function onClick() {
1594
- return _this2.onSelectStatus(statusKey);
1595
- },
1596
- style: {
1597
- backgroundColor: StatusTypes[statusKey].color
1537
+ _this2.setState({
1538
+ selectedSection: 'requestTypes'
1539
+ });
1598
1540
  }
1599
- }, /*#__PURE__*/React.createElement("span", {
1600
- className: "statusLabel_text"
1601
- }, StatusTypes[statusKey].text));
1602
- }));
1541
+ });
1542
+ }
1543
+
1544
+ return /*#__PURE__*/React.createElement(Components$2.HubSidebar, {
1545
+ sections: [{
1546
+ title: 'Requests',
1547
+ items: sectionItems
1548
+ }]
1549
+ });
1603
1550
  }
1604
1551
  }, {
1605
- key: "renderComment",
1606
- value: function renderComment(c) {
1607
- return /*#__PURE__*/React.createElement("div", {
1608
- key: c.Id,
1609
- className: "comment"
1610
- }, /*#__PURE__*/React.createElement("p", {
1611
- className: "comment_text"
1612
- }, Helper$2.toParagraphed(c.Comment)), /*#__PURE__*/React.createElement("div", {
1613
- className: "comment_bottom"
1614
- }, /*#__PURE__*/React.createElement(Components$2.ProfilePic, {
1615
- className: "comment_profilePic",
1616
- size: 25,
1617
- image: c.User.profilePic
1618
- }), /*#__PURE__*/React.createElement("p", {
1619
- className: "comment_name"
1620
- }, c.User.displayName), /*#__PURE__*/React.createElement("p", {
1621
- className: "comment_time"
1622
- }, moment.utc(c.Timestamp).local().format('D MMM YYYY • h:mma'))));
1552
+ key: "renderRight",
1553
+ value: function renderRight() {
1554
+ if (this.state.selectedSection === 'requestTypes') {
1555
+ return /*#__PURE__*/React.createElement(JobTypes$1, null);
1556
+ }
1557
+
1558
+ return /*#__PURE__*/React.createElement(JobList$1, {
1559
+ source: this.state.allList
1560
+ });
1623
1561
  }
1624
1562
  }, {
1625
- key: "renderCommentSection",
1626
- value: function renderCommentSection() {
1627
- var _this3 = this;
1628
-
1629
- if (this.state.loadingComments) return null;
1563
+ key: "render",
1564
+ value: function render() {
1630
1565
  return /*#__PURE__*/React.createElement("div", {
1631
- className: "padding-60 paddingLeft-20"
1632
- }, /*#__PURE__*/React.createElement("div", {
1633
- className: "newTopBar paddingLeft-40"
1634
- }, /*#__PURE__*/React.createElement(Components$2.Text, {
1635
- type: "formTitleSmall",
1636
- className: "marginBottom-16"
1637
- }, "Comments"), /*#__PURE__*/React.createElement("div", {
1638
- className: "commentSection"
1639
- }, this.state.comments.map(function (c) {
1640
- return _this3.renderComment(c);
1641
- })), /*#__PURE__*/React.createElement("div", {
1642
- className: "commentReply"
1643
- }, /*#__PURE__*/React.createElement("div", {
1644
- className: "commentReply_button".concat(!_.isEmpty(this.state.commentInput) ? ' commentReply_button-active' : ''),
1645
- onClick: this.onAddComment
1646
- }, /*#__PURE__*/React.createElement(FontAwesome, {
1647
- className: "commentReply_icon",
1648
- name: "paper-plane-o"
1649
- })), /*#__PURE__*/React.createElement(Textarea, {
1650
- id: "commentInput",
1651
- placeholder: "Reply here...",
1652
- type: "text",
1653
- className: "commentReply_input",
1654
- value: this.state.commentInput,
1655
- onChange: function onChange(e) {
1656
- return _this3.onHandleChange(e);
1657
- }
1658
- }))));
1659
- }
1660
- }, {
1661
- key: "renderInner",
1662
- value: function renderInner() {
1663
- if (this.state.job == null) return null;
1664
- return /*#__PURE__*/React.createElement("div", {
1665
- style: {
1666
- paddingBottom: 40
1667
- }
1668
- }, /*#__PURE__*/React.createElement("div", {
1669
- className: "padding-60 paddingVertical-40 bottomDivideBorder relative"
1670
- }, /*#__PURE__*/React.createElement(Components$2.Text, {
1671
- type: "formTitleLarge",
1672
- className: "marginBottom-24"
1673
- }, this.state.job.title || 'Request'), /*#__PURE__*/React.createElement("div", {
1674
- className: "marginTop-16"
1675
- }, /*#__PURE__*/React.createElement("div", {
1676
- className: 'fieldLabel'
1677
- }, "Request date"), /*#__PURE__*/React.createElement("div", {
1678
- className: 'fontRegular fontSize-16 text-dark marginTop-5'
1679
- }, moment.utc(this.state.job.createdTime).local().format('D MMM YY'))), /*#__PURE__*/React.createElement("div", {
1680
- className: "marginTop-16"
1681
- }, /*#__PURE__*/React.createElement("div", {
1682
- className: 'fieldLabel'
1683
- }, "Type"), /*#__PURE__*/React.createElement("div", {
1684
- className: 'fontRegular fontSize-16 text-dark marginTop-5'
1685
- }, this.state.job.type)), /*#__PURE__*/React.createElement("div", {
1686
- className: "marginTop-16"
1687
- }, /*#__PURE__*/React.createElement("div", {
1688
- className: 'fieldLabel'
1689
- }, "Location"), /*#__PURE__*/React.createElement("div", {
1690
- className: 'fontRegular fontSize-16 text-dark marginTop-5'
1691
- }, this.state.job.room)), /*#__PURE__*/React.createElement("div", {
1692
- className: "marginTop-16"
1693
- }, /*#__PURE__*/React.createElement("div", {
1694
- className: 'fieldLabel'
1695
- }, "Description ", this.state.job.image ? '- (image supplied)' : ''), /*#__PURE__*/React.createElement("div", {
1696
- className: 'fontRegular fontSize-16 text-dark marginTop-5'
1697
- }, this.state.job.description))), /*#__PURE__*/React.createElement("div", {
1698
- className: "padding-60 paddingVertical-40 bottomDivideBorder"
1699
- }, /*#__PURE__*/React.createElement(Components$2.Text, {
1700
- type: "formTitleSmall",
1701
- className: "marginBottom-16"
1702
- }, "Contact Details"), /*#__PURE__*/React.createElement("div", {
1703
- className: "marginTop-16"
1704
- }, /*#__PURE__*/React.createElement("div", {
1705
- className: 'fieldLabel'
1706
- }, "Name"), /*#__PURE__*/React.createElement("div", {
1707
- className: 'fontRegular fontSize-16 text-dark marginTop-5'
1708
- }, this.state.job.userName)), /*#__PURE__*/React.createElement("div", {
1709
- className: "marginTop-16"
1710
- }, /*#__PURE__*/React.createElement("div", {
1711
- className: 'fieldLabel'
1712
- }, "Contact number"), /*#__PURE__*/React.createElement("div", {
1713
- className: 'fontRegular fontSize-16 text-dark marginTop-5'
1714
- }, _.isEmpty(this.state.job.phone) ? 'No phone provided' : this.state.job.phone)), /*#__PURE__*/React.createElement("div", {
1715
- className: "marginTop-16"
1716
- }, /*#__PURE__*/React.createElement("div", {
1717
- className: 'fieldLabel'
1718
- }, "Should person be home?"), /*#__PURE__*/React.createElement("div", {
1719
- className: 'fontRegular fontSize-16 text-dark marginTop-5'
1720
- }, this.state.job.isHome ? 'Yes' : 'No')), this.state.job.isHome && this.state.job.homeText && /*#__PURE__*/React.createElement("div", {
1721
- className: "marginTop-16"
1722
- }, /*#__PURE__*/React.createElement("div", {
1723
- className: 'fieldLabel'
1724
- }, "When"), /*#__PURE__*/React.createElement("div", {
1725
- className: 'fontRegular fontSize-16 text-dark marginTop-5'
1726
- }, this.state.job.homeText))), (this.state.job.image || this.state.job.images) && /*#__PURE__*/React.createElement("div", {
1727
- className: "padding-60 paddingVertical-40 bottomDivideBorder"
1728
- }, /*#__PURE__*/React.createElement(Components$2.Text, {
1729
- type: "formTitleSmall",
1730
- className: "marginBottom-16"
1731
- }, "Image"), /*#__PURE__*/React.createElement("div", {
1732
- style: {
1733
- marginTop: 16,
1734
- height: 180,
1735
- width: 260,
1736
- borderRadius: 4,
1737
- border: '1px solid #aaa',
1738
- backgroundColor: '#ddd',
1739
- backgroundImage: "url(".concat(this.state.job.thumbnail, ")"),
1740
- backgroundPosition: 'center'
1741
- }
1742
- })), this.renderCommentSection());
1566
+ className: "hub-wrapperContainer"
1567
+ }, this.renderLeftBar(), /*#__PURE__*/React.createElement("div", {
1568
+ className: "hub-headerContentWrapper"
1569
+ }, /*#__PURE__*/React.createElement(Components$2.Header, null), /*#__PURE__*/React.createElement("div", {
1570
+ className: "hub-contentWrapper"
1571
+ }, this.renderRight())));
1743
1572
  }
1744
- }, {
1745
- key: "renderHistoryEntry",
1746
- value: function renderHistoryEntry(e, i) {
1747
- var job = this.state.job;
1748
- var entryToUse = e || {
1749
- timestamp: job.createdTime,
1750
- status: 'Unassigned',
1751
- user: {
1752
- displayName: job.userName,
1753
- id: job.userID,
1754
- profilePic: job.userProfilePic
1573
+ }]);
1574
+
1575
+ return RequestsHub;
1576
+ }(Component);
1577
+
1578
+ var styles$4 = {
1579
+ sideBarTitleSection: {
1580
+ lineHeight: '40px',
1581
+ marginTop: 30,
1582
+ marginBottom: 30,
1583
+ paddingLeft: 24,
1584
+ paddingRight: 24
1585
+ },
1586
+ sideBarSection: {
1587
+ weight: '100%',
1588
+ minWidth: 200,
1589
+ padding: 32,
1590
+ paddingLeft: 24,
1591
+ cursor: 'pointer',
1592
+ display: 'flex',
1593
+ flexDirection: 'column',
1594
+ justifyContent: 'center'
1595
+ },
1596
+ spinner: {
1597
+ fontSize: 32,
1598
+ color: FeatureConfig.env.colourBrandingOff
1599
+ }
1600
+ };
1601
+
1602
+ var mapStateToProps$2 = function mapStateToProps(state) {
1603
+ var jobs = state.maintenance.jobs;
1604
+ var auth = state.auth;
1605
+ return {
1606
+ jobs: jobs,
1607
+ auth: auth
1608
+ };
1609
+ };
1610
+
1611
+ var RequestsHub$1 = connect(mapStateToProps$2, {
1612
+ jobsLoaded: jobsLoaded
1613
+ })(withRouter(RequestsHub));
1614
+
1615
+ function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
1616
+
1617
+ function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$3(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
1618
+
1619
+ function _createSuper$7(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$7(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
1620
+
1621
+ function _isNativeReflectConstruct$7() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
1622
+ var Apis = PlussCore.Apis,
1623
+ Helper$1 = PlussCore.Helper,
1624
+ Session$1 = PlussCore.Session,
1625
+ Colours = PlussCore.Colours,
1626
+ Components$1 = PlussCore.Components;
1627
+
1628
+ var Job = /*#__PURE__*/function (_Component) {
1629
+ _inherits(Job, _Component);
1630
+
1631
+ var _super = _createSuper$7(Job);
1632
+
1633
+ function Job(props) {
1634
+ var _this;
1635
+
1636
+ _classCallCheck(this, Job);
1637
+
1638
+ _this = _super.call(this, props);
1639
+
1640
+ _defineProperty(_assertThisInitialized(_this), "getJob", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
1641
+ var res;
1642
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
1643
+ while (1) {
1644
+ switch (_context.prev = _context.next) {
1645
+ case 0:
1646
+ _context.prev = 0;
1647
+ _context.next = 3;
1648
+ return maintenanceActions.getJob(_this.props.auth.site, _this.state.jobId);
1649
+
1650
+ case 3:
1651
+ res = _context.sent;
1652
+
1653
+ _this.setState({
1654
+ updating: false
1655
+ });
1656
+
1657
+ res.data.location = res.data.site;
1658
+
1659
+ _this.setJob(res.data);
1660
+
1661
+ _context.next = 12;
1662
+ break;
1663
+
1664
+ case 9:
1665
+ _context.prev = 9;
1666
+ _context.t0 = _context["catch"](0);
1667
+ console.error('getJob', _context.t0);
1668
+
1669
+ case 12:
1670
+ case "end":
1671
+ return _context.stop();
1672
+ }
1755
1673
  }
1674
+ }, _callee, null, [[0, 9]]);
1675
+ })));
1676
+
1677
+ _defineProperty(_assertThisInitialized(_this), "setJob", function (job) {
1678
+ job.typeIcon = job.type === 'General' ? 'wrench' : 'tree';
1679
+ job.typeColour = job.type === 'General' ? '#666' : 'green';
1680
+
1681
+ if (_.isEmpty(job.lastActivity)) {
1682
+ job.lastActivity = '-- --';
1683
+ job.noActivity = true;
1684
+ }
1685
+
1686
+ if (_.isEmpty(job.status)) {
1687
+ job.status = 'Unassigned';
1688
+ job.notStatus = true;
1689
+ }
1690
+
1691
+ if (_.isEmpty(job.audience)) {
1692
+ job.audience = [{
1693
+ displayName: 'Unassigned',
1694
+ isEmpty: true
1695
+ }];
1696
+ }
1697
+
1698
+ var needToMarkSeen = false;
1699
+
1700
+ if (!job.seen) {
1701
+ job.seen = true;
1702
+ needToMarkSeen = true;
1703
+ }
1704
+
1705
+ _this.setState({
1706
+ job: job
1707
+ }, function () {
1708
+ if (needToMarkSeen) _this.markSeen();
1709
+ });
1710
+
1711
+ _this.props.jobsLoaded([job]);
1712
+ });
1713
+
1714
+ _defineProperty(_assertThisInitialized(_this), "editJob", function () {});
1715
+
1716
+ _defineProperty(_assertThisInitialized(_this), "isReadyToSaveNote", function () {
1717
+ var _this$state = _this.state,
1718
+ noteAttachments = _this$state.noteAttachments,
1719
+ noteInput = _this$state.noteInput;
1720
+ if (_.some(noteAttachments, function (n) {
1721
+ return n.Uploading;
1722
+ })) return false;
1723
+ return !_.isEmpty(noteInput) || !_.isEmpty(noteAttachments);
1724
+ });
1725
+
1726
+ _defineProperty(_assertThisInitialized(_this), "onOpenAddNote", function () {
1727
+ _this.setState({
1728
+ addNoteOpen: true,
1729
+ editingNote: null
1730
+ });
1731
+ });
1732
+
1733
+ _defineProperty(_assertThisInitialized(_this), "onCloseAddNote", function () {
1734
+ var newState = {
1735
+ addNoteOpen: false,
1736
+ editingNote: null
1756
1737
  };
1757
- return /*#__PURE__*/React.createElement("div", {
1758
- className: "ticketHistoryEntry",
1759
- key: i
1760
- }, /*#__PURE__*/React.createElement("p", {
1761
- className: "ticketHistoryEntry_timestamp"
1762
- }, moment.utc(entryToUse.timestamp).local().format('D MMM YYYY h:mma')), /*#__PURE__*/React.createElement("div", {
1763
- className: "statusLabel statusLabel-large statusLabel-full",
1764
- style: {
1765
- backgroundColor: StatusTypes[entryToUse.status].color
1766
- }
1767
- }, /*#__PURE__*/React.createElement("span", {
1768
- className: "statusLabel_text"
1769
- }, e ? "Marked as ".concat(StatusTypes[entryToUse.status].text) : 'Job opened')));
1770
- }
1771
- }, {
1772
- key: "renderNote",
1773
- value: function renderNote(note, index) {
1774
- var _this4 = this;
1775
1738
 
1776
- return /*#__PURE__*/React.createElement("div", {
1777
- className: "ticketHistoryEntry",
1778
- key: index
1779
- }, /*#__PURE__*/React.createElement("p", {
1780
- className: "ticketHistoryEntry_timestamp"
1781
- }, moment.utc(note.Timestamp).local().format('D MMM YYYY h:mma')), /*#__PURE__*/React.createElement("div", {
1782
- className: "statusLabel statusLabel-large statusLabel-full",
1783
- style: {
1784
- backgroundColor: '#6e79c5'
1785
- }
1786
- }, /*#__PURE__*/React.createElement("span", {
1787
- className: "statusLabel_text"
1788
- }, "Staff Notes")), /*#__PURE__*/React.createElement("div", {
1789
- className: "maintenanceNote"
1790
- }, /*#__PURE__*/React.createElement("div", {
1791
- className: "maintenanceNote_top"
1792
- }, this.props.auth && this.props.auth.user && this.props.auth.user.Id === note.User.id && /*#__PURE__*/React.createElement(Components$2.SVGIcon, {
1793
- colour: Colours.COLOUR_DUSK_LIGHT,
1794
- icon: "more15",
1795
- className: "maintenanceNote_moreIcon",
1796
- onClick: function onClick() {
1797
- return _this4.onOpenNoteMenu(index);
1798
- }
1799
- }), /*#__PURE__*/React.createElement("p", {
1800
- className: "maintenanceNote_name"
1801
- }, note.User.displayName), this.state.noteMenuOpen === index && /*#__PURE__*/React.createElement(Components$2.MoreMenu, {
1802
- options: [{
1803
- key: 'edit',
1804
- text: 'Edit',
1805
- onPress: function onPress() {
1806
- return _this4.onOpenEditNote(note);
1807
- }
1808
- }, {
1809
- key: 'delete',
1810
- text: 'Delete',
1811
- onPress: function onPress() {
1812
- return _this4.onDeleteNote(note);
1813
- }
1814
- }]
1815
- })), /*#__PURE__*/React.createElement("p", {
1816
- className: "maintenanceNote_text"
1817
- }, Helper$2.toParagraphed(note.Note)), note.Attachments.map(function (a, i) {
1818
- return _this4.renderAttachment(a, i);
1819
- })));
1820
- }
1821
- }, {
1822
- key: "renderOverview",
1823
- value: function renderOverview() {
1824
- var _this5 = this;
1739
+ if (!!_this.state.editingNote) {
1740
+ newState.noteInput = '';
1741
+ newState.noteAttachments = [];
1742
+ }
1743
+
1744
+ _this.setState(newState);
1745
+ });
1746
+
1747
+ _defineProperty(_assertThisInitialized(_this), "onOpenNoteMenu", function (index) {
1748
+ if (_this.state.noteMenuOpen === index) {
1749
+ _this.setState({
1750
+ noteMenuOpen: null
1751
+ });
1752
+ } else {
1753
+ _this.setState({
1754
+ noteMenuOpen: index
1755
+ });
1756
+ }
1757
+ });
1758
+
1759
+ _defineProperty(_assertThisInitialized(_this), "onHandlePDFFileChange", function (event) {
1760
+ var file = event.target.files[0];
1761
+ if (!file || _this.state.uploadingNoteAttachment) return;
1762
+
1763
+ var noteAttachments = _toConsumableArray(_this.state.noteAttachments);
1764
+
1765
+ var newAttachment = {
1766
+ Uploading: true,
1767
+ Title: file.name
1768
+ };
1769
+ noteAttachments.push(newAttachment);
1770
+
1771
+ _this.setState({
1772
+ noteAttachments: noteAttachments
1773
+ });
1774
+
1775
+ Apis.fileActions.uploadMediaAsync(file, file.name).then(function (fileRes) {
1776
+ newAttachment.Source = fileRes;
1777
+ newAttachment.Uploading = false;
1778
+
1779
+ _this.setState({
1780
+ noteAttachments: _toConsumableArray(_this.state.noteAttachments)
1781
+ });
1782
+ }).catch(function (uploadErrorRes) {
1783
+ console.log(uploadErrorRes);
1784
+ newAttachment.Uploading = false;
1785
+
1786
+ _this.setState({
1787
+ noteAttachments: _toConsumableArray(_this.state.noteAttachments)
1788
+ });
1789
+ });
1790
+ event.target.value = '';
1791
+ });
1792
+
1793
+ _defineProperty(_assertThisInitialized(_this), "onRemoveAttachment", function (a) {
1794
+ var index = _this.state.noteAttachments.indexOf(a);
1795
+
1796
+ if (index > -1) {
1797
+ var newAttachments = _toConsumableArray(_this.state.noteAttachments);
1798
+
1799
+ newAttachments.splice(index, 1);
1800
+
1801
+ _this.setState({
1802
+ noteAttachments: newAttachments
1803
+ });
1804
+ }
1805
+ });
1806
+
1807
+ _defineProperty(_assertThisInitialized(_this), "onConfirmAddNote", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
1808
+ var res;
1809
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
1810
+ while (1) {
1811
+ switch (_context2.prev = _context2.next) {
1812
+ case 0:
1813
+ if (_this.isReadyToSaveNote()) {
1814
+ _context2.next = 2;
1815
+ break;
1816
+ }
1817
+
1818
+ return _context2.abrupt("return");
1819
+
1820
+ case 2:
1821
+ _context2.prev = 2;
1822
+
1823
+ _this.setState({
1824
+ submittingNote: true
1825
+ });
1826
+
1827
+ _context2.next = 6;
1828
+ return _this.state.editingNote ? maintenanceActions.editNote(_this.state.jobId, _this.state.editingNote, _this.state.noteInput, _this.state.noteAttachments.map(function (a) {
1829
+ return {
1830
+ Title: a.Title,
1831
+ Source: a.Source
1832
+ };
1833
+ })) : maintenanceActions.addNote(_this.state.jobId, _this.state.noteInput, _this.state.noteAttachments.map(function (a) {
1834
+ return {
1835
+ Title: a.Title,
1836
+ Source: a.Source
1837
+ };
1838
+ }));
1825
1839
 
1826
- var job = this.state.job;
1827
- if (!job || !job.history) return null;
1840
+ case 6:
1841
+ res = _context2.sent;
1828
1842
 
1829
- var source = _.sortBy([].concat(_toConsumableArray(job.history.map(function (e) {
1830
- return _objectSpread$3(_objectSpread$3({}, e), {}, {
1831
- EntryType: 'status'
1832
- });
1833
- })), _toConsumableArray((job.Notes || []).map(function (e) {
1834
- return _objectSpread$3(_objectSpread$3({}, e), {}, {
1835
- timestamp: e.Timestamp,
1836
- EntryType: 'note'
1837
- });
1838
- }))), 'timestamp');
1843
+ _this.setState({
1844
+ job: res.data.job,
1845
+ submittingNote: false,
1846
+ addNoteOpen: false,
1847
+ noteInput: '',
1848
+ noteAttachments: [],
1849
+ editingNote: null
1850
+ }, function () {
1851
+ _this.props.jobsLoaded([_this.state.job]);
1852
+ });
1839
1853
 
1840
- return /*#__PURE__*/React.createElement("div", {
1841
- className: "padding-32 paddingVertical-40 bottomDivideBorder relative"
1842
- }, /*#__PURE__*/React.createElement("div", {
1843
- className: "newTopBar clearfix flex flex-reverse"
1844
- }, this.renderNotesButton(), this.renderStatusLabel(), /*#__PURE__*/React.createElement(Components$2.Text, {
1845
- type: "formTitleSmall",
1846
- className: "flex-1"
1847
- }, "Status History")), this.renderHistoryEntry(null, -1), _.map(source, function (e, i) {
1848
- switch (e.EntryType) {
1849
- case 'status':
1850
- return _this5.renderHistoryEntry(e, i);
1854
+ _context2.next = 13;
1855
+ break;
1851
1856
 
1852
- case 'note':
1853
- return _this5.renderNote(e, i);
1854
- }
1855
- }));
1856
- }
1857
- }, {
1858
- key: "renderButtons",
1859
- value: function renderButtons() {
1860
- return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Components$2.Button, {
1861
- inline: true,
1862
- buttonType: "tertiary",
1863
- onClick: function onClick() {
1864
- window.history.back();
1865
- },
1866
- isActive: true,
1867
- style: {
1868
- marginRight: 16
1857
+ case 10:
1858
+ _context2.prev = 10;
1859
+ _context2.t0 = _context2["catch"](2);
1860
+ console.error('onConfirmAddNote', _context2.t0);
1861
+
1862
+ case 13:
1863
+ case "end":
1864
+ return _context2.stop();
1865
+ }
1869
1866
  }
1870
- }, "Back"), Session$2.validateAccess(this.props.auth.site, 'maintenanceTracking', this.props.auth) && !_.isEmpty(this.state.job) && /*#__PURE__*/React.createElement(Link, {
1871
- to: "/requestsHub/job/".concat(this.state.jobId)
1872
- }, /*#__PURE__*/React.createElement(Components$2.Button, {
1873
- inline: true,
1874
- style: {
1875
- marginRight: 25
1876
- },
1877
- buttonType: "outlined",
1878
- isActive: true,
1879
- onClick: this.editJob
1880
- }, "Edit Details")));
1881
- }
1882
- }, {
1883
- key: "renderAttachment",
1884
- value: function renderAttachment(attachment, index, onRemove) {
1885
- if (!attachment) return null;
1886
- return /*#__PURE__*/React.createElement(Components$2.Attachment, {
1887
- key: index,
1888
- uploading: attachment.Uploading,
1889
- source: attachment.Source,
1890
- title: attachment.Title,
1891
- onRemove: onRemove ? function () {
1892
- return onRemove(attachment);
1893
- } : undefined
1894
- });
1895
- }
1896
- }, {
1897
- key: "renderAddNotePopup",
1898
- value: function renderAddNotePopup() {
1899
- var _this6 = this;
1867
+ }, _callee2, null, [[2, 10]]);
1868
+ })));
1900
1869
 
1901
- if (!this.state.addNoteOpen) return null;
1870
+ _defineProperty(_assertThisInitialized(_this), "onDeleteNote", function (n) {
1871
+ if (!window.confirm('Are you sure you want to delete that note?')) {
1872
+ _this.setState({
1873
+ noteMenuOpen: null
1874
+ });
1902
1875
 
1903
- if (this.state.submittingNote) {
1904
- return /*#__PURE__*/React.createElement(Components$2.Popup, {
1905
- title: "Saving Note",
1906
- maxWidth: 600,
1907
- hasPadding: true
1908
- }, /*#__PURE__*/React.createElement("div", {
1909
- className: "flex flex-center-row"
1910
- }, /*#__PURE__*/React.createElement(FontAwesome, {
1911
- className: "spinner",
1912
- name: "spinner fa-pulse fa-fw"
1913
- })));
1876
+ return;
1914
1877
  }
1915
1878
 
1916
- return /*#__PURE__*/React.createElement(Components$2.Popup, {
1917
- title: "".concat(this.state.editingNote ? 'Edit' : 'Add', " Note"),
1918
- onClose: this.onCloseAddNote,
1919
- maxWidth: 600,
1920
- hasPadding: true,
1921
- buttons: [{
1922
- type: 'primary',
1923
- onClick: this.onConfirmAddNote,
1924
- isActive: this.isReadyToSaveNote(),
1925
- text: 'Save'
1926
- }, {
1927
- type: 'tertiary',
1928
- onClick: this.onCloseAddNote,
1929
- isActive: true,
1930
- text: 'Cancel'
1931
- }]
1932
- }, /*#__PURE__*/React.createElement(Components$2.GenericInput, {
1933
- id: "noteInput",
1934
- type: "textarea",
1935
- componentClass: "textarea",
1936
- value: this.state.noteInput,
1937
- placeholder: "Enter note",
1938
- onChange: function onChange(e) {
1939
- return _this6.onHandleChange(e);
1940
- },
1941
- inputStyle: {
1942
- width: 400
1943
- }
1944
- }), /*#__PURE__*/React.createElement(Components$2.Text, {
1945
- type: "h5"
1946
- }, "Attachments"), this.state.noteAttachments.map(function (a, i) {
1947
- return _this6.renderAttachment(a, i, _this6.onRemoveAttachment);
1948
- }), /*#__PURE__*/React.createElement("input", {
1949
- ref: function ref(input) {
1950
- return _this6.attachmentInput = input;
1951
- },
1952
- id: "attachmentInput",
1953
- type: "file",
1954
- className: "fileInput",
1955
- onChange: function onChange(e) {
1956
- return _this6.onHandlePDFFileChange(e);
1957
- },
1958
- accept: "application/pdf"
1959
- }), /*#__PURE__*/React.createElement("div", {
1960
- className: "iconTextButton",
1961
- onClick: function onClick() {
1962
- _this6.attachmentInput.click();
1963
- }
1964
- }, /*#__PURE__*/React.createElement(FontAwesome, {
1965
- className: "iconTextButton_icon",
1966
- name: "paperclip"
1967
- }), /*#__PURE__*/React.createElement("p", {
1968
- className: "iconTextButton_text"
1969
- }, "Add Attachment")));
1970
- }
1971
- }, {
1972
- key: "render",
1973
- value: function render() {
1974
- return /*#__PURE__*/React.createElement(Components$2.OverlayPage, null, this.renderAddNotePopup(), /*#__PURE__*/React.createElement(Components$2.OverlayPageContents, null, /*#__PURE__*/React.createElement(Components$2.OverlayPageSection, {
1975
- className: "pageSectionWrapper--newPopup"
1976
- }, this.renderInner()), /*#__PURE__*/React.createElement(Components$2.OverlayPageSection, {
1977
- className: "pageSectionWrapper--newPopupSide pageSectionWrapper--newPopupSide-fixedWidth"
1978
- }, this.renderOverview())), /*#__PURE__*/React.createElement(Components$2.OverlayPageBottomButtons, null, this.renderButtons()));
1979
- }
1980
- }]);
1981
-
1982
- return Job;
1983
- }(Component);
1879
+ maintenanceActions.deleteNote(_this.state.jobId, n.Id);
1984
1880
 
1985
- var mapStateToProps$2 = function mapStateToProps(state) {
1986
- var auth = state.auth;
1987
- return {
1988
- auth: auth
1989
- };
1990
- };
1881
+ var newNotes = _.filter(_this.state.job.Notes, function (note) {
1882
+ return note.Id !== n.Id;
1883
+ });
1991
1884
 
1992
- var Job$1 = connect(mapStateToProps$2, {
1993
- jobsLoaded: jobsLoaded
1994
- })(withRouter(Job));
1885
+ var newJob = _objectSpread$3({}, _this.state.job);
1995
1886
 
1996
- function _createSuper$7(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$7(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
1887
+ newJob.Notes = newNotes;
1997
1888
 
1998
- function _isNativeReflectConstruct$7() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
1999
- var Actions = PlussCore.Actions,
2000
- Components$1 = PlussCore.Components,
2001
- Helper$1 = PlussCore.Helper,
2002
- Session$1 = PlussCore.Session;
1889
+ _this.setState({
1890
+ job: newJob,
1891
+ noteMenuOpen: null
1892
+ });
1893
+ });
2003
1894
 
2004
- var AddJob = /*#__PURE__*/function (_Component) {
2005
- _inherits(AddJob, _Component);
1895
+ _defineProperty(_assertThisInitialized(_this), "onOpenEditNote", function (n) {
1896
+ _this.setState({
1897
+ noteAttachments: n.Attachments || [],
1898
+ noteInput: n.Note || '',
1899
+ addNoteOpen: true,
1900
+ editingNote: n.Id,
1901
+ noteMenuOpen: null
1902
+ });
1903
+ });
2006
1904
 
2007
- var _super = _createSuper$7(AddJob);
1905
+ _defineProperty(_assertThisInitialized(_this), "markSeen", function () {
1906
+ var job = _this.state.job;
1907
+ var auth = _this.props.auth; // Must have maintenance permission and not the requester
2008
1908
 
2009
- function AddJob(props) {
2010
- var _this;
1909
+ if (!Session$1.validateAccess(auth.site, 'maintenanceTracking', auth)) return;
1910
+ if (auth.user.Id === job.userID) return;
2011
1911
 
2012
- _classCallCheck(this, AddJob);
1912
+ _this.setState({
1913
+ updating: true
1914
+ }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
1915
+ var update;
1916
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
1917
+ while (1) {
1918
+ switch (_context3.prev = _context3.next) {
1919
+ case 0:
1920
+ _context3.prev = 0;
1921
+ update = {
1922
+ id: job.id,
1923
+ seen: true,
1924
+ status: job.status || 'Unassigned'
1925
+ };
1926
+ _context3.next = 4;
1927
+ return maintenanceActions.editJob(update, auth.site);
2013
1928
 
2014
- _this = _super.call(this, props);
1929
+ case 4:
1930
+ _context3.next = 11;
1931
+ break;
2015
1932
 
2016
- _defineProperty(_assertThisInitialized(_this), "getJob", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
2017
- var res;
2018
- return _regeneratorRuntime.wrap(function _callee$(_context) {
2019
- while (1) {
2020
- switch (_context.prev = _context.next) {
2021
- case 0:
2022
- _context.prev = 0;
2023
- _context.next = 3;
2024
- return maintenanceActions.getJob(_this.props.auth.site, _this.state.jobId);
1933
+ case 6:
1934
+ _context3.prev = 6;
1935
+ _context3.t0 = _context3["catch"](0);
2025
1936
 
2026
- case 3:
2027
- res = _context.sent;
2028
- res.data.location = res.data.site;
1937
+ _this.setState({
1938
+ updating: false
1939
+ });
2029
1940
 
2030
- _this.setState(res.data);
1941
+ console.log('markSeen error', _context3.t0);
1942
+ alert('Something went wrong with the request. Please try again.');
2031
1943
 
2032
- _context.next = 11;
2033
- break;
1944
+ case 11:
1945
+ case "end":
1946
+ return _context3.stop();
1947
+ }
1948
+ }
1949
+ }, _callee3, null, [[0, 6]]);
1950
+ })));
1951
+ });
2034
1952
 
2035
- case 8:
2036
- _context.prev = 8;
2037
- _context.t0 = _context["catch"](0);
2038
- console.error('getJob', _context.t0);
1953
+ _defineProperty(_assertThisInitialized(_this), "getComments", function () {
1954
+ reactionActions.getComments(_this.state.jobId, 'maintenancerequest', 0).then(function (res) {
1955
+ _this.setState({
1956
+ comments: res.data
1957
+ });
1958
+ });
1959
+ });
2039
1960
 
2040
- case 11:
2041
- case "end":
2042
- return _context.stop();
2043
- }
2044
- }
2045
- }, _callee, null, [[0, 8]]);
2046
- })));
1961
+ _defineProperty(_assertThisInitialized(_this), "onAddComment", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
1962
+ var _this$state2, commentInput, jobId, job, comments, res;
2047
1963
 
2048
- _defineProperty(_assertThisInitialized(_this), "getJobTypes", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
2049
- var res;
2050
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
1964
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
2051
1965
  while (1) {
2052
- switch (_context2.prev = _context2.next) {
1966
+ switch (_context4.prev = _context4.next) {
2053
1967
  case 0:
2054
- _context2.prev = 0;
2055
- _context2.next = 3;
2056
- return maintenanceActions.getJobTypes(_this.props.auth.site);
2057
-
2058
- case 3:
2059
- res = _context2.sent;
1968
+ _this$state2 = _this.state, commentInput = _this$state2.commentInput, jobId = _this$state2.jobId, job = _this$state2.job, comments = _this$state2.comments;
1969
+ _context4.prev = 1;
2060
1970
 
2061
1971
  _this.setState({
2062
- types: res.data
1972
+ commentInput: ''
2063
1973
  });
2064
1974
 
2065
- _this.getDefaultJob();
1975
+ _context4.next = 5;
1976
+ return reactionActions.addComment(jobId, 'maintenancerequest', job.title, job.site, commentInput);
2066
1977
 
2067
- _context2.next = 11;
1978
+ case 5:
1979
+ res = _context4.sent;
1980
+
1981
+ _this.setState({
1982
+ comments: [].concat(_toConsumableArray(comments), [res.data])
1983
+ });
1984
+
1985
+ _context4.next = 12;
2068
1986
  break;
2069
1987
 
2070
- case 8:
2071
- _context2.prev = 8;
2072
- _context2.t0 = _context2["catch"](0);
2073
- console.error('getJobTypes', _context2.t0);
1988
+ case 9:
1989
+ _context4.prev = 9;
1990
+ _context4.t0 = _context4["catch"](1);
1991
+ console.error('onAddComment', _context4.t0);
2074
1992
 
2075
- case 11:
1993
+ case 12:
2076
1994
  case "end":
2077
- return _context2.stop();
1995
+ return _context4.stop();
2078
1996
  }
2079
1997
  }
2080
- }, _callee2, null, [[0, 8]]);
1998
+ }, _callee4, null, [[1, 9]]);
2081
1999
  })));
2082
2000
 
2083
- _defineProperty(_assertThisInitialized(_this), "getDefaultJob", function () {
2084
- if (_this.state.types.length !== 0 && _this.state.jobId == null) {
2085
- _this.setState({
2086
- type: _this.state.types[0].typeName
2087
- });
2088
- }
2089
- });
2090
-
2091
- _defineProperty(_assertThisInitialized(_this), "onSelectType", function (key, e) {
2092
- _this.setState({
2093
- type: key
2094
- });
2095
- });
2096
-
2097
2001
  _defineProperty(_assertThisInitialized(_this), "onHandleChange", function (event) {
2098
2002
  var stateChange = {};
2099
2003
  stateChange[event.target.getAttribute('id')] = event.target.value;
@@ -2101,348 +2005,534 @@ var AddJob = /*#__PURE__*/function (_Component) {
2101
2005
  _this.setState(stateChange);
2102
2006
  });
2103
2007
 
2104
- _defineProperty(_assertThisInitialized(_this), "onSave", function () {
2008
+ _defineProperty(_assertThisInitialized(_this), "onToggleStatusChanger", function () {
2105
2009
  _this.setState({
2106
- showWarnings: false
2010
+ statusChangerOpen: !_this.state.statusChangerOpen
2107
2011
  });
2012
+ });
2108
2013
 
2109
- if (!_this.validateForm()) {
2110
- _this.setState({
2111
- showWarnings: true
2112
- });
2113
-
2114
- return;
2115
- }
2116
-
2117
- if (_this.state.updating) return;
2014
+ _defineProperty(_assertThisInitialized(_this), "onSelectStatus", /*#__PURE__*/function () {
2015
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(status) {
2016
+ var res;
2017
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
2018
+ while (1) {
2019
+ switch (_context5.prev = _context5.next) {
2020
+ case 0:
2021
+ _this.setState({
2022
+ job: _objectSpread$3(_objectSpread$3({}, _this.state.job), {}, {
2023
+ status: status
2024
+ }),
2025
+ statusChangerOpen: false
2026
+ });
2118
2027
 
2119
- _this.setState({
2120
- updating: true
2121
- });
2028
+ _context5.prev = 1;
2029
+ _context5.next = 4;
2030
+ return maintenanceActions.editJobStatus(_this.state.job.id, status);
2122
2031
 
2123
- var job = {
2124
- id: _this.state.id,
2125
- userID: _this.state.userID,
2126
- userName: _this.state.userName,
2127
- room: _this.state.room,
2128
- phone: _this.state.phone,
2129
- location: _this.state.location,
2130
- title: _this.state.title,
2131
- description: _this.state.description,
2132
- isHome: _this.state.isHome,
2133
- homeText: _this.state.homeText,
2134
- type: _this.state.type,
2135
- date: null,
2136
- image: _this.state.image
2137
- };
2032
+ case 4:
2033
+ res = _context5.sent;
2138
2034
 
2139
- if (_this.state.id != null) {
2140
- maintenanceActions.editJob(job, _this.props.auth.site).then(function (res) {
2141
- _this.setState({
2142
- success: true,
2143
- updating: false
2144
- });
2035
+ _this.setState({
2036
+ job: res.data.job
2037
+ }, function () {
2038
+ _this.props.jobsLoaded([_this.state.job]);
2039
+ });
2145
2040
 
2146
- _this.props.jobsLoaded([job]);
2147
- }).catch(function (res) {
2148
- _this.setState({
2149
- updating: false
2150
- });
2041
+ _context5.next = 11;
2042
+ break;
2151
2043
 
2152
- alert('Something went wrong with the request. Please try again.');
2153
- });
2154
- } else {
2155
- // Create New Job
2156
- job.userID = 'undefined';
2157
- maintenanceActions.createJob(job).then(function (res) {
2158
- _this.setState({
2159
- success: true,
2160
- updating: false
2161
- });
2044
+ case 8:
2045
+ _context5.prev = 8;
2046
+ _context5.t0 = _context5["catch"](1);
2047
+ console.error('onSelectStatus', _context5.t0);
2162
2048
 
2163
- _this.props.jobsUpdate(_this.props.auth.site);
2164
- }).catch(function (res) {
2165
- _this.setState({
2166
- updating: false
2167
- });
2049
+ case 11:
2050
+ case "end":
2051
+ return _context5.stop();
2052
+ }
2053
+ }
2054
+ }, _callee5, null, [[1, 8]]);
2055
+ }));
2168
2056
 
2169
- alert('Something went wrong with the request. Please try again.');
2170
- });
2171
- }
2172
- });
2057
+ return function (_x) {
2058
+ return _ref5.apply(this, arguments);
2059
+ };
2060
+ }());
2173
2061
 
2174
2062
  _this.state = {
2175
- jobId: Helper$1.safeReadParams(_this.props, 'jobId') ? _this.props.match.params.jobId : null,
2063
+ jobId: Helper$1.safeReadParams(props, 'jobId') ? props.match.params.jobId : null,
2176
2064
  job: null,
2177
2065
  showingSelector: false,
2178
2066
  updating: false,
2179
- connected: false,
2180
- types: [],
2181
- id: null,
2182
- userID: '',
2183
- userName: '',
2184
- room: '',
2185
- phone: '',
2186
- location: _this.props.auth.site,
2187
- title: '',
2188
- description: '',
2189
- isHome: false,
2190
- homeText: '',
2191
- type: 'General',
2192
- image: null,
2193
- thumbnail: null,
2194
- showWarnings: false,
2195
- success: false
2067
+ comments: [],
2068
+ commentInput: '',
2069
+ loadingComments: false,
2070
+ statusChangerOpen: false,
2071
+ addNoteOpen: false,
2072
+ noteAttachments: [],
2073
+ noteInput: ''
2196
2074
  };
2197
2075
  return _this;
2198
2076
  }
2199
2077
 
2200
- _createClass(AddJob, [{
2201
- key: "UNSAFE_componentWillMount",
2202
- value: function UNSAFE_componentWillMount() {
2078
+ _createClass(Job, [{
2079
+ key: "UNSAFE_componentWillReceiveProps",
2080
+ value: function UNSAFE_componentWillReceiveProps(nextProps) {
2203
2081
  Session$1.checkLoggedIn(this, this.props.auth);
2204
2082
  }
2205
2083
  }, {
2206
- key: "componentDidMount",
2207
- value: function componentDidMount() {
2208
- this.getJobTypes();
2209
- if (this.state.jobId) this.getJob();
2210
- this.props.addRecentlyCreated('maintenance');
2084
+ key: "componentDidMount",
2085
+ value: function componentDidMount() {
2086
+ if (this.state.jobId) {
2087
+ this.getJob();
2088
+ this.getComments();
2089
+ }
2090
+ }
2091
+ }, {
2092
+ key: "renderStatusLabel",
2093
+ value: function renderStatusLabel() {
2094
+ if (!this.state.job.status) return null;
2095
+ var auth = this.props.auth;
2096
+
2097
+ if (Session$1.validateAccess(auth.site, 'maintenanceTracking', auth)) {
2098
+ return /*#__PURE__*/React.createElement("div", {
2099
+ className: "statusLabel pointer",
2100
+ onClick: this.onToggleStatusChanger,
2101
+ style: {
2102
+ backgroundColor: StatusTypes[this.state.job.status].color
2103
+ }
2104
+ }, /*#__PURE__*/React.createElement("span", {
2105
+ className: "statusLabel_text"
2106
+ }, StatusTypes[this.state.job.status].text), this.renderStatusChanger());
2107
+ }
2108
+
2109
+ return /*#__PURE__*/React.createElement("div", {
2110
+ className: "statusLabel",
2111
+ style: {
2112
+ backgroundColor: StatusTypes[this.state.job.status].color
2113
+ }
2114
+ }, /*#__PURE__*/React.createElement("span", {
2115
+ className: "statusLabel_text"
2116
+ }, StatusTypes[this.state.job.status].text));
2117
+ }
2118
+ }, {
2119
+ key: "renderNotesButton",
2120
+ value: function renderNotesButton() {
2121
+ var auth = this.props.auth;
2122
+ if (!Session$1.validateAccess(auth.site, 'maintenanceTracking', auth)) return null;
2123
+ return /*#__PURE__*/React.createElement("div", {
2124
+ className: "statusLabel pointer",
2125
+ onClick: this.onOpenAddNote,
2126
+ style: {
2127
+ backgroundColor: FeatureConfig.env.colourBrandingMain,
2128
+ marginLeft: 8
2129
+ }
2130
+ }, /*#__PURE__*/React.createElement("span", {
2131
+ className: "statusLabel_text"
2132
+ }, "Add Note"));
2211
2133
  }
2212
2134
  }, {
2213
- key: "renderTypeOptions",
2214
- value: function renderTypeOptions() {
2135
+ key: "renderStatusChanger",
2136
+ value: function renderStatusChanger() {
2215
2137
  var _this2 = this;
2216
2138
 
2217
- var source = this.state.types;
2218
- return source.map(function (ev) {
2219
- if (ev != null) {
2220
- return /*#__PURE__*/React.createElement(MenuItem, {
2221
- key: ev.typeName,
2222
- eventKey: ev.typeName,
2223
- active: _this2.state.type === ev.typeName
2224
- }, ev.typeName);
2225
- }
2139
+ if (!this.state.statusChangerOpen) return null;
2140
+ return /*#__PURE__*/React.createElement("div", {
2141
+ className: "statusChanger statusChanger-maintenance"
2142
+ }, Object.keys(StatusTypes).map(function (statusKey) {
2143
+ return /*#__PURE__*/React.createElement("div", {
2144
+ key: statusKey,
2145
+ className: "statusLabel",
2146
+ onClick: function onClick() {
2147
+ return _this2.onSelectStatus(statusKey);
2148
+ },
2149
+ style: {
2150
+ backgroundColor: StatusTypes[statusKey].color
2151
+ }
2152
+ }, /*#__PURE__*/React.createElement("span", {
2153
+ className: "statusLabel_text"
2154
+ }, StatusTypes[statusKey].text));
2155
+ }));
2156
+ }
2157
+ }, {
2158
+ key: "renderComment",
2159
+ value: function renderComment(c) {
2160
+ return /*#__PURE__*/React.createElement("div", {
2161
+ key: c.Id,
2162
+ className: "comment"
2163
+ }, /*#__PURE__*/React.createElement("p", {
2164
+ className: "comment_text"
2165
+ }, Helper$1.toParagraphed(c.Comment)), /*#__PURE__*/React.createElement("div", {
2166
+ className: "comment_bottom"
2167
+ }, /*#__PURE__*/React.createElement(Components$1.ProfilePic, {
2168
+ className: "comment_profilePic",
2169
+ size: 25,
2170
+ image: c.User.profilePic
2171
+ }), /*#__PURE__*/React.createElement("p", {
2172
+ className: "comment_name"
2173
+ }, c.User.displayName), /*#__PURE__*/React.createElement("p", {
2174
+ className: "comment_time"
2175
+ }, moment.utc(c.Timestamp).local().format('D MMM YYYY • h:mma'))));
2176
+ }
2177
+ }, {
2178
+ key: "renderCommentSection",
2179
+ value: function renderCommentSection() {
2180
+ var _this3 = this;
2226
2181
 
2227
- return null;
2228
- });
2182
+ if (this.state.loadingComments) return null;
2183
+ return /*#__PURE__*/React.createElement("div", {
2184
+ className: "padding-60 paddingLeft-20"
2185
+ }, /*#__PURE__*/React.createElement("div", {
2186
+ className: "newTopBar paddingLeft-40"
2187
+ }, /*#__PURE__*/React.createElement(Components$1.Text, {
2188
+ type: "formTitleSmall",
2189
+ className: "marginBottom-16"
2190
+ }, "Comments"), /*#__PURE__*/React.createElement("div", {
2191
+ className: "commentSection"
2192
+ }, this.state.comments.map(function (c) {
2193
+ return _this3.renderComment(c);
2194
+ })), /*#__PURE__*/React.createElement("div", {
2195
+ className: "commentReply"
2196
+ }, /*#__PURE__*/React.createElement("div", {
2197
+ className: "commentReply_button".concat(!_.isEmpty(this.state.commentInput) ? ' commentReply_button-active' : ''),
2198
+ onClick: this.onAddComment
2199
+ }, /*#__PURE__*/React.createElement(FontAwesome, {
2200
+ className: "commentReply_icon",
2201
+ name: "paper-plane-o"
2202
+ })), /*#__PURE__*/React.createElement(Textarea, {
2203
+ id: "commentInput",
2204
+ placeholder: "Reply here...",
2205
+ type: "text",
2206
+ className: "commentReply_input",
2207
+ value: this.state.commentInput,
2208
+ onChange: function onChange(e) {
2209
+ return _this3.onHandleChange(e);
2210
+ }
2211
+ }))));
2229
2212
  }
2230
2213
  }, {
2231
- key: "renderSuccess",
2232
- value: function renderSuccess() {
2233
- if (!this.state.success) return null;
2234
- return /*#__PURE__*/React.createElement(Components$1.SuccessPopup, {
2235
- text: "Maintenance request has been ".concat(this.state.id != null ? 'edited' : 'added'),
2236
- buttons: [{
2237
- type: 'outlined',
2238
- onClick: function onClick() {
2239
- window.history.back();
2240
- },
2241
- text: "Back to Maintenance"
2214
+ key: "renderInner",
2215
+ value: function renderInner() {
2216
+ if (this.state.job == null) return null;
2217
+ return /*#__PURE__*/React.createElement("div", {
2218
+ style: {
2219
+ paddingBottom: 40
2220
+ }
2221
+ }, /*#__PURE__*/React.createElement("div", {
2222
+ className: "padding-60 paddingVertical-40 bottomDivideBorder relative"
2223
+ }, /*#__PURE__*/React.createElement(Components$1.Text, {
2224
+ type: "formTitleLarge",
2225
+ className: "marginBottom-24"
2226
+ }, this.state.job.title || 'Request'), /*#__PURE__*/React.createElement("div", {
2227
+ className: "marginTop-16"
2228
+ }, /*#__PURE__*/React.createElement("div", {
2229
+ className: 'fieldLabel'
2230
+ }, "Request date"), /*#__PURE__*/React.createElement("div", {
2231
+ className: 'fontRegular fontSize-16 text-dark marginTop-5'
2232
+ }, moment.utc(this.state.job.createdTime).local().format('D MMM YY'))), /*#__PURE__*/React.createElement("div", {
2233
+ className: "marginTop-16"
2234
+ }, /*#__PURE__*/React.createElement("div", {
2235
+ className: 'fieldLabel'
2236
+ }, "Type"), /*#__PURE__*/React.createElement("div", {
2237
+ className: 'fontRegular fontSize-16 text-dark marginTop-5'
2238
+ }, this.state.job.type)), /*#__PURE__*/React.createElement("div", {
2239
+ className: "marginTop-16"
2240
+ }, /*#__PURE__*/React.createElement("div", {
2241
+ className: 'fieldLabel'
2242
+ }, "Location"), /*#__PURE__*/React.createElement("div", {
2243
+ className: 'fontRegular fontSize-16 text-dark marginTop-5'
2244
+ }, this.state.job.room)), /*#__PURE__*/React.createElement("div", {
2245
+ className: "marginTop-16"
2246
+ }, /*#__PURE__*/React.createElement("div", {
2247
+ className: 'fieldLabel'
2248
+ }, "Description ", this.state.job.image ? '- (image supplied)' : ''), /*#__PURE__*/React.createElement("div", {
2249
+ className: 'fontRegular fontSize-16 text-dark marginTop-5'
2250
+ }, this.state.job.description))), /*#__PURE__*/React.createElement("div", {
2251
+ className: "padding-60 paddingVertical-40 bottomDivideBorder"
2252
+ }, /*#__PURE__*/React.createElement(Components$1.Text, {
2253
+ type: "formTitleSmall",
2254
+ className: "marginBottom-16"
2255
+ }, "Contact Details"), /*#__PURE__*/React.createElement("div", {
2256
+ className: "marginTop-16"
2257
+ }, /*#__PURE__*/React.createElement("div", {
2258
+ className: 'fieldLabel'
2259
+ }, "Name"), /*#__PURE__*/React.createElement("div", {
2260
+ className: 'fontRegular fontSize-16 text-dark marginTop-5'
2261
+ }, this.state.job.userName)), /*#__PURE__*/React.createElement("div", {
2262
+ className: "marginTop-16"
2263
+ }, /*#__PURE__*/React.createElement("div", {
2264
+ className: 'fieldLabel'
2265
+ }, "Contact number"), /*#__PURE__*/React.createElement("div", {
2266
+ className: 'fontRegular fontSize-16 text-dark marginTop-5'
2267
+ }, _.isEmpty(this.state.job.phone) ? 'No phone provided' : this.state.job.phone)), /*#__PURE__*/React.createElement("div", {
2268
+ className: "marginTop-16"
2269
+ }, /*#__PURE__*/React.createElement("div", {
2270
+ className: 'fieldLabel'
2271
+ }, "Should person be home?"), /*#__PURE__*/React.createElement("div", {
2272
+ className: 'fontRegular fontSize-16 text-dark marginTop-5'
2273
+ }, this.state.job.isHome ? 'Yes' : 'No')), this.state.job.isHome && this.state.job.homeText && /*#__PURE__*/React.createElement("div", {
2274
+ className: "marginTop-16"
2275
+ }, /*#__PURE__*/React.createElement("div", {
2276
+ className: 'fieldLabel'
2277
+ }, "When"), /*#__PURE__*/React.createElement("div", {
2278
+ className: 'fontRegular fontSize-16 text-dark marginTop-5'
2279
+ }, this.state.job.homeText))), (this.state.job.image || this.state.job.images) && /*#__PURE__*/React.createElement("div", {
2280
+ className: "padding-60 paddingVertical-40 bottomDivideBorder"
2281
+ }, /*#__PURE__*/React.createElement(Components$1.Text, {
2282
+ type: "formTitleSmall",
2283
+ className: "marginBottom-16"
2284
+ }, "Image"), /*#__PURE__*/React.createElement("div", {
2285
+ style: {
2286
+ marginTop: 16,
2287
+ height: 180,
2288
+ width: 260,
2289
+ borderRadius: 4,
2290
+ border: '1px solid #aaa',
2291
+ backgroundColor: '#ddd',
2292
+ backgroundImage: "url(".concat(this.state.job.thumbnail, ")"),
2293
+ backgroundPosition: 'center'
2294
+ }
2295
+ })), this.renderCommentSection());
2296
+ }
2297
+ }, {
2298
+ key: "renderHistoryEntry",
2299
+ value: function renderHistoryEntry(e, i) {
2300
+ var job = this.state.job;
2301
+ var entryToUse = e || {
2302
+ timestamp: job.createdTime,
2303
+ status: 'Unassigned',
2304
+ user: {
2305
+ displayName: job.userName,
2306
+ id: job.userID,
2307
+ profilePic: job.userProfilePic
2308
+ }
2309
+ };
2310
+ return /*#__PURE__*/React.createElement("div", {
2311
+ className: "ticketHistoryEntry",
2312
+ key: i
2313
+ }, /*#__PURE__*/React.createElement("p", {
2314
+ className: "ticketHistoryEntry_timestamp"
2315
+ }, moment.utc(entryToUse.timestamp).local().format('D MMM YYYY h:mma')), /*#__PURE__*/React.createElement("div", {
2316
+ className: "statusLabel statusLabel-large statusLabel-full",
2317
+ style: {
2318
+ backgroundColor: StatusTypes[entryToUse.status].color
2319
+ }
2320
+ }, /*#__PURE__*/React.createElement("span", {
2321
+ className: "statusLabel_text"
2322
+ }, e ? "Marked as ".concat(StatusTypes[entryToUse.status].text) : 'Job opened')));
2323
+ }
2324
+ }, {
2325
+ key: "renderNote",
2326
+ value: function renderNote(note, index) {
2327
+ var _this4 = this;
2328
+
2329
+ return /*#__PURE__*/React.createElement("div", {
2330
+ className: "ticketHistoryEntry",
2331
+ key: index
2332
+ }, /*#__PURE__*/React.createElement("p", {
2333
+ className: "ticketHistoryEntry_timestamp"
2334
+ }, moment.utc(note.Timestamp).local().format('D MMM YYYY h:mma')), /*#__PURE__*/React.createElement("div", {
2335
+ className: "statusLabel statusLabel-large statusLabel-full",
2336
+ style: {
2337
+ backgroundColor: '#6e79c5'
2338
+ }
2339
+ }, /*#__PURE__*/React.createElement("span", {
2340
+ className: "statusLabel_text"
2341
+ }, "Staff Notes")), /*#__PURE__*/React.createElement("div", {
2342
+ className: "maintenanceNote"
2343
+ }, /*#__PURE__*/React.createElement("div", {
2344
+ className: "maintenanceNote_top"
2345
+ }, this.props.auth && this.props.auth.user && this.props.auth.user.Id === note.User.id && /*#__PURE__*/React.createElement(Components$1.SVGIcon, {
2346
+ colour: Colours.COLOUR_DUSK_LIGHT,
2347
+ icon: "more15",
2348
+ className: "maintenanceNote_moreIcon",
2349
+ onClick: function onClick() {
2350
+ return _this4.onOpenNoteMenu(index);
2351
+ }
2352
+ }), /*#__PURE__*/React.createElement("p", {
2353
+ className: "maintenanceNote_name"
2354
+ }, note.User.displayName), this.state.noteMenuOpen === index && /*#__PURE__*/React.createElement(Components$1.MoreMenu, {
2355
+ options: [{
2356
+ key: 'edit',
2357
+ text: 'Edit',
2358
+ onPress: function onPress() {
2359
+ return _this4.onOpenEditNote(note);
2360
+ }
2361
+ }, {
2362
+ key: 'delete',
2363
+ text: 'Delete',
2364
+ onPress: function onPress() {
2365
+ return _this4.onDeleteNote(note);
2366
+ }
2242
2367
  }]
2243
- });
2244
- }
2245
- }, {
2246
- key: "validateForm",
2247
- value: function validateForm() {
2248
- if (_.isEmpty(this.state.userName)) return false;
2249
- if (_.isEmpty(this.state.room)) return false;
2250
- if (_.isEmpty(this.state.title)) return false;
2251
- if (this.state.isHome && _.isEmpty(this.state.homeText)) return false;
2252
- return true;
2368
+ })), /*#__PURE__*/React.createElement("p", {
2369
+ className: "maintenanceNote_text"
2370
+ }, Helper$1.toParagraphed(note.Note)), note.Attachments.map(function (a, i) {
2371
+ return _this4.renderAttachment(a, i);
2372
+ })));
2253
2373
  }
2254
2374
  }, {
2255
- key: "renderSubmit",
2256
- value: function renderSubmit() {
2257
- var _this3 = this;
2375
+ key: "renderOverview",
2376
+ value: function renderOverview() {
2377
+ var _this5 = this;
2258
2378
 
2259
- if (this.state.updating) {
2260
- return /*#__PURE__*/React.createElement(Components$1.Button, {
2261
- buttonType: "secondary"
2262
- }, "Saving...");
2263
- }
2379
+ var job = this.state.job;
2380
+ if (!job || !job.history) return null;
2381
+
2382
+ var source = _.sortBy([].concat(_toConsumableArray(job.history.map(function (e) {
2383
+ return _objectSpread$3(_objectSpread$3({}, e), {}, {
2384
+ EntryType: 'status'
2385
+ });
2386
+ })), _toConsumableArray((job.Notes || []).map(function (e) {
2387
+ return _objectSpread$3(_objectSpread$3({}, e), {}, {
2388
+ timestamp: e.Timestamp,
2389
+ EntryType: 'note'
2390
+ });
2391
+ }))), 'timestamp');
2392
+
2393
+ return /*#__PURE__*/React.createElement("div", {
2394
+ className: "padding-32 paddingVertical-40 bottomDivideBorder relative"
2395
+ }, /*#__PURE__*/React.createElement("div", {
2396
+ className: "newTopBar clearfix flex flex-reverse"
2397
+ }, this.renderNotesButton(), this.renderStatusLabel(), /*#__PURE__*/React.createElement(Components$1.Text, {
2398
+ type: "formTitleSmall",
2399
+ className: "flex-1"
2400
+ }, "Status History")), this.renderHistoryEntry(null, -1), _.map(source, function (e, i) {
2401
+ switch (e.EntryType) {
2402
+ case 'status':
2403
+ return _this5.renderHistoryEntry(e, i);
2264
2404
 
2405
+ case 'note':
2406
+ return _this5.renderNote(e, i);
2407
+ }
2408
+ }));
2409
+ }
2410
+ }, {
2411
+ key: "renderButtons",
2412
+ value: function renderButtons() {
2265
2413
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Components$1.Button, {
2266
2414
  inline: true,
2267
2415
  buttonType: "tertiary",
2268
2416
  onClick: function onClick() {
2269
- return _this3.props.history.push('/requestsHub');
2417
+ window.history.back();
2270
2418
  },
2271
2419
  isActive: true,
2272
2420
  style: {
2273
2421
  marginRight: 16
2274
2422
  }
2275
- }, "Cancel"), /*#__PURE__*/React.createElement(Components$1.Button, {
2423
+ }, "Back"), Session$1.validateAccess(this.props.auth.site, 'maintenanceTracking', this.props.auth) && !_.isEmpty(this.state.job) && /*#__PURE__*/React.createElement(Link, {
2424
+ to: "/requestsHub/job/".concat(this.state.jobId)
2425
+ }, /*#__PURE__*/React.createElement(Components$1.Button, {
2276
2426
  inline: true,
2277
- buttonType: "primary",
2278
- onClick: this.onSave,
2279
- isActive: this.validateForm()
2280
- }, "Save"));
2427
+ style: {
2428
+ marginRight: 25
2429
+ },
2430
+ buttonType: "outlined",
2431
+ isActive: true,
2432
+ onClick: this.editJob
2433
+ }, "Edit Details")));
2281
2434
  }
2282
2435
  }, {
2283
- key: "renderMain",
2284
- value: function renderMain() {
2285
- var _this4 = this;
2436
+ key: "renderAttachment",
2437
+ value: function renderAttachment(attachment, index, onRemove) {
2438
+ if (!attachment) return null;
2439
+ return /*#__PURE__*/React.createElement(Components$1.Attachment, {
2440
+ key: index,
2441
+ uploading: attachment.Uploading,
2442
+ source: attachment.Source,
2443
+ title: attachment.Title,
2444
+ onRemove: onRemove ? function () {
2445
+ return onRemove(attachment);
2446
+ } : undefined
2447
+ });
2448
+ }
2449
+ }, {
2450
+ key: "renderAddNotePopup",
2451
+ value: function renderAddNotePopup() {
2452
+ var _this6 = this;
2286
2453
 
2287
- return /*#__PURE__*/React.createElement("div", {
2288
- style: {
2289
- marginBottom: 15
2290
- }
2291
- }, /*#__PURE__*/React.createElement("div", {
2292
- className: "padding-60 paddingVertical-40 bottomDivideBorder"
2293
- }, /*#__PURE__*/React.createElement(Components$1.Text, {
2294
- type: "formTitleLarge",
2295
- className: "marginBottom-24"
2296
- }, this.state.infoId == null ? 'New' : 'Edit', " Request"), /*#__PURE__*/React.createElement(Components$1.GenericInput, {
2297
- id: "userName",
2298
- type: "text",
2299
- label: "Name",
2300
- placeholder: "Insert name here",
2301
- value: this.state.userName,
2302
- onChange: function onChange(e) {
2303
- return _this4.onHandleChange(e);
2304
- },
2305
- isRequired: true,
2306
- alwaysShowLabel: true,
2307
- isValid: function isValid() {
2308
- return !_.isEmpty(_this4.state.userName);
2309
- },
2310
- showError: function showError() {
2311
- return _this4.state.showWarnings && _.isEmpty(_this4.state.userName);
2312
- }
2313
- }), /*#__PURE__*/React.createElement(Components$1.GenericInput, {
2314
- id: "room",
2315
- type: "text",
2316
- label: "Location",
2317
- placeholder: "Insert address here",
2318
- value: this.state.room,
2319
- onChange: function onChange(e) {
2320
- return _this4.onHandleChange(e);
2321
- },
2322
- isRequired: true,
2323
- alwaysShowLabel: true,
2324
- isValid: function isValid() {
2325
- return !_.isEmpty(_this4.state.room);
2326
- },
2327
- showError: function showError() {
2328
- return _this4.state.showWarnings && _.isEmpty(_this4.state.room);
2329
- }
2330
- }), /*#__PURE__*/React.createElement(Components$1.GenericInput, {
2331
- id: "phone",
2332
- type: "text",
2333
- label: "Contact number",
2334
- placeholder: "04XX XXX XXX",
2335
- value: this.state.phone // showError={this.state.showWarnings && !this.validateImage()}
2336
- ,
2337
- onChange: function onChange(e) {
2338
- return _this4.onHandleChange(e);
2339
- },
2340
- alwaysShowLabel: true
2341
- }), /*#__PURE__*/React.createElement("div", {
2342
- style: {
2343
- marginBottom: 15
2344
- }
2345
- }, /*#__PURE__*/React.createElement(Components$1.Text, {
2346
- type: "formLabel"
2347
- }, "Job Type"), /*#__PURE__*/React.createElement(DropdownButton, {
2348
- style: {
2349
- minWidth: 80
2350
- },
2351
- bsStyle: "default",
2352
- title: this.state.type,
2353
- id: "typeSelect",
2354
- onSelect: this.onSelectType
2355
- }, this.renderTypeOptions())), /*#__PURE__*/React.createElement(Components$1.GenericInput, {
2356
- id: "title",
2357
- label: "Title for the work required",
2358
- type: "textarea",
2359
- placeholder: "Title for the work required",
2360
- value: this.state.title,
2361
- onChange: function onChange(e) {
2362
- return _this4.onHandleChange(e);
2363
- },
2364
- inputStyle: {
2365
- height: 80
2366
- },
2367
- isRequired: true,
2368
- isValid: function isValid() {
2369
- return !_.isEmpty(_this4.state.title);
2370
- },
2371
- showError: function showError() {
2372
- return _this4.state.showWarnings && _.isEmpty(_this4.state.title);
2373
- },
2374
- alwaysShowLabel: true
2375
- }), /*#__PURE__*/React.createElement(Components$1.GenericInput, {
2376
- id: "description",
2377
- label: "Description of work required",
2378
- type: "textarea",
2379
- placeholder: "Description of work required",
2380
- value: this.state.description,
2381
- onChange: function onChange(e) {
2382
- return _this4.onHandleChange(e);
2383
- },
2384
- inputStyle: {
2385
- height: 80
2386
- },
2387
- alwaysShowLabel: true
2388
- }), /*#__PURE__*/React.createElement(Components$1.RadioButton, {
2389
- label: "Person must be home during work?",
2390
- isActive: this.state.isHome,
2391
- options: [{
2392
- Label: 'No',
2393
- Value: false,
2394
- onChange: function onChange() {
2395
- return _this4.setState({
2396
- isHome: false
2397
- });
2398
- }
2454
+ if (!this.state.addNoteOpen) return null;
2455
+
2456
+ if (this.state.submittingNote) {
2457
+ return /*#__PURE__*/React.createElement(Components$1.Popup, {
2458
+ title: "Saving Note",
2459
+ maxWidth: 600,
2460
+ hasPadding: true
2461
+ }, /*#__PURE__*/React.createElement("div", {
2462
+ className: "flex flex-center-row"
2463
+ }, /*#__PURE__*/React.createElement(FontAwesome, {
2464
+ className: "spinner",
2465
+ name: "spinner fa-pulse fa-fw"
2466
+ })));
2467
+ }
2468
+
2469
+ return /*#__PURE__*/React.createElement(Components$1.Popup, {
2470
+ title: "".concat(this.state.editingNote ? 'Edit' : 'Add', " Note"),
2471
+ onClose: this.onCloseAddNote,
2472
+ maxWidth: 600,
2473
+ hasPadding: true,
2474
+ buttons: [{
2475
+ type: 'primary',
2476
+ onClick: this.onConfirmAddNote,
2477
+ isActive: this.isReadyToSaveNote(),
2478
+ text: 'Save'
2399
2479
  }, {
2400
- Label: 'Yes',
2401
- Value: true,
2402
- onChange: function onChange() {
2403
- return _this4.setState({
2404
- isHome: true
2405
- });
2406
- }
2480
+ type: 'tertiary',
2481
+ onClick: this.onCloseAddNote,
2482
+ isActive: true,
2483
+ text: 'Cancel'
2407
2484
  }]
2408
- }), this.state.isHome && /*#__PURE__*/React.createElement(Components$1.GenericInput, {
2409
- style: {
2410
- marginTop: 16
2411
- },
2412
- label: "Description of person's available times",
2413
- id: "homeText",
2485
+ }, /*#__PURE__*/React.createElement(Components$1.GenericInput, {
2486
+ id: "noteInput",
2414
2487
  type: "textarea",
2415
- placeholder: "Description of person's available times",
2416
- value: this.state.homeText,
2488
+ componentClass: "textarea",
2489
+ value: this.state.noteInput,
2490
+ placeholder: "Enter note",
2417
2491
  onChange: function onChange(e) {
2418
- return _this4.onHandleChange(e);
2419
- },
2420
- inputStyle: {
2421
- height: 80
2492
+ return _this6.onHandleChange(e);
2422
2493
  },
2423
- isRequired: true,
2424
- isValid: function isValid() {
2425
- return !_.isEmpty(_this4.state.homeText);
2494
+ inputStyle: {
2495
+ width: 400
2496
+ }
2497
+ }), /*#__PURE__*/React.createElement(Components$1.Text, {
2498
+ type: "h5"
2499
+ }, "Attachments"), this.state.noteAttachments.map(function (a, i) {
2500
+ return _this6.renderAttachment(a, i, _this6.onRemoveAttachment);
2501
+ }), /*#__PURE__*/React.createElement("input", {
2502
+ ref: function ref(input) {
2503
+ return _this6.attachmentInput = input;
2426
2504
  },
2427
- showError: function showError() {
2428
- return _this4.state.showWarnings && _.isEmpty(_this4.state.homeText);
2505
+ id: "attachmentInput",
2506
+ type: "file",
2507
+ className: "fileInput",
2508
+ onChange: function onChange(e) {
2509
+ return _this6.onHandlePDFFileChange(e);
2429
2510
  },
2430
- alwaysShowLabel: true
2431
- })));
2511
+ accept: "application/pdf"
2512
+ }), /*#__PURE__*/React.createElement("div", {
2513
+ className: "iconTextButton",
2514
+ onClick: function onClick() {
2515
+ _this6.attachmentInput.click();
2516
+ }
2517
+ }, /*#__PURE__*/React.createElement(FontAwesome, {
2518
+ className: "iconTextButton_icon",
2519
+ name: "paperclip"
2520
+ }), /*#__PURE__*/React.createElement("p", {
2521
+ className: "iconTextButton_text"
2522
+ }, "Add Attachment")));
2432
2523
  }
2433
2524
  }, {
2434
2525
  key: "render",
2435
2526
  value: function render() {
2436
- var success = this.state.success;
2437
- return /*#__PURE__*/React.createElement(Components$1.OverlayPage, null, /*#__PURE__*/React.createElement(Components$1.OverlayPageContents, {
2438
- noBottomButtons: success
2439
- }, /*#__PURE__*/React.createElement(Components$1.OverlayPageSection, {
2527
+ return /*#__PURE__*/React.createElement(Components$1.OverlayPage, null, this.renderAddNotePopup(), /*#__PURE__*/React.createElement(Components$1.OverlayPageContents, null, /*#__PURE__*/React.createElement(Components$1.OverlayPageSection, {
2440
2528
  className: "pageSectionWrapper--newPopup"
2441
- }, /*#__PURE__*/React.createElement("div", null, this.renderSuccess(), !success && this.renderMain()))), /*#__PURE__*/React.createElement(Components$1.OverlayPageBottomButtons, null, this.renderSubmit()));
2529
+ }, this.renderInner()), /*#__PURE__*/React.createElement(Components$1.OverlayPageSection, {
2530
+ className: "pageSectionWrapper--newPopupSide pageSectionWrapper--newPopupSide-fixedWidth"
2531
+ }, this.renderOverview())), /*#__PURE__*/React.createElement(Components$1.OverlayPageBottomButtons, null, this.renderButtons()));
2442
2532
  }
2443
2533
  }]);
2444
2534
 
2445
- return AddJob;
2535
+ return Job;
2446
2536
  }(Component);
2447
2537
 
2448
2538
  var mapStateToProps$1 = function mapStateToProps(state) {
@@ -2452,32 +2542,31 @@ var mapStateToProps$1 = function mapStateToProps(state) {
2452
2542
  };
2453
2543
  };
2454
2544
 
2455
- var AddJob$1 = connect(mapStateToProps$1, {
2456
- jobsUpdate: jobsUpdate,
2457
- jobsLoaded: jobsLoaded,
2458
- addRecentlyCreated: Actions.addRecentlyCreated
2459
- })(withRouter(AddJob));
2545
+ var Job$1 = connect(mapStateToProps$1, {
2546
+ jobsLoaded: jobsLoaded
2547
+ })(withRouter(Job));
2460
2548
 
2461
2549
  function _createSuper$6(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$6(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
2462
2550
 
2463
2551
  function _isNativeReflectConstruct$6() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
2464
- var Session = PlussCore.Session,
2552
+ var Actions = PlussCore.Actions,
2465
2553
  Components = PlussCore.Components,
2466
- Helper = PlussCore.Helper;
2554
+ Helper = PlussCore.Helper,
2555
+ Session = PlussCore.Session;
2467
2556
 
2468
- var JobTypes = /*#__PURE__*/function (_Component) {
2469
- _inherits(JobTypes, _Component);
2557
+ var AddJob = /*#__PURE__*/function (_Component) {
2558
+ _inherits(AddJob, _Component);
2470
2559
 
2471
- var _super = _createSuper$6(JobTypes);
2560
+ var _super = _createSuper$6(AddJob);
2472
2561
 
2473
- function JobTypes(props) {
2562
+ function AddJob(props) {
2474
2563
  var _this;
2475
2564
 
2476
- _classCallCheck(this, JobTypes);
2565
+ _classCallCheck(this, AddJob);
2477
2566
 
2478
2567
  _this = _super.call(this, props);
2479
2568
 
2480
- _defineProperty(_assertThisInitialized(_this), "getJobTypes", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
2569
+ _defineProperty(_assertThisInitialized(_this), "getJob", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
2481
2570
  var res;
2482
2571
  return _regeneratorRuntime.wrap(function _callee$(_context) {
2483
2572
  while (1) {
@@ -2485,141 +2574,76 @@ var JobTypes = /*#__PURE__*/function (_Component) {
2485
2574
  case 0:
2486
2575
  _context.prev = 0;
2487
2576
  _context.next = 3;
2488
- return maintenanceActions.getJobTypes(_this.props.auth.site);
2577
+ return maintenanceActions.getJob(_this.props.auth.site, _this.state.jobId);
2489
2578
 
2490
2579
  case 3:
2491
2580
  res = _context.sent;
2492
- if (res.data != null) _this.props.jobTypesLoaded(res.data);
2493
- _context.next = 10;
2494
- break;
2495
-
2496
- case 7:
2497
- _context.prev = 7;
2498
- _context.t0 = _context["catch"](0);
2499
- console.error('getJobTypes', _context.t0);
2581
+ res.data.location = res.data.site;
2500
2582
 
2501
- case 10:
2502
- _context.prev = 10;
2583
+ _this.setState(res.data);
2503
2584
 
2504
- _this.setState({
2505
- loading: false
2506
- });
2585
+ _context.next = 11;
2586
+ break;
2507
2587
 
2508
- return _context.finish(10);
2588
+ case 8:
2589
+ _context.prev = 8;
2590
+ _context.t0 = _context["catch"](0);
2591
+ console.error('getJob', _context.t0);
2509
2592
 
2510
- case 13:
2593
+ case 11:
2511
2594
  case "end":
2512
2595
  return _context.stop();
2513
2596
  }
2514
2597
  }
2515
- }, _callee, null, [[0, 7, 10, 13]]);
2598
+ }, _callee, null, [[0, 8]]);
2516
2599
  })));
2517
2600
 
2518
- _defineProperty(_assertThisInitialized(_this), "sortByCol", function (col) {
2519
- if (_this.state.sortColumn === col) {
2520
- _this.setState({
2521
- sortDesc: !_this.state.sortDesc
2522
- });
2523
- } else {
2524
- _this.setState({
2525
- sortColumn: col,
2526
- sortDesc: false
2527
- });
2528
- }
2529
- });
2530
-
2531
- _defineProperty(_assertThisInitialized(_this), "validateEmail", function () {
2532
- var jobTypeEmail = _this.state.jobTypeEmail;
2533
- return !_.isEmpty(jobTypeEmail) && Helper.isEmail(jobTypeEmail);
2534
- });
2535
-
2536
- _defineProperty(_assertThisInitialized(_this), "isJobTypeValid", function () {
2537
- var _this$state = _this.state,
2538
- jobTypeName = _this$state.jobTypeName,
2539
- jobTypeDescription = _this$state.jobTypeDescription;
2540
- if (_.isEmpty(jobTypeName)) return false;
2541
- if (!_this.validateEmail()) return false;
2542
- if (_.isEmpty(jobTypeDescription)) return false;
2543
- return true;
2544
- });
2545
-
2546
- _defineProperty(_assertThisInitialized(_this), "onRemoveJobType", /*#__PURE__*/function () {
2547
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(ev) {
2548
- var index, newJobTypes;
2549
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
2550
- while (1) {
2551
- switch (_context2.prev = _context2.next) {
2552
- case 0:
2553
- if (window.confirm("Are you sure you want to delete ".concat(ev.typeName, "?"))) {
2554
- _context2.next = 2;
2555
- break;
2556
- }
2557
-
2558
- return _context2.abrupt("return");
2559
-
2560
- case 2:
2561
- _context2.prev = 2;
2562
- _context2.next = 5;
2563
- return maintenanceActions.deleteJobType(_this.props.auth.site, ev.id);
2601
+ _defineProperty(_assertThisInitialized(_this), "getJobTypes", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
2602
+ var res;
2603
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
2604
+ while (1) {
2605
+ switch (_context2.prev = _context2.next) {
2606
+ case 0:
2607
+ _context2.prev = 0;
2608
+ _context2.next = 3;
2609
+ return maintenanceActions.getJobTypes(_this.props.auth.site);
2564
2610
 
2565
- case 5:
2566
- index = _.findIndex(_this.state.jobList, function (job) {
2567
- return job != null && job.id === ev.id;
2568
- });
2611
+ case 3:
2612
+ res = _context2.sent;
2569
2613
 
2570
- if (index > -1) {
2571
- newJobTypes = _toConsumableArray(_this.state.jobList);
2572
- newJobTypes[index].Deleted = true;
2614
+ _this.setState({
2615
+ types: res.data
2616
+ });
2573
2617
 
2574
- _this.props.jobTypesLoaded(newJobTypes);
2575
- }
2618
+ _this.getDefaultJob();
2576
2619
 
2577
- _context2.next = 13;
2578
- break;
2620
+ _context2.next = 11;
2621
+ break;
2579
2622
 
2580
- case 9:
2581
- _context2.prev = 9;
2582
- _context2.t0 = _context2["catch"](2);
2583
- console.error('onRemoveJobType', _context2.t0);
2584
- alert('Something went wrong with the request. Please try again.');
2623
+ case 8:
2624
+ _context2.prev = 8;
2625
+ _context2.t0 = _context2["catch"](0);
2626
+ console.error('getJobTypes', _context2.t0);
2585
2627
 
2586
- case 13:
2587
- case "end":
2588
- return _context2.stop();
2589
- }
2628
+ case 11:
2629
+ case "end":
2630
+ return _context2.stop();
2590
2631
  }
2591
- }, _callee2, null, [[2, 9]]);
2592
- }));
2593
-
2594
- return function (_x) {
2595
- return _ref2.apply(this, arguments);
2596
- };
2597
- }());
2598
-
2599
- _defineProperty(_assertThisInitialized(_this), "onShowJobType", function () {
2600
- var job = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
2632
+ }
2633
+ }, _callee2, null, [[0, 8]]);
2634
+ })));
2601
2635
 
2602
- _this.setState({
2603
- showJobType: true,
2604
- jobTypeId: job ? job.id : null,
2605
- jobTypeName: job ? job.typeName : '',
2606
- jobTypeEmail: job ? job.email : '',
2607
- jobTypeDescription: job ? job.description : '',
2608
- jobTypeLevel: job ? job.level : 1
2609
- });
2636
+ _defineProperty(_assertThisInitialized(_this), "getDefaultJob", function () {
2637
+ if (_this.state.types.length !== 0 && _this.state.jobId == null) {
2638
+ _this.setState({
2639
+ type: _this.state.types[0].typeName
2640
+ });
2641
+ }
2610
2642
  });
2611
2643
 
2612
- _defineProperty(_assertThisInitialized(_this), "onHideJobType", function () {
2613
- if (_this.state.submitting) return;
2614
-
2644
+ _defineProperty(_assertThisInitialized(_this), "onSelectType", function (key, e) {
2615
2645
  _this.setState({
2616
- showWarnings: false,
2617
- showJobType: false,
2618
- jobTypeId: null,
2619
- jobTypeName: '',
2620
- jobTypeEmail: '',
2621
- jobTypeDescription: '',
2622
- jobTypeLevel: 1
2646
+ type: key
2623
2647
  });
2624
2648
  });
2625
2649
 
@@ -2631,17 +2655,11 @@ var JobTypes = /*#__PURE__*/function (_Component) {
2631
2655
  });
2632
2656
 
2633
2657
  _defineProperty(_assertThisInitialized(_this), "onSave", function () {
2634
- var site = _this.props.auth.site;
2635
- var _this$state2 = _this.state,
2636
- submitting = _this$state2.submitting,
2637
- jobTypeId = _this$state2.jobTypeId,
2638
- jobTypeName = _this$state2.jobTypeName,
2639
- jobTypeEmail = _this$state2.jobTypeEmail,
2640
- jobTypeDescription = _this$state2.jobTypeDescription,
2641
- jobTypeLevel = _this$state2.jobTypeLevel;
2642
- if (submitting) return;
2658
+ _this.setState({
2659
+ showWarnings: false
2660
+ });
2643
2661
 
2644
- if (!_this.isJobTypeValid()) {
2662
+ if (!_this.validateForm()) {
2645
2663
  _this.setState({
2646
2664
  showWarnings: true
2647
2665
  });
@@ -2649,391 +2667,349 @@ var JobTypes = /*#__PURE__*/function (_Component) {
2649
2667
  return;
2650
2668
  }
2651
2669
 
2652
- _this.setState({
2653
- submitting: true
2654
- }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
2655
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
2656
- while (1) {
2657
- switch (_context3.prev = _context3.next) {
2658
- case 0:
2659
- _context3.prev = 0;
2660
-
2661
- if (!jobTypeId) {
2662
- _context3.next = 6;
2663
- break;
2664
- }
2665
-
2666
- _context3.next = 4;
2667
- return maintenanceActions.editJobType(site, jobTypeId, jobTypeName, jobTypeEmail, jobTypeDescription, jobTypeLevel);
2668
-
2669
- case 4:
2670
- _context3.next = 8;
2671
- break;
2672
-
2673
- case 6:
2674
- _context3.next = 8;
2675
- return maintenanceActions.addJobType(site, jobTypeName, jobTypeEmail, jobTypeDescription, jobTypeLevel);
2670
+ if (_this.state.updating) return;
2676
2671
 
2677
- case 8:
2678
- _this.props.jobTypesUpdate(site);
2672
+ _this.setState({
2673
+ updating: true
2674
+ });
2679
2675
 
2680
- _this.setState({
2681
- submitting: false
2682
- }, _this.onHideJobType);
2676
+ var job = {
2677
+ id: _this.state.id,
2678
+ userID: _this.state.userID,
2679
+ userName: _this.state.userName,
2680
+ room: _this.state.room,
2681
+ phone: _this.state.phone,
2682
+ location: _this.state.location,
2683
+ title: _this.state.title,
2684
+ description: _this.state.description,
2685
+ isHome: _this.state.isHome,
2686
+ homeText: _this.state.homeText,
2687
+ type: _this.state.type,
2688
+ date: null,
2689
+ image: _this.state.image
2690
+ };
2683
2691
 
2684
- _context3.next = 17;
2685
- break;
2692
+ if (_this.state.id != null) {
2693
+ maintenanceActions.editJob(job, _this.props.auth.site).then(function (res) {
2694
+ _this.setState({
2695
+ success: true,
2696
+ updating: false
2697
+ });
2686
2698
 
2687
- case 12:
2688
- _context3.prev = 12;
2689
- _context3.t0 = _context3["catch"](0);
2690
- console.error('onSave', _context3.t0);
2699
+ _this.props.jobsLoaded([job]);
2700
+ }).catch(function (res) {
2701
+ _this.setState({
2702
+ updating: false
2703
+ });
2691
2704
 
2692
- _this.setState({
2693
- submitting: false
2694
- });
2705
+ alert('Something went wrong with the request. Please try again.');
2706
+ });
2707
+ } else {
2708
+ // Create New Job
2709
+ job.userID = 'undefined';
2710
+ maintenanceActions.createJob(job).then(function (res) {
2711
+ _this.setState({
2712
+ success: true,
2713
+ updating: false
2714
+ });
2695
2715
 
2696
- alert('Something went wrong with the request. Please try again.');
2716
+ _this.props.jobsUpdate(_this.props.auth.site);
2717
+ }).catch(function (res) {
2718
+ _this.setState({
2719
+ updating: false
2720
+ });
2697
2721
 
2698
- case 17:
2699
- case "end":
2700
- return _context3.stop();
2701
- }
2702
- }
2703
- }, _callee3, null, [[0, 12]]);
2704
- })));
2722
+ alert('Something went wrong with the request. Please try again.');
2723
+ });
2724
+ }
2705
2725
  });
2706
2726
 
2707
2727
  _this.state = {
2708
- jobList: [],
2709
- showCompleted: false,
2710
- sortColumn: 'name',
2711
- sortDesc: false,
2712
- loading: true,
2713
- showJobType: false,
2714
- jobTypeId: null,
2715
- jobTypeName: '',
2716
- jobTypeEmail: '',
2717
- jobTypeDescription: '',
2718
- jobTypeLevel: 1,
2728
+ jobId: Helper.safeReadParams(_this.props, 'jobId') ? _this.props.match.params.jobId : null,
2729
+ job: null,
2730
+ showingSelector: false,
2731
+ updating: false,
2732
+ connected: false,
2733
+ types: [],
2734
+ id: null,
2735
+ userID: '',
2736
+ userName: '',
2737
+ room: '',
2738
+ phone: '',
2739
+ location: _this.props.auth.site,
2740
+ title: '',
2741
+ description: '',
2742
+ isHome: false,
2743
+ homeText: '',
2744
+ type: 'General',
2745
+ image: null,
2746
+ thumbnail: null,
2719
2747
  showWarnings: false,
2720
- submitting: false
2748
+ success: false
2721
2749
  };
2722
2750
  return _this;
2723
2751
  }
2724
2752
 
2725
- _createClass(JobTypes, [{
2726
- key: "componentWillMount",
2727
- value: function componentWillMount() {
2728
- this.updateProps(this.props);
2753
+ _createClass(AddJob, [{
2754
+ key: "UNSAFE_componentWillMount",
2755
+ value: function UNSAFE_componentWillMount() {
2729
2756
  Session.checkLoggedIn(this, this.props.auth);
2730
2757
  }
2731
2758
  }, {
2732
2759
  key: "componentDidMount",
2733
2760
  value: function componentDidMount() {
2734
2761
  this.getJobTypes();
2762
+ if (this.state.jobId) this.getJob();
2763
+ this.props.addRecentlyCreated('maintenance');
2735
2764
  }
2736
2765
  }, {
2737
- key: "componentWillReceiveProps",
2738
- value: function componentWillReceiveProps(nextProps) {
2739
- this.updateProps(nextProps);
2740
- }
2741
- }, {
2742
- key: "updateProps",
2743
- value: function updateProps(props) {
2744
- this.setState({
2745
- jobList: props.jobtypes
2746
- });
2747
- }
2748
- }, {
2749
- key: "renderList",
2750
- value: function renderList() {
2766
+ key: "renderTypeOptions",
2767
+ value: function renderTypeOptions() {
2751
2768
  var _this2 = this;
2752
2769
 
2753
- var source = _.sortBy(this.state.jobList, this.state.sortColumn);
2754
-
2755
- if (this.state.sortDesc) source.reverse();
2756
- source = _.filter(source, function (ev) {
2757
- if (!ev) return false;
2758
- if (ev.Deleted) return false;
2759
- return true;
2760
- });
2761
- return source.map(function (ev, index) {
2770
+ var source = this.state.types;
2771
+ return source.map(function (ev) {
2762
2772
  if (ev != null) {
2763
- return /*#__PURE__*/React.createElement("tr", {
2764
- key: index
2765
- }, /*#__PURE__*/React.createElement("td", {
2766
- className: "table-TitleColumn"
2767
- }, /*#__PURE__*/React.createElement("a", {
2768
- onClick: function onClick() {
2769
- return _this2.onShowJobType(ev);
2770
- }
2771
- }, ev.typeName)), /*#__PURE__*/React.createElement("td", null, ev.description), /*#__PURE__*/React.createElement("td", null, ev.email), /*#__PURE__*/React.createElement("td", {
2772
- className: "table-options"
2773
- }, /*#__PURE__*/React.createElement("div", {
2774
- style: {
2775
- display: 'flex',
2776
- alignItems: 'center'
2777
- }
2778
- }, Session.validateAccess(_this2.props.auth.site, 'maintenanceTypes', _this2.props.auth) && /*#__PURE__*/React.createElement("a", {
2779
- onClick: function onClick() {
2780
- return _this2.onShowJobType(ev);
2781
- }
2782
- }, /*#__PURE__*/React.createElement(FontAwesome, {
2783
- style: {
2784
- fontSize: 20,
2785
- padding: 5,
2786
- marginLeft: 12,
2787
- cursor: 'pointer'
2788
- },
2789
- name: "pencil"
2790
- })), Session.validateAccess(_this2.props.auth.site, 'maintenanceTypes', _this2.props.auth) && /*#__PURE__*/React.createElement("a", {
2791
- onClick: function onClick() {
2792
- return _this2.onRemoveJobType(ev);
2793
- }
2794
- }, /*#__PURE__*/React.createElement(FontAwesome, {
2795
- style: {
2796
- fontSize: 20,
2797
- padding: 5,
2798
- marginLeft: 8,
2799
- cursor: 'pointer'
2800
- },
2801
- name: "minus-circle"
2802
- })))));
2773
+ return /*#__PURE__*/React.createElement(MenuItem, {
2774
+ key: ev.typeName,
2775
+ eventKey: ev.typeName,
2776
+ active: _this2.state.type === ev.typeName
2777
+ }, ev.typeName);
2803
2778
  }
2804
2779
 
2805
2780
  return null;
2806
2781
  });
2807
2782
  }
2808
2783
  }, {
2809
- key: "renderView",
2810
- value: function renderView() {
2811
- var _this3 = this;
2812
-
2813
- return /*#__PURE__*/React.createElement(Table, {
2814
- className: "plussTable",
2815
- striped: true,
2816
- bordered: true,
2817
- condensed: true,
2818
- hover: true,
2819
- style: {
2820
- minWidth: '100%'
2821
- }
2822
- }, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
2823
- style: {
2824
- cursor: 'pointer'
2825
- },
2826
- onClick: function onClick() {
2827
- return _this3.sortByCol('name');
2828
- }
2829
- }, "Request type"), /*#__PURE__*/React.createElement("th", {
2830
- style: {
2831
- cursor: 'pointer'
2832
- },
2833
- onClick: function onClick() {
2834
- return _this3.sortByCol('name');
2835
- }
2836
- }, "Type Description"), /*#__PURE__*/React.createElement("th", {
2837
- style: {
2838
- cursor: 'pointer'
2839
- },
2840
- onClick: function onClick() {
2841
- return _this3.sortByCol('email');
2842
- }
2843
- }, "Email"), /*#__PURE__*/React.createElement("th", {
2844
- style: {
2845
- width: 70
2846
- }
2847
- }))), /*#__PURE__*/React.createElement("tbody", null, this.renderList()));
2848
- }
2849
- }, {
2850
- key: "renderEmpty",
2851
- value: function renderEmpty() {
2852
- return /*#__PURE__*/React.createElement("div", {
2853
- style: {
2854
- display: 'flex',
2855
- flexDirection: 'column',
2856
- flex: 1,
2857
- justifyContent: 'center',
2858
- alignItems: 'center',
2859
- marginTop: 32
2860
- }
2861
- }, /*#__PURE__*/React.createElement("div", {
2862
- className: "emptyState"
2863
- }), /*#__PURE__*/React.createElement("div", {
2864
- className: "marginTop-32",
2865
- style: {
2866
- maxWidth: 500,
2867
- textAlign: 'center'
2868
- }
2869
- }, /*#__PURE__*/React.createElement("span", {
2870
- className: "fontRegular fontSize-13"
2871
- }, "Please add the many categories of request types that exist in your village which work alongside the Maintenance area.")), /*#__PURE__*/React.createElement("div", {
2872
- className: "marginTop-8 fontRegular fontSize-13",
2873
- style: {
2874
- maxWidth: 500,
2875
- textAlign: 'center'
2876
- }
2877
- }, "Examples might be; OH&S, Electrical, General. Remember to add a description too."));
2784
+ key: "renderSuccess",
2785
+ value: function renderSuccess() {
2786
+ if (!this.state.success) return null;
2787
+ return /*#__PURE__*/React.createElement(Components.SuccessPopup, {
2788
+ text: "Maintenance request has been ".concat(this.state.id != null ? 'edited' : 'added'),
2789
+ buttons: [{
2790
+ type: 'outlined',
2791
+ onClick: function onClick() {
2792
+ window.history.back();
2793
+ },
2794
+ text: "Back to Maintenance"
2795
+ }]
2796
+ });
2878
2797
  }
2879
- }, {
2880
- key: "renderContent",
2881
- value: function renderContent() {
2882
- if (_.isEmpty(this.state.jobList)) return this.renderEmpty();
2883
- return this.renderView();
2798
+ }, {
2799
+ key: "validateForm",
2800
+ value: function validateForm() {
2801
+ if (_.isEmpty(this.state.userName)) return false;
2802
+ if (_.isEmpty(this.state.room)) return false;
2803
+ if (_.isEmpty(this.state.title)) return false;
2804
+ if (this.state.isHome && _.isEmpty(this.state.homeText)) return false;
2805
+ return true;
2884
2806
  }
2885
2807
  }, {
2886
- key: "renderJobTypes",
2887
- value: function renderJobTypes() {
2888
- var _this4 = this;
2889
-
2890
- var _this$state3 = this.state,
2891
- jobList = _this$state3.jobList,
2892
- loading = _this$state3.loading;
2808
+ key: "renderSubmit",
2809
+ value: function renderSubmit() {
2810
+ var _this3 = this;
2893
2811
 
2894
- if (jobList.length === 0 && loading) {
2895
- return /*#__PURE__*/React.createElement("div", {
2896
- style: {
2897
- minWidth: '100%'
2898
- }
2899
- }, /*#__PURE__*/React.createElement("div", {
2900
- className: "padding-60 paddingVertical-40",
2901
- style: {
2902
- textAlign: 'center'
2903
- }
2904
- }, /*#__PURE__*/React.createElement(FontAwesome, {
2905
- style: {
2906
- fontSize: 30,
2907
- color: FeatureConfig.env.colourBrandingOff
2908
- },
2909
- name: "spinner fa-pulse fa-fw"
2910
- })));
2812
+ if (this.state.updating) {
2813
+ return /*#__PURE__*/React.createElement(Components.Button, {
2814
+ buttonType: "secondary"
2815
+ }, "Saving...");
2911
2816
  }
2912
2817
 
2913
- return /*#__PURE__*/React.createElement("div", {
2914
- style: {
2915
- minWidth: '100%'
2916
- }
2917
- }, /*#__PURE__*/React.createElement("div", {
2918
- className: "flex flex-row flex-center flex-between marginBottom-32"
2919
- }, /*#__PURE__*/React.createElement(Components.PageTitle, null, "Request Types"), /*#__PURE__*/React.createElement(Components.AddButton, {
2818
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Components.Button, {
2819
+ inline: true,
2820
+ buttonType: "tertiary",
2920
2821
  onClick: function onClick() {
2921
- return _this4.onShowJobType();
2822
+ return _this3.props.history.push('/requestsHub');
2922
2823
  },
2923
- text: "NEW REQUEST TYPE"
2924
- })), this.renderContent());
2824
+ isActive: true,
2825
+ style: {
2826
+ marginRight: 16
2827
+ }
2828
+ }, "Cancel"), /*#__PURE__*/React.createElement(Components.Button, {
2829
+ inline: true,
2830
+ buttonType: "primary",
2831
+ onClick: this.onSave,
2832
+ isActive: this.validateForm()
2833
+ }, "Save"));
2925
2834
  }
2926
2835
  }, {
2927
- key: "renderNewUserTypePopup",
2928
- value: function renderNewUserTypePopup() {
2929
- var _this5 = this;
2836
+ key: "renderMain",
2837
+ value: function renderMain() {
2838
+ var _this4 = this;
2930
2839
 
2931
- var _this$state4 = this.state,
2932
- submitting = _this$state4.submitting,
2933
- showJobType = _this$state4.showJobType,
2934
- jobTypeId = _this$state4.jobTypeId,
2935
- showWarnings = _this$state4.showWarnings,
2936
- jobTypeName = _this$state4.jobTypeName,
2937
- jobTypeEmail = _this$state4.jobTypeEmail,
2938
- jobTypeDescription = _this$state4.jobTypeDescription;
2939
- if (!showJobType) return null;
2940
- return /*#__PURE__*/React.createElement(Components.Popup, {
2941
- maxWidth: 800,
2942
- hasPadding: true,
2943
- buttons: [{
2944
- type: 'primaryAction',
2945
- onClick: this.onSave,
2946
- isActive: !submitting && this.isJobTypeValid(),
2947
- text: submitting ? 'Saving...' : 'Save',
2948
- className: 'popupButton'
2949
- }, {
2950
- type: 'outlinedAction',
2951
- onClick: this.onHideJobType,
2952
- isActive: !submitting,
2953
- text: 'Cancel',
2954
- className: 'popupButton'
2955
- }],
2956
- onClose: this.onHideJobType,
2957
- title: jobTypeId ? 'Edit Request Type' : 'Create New Request Type'
2958
- }, /*#__PURE__*/React.createElement(Components.GenericInput, {
2959
- id: "jobTypeName",
2840
+ return /*#__PURE__*/React.createElement("div", {
2841
+ style: {
2842
+ marginBottom: 15
2843
+ }
2844
+ }, /*#__PURE__*/React.createElement("div", {
2845
+ className: "padding-60 paddingVertical-40 bottomDivideBorder"
2846
+ }, /*#__PURE__*/React.createElement(Components.Text, {
2847
+ type: "formTitleLarge",
2848
+ className: "marginBottom-24"
2849
+ }, this.state.infoId == null ? 'New' : 'Edit', " Request"), /*#__PURE__*/React.createElement(Components.GenericInput, {
2850
+ id: "userName",
2960
2851
  type: "text",
2961
- label: "Request type title",
2962
- placeholder: "Request type title",
2963
- value: jobTypeName,
2964
- onChange: this.onHandleChange,
2852
+ label: "Name",
2853
+ placeholder: "Insert name here",
2854
+ value: this.state.userName,
2855
+ onChange: function onChange(e) {
2856
+ return _this4.onHandleChange(e);
2857
+ },
2965
2858
  isRequired: true,
2859
+ alwaysShowLabel: true,
2966
2860
  isValid: function isValid() {
2967
- return !_.isEmpty(jobTypeName);
2861
+ return !_.isEmpty(_this4.state.userName);
2968
2862
  },
2969
2863
  showError: function showError() {
2970
- return showWarnings && _.isEmpty(jobTypeName);
2864
+ return _this4.state.showWarnings && _.isEmpty(_this4.state.userName);
2865
+ }
2866
+ }), /*#__PURE__*/React.createElement(Components.GenericInput, {
2867
+ id: "room",
2868
+ type: "text",
2869
+ label: "Location",
2870
+ placeholder: "Insert address here",
2871
+ value: this.state.room,
2872
+ onChange: function onChange(e) {
2873
+ return _this4.onHandleChange(e);
2971
2874
  },
2972
- alwaysShowLabel: true
2875
+ isRequired: true,
2876
+ alwaysShowLabel: true,
2877
+ isValid: function isValid() {
2878
+ return !_.isEmpty(_this4.state.room);
2879
+ },
2880
+ showError: function showError() {
2881
+ return _this4.state.showWarnings && _.isEmpty(_this4.state.room);
2882
+ }
2973
2883
  }), /*#__PURE__*/React.createElement(Components.GenericInput, {
2974
- id: "jobTypeEmail",
2884
+ id: "phone",
2975
2885
  type: "text",
2976
- label: "Email",
2977
- placeholder: "Request email",
2978
- help: "This is the email address that'll receive service requests of this type",
2979
- value: jobTypeEmail,
2980
- onChange: this.onHandleChange,
2886
+ label: "Contact number",
2887
+ placeholder: "04XX XXX XXX",
2888
+ value: this.state.phone // showError={this.state.showWarnings && !this.validateImage()}
2889
+ ,
2890
+ onChange: function onChange(e) {
2891
+ return _this4.onHandleChange(e);
2892
+ },
2893
+ alwaysShowLabel: true
2894
+ }), /*#__PURE__*/React.createElement("div", {
2895
+ style: {
2896
+ marginBottom: 15
2897
+ }
2898
+ }, /*#__PURE__*/React.createElement(Components.Text, {
2899
+ type: "formLabel"
2900
+ }, "Job Type"), /*#__PURE__*/React.createElement(DropdownButton, {
2901
+ style: {
2902
+ minWidth: 80
2903
+ },
2904
+ bsStyle: "default",
2905
+ title: this.state.type,
2906
+ id: "typeSelect",
2907
+ onSelect: this.onSelectType
2908
+ }, this.renderTypeOptions())), /*#__PURE__*/React.createElement(Components.GenericInput, {
2909
+ id: "title",
2910
+ label: "Title for the work required",
2911
+ type: "textarea",
2912
+ placeholder: "Title for the work required",
2913
+ value: this.state.title,
2914
+ onChange: function onChange(e) {
2915
+ return _this4.onHandleChange(e);
2916
+ },
2917
+ inputStyle: {
2918
+ height: 80
2919
+ },
2981
2920
  isRequired: true,
2982
- isValid: this.validateEmail,
2921
+ isValid: function isValid() {
2922
+ return !_.isEmpty(_this4.state.title);
2923
+ },
2983
2924
  showError: function showError() {
2984
- return showWarnings && !_this5.validateEmail();
2925
+ return _this4.state.showWarnings && _.isEmpty(_this4.state.title);
2985
2926
  },
2986
2927
  alwaysShowLabel: true
2987
2928
  }), /*#__PURE__*/React.createElement(Components.GenericInput, {
2988
- id: "jobTypeDescription",
2989
- type: "text",
2990
- label: "Description",
2991
- placeholder: "Add a description. ",
2992
- help: "This description will be visible to the people to help them select the correct request type.",
2993
- value: jobTypeDescription,
2994
- onChange: this.onHandleChange,
2929
+ id: "description",
2930
+ label: "Description of work required",
2931
+ type: "textarea",
2932
+ placeholder: "Description of work required",
2933
+ value: this.state.description,
2934
+ onChange: function onChange(e) {
2935
+ return _this4.onHandleChange(e);
2936
+ },
2937
+ inputStyle: {
2938
+ height: 80
2939
+ },
2940
+ alwaysShowLabel: true
2941
+ }), /*#__PURE__*/React.createElement(Components.RadioButton, {
2942
+ label: "Person must be home during work?",
2943
+ isActive: this.state.isHome,
2944
+ options: [{
2945
+ Label: 'No',
2946
+ Value: false,
2947
+ onChange: function onChange() {
2948
+ return _this4.setState({
2949
+ isHome: false
2950
+ });
2951
+ }
2952
+ }, {
2953
+ Label: 'Yes',
2954
+ Value: true,
2955
+ onChange: function onChange() {
2956
+ return _this4.setState({
2957
+ isHome: true
2958
+ });
2959
+ }
2960
+ }]
2961
+ }), this.state.isHome && /*#__PURE__*/React.createElement(Components.GenericInput, {
2962
+ style: {
2963
+ marginTop: 16
2964
+ },
2965
+ label: "Description of person's available times",
2966
+ id: "homeText",
2967
+ type: "textarea",
2968
+ placeholder: "Description of person's available times",
2969
+ value: this.state.homeText,
2970
+ onChange: function onChange(e) {
2971
+ return _this4.onHandleChange(e);
2972
+ },
2973
+ inputStyle: {
2974
+ height: 80
2975
+ },
2995
2976
  isRequired: true,
2996
2977
  isValid: function isValid() {
2997
- return !_.isEmpty(jobTypeDescription);
2978
+ return !_.isEmpty(_this4.state.homeText);
2998
2979
  },
2999
2980
  showError: function showError() {
3000
- return showWarnings && _.isEmpty(jobTypeDescription);
2981
+ return _this4.state.showWarnings && _.isEmpty(_this4.state.homeText);
3001
2982
  },
3002
2983
  alwaysShowLabel: true
3003
- }));
2984
+ })));
3004
2985
  }
3005
2986
  }, {
3006
2987
  key: "render",
3007
2988
  value: function render() {
3008
- return /*#__PURE__*/React.createElement("div", {
3009
- className: "hub-wrapperContainer"
3010
- }, /*#__PURE__*/React.createElement("div", {
3011
- className: "hub-headerContentWrapper"
3012
- }, /*#__PURE__*/React.createElement(Components.Header, null), /*#__PURE__*/React.createElement("div", {
3013
- className: "hub-contentWrapper",
3014
- style: {
3015
- position: 'relative'
3016
- }
3017
- }, this.renderJobTypes()), this.renderNewUserTypePopup()));
2989
+ var success = this.state.success;
2990
+ return /*#__PURE__*/React.createElement(Components.OverlayPage, null, /*#__PURE__*/React.createElement(Components.OverlayPageContents, {
2991
+ noBottomButtons: success
2992
+ }, /*#__PURE__*/React.createElement(Components.OverlayPageSection, {
2993
+ className: "pageSectionWrapper--newPopup"
2994
+ }, /*#__PURE__*/React.createElement("div", null, this.renderSuccess(), !success && this.renderMain()))), /*#__PURE__*/React.createElement(Components.OverlayPageBottomButtons, null, this.renderSubmit()));
3018
2995
  }
3019
2996
  }]);
3020
2997
 
3021
- return JobTypes;
2998
+ return AddJob;
3022
2999
  }(Component);
3023
3000
 
3024
3001
  var mapStateToProps = function mapStateToProps(state) {
3025
- var jobtypes = state.maintenance.jobtypes;
3026
3002
  var auth = state.auth;
3027
3003
  return {
3028
- jobtypes: jobtypes,
3029
3004
  auth: auth
3030
3005
  };
3031
3006
  };
3032
3007
 
3033
- var JobTypes$1 = connect(mapStateToProps, {
3034
- jobTypesLoaded: jobTypesLoaded,
3035
- jobTypesUpdate: jobTypesUpdate
3036
- })(withRouter(JobTypes));
3008
+ var AddJob$1 = connect(mapStateToProps, {
3009
+ jobsUpdate: jobsUpdate,
3010
+ jobsLoaded: jobsLoaded,
3011
+ addRecentlyCreated: Actions.addRecentlyCreated
3012
+ })(withRouter(AddJob));
3037
3013
 
3038
3014
  function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
3039
3015
 
@@ -3428,8 +3404,7 @@ var Reducers = {
3428
3404
  var Screens = {
3429
3405
  RequestsHub: RequestsHub$1,
3430
3406
  Job: Job$1,
3431
- AddJob: AddJob$1,
3432
- JobTypes: JobTypes$1
3407
+ AddJob: AddJob$1
3433
3408
  };
3434
3409
 
3435
3410
  export { ActivityText, FeatureConfig as Config, PreviewFull, PreviewGrid, PreviewWidget, Reducers, Screens, ViewFull, ViewWidget };