@plusscommunities/pluss-maintenance-web-a 1.1.27 → 1.1.28

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.
@@ -33,6 +33,8 @@ class Job extends Component {
33
33
  noteInput: '',
34
34
  noteImages: [],
35
35
  assignees: [],
36
+ externalSync: null,
37
+ loadingExternalSync: false,
36
38
  };
37
39
  }
38
40
 
@@ -46,6 +48,7 @@ class Job extends Component {
46
48
  this.getJob();
47
49
  this.getComments();
48
50
  this.getAssignees();
51
+ this.getExternalSync();
49
52
  }
50
53
  }
51
54
 
@@ -69,6 +72,20 @@ class Job extends Component {
69
72
  }
70
73
  };
71
74
 
75
+ getExternalSync = async () => {
76
+ try {
77
+ this.setState({ loadingExternalSync: true });
78
+ const res = await maintenanceActions.getExternalSync(this.state.jobId);
79
+ this.setState({ externalSync: res.data, loadingExternalSync: false });
80
+ } catch (error) {
81
+ // 404 is expected if no sync - don't show error
82
+ if (error.response?.status !== 404) {
83
+ console.error('getExternalSync', error);
84
+ }
85
+ this.setState({ loadingExternalSync: false });
86
+ }
87
+ };
88
+
72
89
  getStatusType = (status) => {
73
90
  const { statusTypes } = this.props;
74
91
  let statusType = statusTypes.find((s) => s.text === status);
@@ -801,6 +818,24 @@ class Job extends Component {
801
818
  );
802
819
  }
803
820
 
821
+ renderExternalSyncEntry(e, i) {
822
+ const isSuccess = e.EntryType === 'ExternalIDSet';
823
+ const backgroundColor = isSuccess ? Colours.COLOUR_GREEN : Colours.COLOUR_RED; // Green for success, red for failure
824
+
825
+ return (
826
+ <div className="ticketHistoryEntry" key={i}>
827
+ <p className="ticketHistoryEntry_timestamp">{moment.utc(e.timestamp).local().format('D MMM YYYY h:mma')}</p>
828
+ <div className="statusLabel statusLabel-large statusLabel-full" style={{ backgroundColor }}>
829
+ <span className="statusLabel_text">
830
+ {isSuccess
831
+ ? `Synced to ${e.externalSystem || 'external system'}${e.externalId ? ` (ID: ${e.externalId})` : ''}`
832
+ : `Failed to sync to external system${e.error ? `: ${e.error}` : ''}`}
833
+ </span>
834
+ </div>
835
+ </div>
836
+ );
837
+ }
838
+
804
839
  renderPriority() {
805
840
  const { auth } = this.props;
806
841
  if (!Session.validateAccess(auth.site, values.permissionMaintenanceTracking, auth)) return null;
@@ -817,6 +852,40 @@ class Job extends Component {
817
852
  );
818
853
  }
819
854
 
855
+ renderExternalSync() {
856
+ const { externalSync, loadingExternalSync } = this.state;
857
+
858
+ // Only show if external sync data exists
859
+ if (!externalSync || loadingExternalSync) return null;
860
+
861
+ return (
862
+ <div className="padding-32 paddingVertical-40 bottomDivideBorder relative">
863
+ <div className="newTopBar clearfix flex flex-reverse">
864
+ <Components.Text type="formTitleSmall" className="flex-1">
865
+ External Sync
866
+ </Components.Text>
867
+ </div>
868
+ <div className="marginTop-16">
869
+ {externalSync.externalSystem && (
870
+ <Components.Text type="body" className="marginBottom-8">
871
+ <strong>System:</strong> {externalSync.externalSystem}
872
+ </Components.Text>
873
+ )}
874
+ {externalSync.externalId && (
875
+ <Components.Text type="body" className="marginBottom-8">
876
+ <strong>External ID:</strong> {externalSync.externalId}
877
+ </Components.Text>
878
+ )}
879
+ {externalSync.syncedAt && (
880
+ <Components.Text type="body" className="marginBottom-8">
881
+ <strong>Synced:</strong> {moment.utc(externalSync.syncedAt).local().format('D MMM YYYY h:mma')}
882
+ </Components.Text>
883
+ )}
884
+ </div>
885
+ </div>
886
+ );
887
+ }
888
+
820
889
  renderOverview() {
821
890
  const { job } = this.state;
822
891
  if (!job || !job.history) return null;
@@ -851,6 +920,9 @@ class Job extends Component {
851
920
  return this.renderNote(e, i);
852
921
  case 'assignment':
853
922
  return this.renderAssignmentEntry(e, i);
923
+ case 'ExternalIDSet':
924
+ case 'ExternalIDSetFailed':
925
+ return this.renderExternalSyncEntry(e, i);
854
926
  default:
855
927
  break;
856
928
  }
@@ -1080,6 +1152,7 @@ class Job extends Component {
1080
1152
  <Components.OverlayPageSection className="pageSectionWrapper--newPopupSide pageSectionWrapper--newPopupSide-fixedWidth">
1081
1153
  {this.renderAssignment()}
1082
1154
  {this.renderPriority()}
1155
+ {this.renderExternalSync()}
1083
1156
  {this.renderOverview()}
1084
1157
  </Components.OverlayPageSection>
1085
1158
  </Components.OverlayPageContents>