@mseva/upyog-ui-module-ads 1.1.58 → 1.1.60

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.
@@ -1,4 +1,4 @@
1
- import { Modal, Card as Card$1, CheckBox, Header, SearchForm, SearchField, TextInput, Dropdown, MobileNumber, CardLabelError as CardLabelError$1, DatePicker, SubmitBar, Table, Loader as Loader$2, Toast, AppContainer, BackButton, PrivateRoute, CloseSvg, RadioButtons, Banner, CardText as CardText$1, ActionBar, KeyNote, DeleteIcon, CardSubHeader, FormStep, CardHeader as CardHeader$1, CardLabel, TelePhone, DisplayPhotos, LocationSearchCard as LocationSearchCard$1, CheckPoint, ConnectingCheckPoints, CardSectionHeader, TickMark, CardLabelDesc, TextArea, LabelFieldPair, UploadFile, StatusTable, Row, LinkButton, EmployeeModuleCard, PropertyHouse, Label, LinkLabel, Localities, DetailsCard, SearchAction, FilterAction, PopUp, ShippingTruck, MultiLink, FormComposer, Menu, CitizenHomeCard } from '@mseva/digit-ui-react-components';
1
+ import { Modal, Card as Card$1, CheckBox, Header, SearchForm, SearchField, TextInput, Dropdown, MobileNumber, CardLabelError as CardLabelError$1, DatePicker, SubmitBar, Table, Loader as Loader$2, Toast, AppContainer, BackButton, PrivateRoute, CloseSvg, RadioButtons, Banner, CardText as CardText$1, ActionBar, KeyNote, DeleteIcon, CardSubHeader, FormStep, CardHeader as CardHeader$1, CardLabel, TelePhone, DisplayPhotos, LocationSearchCard as LocationSearchCard$1, CheckPoint, ConnectingCheckPoints, TickMark, CardLabelDesc, TextArea, LabelFieldPair, UploadFile, StatusTable, Row, LinkButton, EmployeeModuleCard, PropertyHouse, Label, LinkLabel, Localities, DetailsCard, SearchAction, FilterAction, PopUp, ShippingTruck, MultiLink, FormComposer, Menu, CitizenHomeCard } from '@mseva/digit-ui-react-components';
2
2
  import React, { useState, useEffect, useMemo, useCallback, useRef, Fragment as Fragment$1 } from 'react';
3
3
  import { useTranslation } from 'react-i18next';
4
4
  import { useHistory, Link, useParams, useRouteMatch, Switch, useLocation, Route, Redirect } from 'react-router-dom';
@@ -16763,13 +16763,20 @@ const GIS = ({
16763
16763
  }))));
16764
16764
  };
16765
16765
 
16766
- const getTimelineAcknowledgementData = (workflowDetails, tenantInfo, t) => {
16766
+ const getTimelineAcknowledgementData = (workflowDetails, tenantInfo, pdfFiles = {}, t) => {
16767
16767
  var _workflowDetails$data, _workflowDetails$data2, _processInstances$, _processInstances$2, _processInstances$3, _timeline$, _timeline$2, _timeline$3, _timeline$4;
16768
+ console.log('pdfFiles', pdfFiles);
16768
16769
  const timeline = (workflowDetails === null || workflowDetails === void 0 ? void 0 : (_workflowDetails$data = workflowDetails.data) === null || _workflowDetails$data === void 0 ? void 0 : _workflowDetails$data.timeline) || (workflowDetails === null || workflowDetails === void 0 ? void 0 : workflowDetails.timeline) || [];
16769
16770
  const processInstances = (workflowDetails === null || workflowDetails === void 0 ? void 0 : (_workflowDetails$data2 = workflowDetails.data) === null || _workflowDetails$data2 === void 0 ? void 0 : _workflowDetails$data2.processInstances) || (workflowDetails === null || workflowDetails === void 0 ? void 0 : workflowDetails.processInstances) || [];
16770
16771
  const businessId = (processInstances === null || processInstances === void 0 ? void 0 : (_processInstances$ = processInstances[0]) === null || _processInstances$ === void 0 ? void 0 : _processInstances$.businessId) || "N/A";
16771
16772
  const businessService = (processInstances === null || processInstances === void 0 ? void 0 : (_processInstances$2 = processInstances[0]) === null || _processInstances$2 === void 0 ? void 0 : _processInstances$2.businessService) || "N/A";
16772
16773
  const moduleName = (processInstances === null || processInstances === void 0 ? void 0 : (_processInstances$3 = processInstances[0]) === null || _processInstances$3 === void 0 ? void 0 : _processInstances$3.moduleName) || "N/A";
16774
+ const pdfDownloadLink = (documents, fileStoreId) => {
16775
+ var _downloadLink$split;
16776
+ const downloadLink = (documents === null || documents === void 0 ? void 0 : documents[fileStoreId]) || "";
16777
+ const formats = (downloadLink === null || downloadLink === void 0 ? void 0 : (_downloadLink$split = downloadLink.split(",")) === null || _downloadLink$split === void 0 ? void 0 : _downloadLink$split.filter(Boolean)) || [];
16778
+ return (formats === null || formats === void 0 ? void 0 : formats.find(link => !(link !== null && link !== void 0 && link.includes("large")) && !(link !== null && link !== void 0 && link.includes("medium")) && !(link !== null && link !== void 0 && link.includes("small")))) || (formats === null || formats === void 0 ? void 0 : formats[0]) || "";
16779
+ };
16773
16780
  const timelineRows = timeline.map((item, index) => {
16774
16781
  var _item$auditDetails, _item$auditDetails2, _item$assigner, _item$assigner2, _item$assigner3, _item$wfComment;
16775
16782
  const createdDate = (item === null || item === void 0 ? void 0 : (_item$auditDetails = item.auditDetails) === null || _item$auditDetails === void 0 ? void 0 : _item$auditDetails.created) || "N/A";
@@ -16796,7 +16803,8 @@ const getTimelineAcknowledgementData = (workflowDetails, tenantInfo, t) => {
16796
16803
  documents: documents.map(doc => ({
16797
16804
  name: (doc === null || doc === void 0 ? void 0 : doc.fileName) || (doc === null || doc === void 0 ? void 0 : doc.documentType) || "Document",
16798
16805
  type: (doc === null || doc === void 0 ? void 0 : doc.documentType) || "Document",
16799
- fileStoreId: doc === null || doc === void 0 ? void 0 : doc.fileStoreId
16806
+ fileStoreId: doc === null || doc === void 0 ? void 0 : doc.fileStoreId,
16807
+ link: pdfDownloadLink(pdfFiles, doc === null || doc === void 0 ? void 0 : doc.fileStoreId)
16800
16808
  })),
16801
16809
  hasDocuments: documents.length > 0
16802
16810
  };
@@ -16980,18 +16988,30 @@ const ApplicationTimeline = ({
16980
16988
  workflowDetails,
16981
16989
  t
16982
16990
  }) => {
16983
- var _workflowDetails$data2, _workflowDetails$data3, _workflowDetails$data4, _timeline$;
16991
+ var _workflowDetails$data2, _workflowDetails$data3, _workflowDetails$data4, _workflowDetails$data5, _workflowDetails$data6, _workflowDetails$data7, _workflowDetails$data8, _timeline$;
16984
16992
  const details = (workflowDetails === null || workflowDetails === void 0 ? void 0 : workflowDetails.data) || workflowDetails;
16985
16993
  const timeline = useMemo(() => normalizeTimeline({
16986
16994
  data: details
16987
16995
  }), [details]);
16988
16996
  const currentState = workflowDetails === null || workflowDetails === void 0 ? void 0 : (_workflowDetails$data2 = workflowDetails.data) === null || _workflowDetails$data2 === void 0 ? void 0 : (_workflowDetails$data3 = _workflowDetails$data2.timeline) === null || _workflowDetails$data3 === void 0 ? void 0 : (_workflowDetails$data4 = _workflowDetails$data3[0]) === null || _workflowDetails$data4 === void 0 ? void 0 : _workflowDetails$data4.state;
16997
+ const {
16998
+ isLoading,
16999
+ data
17000
+ } = Digit.Hooks.ads.useADSDocumentSearch({
17001
+ value: (workflowDetails === null || workflowDetails === void 0 ? void 0 : (_workflowDetails$data5 = workflowDetails.data) === null || _workflowDetails$data5 === void 0 ? void 0 : (_workflowDetails$data6 = _workflowDetails$data5.timeline) === null || _workflowDetails$data6 === void 0 ? void 0 : _workflowDetails$data6.flatMap(item => item === null || item === void 0 ? void 0 : item.wfDocuments)) || []
17002
+ }, {
17003
+ value: (workflowDetails === null || workflowDetails === void 0 ? void 0 : (_workflowDetails$data7 = workflowDetails.data) === null || _workflowDetails$data7 === void 0 ? void 0 : (_workflowDetails$data8 = _workflowDetails$data7.timeline) === null || _workflowDetails$data8 === void 0 ? void 0 : _workflowDetails$data8.flatMap(item => item === null || item === void 0 ? void 0 : item.wfDocuments)) || []
17004
+ }, null, 0);
17005
+ console.log('data of doc hook', data);
16989
17006
  const handleDownloadPDF = useCallback(() => {
16990
- const tenantInfo = Digit.SessionStorage.get("CITIZEN.COMMON.HOME.CITY") || {};
16991
- const acknowledgementData = getTimelineAcknowledgementData(workflowDetails, tenantInfo, t);
16992
- Digit.Utils.pdf.generateTimelinePDF(acknowledgementData);
16993
- }, [workflowDetails, t]);
17007
+ if (!isLoading) {
17008
+ const tenantInfo = Digit.SessionStorage.get("CITIZEN.COMMON.HOME.CITY") || {};
17009
+ const acknowledgementData = getTimelineAcknowledgementData(workflowDetails, tenantInfo, (data === null || data === void 0 ? void 0 : data.pdfFiles) || {}, t);
17010
+ Digit.Utils.pdf.generateTimelinePDF(acknowledgementData);
17011
+ }
17012
+ }, [workflowDetails, data, t]);
16994
17013
  if (!(timeline !== null && timeline !== void 0 && timeline.length)) return null;
17014
+ if (isLoading) return /*#__PURE__*/React.createElement(Loader$2, null);
16995
17015
  return /*#__PURE__*/React.createElement("div", {
16996
17016
  className: "timeline-hoc-container"
16997
17017
  }, /*#__PURE__*/React.createElement("div", {
@@ -17023,7 +17043,7 @@ const ApplicationTimeline = ({
17023
17043
  };
17024
17044
 
17025
17045
  const ADSWFApplicationTimeline = props => {
17026
- var _props$application2, _props$application3, _props$application4, _data$timeline;
17046
+ var _props$application2, _props$application3, _props$application4;
17027
17047
  const {
17028
17048
  t
17029
17049
  } = useTranslation();
@@ -17036,12 +17056,7 @@ const ADSWFApplicationTimeline = props => {
17036
17056
  moduleCode: "advandhoarding-services"
17037
17057
  });
17038
17058
  if (isLoading) return /*#__PURE__*/React.createElement(Loader$2, null);
17039
- return /*#__PURE__*/React.createElement(React.Fragment, null, (data === null || data === void 0 ? void 0 : (_data$timeline = data.timeline) === null || _data$timeline === void 0 ? void 0 : _data$timeline.length) > 0 && /*#__PURE__*/React.createElement(CardSectionHeader, {
17040
- style: {
17041
- marginBottom: "16px",
17042
- marginTop: "32px"
17043
- }
17044
- }, t("CS_APPLICATION_DETAILS_APPLICATION_TIMELINE")), /*#__PURE__*/React.createElement(ApplicationTimeline, {
17059
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ApplicationTimeline, {
17045
17060
  workflowDetails: data,
17046
17061
  t: t
17047
17062
  }));
@@ -19749,7 +19764,8 @@ const ReservationTimer = ({
19749
19764
  const AdsApplication = ({
19750
19765
  application,
19751
19766
  tenantId,
19752
- buttonLabel
19767
+ buttonLabel,
19768
+ refetchBookings
19753
19769
  }) => {
19754
19770
  var _application$auditDet, _application$auditDet2, _application$applican;
19755
19771
  const {
@@ -19760,6 +19776,35 @@ const AdsApplication = ({
19760
19776
  const handleMakePayment = () => {
19761
19777
  history.push(`/digit-ui/citizen/payment/my-bills/adv-services/${application === null || application === void 0 ? void 0 : application.bookingNo}`);
19762
19778
  };
19779
+ const handleCancelBooking = async () => {
19780
+ const formData = {
19781
+ tenantId: application === null || application === void 0 ? void 0 : application.tenantId,
19782
+ ...application,
19783
+ workflow: {
19784
+ businessService: "advandhoarding",
19785
+ action: "CANCEL",
19786
+ comments: "User cancelled booking"
19787
+ }
19788
+ };
19789
+ try {
19790
+ var _response$ResponseInf;
19791
+ const response = await Digit.ADSServices.update({
19792
+ bookingApplication: formData
19793
+ }, application === null || application === void 0 ? void 0 : application.tenantId);
19794
+ if ((response === null || response === void 0 ? void 0 : (_response$ResponseInf = response.ResponseInfo) === null || _response$ResponseInf === void 0 ? void 0 : _response$ResponseInf.status) == "SUCCESSFUL" || (response === null || response === void 0 ? void 0 : response.status) == "SUCCESSFUL") {
19795
+ setShowToast({
19796
+ label: t((response === null || response === void 0 ? void 0 : response.resMsgId) || "ADS_CANCEL_SUCCESS"),
19797
+ error: false
19798
+ });
19799
+ refetchBookings();
19800
+ }
19801
+ } catch (err) {
19802
+ setShowToast({
19803
+ label: "ADS_CANCEL_FAILED",
19804
+ error: true
19805
+ });
19806
+ }
19807
+ };
19763
19808
  useEffect(() => {
19764
19809
  if (showToast) {
19765
19810
  const timer = setTimeout(() => {
@@ -19802,6 +19847,13 @@ const AdsApplication = ({
19802
19847
  margin: "20px"
19803
19848
  },
19804
19849
  disabled: expired
19850
+ }), application.bookingStatus === "BOOKED" && /*#__PURE__*/React.createElement(SubmitBar, {
19851
+ label: t("ADS_CANCEL_BOOKING"),
19852
+ onSubmit: handleCancelBooking,
19853
+ style: {
19854
+ margin: "20px"
19855
+ },
19856
+ disabled: expired
19805
19857
  })), showToast && /*#__PURE__*/React.createElement(Toast, {
19806
19858
  error: showToast.error,
19807
19859
  warning: showToast.warning,
@@ -19893,7 +19945,8 @@ const ADSMyApplications = () => {
19893
19945
  }, /*#__PURE__*/React.createElement(AdsApplication, {
19894
19946
  application: application,
19895
19947
  tenantId: tenantId,
19896
- buttonLabel: t("ADS_SUMMARY")
19948
+ buttonLabel: t("ADS_SUMMARY"),
19949
+ refetchBookings: refetch
19897
19950
  }))), !(applications !== null && applications !== void 0 && applications.length) > 0 && /*#__PURE__*/React.createElement("p", {
19898
19951
  style: {
19899
19952
  marginLeft: "16px",
@@ -23099,7 +23152,7 @@ const ApplicationDetails = () => {
23099
23152
  const appNo = (displayData === null || displayData === void 0 ? void 0 : (_displayData$applican3 = displayData.applicantData) === null || _displayData$applican3 === void 0 ? void 0 : _displayData$applican3.applicationNo) || id;
23100
23153
  return history.push(`/digit-ui/employee/payment/collect/adv-services/${appNo}/${tenantId}?tenantId=${tenantId}`);
23101
23154
  }
23102
- if (wfAction.action === "SUBMIT" || wfAction.action === "INITIATE") {
23155
+ if (wfAction.action === "SUBMIT" || wfAction.action === "INITIATE" || wfAction.action === "CANCEL") {
23103
23156
  const payloadAction = {
23104
23157
  action: wfAction.action,
23105
23158
  comment: wfAction.action || ""