@djb25/digit-ui-module-ws 1.0.66 → 1.0.68

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.
@@ -10914,6 +10914,11 @@ const BILLSBreadCrumbs = _ref => {
10914
10914
  path: "/digit-ui/employee/ws/required-documents",
10915
10915
  label: t("ES_COMMON_WS_DOCUMENTS_REQUIRED"),
10916
10916
  show: location.pathname.includes("/required-documents") ? true : false
10917
+ }, {
10918
+ path: "" + (location === null || location === void 0 ? void 0 : location.pathname) + location.search,
10919
+ label: t("WS_MUTATION_CONNECTION_LABEL"),
10920
+ show: location.pathname.includes("/mutation-application") ? true : false,
10921
+ isBack: true
10917
10922
  }, {
10918
10923
  path: requestParam ? "/digit-ui/employee/ws/bill-amendment?" + requestParam : "/digit-ui/employee/ws/bill-amendment",
10919
10924
  label: t("WS_BILL_AMEND_APP"),
@@ -11248,6 +11253,9 @@ const App$1 = _ref2 => {
11248
11253
  let actions = [];
11249
11254
  const getAction = flow => {
11250
11255
  switch (flow) {
11256
+ case "MUTATION":
11257
+ actions = ['WS_MUTATION_DETAILS', 'WS_MUTATION_NEW_CONSUMER', 'WS_MUTATION_DOCUMENTS', 'WS_MUTATION_PREVIEW'];
11258
+ break;
11251
11259
  default:
11252
11260
  actions = ['WS_COMMON_PROPERTY_DETAILS', 'WS_COMMON_CONNECTION_DETAIL', 'WS_COMMON_DOCUMENT_DETAILS', 'WS_COMMON_SUMMARY'];
11253
11261
  }
@@ -17430,13 +17438,13 @@ const UploadFileDigiLocker = props => {
17430
17438
  useEffect(() => handleEmpty(), [inpRef === null || inpRef === void 0 ? void 0 : (_inpRef$current = inpRef.current) === null || _inpRef$current === void 0 ? void 0 : _inpRef$current.files]);
17431
17439
  useEffect(() => handleChange(), [props.message]);
17432
17440
  const dataURItoBlob = dataURI => {
17433
- var binary = atob(dataURI.split(',')[1]);
17441
+ var binary = atob(dataURI.split(",")[1]);
17434
17442
  var array = [];
17435
17443
  for (var i = 0; i < binary.length; i++) {
17436
17444
  array.push(binary.charCodeAt(i));
17437
17445
  }
17438
17446
  return new Blob([new Uint8Array(array)], {
17439
- type: 'application/pdf'
17447
+ type: "application/pdf"
17440
17448
  });
17441
17449
  };
17442
17450
  const fetchDigiLockerDocuments = function (e) {
@@ -17470,20 +17478,69 @@ const UploadFileDigiLocker = props => {
17470
17478
  const code = props.documentType.toUpperCase();
17471
17479
  if (code.includes("AADHAAR") || code.includes("AADHAR")) doctype = "ADHAR";else if (code.includes("DRIVING") || code.includes("DRVLC")) doctype = "DRVLC";else if (code.includes("PAN")) doctype = "PANCR";else if (code.includes("VOTER")) doctype = "VOTER";
17472
17480
  }
17473
- let uri = res1.IssuedDoc.filter(item => item.doctype === doctype);
17474
- const _temp = function () {
17481
+ const DOCTYPE_ALIASES = {
17482
+ ADHAR: ["ADHAR", "AADHAAR", "AADHAR"],
17483
+ DRVLC: ["DRVLC", "DRIVING"],
17484
+ PANCR: ["PANCR", "PANCH", "PAN"],
17485
+ VOTER: ["VOTER", "VOTERID"]
17486
+ };
17487
+ const aliases = DOCTYPE_ALIASES[doctype] || [doctype];
17488
+ let uri = res1.IssuedDoc.filter(item => aliases.some(alias => item.doctype === alias));
17489
+ const _temp5 = function () {
17475
17490
  if ((uri === null || uri === void 0 ? void 0 : uri.length) > 0) {
17491
+ const uriStr = uri[0].uri || "";
17492
+ const parts = uriStr.split("-");
17493
+ const documentNumber = parts.length > 1 ? parts[parts.length - 1] : "";
17494
+ if (documentNumber && props !== null && props !== void 0 && props.onDocumentNumber) {
17495
+ props.onDocumentNumber(documentNumber);
17496
+ }
17476
17497
  let TokenReqNew = {
17477
17498
  authToken: digiLockerToken,
17478
- id: uri[0].uri
17499
+ id: uriStr
17479
17500
  };
17480
17501
  const tenantId = Digit.ULBService.getCurrentTenantId() || "dl.djb";
17481
17502
  return Promise.resolve(Digit.DigiLockerService.uri({
17482
17503
  TokenReq: TokenReqNew
17483
17504
  }, tenantId)).then(function (res2) {
17484
- let c = new Blob([res2]);
17485
- let filename = doctype + "_" + (uri[0].name || "document") + ".pdf";
17486
- convertToFile(e, c, filename);
17505
+ function _temp4() {
17506
+ let filename = doctype + "_" + (uri[0].name || "document") + ".pdf";
17507
+ if (blobData) convertToFile(e, blobData, filename);else setShowToast({
17508
+ error: true,
17509
+ label: "Failed to read document from DigiLocker."
17510
+ });
17511
+ }
17512
+ let blobData;
17513
+ const _temp3 = function () {
17514
+ if (typeof res2 === "string" && res2.includes("base64")) {
17515
+ blobData = dataURItoBlob(res2);
17516
+ } else {
17517
+ const _temp2 = function () {
17518
+ if (res2 instanceof Blob) {
17519
+ blobData = res2;
17520
+ } else {
17521
+ const _temp = function () {
17522
+ if (res2 && typeof res2 === "object" && res2.fileStoreId) {
17523
+ return Promise.resolve(Digit.UploadServices.FileFetchbyid(res2.fileStoreId, Digit.ULBService.getStateId())).then(function (fileRes) {
17524
+ if (fileRes !== null && fileRes !== void 0 && fileRes.data) {
17525
+ var _fileRes$headers;
17526
+ blobData = fileRes.data instanceof Blob ? fileRes.data : new Blob([fileRes.data], {
17527
+ type: ((_fileRes$headers = fileRes.headers) === null || _fileRes$headers === void 0 ? void 0 : _fileRes$headers["content-type"]) || "application/pdf"
17528
+ });
17529
+ }
17530
+ });
17531
+ } else {
17532
+ blobData = new Blob([JSON.stringify(res2)], {
17533
+ type: "application/pdf"
17534
+ });
17535
+ }
17536
+ }();
17537
+ if (_temp && _temp.then) return _temp.then(function () {});
17538
+ }
17539
+ }();
17540
+ if (_temp2 && _temp2.then) return _temp2.then(function () {});
17541
+ }
17542
+ }();
17543
+ return _temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3);
17487
17544
  });
17488
17545
  } else {
17489
17546
  setShowToast({
@@ -17492,7 +17549,7 @@ const UploadFileDigiLocker = props => {
17492
17549
  });
17493
17550
  }
17494
17551
  }();
17495
- if (_temp && _temp.then) return _temp.then(function () {});
17552
+ if (_temp5 && _temp5.then) return _temp5.then(function () {});
17496
17553
  });
17497
17554
  }, function (error) {
17498
17555
  console.error("DigiLocker Fetch Error:", error);
@@ -17818,25 +17875,28 @@ function SelectDocument(_ref2) {
17818
17875
  documentUid = _useState7[0],
17819
17876
  setDocumentUid = _useState7[1];
17820
17877
  const _useState8 = useState(false),
17821
- showCamera = _useState8[0],
17822
- setShowCamera = _useState8[1];
17878
+ isDocumentUidLocked = _useState8[0],
17879
+ setIsDocumentUidLocked = _useState8[1];
17823
17880
  const _useState9 = useState(false),
17824
- isUploading = _useState9[0],
17825
- setIsUploading = _useState9[1];
17881
+ showCamera = _useState9[0],
17882
+ setShowCamera = _useState9[1];
17826
17883
  const _useState0 = useState(false),
17827
- setIsCameraFile = _useState0[1];
17884
+ isUploading = _useState0[0],
17885
+ setIsUploading = _useState0[1];
17828
17886
  const _useState1 = useState(false),
17829
- showDocModal = _useState1[0],
17830
- setShowDocModal = _useState1[1];
17831
- const _useState10 = useState(""),
17832
- docFileUrl = _useState10[0],
17833
- setDocFileUrl = _useState10[1];
17887
+ setIsCameraFile = _useState1[1];
17888
+ const _useState10 = useState(false),
17889
+ showDocModal = _useState10[0],
17890
+ setShowDocModal = _useState10[1];
17834
17891
  const _useState11 = useState(""),
17835
- docFileType = _useState11[0],
17836
- setDocFileType = _useState11[1];
17837
- const _useState12 = useState(false),
17838
- digiLockerUpload = _useState12[0],
17839
- setDigilockerUpload = _useState12[1];
17892
+ docFileUrl = _useState11[0],
17893
+ setDocFileUrl = _useState11[1];
17894
+ const _useState12 = useState(""),
17895
+ docFileType = _useState12[0],
17896
+ setDocFileType = _useState12[1];
17897
+ const _useState13 = useState(false),
17898
+ digiLockerUpload = _useState13[0],
17899
+ setDigilockerUpload = _useState13[1];
17840
17900
  useEffect(() => {
17841
17901
  const eligible = isDigiLockerEligible((selectedDocument === null || selectedDocument === void 0 ? void 0 : selectedDocument.code) || "");
17842
17902
  setDigilockerUpload(eligible);
@@ -17854,17 +17914,16 @@ function SelectDocument(_ref2) {
17854
17914
  const _temp = _catch(function () {
17855
17915
  return Promise.resolve(Digit.UploadServices.FileFetchbyid(uploadedFile, Digit.ULBService.getStateId())).then(function (res) {
17856
17916
  if (res !== null && res !== void 0 && res.data) {
17917
+ var _res$headers, _res$headers2;
17918
+ const contentType = ((_res$headers = res.headers) === null || _res$headers === void 0 ? void 0 : _res$headers["content-type"]) || ((_res$headers2 = res.headers) === null || _res$headers2 === void 0 ? void 0 : _res$headers2["Content-Type"]) || "";
17919
+ const isPdf = contentType.toLowerCase().includes("pdf") || res.data instanceof Blob && res.data.type && res.data.type.toLowerCase().includes("pdf");
17920
+ const mimeType = isPdf ? "application/pdf" : contentType || "image/jpeg";
17857
17921
  const blob = res.data instanceof Blob ? res.data : new Blob([res.data], {
17858
- type: res.headers["content-type"] || res.headers["Content-Type"] || "image/jpeg"
17922
+ type: mimeType
17859
17923
  });
17860
17924
  const fileURL = URL.createObjectURL(blob);
17861
17925
  setDocFileUrl(fileURL);
17862
- const contentType = res.headers["content-type"] || res.headers["Content-Type"] || "";
17863
- if (contentType.toLowerCase().includes("pdf")) {
17864
- setDocFileType("pdf");
17865
- } else {
17866
- setDocFileType("image");
17867
- }
17926
+ setDocFileType(isPdf ? "pdf" : "image");
17868
17927
  setShowDocModal(true);
17869
17928
  }
17870
17929
  });
@@ -17903,8 +17962,8 @@ function SelectDocument(_ref2) {
17903
17962
  }
17904
17963
  const dropdownData = doc.dropdownData;
17905
17964
  var dropDownData = dropdownData;
17906
- const _useState13 = useState(false),
17907
- isHidden = _useState13[0];
17965
+ const _useState14 = useState(false),
17966
+ isHidden = _useState14[0];
17908
17967
  const addError = () => {
17909
17968
  var _formState$errors, _formState$errors$con;
17910
17969
  let type = formState === null || formState === void 0 ? void 0 : (_formState$errors = formState.errors) === null || _formState$errors === void 0 ? void 0 : (_formState$errors$con = _formState$errors[config.key]) === null || _formState$errors$con === void 0 ? void 0 : _formState$errors$con.type;
@@ -18044,8 +18103,16 @@ function SelectDocument(_ref2) {
18044
18103
  }, /*#__PURE__*/React.createElement(TextInput, {
18045
18104
  type: "text",
18046
18105
  value: documentUid,
18047
- onChange: e => setDocumentUid(e.target.value),
18048
- placeholder: t("WS_IDENTITY_NO_PLACEHOLDER")
18106
+ onChange: e => {
18107
+ if (!isDocumentUidLocked) setDocumentUid(e.target.value);
18108
+ },
18109
+ placeholder: t("WS_IDENTITY_NO_PLACEHOLDER"),
18110
+ disabled: isDocumentUidLocked,
18111
+ style: isDocumentUidLocked ? {
18112
+ backgroundColor: "#f0f0f0",
18113
+ cursor: "not-allowed",
18114
+ color: "#555"
18115
+ } : {}
18049
18116
  }))), /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, null, doc !== null && doc !== void 0 && doc.required ? t((doc === null || doc === void 0 ? void 0 : (_doc$i18nKey2 = doc.i18nKey) === null || _doc$i18nKey2 === void 0 ? void 0 : _doc$i18nKey2.replaceAll(".", "_")) + "_UPLOAD_DOCUMENT") + "*" : "" + t((doc === null || doc === void 0 ? void 0 : (_doc$i18nKey3 = doc.i18nKey) === null || _doc$i18nKey3 === void 0 ? void 0 : _doc$i18nKey3.replaceAll(".", "_")) + "_UPLOAD_DOCUMENT")), /*#__PURE__*/React.createElement("div", {
18050
18117
  className: "field",
18051
18118
  style: {
@@ -18064,6 +18131,7 @@ function SelectDocument(_ref2) {
18064
18131
  setUploadedFile(null);
18065
18132
  setFile(null);
18066
18133
  setIsCameraFile(false);
18134
+ setIsDocumentUidLocked(false);
18067
18135
  },
18068
18136
  id: id,
18069
18137
  message: uploadedFile ? "1 " + t("CS_ACTION_FILEUPLOADED") : t("CS_ACTION_NO_FILEUPLOADED"),
@@ -18080,8 +18148,13 @@ function SelectDocument(_ref2) {
18080
18148
  setUploadedFile(null);
18081
18149
  setFile(null);
18082
18150
  setIsCameraFile(false);
18151
+ setIsDocumentUidLocked(false);
18083
18152
  },
18084
- documentType: selectedDocument === null || selectedDocument === void 0 ? void 0 : selectedDocument.code
18153
+ documentType: selectedDocument === null || selectedDocument === void 0 ? void 0 : selectedDocument.code,
18154
+ onDocumentNumber: num => {
18155
+ setDocumentUid(num);
18156
+ setIsDocumentUidLocked(true);
18157
+ }
18085
18158
  }) : /*#__PURE__*/React.createElement(UploadFile, {
18086
18159
  onUpload: selectfile,
18087
18160
  onDelete: () => {
@@ -18218,12 +18291,12 @@ const CameraCaptureModal = _ref4 => {
18218
18291
  t = _ref4.t;
18219
18292
  const videoRef = useRef(null);
18220
18293
  const canvasRef = useRef(null);
18221
- const _useState14 = useState(null),
18222
- stream = _useState14[0],
18223
- setStream = _useState14[1];
18224
18294
  const _useState15 = useState(null),
18225
- error = _useState15[0],
18226
- setError = _useState15[1];
18295
+ stream = _useState15[0],
18296
+ setStream = _useState15[1];
18297
+ const _useState16 = useState(null),
18298
+ error = _useState16[0],
18299
+ setError = _useState16[1];
18227
18300
  useEffect(() => {
18228
18301
  const startCamera = function () {
18229
18302
  try {
@@ -47995,11 +48068,11 @@ const ApplicationDetails$1 = () => {
47995
48068
  };
47996
48069
 
47997
48070
  const GetConnectionDetails = () => {
47998
- var _applicationDetails$a, _applicationDetails$a2, _applicationDetails$a3, _applicationDetails$a4, _applicationDetails$a5, _applicationDetails$a6, _applicationDetails$a7, _applicationDetails$a8, _applicationDetails$a9, _applicationDetails$a0, _applicationDetails$a1, _applicationDetails$a10, _applicationDetails$a11, _applicationDetails$a12, _mdmsCommonmastersDat, _applicationDetails$a14, _applicationDetails$a18, _applicationDetails$f5, _applicationDetails$p3, _applicationDetails$p4, _applicationDetails$a19, _applicationDetails$a20, _applicationDetails$a21, _applicationDetails$f6, _applicationDetails$f7;
48071
+ var _applicationDetails$a, _applicationDetails$a2, _applicationDetails$a3, _applicationDetails$a4, _applicationDetails$a5, _applicationDetails$a6, _applicationDetails$a7, _applicationDetails$a8, _applicationDetails$a9, _applicationDetails$a0, _applicationDetails$a1, _applicationDetails$a10, _applicationDetails$a11, _applicationDetails$a12, _mdmsCommonmastersDat, _applicationDetails$a14, _applicationDetails$a18, _applicationDetails$f7, _applicationDetails$p3, _applicationDetails$p4, _applicationDetails$a19, _applicationDetails$a20, _applicationDetails$a21, _applicationDetails$f8, _applicationDetails$f9;
47999
48072
  const getBillSearch = function () {
48000
48073
  try {
48001
- const _temp = function (_applicationDetails$f8) {
48002
- if ((applicationDetails === null || applicationDetails === void 0 ? void 0 : (_applicationDetails$f8 = applicationDetails.fetchBillsData) === null || _applicationDetails$f8 === void 0 ? void 0 : _applicationDetails$f8.length) > 0) {
48074
+ const _temp = function (_applicationDetails$f0) {
48075
+ if ((applicationDetails === null || applicationDetails === void 0 ? void 0 : (_applicationDetails$f0 = applicationDetails.fetchBillsData) === null || _applicationDetails$f0 === void 0 ? void 0 : _applicationDetails$f0.length) > 0) {
48003
48076
  var _applicationDetails$a22;
48004
48077
  const service = serviceType === "WATER" ? "WS" : "SW";
48005
48078
  let wsSearchFilters = {
@@ -48129,7 +48202,7 @@ const GetConnectionDetails = () => {
48129
48202
  const checkApplicationStatus = (applicationDetails === null || applicationDetails === void 0 ? void 0 : (_applicationDetails$a14 = applicationDetails.applicationData) === null || _applicationDetails$a14 === void 0 ? void 0 : _applicationDetails$a14.status) === "Active" ? true : false;
48130
48203
  const checkWorkflow = applicationDetails === null || applicationDetails === void 0 ? void 0 : applicationDetails.isApplicationApproved;
48131
48204
  const getModifyConnectionButton = () => {
48132
- var _applicationDetails$f, _applicationDetails$a15, _applicationDetails$p;
48205
+ var _applicationDetails$f, _applicationDetails$f2, _applicationDetails$a15, _applicationDetails$p;
48133
48206
  if (!checkApplicationStatus) {
48134
48207
  setshowActionToast({
48135
48208
  key: "error",
@@ -48137,7 +48210,7 @@ const GetConnectionDetails = () => {
48137
48210
  });
48138
48211
  return;
48139
48212
  }
48140
- if ((applicationDetails === null || applicationDetails === void 0 ? void 0 : (_applicationDetails$f = applicationDetails.fetchBillsData[0]) === null || _applicationDetails$f === void 0 ? void 0 : _applicationDetails$f.totalAmount) > 0) {
48213
+ if ((applicationDetails === null || applicationDetails === void 0 ? void 0 : (_applicationDetails$f = applicationDetails.fetchBillsData) === null || _applicationDetails$f === void 0 ? void 0 : (_applicationDetails$f2 = _applicationDetails$f[0]) === null || _applicationDetails$f2 === void 0 ? void 0 : _applicationDetails$f2.totalAmount) > 0) {
48141
48214
  setshowActionToast({
48142
48215
  key: "error",
48143
48216
  label: "WS_DUE_AMOUNT_SHOULD_BE_ZERO"
@@ -48150,7 +48223,7 @@ const GetConnectionDetails = () => {
48150
48223
  }));
48151
48224
  };
48152
48225
  const getMutationButton = () => {
48153
- var _applicationDetails$f2, _applicationDetails$a16, _applicationDetails$p2;
48226
+ var _applicationDetails$f3, _applicationDetails$f4, _applicationDetails$a16, _applicationDetails$p2;
48154
48227
  if (!checkApplicationStatus) {
48155
48228
  setshowActionToast({
48156
48229
  key: "error",
@@ -48158,7 +48231,7 @@ const GetConnectionDetails = () => {
48158
48231
  });
48159
48232
  return;
48160
48233
  }
48161
- if ((applicationDetails === null || applicationDetails === void 0 ? void 0 : (_applicationDetails$f2 = applicationDetails.fetchBillsData[0]) === null || _applicationDetails$f2 === void 0 ? void 0 : _applicationDetails$f2.totalAmount) > 0) {
48234
+ if ((applicationDetails === null || applicationDetails === void 0 ? void 0 : (_applicationDetails$f3 = applicationDetails.fetchBillsData) === null || _applicationDetails$f3 === void 0 ? void 0 : (_applicationDetails$f4 = _applicationDetails$f3[0]) === null || _applicationDetails$f4 === void 0 ? void 0 : _applicationDetails$f4.totalAmount) > 0) {
48162
48235
  setshowActionToast({
48163
48236
  key: "error",
48164
48237
  label: "WS_DUE_AMOUNT_SHOULD_BE_ZERO"
@@ -48212,9 +48285,9 @@ const GetConnectionDetails = () => {
48212
48285
  label: "WORKFLOW_IN_PROGRESS"
48213
48286
  });
48214
48287
  } else {
48215
- var _billData$, _applicationDetails$f3;
48288
+ var _billData$, _applicationDetails$f5;
48216
48289
  console.log("due", due, applicationDetails);
48217
- if (((_billData$ = billData[0]) === null || _billData$ === void 0 ? void 0 : _billData$.status) === "ACTIVE" || (applicationDetails === null || applicationDetails === void 0 ? void 0 : (_applicationDetails$f3 = applicationDetails.fetchBillsData) === null || _applicationDetails$f3 === void 0 ? void 0 : _applicationDetails$f3.length) <= 0 || due == "0" || due < 0) {
48290
+ if (((_billData$ = billData[0]) === null || _billData$ === void 0 ? void 0 : _billData$.status) === "ACTIVE" || (applicationDetails === null || applicationDetails === void 0 ? void 0 : (_applicationDetails$f5 = applicationDetails.fetchBillsData) === null || _applicationDetails$f5 === void 0 ? void 0 : _applicationDetails$f5.length) <= 0 || due == "0" || due < 0) {
48218
48291
  Digit.SessionStorage.set("WS_DISCONNECTION", applicationDetails);
48219
48292
  history.push("" + pathname);
48220
48293
  } else {
@@ -48230,8 +48303,8 @@ const GetConnectionDetails = () => {
48230
48303
  label: "WORKFLOW_IN_PROGRESS"
48231
48304
  });
48232
48305
  } else {
48233
- var _billData$2, _applicationDetails$f4;
48234
- if (((_billData$2 = billData[0]) === null || _billData$2 === void 0 ? void 0 : _billData$2.status) === "ACTIVE" || (applicationDetails === null || applicationDetails === void 0 ? void 0 : (_applicationDetails$f4 = applicationDetails.fetchBillsData) === null || _applicationDetails$f4 === void 0 ? void 0 : _applicationDetails$f4.length) <= 0 || due === "0") {
48306
+ var _billData$2, _applicationDetails$f6;
48307
+ if (((_billData$2 = billData[0]) === null || _billData$2 === void 0 ? void 0 : _billData$2.status) === "ACTIVE" || (applicationDetails === null || applicationDetails === void 0 ? void 0 : (_applicationDetails$f6 = applicationDetails.fetchBillsData) === null || _applicationDetails$f6 === void 0 ? void 0 : _applicationDetails$f6.length) <= 0 || due === "0") {
48235
48308
  Digit.SessionStorage.set("WS_DISCONNECTION", applicationDetails);
48236
48309
  history.push("" + pathname);
48237
48310
  } else {
@@ -48266,7 +48339,7 @@ const GetConnectionDetails = () => {
48266
48339
  label: t("WS_CONNECTION_DETAILS"),
48267
48340
  onClick: () => downloadConnectionDetails()
48268
48341
  };
48269
- if ((applicationDetails === null || applicationDetails === void 0 ? void 0 : (_applicationDetails$f5 = applicationDetails.fetchBillsData) === null || _applicationDetails$f5 === void 0 ? void 0 : _applicationDetails$f5.length) > 0) dowloadOptions = [appFeeDownloadReceipt, connectionDetailsReceipt];else dowloadOptions = [connectionDetailsReceipt];
48342
+ if ((applicationDetails === null || applicationDetails === void 0 ? void 0 : (_applicationDetails$f7 = applicationDetails.fetchBillsData) === null || _applicationDetails$f7 === void 0 ? void 0 : _applicationDetails$f7.length) > 0) dowloadOptions = [appFeeDownloadReceipt, connectionDetailsReceipt];else dowloadOptions = [connectionDetailsReceipt];
48270
48343
  const Close = () => /*#__PURE__*/React.createElement("svg", {
48271
48344
  xmlns: "http://www.w3.org/2000/svg",
48272
48345
  viewBox: "0 0 24 24",
@@ -48389,7 +48462,7 @@ const GetConnectionDetails = () => {
48389
48462
  className: "modal-header-ws"
48390
48463
  }, t("WS_CLEAR_DUES_DISCONNECTION_SUB_HEADER_LABEL"), " "), /*#__PURE__*/React.createElement("div", {
48391
48464
  className: "modal-body-ws"
48392
- }, /*#__PURE__*/React.createElement("span", null, t("WS_COMMON_TABLE_COL_AMT_DUE_LABEL"), ": \u20B9", due ? due : applicationDetails === null || applicationDetails === void 0 ? void 0 : (_applicationDetails$f6 = applicationDetails.fetchBillsData) === null || _applicationDetails$f6 === void 0 ? void 0 : (_applicationDetails$f7 = _applicationDetails$f6[0]) === null || _applicationDetails$f7 === void 0 ? void 0 : _applicationDetails$f7.totalAmount))) : null, showActionToast && /*#__PURE__*/React.createElement(Toast, {
48465
+ }, /*#__PURE__*/React.createElement("span", null, t("WS_COMMON_TABLE_COL_AMT_DUE_LABEL"), ": \u20B9", due ? due : applicationDetails === null || applicationDetails === void 0 ? void 0 : (_applicationDetails$f8 = applicationDetails.fetchBillsData) === null || _applicationDetails$f8 === void 0 ? void 0 : (_applicationDetails$f9 = _applicationDetails$f8[0]) === null || _applicationDetails$f9 === void 0 ? void 0 : _applicationDetails$f9.totalAmount))) : null, showActionToast && /*#__PURE__*/React.createElement(Toast, {
48393
48466
  error: showActionToast.key,
48394
48467
  label: t("" + showActionToast.label),
48395
48468
  onClose: closeBillToast
@@ -49543,7 +49616,15 @@ const ConsumptionDetails = _ref => {
49543
49616
  meterReadings = _ref2.meterReadings;
49544
49617
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
49545
49618
  className: "employee-form-section-wrapper"
49546
- }, /*#__PURE__*/React.createElement("div", {
49619
+ }, /*#__PURE__*/React.createElement(VerticalTimeline, {
49620
+ config: [{
49621
+ timeLine: [{
49622
+ actions: "WS_VIEW_CONSUMPTION",
49623
+ currentStep: 1
49624
+ }]
49625
+ }],
49626
+ showFinalStep: false
49627
+ }), /*#__PURE__*/React.createElement("div", {
49547
49628
  style: {
49548
49629
  flex: 1,
49549
49630
  display: "flex",
@@ -50167,49 +50248,230 @@ const EditModifyApplication = () => {
50167
50248
  }));
50168
50249
  };
50169
50250
 
50170
- const WSMutationApplicantDetails = _ref => {
50171
- var _formData$config$key, _errors$proposedNewCo, _errors$newOwnerMobil, _errors$newOwnerEmail, _errors$relationshipW, _errors$reasonForName;
50251
+ const Step1_ExistingConnection = _ref => {
50252
+ var _appData$connectionHo, _propertyData$Propert, _propertyData$Propert2, _appData$property, _propertyAddress$loca;
50253
+ let applicationDetails = _ref.applicationDetails,
50254
+ propertyId = _ref.propertyId;
50255
+ const getMaskedName = name => {
50256
+ if (!name) return "NA";
50257
+ return name.split("").map((char, index) => index % 2 === 1 && char !== " " ? "*" : char).join("");
50258
+ };
50259
+ const getMaskedPhone = phone => {
50260
+ if (!phone || phone.length < 10) return "NA";
50261
+ return "******" + phone.slice(-4);
50262
+ };
50263
+ const appData = (applicationDetails === null || applicationDetails === void 0 ? void 0 : applicationDetails.applicationData) || {};
50264
+ const connectionNo = (appData === null || appData === void 0 ? void 0 : appData.connectionNo) || "NA";
50265
+ const meterId = (appData === null || appData === void 0 ? void 0 : appData.meterId) || "NA";
50266
+ const connectionStatus = (appData === null || appData === void 0 ? void 0 : appData.status) || "NA";
50267
+ const holderDetails = (appData === null || appData === void 0 ? void 0 : (_appData$connectionHo = appData.connectionHolders) === null || _appData$connectionHo === void 0 ? void 0 : _appData$connectionHo[0]) || {};
50268
+ const registeredName = getMaskedName(holderDetails === null || holderDetails === void 0 ? void 0 : holderDetails.name);
50269
+ const registeredPhone = getMaskedPhone(holderDetails === null || holderDetails === void 0 ? void 0 : holderDetails.mobileNumber);
50270
+ const tenantId = Digit.ULBService.getCurrentTenantId();
50271
+ const _Digit$Hooks$pt$usePr = Digit.Hooks.pt.usePropertySearch({
50272
+ filters: {
50273
+ propertyIds: propertyId
50274
+ },
50275
+ tenantId
50276
+ }, {
50277
+ enabled: !!propertyId
50278
+ }),
50279
+ propertyData = _Digit$Hooks$pt$usePr.data;
50280
+ const propertyAddress = (propertyData === null || propertyData === void 0 ? void 0 : (_propertyData$Propert = propertyData.Properties) === null || _propertyData$Propert === void 0 ? void 0 : (_propertyData$Propert2 = _propertyData$Propert[0]) === null || _propertyData$Propert2 === void 0 ? void 0 : _propertyData$Propert2.address) || (appData === null || appData === void 0 ? void 0 : (_appData$property = appData.property) === null || _appData$property === void 0 ? void 0 : _appData$property.address) || {};
50281
+ const formattedAddress = [(propertyAddress === null || propertyAddress === void 0 ? void 0 : propertyAddress.houseNo) || (propertyAddress === null || propertyAddress === void 0 ? void 0 : propertyAddress.doorNo), propertyAddress === null || propertyAddress === void 0 ? void 0 : propertyAddress.buildingName, propertyAddress === null || propertyAddress === void 0 ? void 0 : propertyAddress.street, propertyAddress === null || propertyAddress === void 0 ? void 0 : (_propertyAddress$loca = propertyAddress.locality) === null || _propertyAddress$loca === void 0 ? void 0 : _propertyAddress$loca.name, propertyAddress === null || propertyAddress === void 0 ? void 0 : propertyAddress.city, propertyAddress === null || propertyAddress === void 0 ? void 0 : propertyAddress.pincode].filter(Boolean).join(", ") || "NA";
50282
+ const missingFields = [];
50283
+ if (connectionNo === "NA") missingFields.push("Connection Number");
50284
+ if (registeredName === "NA") missingFields.push("Owner Name");
50285
+ if (formattedAddress === "NA") missingFields.push("Property Address");
50286
+ return /*#__PURE__*/React.createElement(Card, {
50287
+ style: {
50288
+ marginBottom: "20px"
50289
+ }
50290
+ }, /*#__PURE__*/React.createElement("div", {
50291
+ style: {
50292
+ padding: "16px",
50293
+ backgroundColor: "#fff3cd",
50294
+ color: "#856404",
50295
+ borderRadius: "8px",
50296
+ border: "1px solid #ffeeba",
50297
+ marginBottom: "20px",
50298
+ display: "flex",
50299
+ alignItems: "center"
50300
+ }
50301
+ }, /*#__PURE__*/React.createElement("span", {
50302
+ style: {
50303
+ marginRight: "8px",
50304
+ fontSize: "20px"
50305
+ }
50306
+ }, "\u2139\uFE0F"), /*#__PURE__*/React.createElement("span", {
50307
+ style: {
50308
+ fontWeight: "500"
50309
+ }
50310
+ }, "Name Change / Mutation is limited to changing the name of the consumer/account holder on the existing water connection. It does not constitute or imply transfer of property ownership.")), missingFields.length > 0 && /*#__PURE__*/React.createElement("div", {
50311
+ style: {
50312
+ padding: "12px 16px",
50313
+ backgroundColor: "#fdecea",
50314
+ color: "#611a15",
50315
+ borderRadius: "8px",
50316
+ border: "1px solid #f5c6cb",
50317
+ marginBottom: "16px",
50318
+ display: "flex",
50319
+ alignItems: "center"
50320
+ }
50321
+ }, /*#__PURE__*/React.createElement("span", {
50322
+ style: {
50323
+ marginRight: "8px",
50324
+ fontSize: "18px"
50325
+ }
50326
+ }, "\u26A0\uFE0F"), /*#__PURE__*/React.createElement("span", {
50327
+ style: {
50328
+ fontWeight: "500",
50329
+ fontSize: "14px"
50330
+ }
50331
+ }, "Please verify the connection data before proceeding.")), /*#__PURE__*/React.createElement("div", {
50332
+ style: {
50333
+ display: "flex",
50334
+ alignItems: "center",
50335
+ marginBottom: "16px"
50336
+ }
50337
+ }, /*#__PURE__*/React.createElement("span", {
50338
+ style: {
50339
+ fontSize: "24px",
50340
+ marginRight: "8px"
50341
+ }
50342
+ }, "\uD83C\uDFE2"), /*#__PURE__*/React.createElement("h2", {
50343
+ style: {
50344
+ fontSize: "20px",
50345
+ fontWeight: "700",
50346
+ margin: 0
50347
+ }
50348
+ }, "1. Existing Connection & Current Consumer Details.")), /*#__PURE__*/React.createElement("div", {
50349
+ style: {
50350
+ padding: "16px",
50351
+ backgroundColor: "#f9f9f9",
50352
+ borderRadius: "8px",
50353
+ borderLeft: "4px solid #00497e"
50354
+ }
50355
+ }, /*#__PURE__*/React.createElement("div", {
50356
+ style: {
50357
+ display: "grid",
50358
+ gridTemplateColumns: "1fr 1fr 1fr",
50359
+ gap: "16px"
50360
+ }
50361
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
50362
+ style: {
50363
+ color: "#555",
50364
+ fontSize: "14px",
50365
+ marginBottom: "4px"
50366
+ }
50367
+ }, "Connection Number"), /*#__PURE__*/React.createElement("div", {
50368
+ style: {
50369
+ fontWeight: "bold"
50370
+ }
50371
+ }, connectionNo)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
50372
+ style: {
50373
+ color: "#555",
50374
+ fontSize: "14px",
50375
+ marginBottom: "4px"
50376
+ }
50377
+ }, "Current Owner Name"), /*#__PURE__*/React.createElement("div", {
50378
+ style: {
50379
+ fontWeight: "bold"
50380
+ }
50381
+ }, registeredName)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
50382
+ style: {
50383
+ color: "#555",
50384
+ fontSize: "14px",
50385
+ marginBottom: "4px"
50386
+ }
50387
+ }, "Property Address"), /*#__PURE__*/React.createElement("div", {
50388
+ style: {
50389
+ fontWeight: "bold"
50390
+ }
50391
+ }, formattedAddress)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
50392
+ style: {
50393
+ color: "#555",
50394
+ fontSize: "14px",
50395
+ marginBottom: "4px"
50396
+ }
50397
+ }, "Connection Status"), /*#__PURE__*/React.createElement("div", {
50398
+ style: {
50399
+ fontWeight: "bold",
50400
+ color: (connectionStatus === null || connectionStatus === void 0 ? void 0 : connectionStatus.toLowerCase()) === "active" ? "#28a745" : "#dc3545"
50401
+ }
50402
+ }, connectionStatus)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
50403
+ style: {
50404
+ color: "#555",
50405
+ fontSize: "14px",
50406
+ marginBottom: "4px"
50407
+ }
50408
+ }, "Meter Number"), /*#__PURE__*/React.createElement("div", {
50409
+ style: {
50410
+ fontWeight: "bold"
50411
+ }
50412
+ }, meterId)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
50413
+ style: {
50414
+ color: "#555",
50415
+ fontSize: "14px",
50416
+ marginBottom: "4px"
50417
+ }
50418
+ }, "Mobile Number"), /*#__PURE__*/React.createElement("div", {
50419
+ style: {
50420
+ fontWeight: "bold"
50421
+ }
50422
+ }, registeredPhone)))));
50423
+ };
50424
+
50425
+ const Step2_NewConsumerDetails = _ref => {
50426
+ var _errors$proposedNewCo, _errors$gender, _errors$newOwnerMobil, _errors$newOwnerEmail, _errors$reasonForName, _errors$relationshipW;
50172
50427
  let t = _ref.t,
50173
- config = _ref.config,
50174
- onSelect = _ref.onSelect,
50175
- formData = _ref.formData,
50176
- clearErrors = _ref.clearErrors;
50428
+ onNext = _ref.onNext,
50429
+ onBack = _ref.onBack,
50430
+ defaultValues = _ref.defaultValues;
50177
50431
  const _useForm = useForm({
50178
- defaultValues: (formData === null || formData === void 0 ? void 0 : formData[config.key]) || {}
50432
+ defaultValues: defaultValues || {},
50433
+ mode: "onBlur"
50179
50434
  }),
50180
50435
  control = _useForm.control,
50181
- watch = _useForm.watch,
50182
- localFormState = _useForm.formState;
50183
- const formValue = watch();
50184
- const errors = localFormState.errors;
50436
+ handleSubmit = _useForm.handleSubmit,
50437
+ errors = _useForm.formState.errors,
50438
+ trigger = _useForm.trigger,
50439
+ setError = _useForm.setError,
50440
+ clearErrors = _useForm.clearErrors;
50441
+ const _useState = useState(null),
50442
+ showToast = _useState[0],
50443
+ setShowToast = _useState[1];
50444
+ const _useState2 = useState({}),
50445
+ touched = _useState2[0],
50446
+ setTouched = _useState2[1];
50447
+ const selectedReason = useWatch({
50448
+ control,
50449
+ name: "reasonForNameChange"
50450
+ });
50451
+ const isOtherReason = (selectedReason === null || selectedReason === void 0 ? void 0 : selectedReason.code) === "OTHER" || selectedReason === "OTHER";
50452
+ const genderOptions = [{
50453
+ code: "MALE",
50454
+ i18nKey: "Male"
50455
+ }, {
50456
+ code: "FEMALE",
50457
+ i18nKey: "Female"
50458
+ }, {
50459
+ code: "TRANSGENDER",
50460
+ i18nKey: "Transgender"
50461
+ }];
50185
50462
  const reasonOptions = [{
50186
50463
  code: "SALE_PURCHASE",
50187
- i18nKey: "Sale / Purchase of Property"
50464
+ i18nKey: "Purchase of Property"
50188
50465
  }, {
50189
50466
  code: "DEVOLUTION_INHERITANCE",
50190
50467
  i18nKey: "Devolution/Inheritance"
50191
50468
  }, {
50192
50469
  code: "OTHER",
50193
- i18nKey: "Other Reason(Gift, Lease, etc)"
50470
+ i18nKey: "Other Reason(Gift Deed, Lease Agreement, etc)"
50194
50471
  }];
50195
50472
  const relationshipOptions = [{
50196
- code: "MOTHER",
50197
- i18nKey: "Mother"
50198
- }, {
50199
- code: "FATHER",
50200
- i18nKey: "Father"
50201
- }, {
50202
- code: "SIBLING",
50203
- i18nKey: "Sibling"
50204
- }, {
50205
- code: "SPOUSE",
50206
- i18nKey: "Spouse"
50207
- }, {
50208
- code: "SON",
50209
- i18nKey: "Son"
50210
- }, {
50211
- code: "DAUGHTER",
50212
- i18nKey: "Daughter"
50473
+ code: "BLOOD_RELATION",
50474
+ i18nKey: "Blood Relation (Son / Daughter / Spouse)"
50213
50475
  }, {
50214
50476
  code: "LEGAL_HEIR",
50215
50477
  i18nKey: "Legal heir"
@@ -50217,432 +50479,1357 @@ const WSMutationApplicantDetails = _ref => {
50217
50479
  code: "OTHER",
50218
50480
  i18nKey: "Other"
50219
50481
  }];
50220
- const _useState = useState((formData === null || formData === void 0 ? void 0 : (_formData$config$key = formData[config.key]) === null || _formData$config$key === void 0 ? void 0 : _formData$config$key.saleDeedDocumentId) || null),
50221
- uploadedFile = _useState[0],
50222
- setUploadedFile = _useState[1];
50223
- const _useState2 = useState(null),
50224
- file = _useState2[0],
50225
- setFile = _useState2[1];
50226
- const _useState3 = useState(false),
50227
- isUploading = _useState3[0],
50228
- setIsUploading = _useState3[1];
50229
- useEffect(() => {
50230
- const currentState = _extends({}, formValue, {
50231
- saleDeedDocumentId: uploadedFile
50232
- });
50233
- if (!lodash.isEqual(formData === null || formData === void 0 ? void 0 : formData[config.key], currentState)) {
50234
- onSelect(config.key, currentState);
50235
- }
50236
- }, [formValue, uploadedFile]);
50237
- useEffect(() => {
50238
- (function () {
50239
- try {
50240
- const _temp2 = function () {
50241
- if (file) {
50242
- const _temp = _finallyRethrows(function () {
50243
- return _catch(function () {
50244
- setIsUploading(true);
50245
- return Promise.resolve(window.Digit.UploadServices.Filestorage("WS", file, window.Digit.ULBService.getStateId())).then(function (response) {
50246
- var _response$data, _response$data$files;
50247
- if ((response === null || response === void 0 ? void 0 : (_response$data = response.data) === null || _response$data === void 0 ? void 0 : (_response$data$files = _response$data.files) === null || _response$data$files === void 0 ? void 0 : _response$data$files.length) > 0) {
50248
- setUploadedFile(response.data.files[0].fileStoreId);
50249
- clearErrors && clearErrors(config.key);
50250
- }
50251
- });
50252
- }, function (err) {
50253
- console.error("File upload error", err);
50254
- });
50255
- }, function (_wasThrown, _result) {
50256
- setIsUploading(false);
50257
- if (_wasThrown) throw _result;
50258
- return _result;
50259
- });
50260
- if (_temp && _temp.then) return _temp.then(function () {});
50261
- }
50262
- }();
50263
- return _temp2 && _temp2.then ? _temp2.then(function () {}) : void 0;
50264
- } catch (e) {
50265
- Promise.reject(e);
50266
- }
50267
- })();
50268
- }, [file]);
50269
50482
  const errorStyle = {
50270
50483
  width: "100%",
50271
50484
  marginLeft: "0px",
50272
50485
  fontSize: "12px",
50273
- marginTop: "4px"
50486
+ marginTop: "4px",
50487
+ color: "#d32f2f"
50274
50488
  };
50275
- return /*#__PURE__*/React.createElement("div", {
50276
- className: "formcomposer-section-grid",
50489
+ const getFieldBorderStyle = fieldName => {
50490
+ if (errors !== null && errors !== void 0 && errors[fieldName]) return {
50491
+ border: "1px solid #d32f2f"
50492
+ };
50493
+ if (touched[fieldName] && !(errors !== null && errors !== void 0 && errors[fieldName])) return {
50494
+ border: "1px solid #28a745"
50495
+ };
50496
+ return {};
50497
+ };
50498
+ const onSubmit = data => {
50499
+ if (data.proposedNewConsumerName && data.proposedNewConsumerName.trim().length < 3) {
50500
+ setError("proposedNewConsumerName", {
50501
+ type: "manual",
50502
+ message: "Name must be at least 3 characters"
50503
+ });
50504
+ return;
50505
+ }
50506
+ if (data.proposedNewConsumerName && !/^[a-zA-Z\s.'-]+$/.test(data.proposedNewConsumerName.trim())) {
50507
+ setError("proposedNewConsumerName", {
50508
+ type: "manual",
50509
+ message: "Name should only contain alphabets, spaces, dots, hyphens"
50510
+ });
50511
+ return;
50512
+ }
50513
+ onNext(data);
50514
+ };
50515
+ const onError = () => {
50516
+ const errorCount = Object.keys(errors).length;
50517
+ setShowToast({
50518
+ key: "error",
50519
+ message: "Please fix " + errorCount + " validation error" + (errorCount > 1 ? "s" : "") + " before proceeding."
50520
+ });
50521
+ };
50522
+ const mandatoryIndicator = /*#__PURE__*/React.createElement("span", {
50277
50523
  style: {
50278
- gridTemplateColumns: "1fr 1fr",
50279
- gap: "20px",
50280
- display: "grid"
50524
+ color: "#d32f2f",
50525
+ marginLeft: "2px"
50526
+ }
50527
+ }, "*");
50528
+ return /*#__PURE__*/React.createElement(Card, {
50529
+ style: {
50530
+ marginBottom: "20px"
50281
50531
  }
50282
50532
  }, /*#__PURE__*/React.createElement("div", {
50283
50533
  style: {
50284
50534
  display: "flex",
50285
- flexDirection: "column",
50286
- gap: "20px"
50535
+ alignItems: "center",
50536
+ marginBottom: "16px"
50537
+ }
50538
+ }, /*#__PURE__*/React.createElement("span", {
50539
+ style: {
50540
+ fontSize: "24px",
50541
+ marginRight: "8px"
50542
+ }
50543
+ }, "\uD83D\uDC64"), /*#__PURE__*/React.createElement("h2", {
50544
+ style: {
50545
+ fontSize: "20px",
50546
+ fontWeight: "700",
50547
+ margin: 0
50287
50548
  }
50288
- }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(LabelFieldPair, {
50549
+ }, "2. New Consumer Details.")), Object.keys(errors).length > 0 && /*#__PURE__*/React.createElement("div", {
50289
50550
  style: {
50551
+ padding: "12px 16px",
50552
+ backgroundColor: "#fdecea",
50553
+ color: "#611a15",
50554
+ borderRadius: "8px",
50555
+ border: "1px solid #f5c6cb",
50556
+ marginBottom: "16px",
50290
50557
  display: "flex",
50291
- flexDirection: "column",
50292
- alignItems: "flex-start",
50293
- gap: "4px"
50558
+ alignItems: "center"
50294
50559
  }
50295
- }, /*#__PURE__*/React.createElement(CardLabel, {
50560
+ }, /*#__PURE__*/React.createElement("span", {
50296
50561
  style: {
50297
- margin: 0,
50562
+ marginRight: "8px",
50563
+ fontSize: "18px"
50564
+ }
50565
+ }, "\u26A0\uFE0F"), /*#__PURE__*/React.createElement("span", {
50566
+ style: {
50567
+ fontWeight: "500",
50568
+ fontSize: "14px"
50569
+ }
50570
+ }, "Please fill in all required fields marked with ", /*#__PURE__*/React.createElement("span", {
50571
+ style: {
50572
+ color: "#d32f2f",
50298
50573
  fontWeight: "bold"
50299
50574
  }
50300
- }, "PROPOSED NEW CONSUMER NAME*"), /*#__PURE__*/React.createElement("div", {
50301
- className: "field",
50575
+ }, "*"), " before proceeding.")), /*#__PURE__*/React.createElement("form", {
50576
+ onSubmit: handleSubmit(onSubmit, onError)
50577
+ }, /*#__PURE__*/React.createElement("div", {
50302
50578
  style: {
50303
- width: "100%"
50579
+ display: "grid",
50580
+ gridTemplateColumns: "1fr 1fr 1fr",
50581
+ gap: "24px",
50582
+ padding: "16px 0"
50304
50583
  }
50305
- }, /*#__PURE__*/React.createElement(Controller, {
50584
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(CardLabel, {
50585
+ style: {
50586
+ fontWeight: "bold"
50587
+ }
50588
+ }, "New Consumer Full Name ", mandatoryIndicator), /*#__PURE__*/React.createElement(Controller, {
50306
50589
  control: control,
50307
50590
  name: "proposedNewConsumerName",
50308
50591
  rules: {
50309
- required: "Required field"
50592
+ required: "Consumer name is required",
50593
+ minLength: {
50594
+ value: 3,
50595
+ message: "Name must be at least 3 characters"
50596
+ },
50597
+ pattern: {
50598
+ value: /^[a-zA-Z\s.'-]+$/,
50599
+ message: "Only alphabets, spaces, dots and hyphens allowed"
50600
+ }
50310
50601
  },
50311
50602
  render: props => /*#__PURE__*/React.createElement(TextInput, {
50312
50603
  value: props.value,
50313
50604
  onChange: e => {
50314
50605
  props.onChange(e.target.value);
50606
+ clearErrors("proposedNewConsumerName");
50315
50607
  },
50316
- placeholder: "Enter full legal name of new owner",
50317
- onBlur: props.onBlur
50608
+ onBlur: () => {
50609
+ props.onBlur();
50610
+ setTouched(p => _extends({}, p, {
50611
+ proposedNewConsumerName: true
50612
+ }));
50613
+ trigger("proposedNewConsumerName");
50614
+ },
50615
+ placeholder: "Enter full name (e.g. Rajesh Kumar)",
50616
+ style: getFieldBorderStyle("proposedNewConsumerName")
50318
50617
  })
50319
- }))), (errors === null || errors === void 0 ? void 0 : errors.proposedNewConsumerName) && /*#__PURE__*/React.createElement(CardLabelError, {
50618
+ }), (errors === null || errors === void 0 ? void 0 : errors.proposedNewConsumerName) && /*#__PURE__*/React.createElement(CardLabelError, {
50320
50619
  style: errorStyle
50321
- }, errors === null || errors === void 0 ? void 0 : (_errors$proposedNewCo = errors.proposedNewConsumerName) === null || _errors$proposedNewCo === void 0 ? void 0 : _errors$proposedNewCo.message)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(LabelFieldPair, {
50620
+ }, errors === null || errors === void 0 ? void 0 : (_errors$proposedNewCo = errors.proposedNewConsumerName) === null || _errors$proposedNewCo === void 0 ? void 0 : _errors$proposedNewCo.message)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(CardLabel, {
50322
50621
  style: {
50323
- display: "flex",
50324
- flexDirection: "column",
50325
- alignItems: "flex-start",
50326
- gap: "4px"
50327
- }
50328
- }, /*#__PURE__*/React.createElement(CardLabel, {
50329
- style: {
50330
- margin: 0,
50331
50622
  fontWeight: "bold"
50332
50623
  }
50333
- }, "NEW OWNER MOBILE NUMBER*"), /*#__PURE__*/React.createElement("div", {
50334
- className: "field",
50624
+ }, "Gender ", mandatoryIndicator), /*#__PURE__*/React.createElement(Controller, {
50625
+ control: control,
50626
+ name: "gender",
50627
+ rules: {
50628
+ required: "Please select gender"
50629
+ },
50630
+ render: props => /*#__PURE__*/React.createElement(Dropdown, {
50631
+ selected: props.value,
50632
+ option: genderOptions,
50633
+ select: val => {
50634
+ props.onChange(val);
50635
+ setTouched(p => _extends({}, p, {
50636
+ gender: true
50637
+ }));
50638
+ },
50639
+ optionKey: "i18nKey",
50640
+ t: t,
50641
+ placeholder: "Select Gender"
50642
+ })
50643
+ }), (errors === null || errors === void 0 ? void 0 : errors.gender) && /*#__PURE__*/React.createElement(CardLabelError, {
50644
+ style: errorStyle
50645
+ }, errors === null || errors === void 0 ? void 0 : (_errors$gender = errors.gender) === null || _errors$gender === void 0 ? void 0 : _errors$gender.message)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(CardLabel, {
50335
50646
  style: {
50336
- width: "100%"
50647
+ fontWeight: "bold"
50337
50648
  }
50338
- }, /*#__PURE__*/React.createElement(Controller, {
50649
+ }, "Mobile Number ", mandatoryIndicator), /*#__PURE__*/React.createElement(Controller, {
50339
50650
  control: control,
50340
50651
  name: "newOwnerMobileNumber",
50341
50652
  rules: {
50342
- required: "Required field",
50653
+ required: "Mobile number is required",
50343
50654
  pattern: {
50344
50655
  value: /^[6-9]\d{9}$/,
50345
- message: "Invalid mobile number"
50656
+ message: "Enter a valid 10-digit mobile number starting with 6-9"
50346
50657
  }
50347
50658
  },
50348
50659
  render: props => /*#__PURE__*/React.createElement(MobileNumber, {
50349
50660
  value: props.value || "",
50350
50661
  onChange: val => {
50351
50662
  props.onChange(val);
50663
+ clearErrors("newOwnerMobileNumber");
50352
50664
  },
50353
- placeholder: "Enter mobile number",
50354
- onBlur: props.onBlur
50665
+ onBlur: () => {
50666
+ setTouched(p => _extends({}, p, {
50667
+ newOwnerMobileNumber: true
50668
+ }));
50669
+ trigger("newOwnerMobileNumber");
50670
+ },
50671
+ placeholder: "Enter 10-digit mobile number",
50672
+ maxLength: 10
50355
50673
  })
50356
- }))), (errors === null || errors === void 0 ? void 0 : errors.newOwnerMobileNumber) && /*#__PURE__*/React.createElement(CardLabelError, {
50674
+ }), (errors === null || errors === void 0 ? void 0 : errors.newOwnerMobileNumber) && /*#__PURE__*/React.createElement(CardLabelError, {
50357
50675
  style: errorStyle
50358
- }, errors === null || errors === void 0 ? void 0 : (_errors$newOwnerMobil = errors.newOwnerMobileNumber) === null || _errors$newOwnerMobil === void 0 ? void 0 : _errors$newOwnerMobil.message)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(LabelFieldPair, {
50359
- style: {
50360
- display: "flex",
50361
- flexDirection: "column",
50362
- alignItems: "flex-start",
50363
- gap: "4px"
50364
- }
50365
- }, /*#__PURE__*/React.createElement(CardLabel, {
50676
+ }, errors === null || errors === void 0 ? void 0 : (_errors$newOwnerMobil = errors.newOwnerMobileNumber) === null || _errors$newOwnerMobil === void 0 ? void 0 : _errors$newOwnerMobil.message)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(CardLabel, {
50366
50677
  style: {
50367
- margin: 0,
50368
50678
  fontWeight: "bold"
50369
50679
  }
50370
- }, "NEW OWNER EMAIL ADDRESS"), /*#__PURE__*/React.createElement("div", {
50371
- className: "field",
50680
+ }, "Email ID ", /*#__PURE__*/React.createElement("span", {
50372
50681
  style: {
50373
- width: "100%"
50682
+ color: "#999",
50683
+ fontSize: "12px"
50374
50684
  }
50375
- }, /*#__PURE__*/React.createElement(Controller, {
50685
+ }, "(Optional)")), /*#__PURE__*/React.createElement(Controller, {
50376
50686
  control: control,
50377
50687
  name: "newOwnerEmailAddress",
50378
50688
  rules: {
50379
50689
  pattern: {
50380
50690
  value: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
50381
- message: "Invalid email address"
50691
+ message: "Please enter a valid email address"
50382
50692
  }
50383
50693
  },
50384
50694
  render: props => /*#__PURE__*/React.createElement(TextInput, {
50385
50695
  value: props.value,
50386
50696
  onChange: e => {
50387
50697
  props.onChange(e.target.value);
50698
+ clearErrors("newOwnerEmailAddress");
50388
50699
  },
50389
- placeholder: "Enter email address",
50390
- onBlur: props.onBlur
50700
+ onBlur: () => {
50701
+ props.onBlur();
50702
+ setTouched(p => _extends({}, p, {
50703
+ newOwnerEmailAddress: true
50704
+ }));
50705
+ trigger("newOwnerEmailAddress");
50706
+ },
50707
+ placeholder: "example@email.com",
50708
+ style: getFieldBorderStyle("newOwnerEmailAddress")
50391
50709
  })
50392
- }))), (errors === null || errors === void 0 ? void 0 : errors.newOwnerEmailAddress) && /*#__PURE__*/React.createElement(CardLabelError, {
50710
+ }), (errors === null || errors === void 0 ? void 0 : errors.newOwnerEmailAddress) && /*#__PURE__*/React.createElement(CardLabelError, {
50393
50711
  style: errorStyle
50394
- }, errors === null || errors === void 0 ? void 0 : (_errors$newOwnerEmail = errors.newOwnerEmailAddress) === null || _errors$newOwnerEmail === void 0 ? void 0 : _errors$newOwnerEmail.message)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(LabelFieldPair, {
50395
- style: {
50396
- display: "flex",
50397
- flexDirection: "column",
50398
- alignItems: "flex-start",
50399
- gap: "4px"
50400
- }
50401
- }, /*#__PURE__*/React.createElement(CardLabel, {
50712
+ }, errors === null || errors === void 0 ? void 0 : (_errors$newOwnerEmail = errors.newOwnerEmailAddress) === null || _errors$newOwnerEmail === void 0 ? void 0 : _errors$newOwnerEmail.message)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(CardLabel, {
50402
50713
  style: {
50403
- margin: 0,
50404
50714
  fontWeight: "bold"
50405
50715
  }
50406
- }, "RELATIONSHIP WITH EXISTING CONSUMER*"), /*#__PURE__*/React.createElement("div", {
50407
- className: "field",
50408
- style: {
50409
- width: "100%"
50410
- }
50411
- }, /*#__PURE__*/React.createElement(Controller, {
50716
+ }, "Reason for Name Change / Mutation ", mandatoryIndicator), /*#__PURE__*/React.createElement(Controller, {
50412
50717
  control: control,
50413
- name: "relationshipWithExistingConsumer",
50718
+ name: "reasonForNameChange",
50414
50719
  rules: {
50415
- required: "Required field"
50720
+ required: "Please select a reason for mutation"
50416
50721
  },
50417
50722
  render: props => /*#__PURE__*/React.createElement(Dropdown, {
50418
50723
  selected: props.value,
50419
- option: relationshipOptions,
50420
- select: e => {
50421
- props.onChange(e);
50724
+ option: reasonOptions,
50725
+ select: val => {
50726
+ props.onChange(val);
50727
+ setTouched(p => _extends({}, p, {
50728
+ reasonForNameChange: true
50729
+ }));
50422
50730
  },
50423
50731
  optionKey: "i18nKey",
50424
50732
  t: t,
50425
- placeholder: "Select relationship"
50733
+ placeholder: "Select reason"
50426
50734
  })
50427
- }))), (errors === null || errors === void 0 ? void 0 : errors.relationshipWithExistingConsumer) && /*#__PURE__*/React.createElement(CardLabelError, {
50735
+ }), (errors === null || errors === void 0 ? void 0 : errors.reasonForNameChange) && /*#__PURE__*/React.createElement(CardLabelError, {
50428
50736
  style: errorStyle
50429
- }, errors === null || errors === void 0 ? void 0 : (_errors$relationshipW = errors.relationshipWithExistingConsumer) === null || _errors$relationshipW === void 0 ? void 0 : _errors$relationshipW.message))), /*#__PURE__*/React.createElement("div", {
50430
- style: {
50431
- display: "flex",
50432
- flexDirection: "column",
50433
- gap: "20px"
50434
- }
50435
- }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(LabelFieldPair, {
50737
+ }, errors === null || errors === void 0 ? void 0 : (_errors$reasonForName = errors.reasonForNameChange) === null || _errors$reasonForName === void 0 ? void 0 : _errors$reasonForName.message)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(CardLabel, {
50436
50738
  style: {
50437
- display: "flex",
50438
- flexDirection: "column",
50439
- alignItems: "flex-start",
50440
- gap: "4px"
50441
- }
50442
- }, /*#__PURE__*/React.createElement(CardLabel, {
50443
- style: {
50444
- margin: 0,
50445
- fontWeight: "bold"
50446
- }
50447
- }, "REASON FOR NAME CHANGE*"), /*#__PURE__*/React.createElement("div", {
50448
- className: "field",
50449
- style: {
50450
- width: "100%"
50739
+ fontWeight: "bold",
50740
+ color: isOtherReason ? "inherit" : "#999"
50451
50741
  }
50452
- }, /*#__PURE__*/React.createElement(Controller, {
50742
+ }, "Relationship with Existing Consumer ", isOtherReason && mandatoryIndicator), /*#__PURE__*/React.createElement(Controller, {
50453
50743
  control: control,
50454
- name: "reasonForNameChange",
50744
+ name: "relationshipWithExistingConsumer",
50455
50745
  rules: {
50456
- required: "Required field"
50746
+ required: isOtherReason ? "Relationship is required when 'Other Reason' is selected" : false
50457
50747
  },
50458
50748
  render: props => /*#__PURE__*/React.createElement(Dropdown, {
50459
50749
  selected: props.value,
50460
- option: reasonOptions,
50461
- select: e => {
50462
- props.onChange(e);
50750
+ option: relationshipOptions,
50751
+ select: val => {
50752
+ props.onChange(val);
50753
+ setTouched(p => _extends({}, p, {
50754
+ relationshipWithExistingConsumer: true
50755
+ }));
50463
50756
  },
50464
50757
  optionKey: "i18nKey",
50465
50758
  t: t,
50466
- placeholder: "Select reason"
50759
+ placeholder: "Select relationship",
50760
+ disable: !isOtherReason
50467
50761
  })
50468
- }))), (errors === null || errors === void 0 ? void 0 : errors.reasonForNameChange) && /*#__PURE__*/React.createElement(CardLabelError, {
50469
- style: errorStyle
50470
- }, errors === null || errors === void 0 ? void 0 : (_errors$reasonForName = errors.reasonForNameChange) === null || _errors$reasonForName === void 0 ? void 0 : _errors$reasonForName.message)), /*#__PURE__*/React.createElement("div", {
50762
+ }), !isOtherReason && /*#__PURE__*/React.createElement("span", {
50471
50763
  style: {
50472
- marginTop: "10px",
50473
- padding: "20px",
50474
- border: "1px dashed #ccc",
50475
- borderRadius: "8px",
50476
- backgroundColor: "#fafafa"
50764
+ fontSize: "11px",
50765
+ color: "#999",
50766
+ marginTop: "4px",
50767
+ display: "block"
50477
50768
  }
50478
- }, /*#__PURE__*/React.createElement(LabelFieldPair, {
50769
+ }, "Enabled only when \"Other Reason\" is selected above"), (errors === null || errors === void 0 ? void 0 : errors.relationshipWithExistingConsumer) && /*#__PURE__*/React.createElement(CardLabelError, {
50770
+ style: errorStyle
50771
+ }, errors === null || errors === void 0 ? void 0 : (_errors$relationshipW = errors.relationshipWithExistingConsumer) === null || _errors$relationshipW === void 0 ? void 0 : _errors$relationshipW.message))), /*#__PURE__*/React.createElement("div", {
50479
50772
  style: {
50480
50773
  display: "flex",
50481
- flexDirection: "column",
50482
- alignItems: "flex-start",
50483
- gap: "4px"
50774
+ justifyContent: "space-between",
50775
+ alignItems: "center",
50776
+ marginTop: "24px"
50484
50777
  }
50485
- }, /*#__PURE__*/React.createElement(CardLabel, {
50778
+ }, /*#__PURE__*/React.createElement("button", {
50779
+ type: "button",
50780
+ onClick: onBack,
50486
50781
  style: {
50487
- margin: 0,
50782
+ padding: "8px 24px",
50783
+ backgroundColor: "#e0e0e0",
50784
+ border: "none",
50785
+ borderRadius: "4px",
50786
+ cursor: "pointer",
50488
50787
  fontWeight: "bold"
50489
50788
  }
50490
- }, "UPLOAD REGISTERED SALE DEED*"), /*#__PURE__*/React.createElement("p", {
50789
+ }, "\u2190 Back"), /*#__PURE__*/React.createElement("div", {
50491
50790
  style: {
50492
- color: "#666",
50493
- fontSize: "12px",
50494
- marginBottom: "15px",
50495
- marginTop: "5px"
50791
+ display: "flex",
50792
+ alignItems: "center",
50793
+ gap: "12px"
50496
50794
  }
50497
- }, "Submit a clear scan of the stamp duty Registered Sale Deed."), /*#__PURE__*/React.createElement("div", {
50498
- className: "field",
50795
+ }, /*#__PURE__*/React.createElement("span", {
50499
50796
  style: {
50500
- width: "100%"
50797
+ fontSize: "12px",
50798
+ color: "#999"
50501
50799
  }
50502
- }, /*#__PURE__*/React.createElement(UploadFile, {
50503
- id: "sale-deed-upload",
50504
- onUpload: e => {
50505
- setFile(e.target.files[0]);
50506
- },
50507
- onDelete: () => {
50508
- setUploadedFile(null);
50509
- setFile(null);
50510
- },
50511
- message: uploadedFile ? "1 File Uploaded" : "Click to upload document",
50512
- accept: "image/*, .pdf, .png, .jpeg, .jpg",
50513
- uploadedFiles: uploadedFile && !file ? [["Document", {
50514
- fileStoreId: uploadedFile
50515
- }]] : undefined,
50516
- removeTargetedFile: () => {
50517
- setUploadedFile(null);
50518
- setFile(null);
50800
+ }, "Fields marked with ", /*#__PURE__*/React.createElement("span", {
50801
+ style: {
50802
+ color: "#d32f2f"
50519
50803
  }
50520
- }))), isUploading && /*#__PURE__*/React.createElement("span", {
50804
+ }, "*"), " are mandatory"), /*#__PURE__*/React.createElement("button", {
50805
+ type: "submit",
50521
50806
  style: {
50522
- color: "#00497e",
50523
- fontWeight: "bold",
50524
- fontSize: "12px"
50807
+ padding: "10px 24px",
50808
+ backgroundColor: "#00497e",
50809
+ color: "white",
50810
+ border: "none",
50811
+ borderRadius: "4px",
50812
+ cursor: "pointer",
50813
+ fontWeight: "bold"
50525
50814
  }
50526
- }, "Uploading..."))));
50815
+ }, "Save & Proceed to Documents \u2192")))), showToast && /*#__PURE__*/React.createElement(Toast, {
50816
+ error: showToast.key === "error",
50817
+ warning: showToast.key === "warning",
50818
+ label: t(showToast.message),
50819
+ onClose: () => setShowToast(null),
50820
+ isDleteBtn: true
50821
+ }));
50527
50822
  };
50528
50823
 
50529
- const MutationApplication = () => {
50530
- var _state, _details, _details2, _details2$application, _applicationDetails$a, _applicationDetails$a2, _applicationDetails$a3, _applicationDetails$a4, _applicationDetails$a5, _applicationDetails$a6, _applicationDetails$a7;
50531
- const _useTranslation = useTranslation(),
50532
- t = _useTranslation.t;
50533
- let _useLocation = useLocation(),
50534
- state = _useLocation.state;
50535
- state = state ? typeof state === "string" ? JSON.parse(state) : state : {};
50536
- const history = useHistory();
50537
- let filters = getQueryStringParams(location.search);
50538
- const _useState = useState(false),
50539
- canSubmit = _useState[0],
50540
- setSubmitValve = _useState[1];
50541
- const _useState2 = useState(null),
50542
- showToast = _useState2[0],
50543
- setShowToast = _useState2[1];
50544
- const _useState3 = useState({}),
50545
- appData = _useState3[0],
50546
- setAppData = _useState3[1];
50547
- const _useState4 = useState({
50548
- head: "",
50549
- body: []
50824
+ const Step3_UploadDocuments = _ref => {
50825
+ var _defaultValues$reason;
50826
+ let t = _ref.t,
50827
+ onNext = _ref.onNext,
50828
+ onBack = _ref.onBack,
50829
+ defaultValues = _ref.defaultValues;
50830
+ const _useState = useState((defaultValues === null || defaultValues === void 0 ? void 0 : defaultValues.identityProofType) || null),
50831
+ identityProofType = _useState[0],
50832
+ setIdentityProofType = _useState[1];
50833
+ const _useState2 = useState((defaultValues === null || defaultValues === void 0 ? void 0 : defaultValues.documentNumber) || ""),
50834
+ documentNumber = _useState2[0],
50835
+ setDocumentNumber = _useState2[1];
50836
+ const _useState3 = useState((defaultValues === null || defaultValues === void 0 ? void 0 : defaultValues.identityProofDocumentId) || null),
50837
+ identityProofFile = _useState3[0],
50838
+ setIdentityProofFile = _useState3[1];
50839
+ const _useState4 = useState((defaultValues === null || defaultValues === void 0 ? void 0 : defaultValues.saleDeedDocumentId) || null),
50840
+ mutationDocFile = _useState4[0],
50841
+ setMutationDocFile = _useState4[1];
50842
+ const _useState5 = useState({
50843
+ identity: null,
50844
+ mutation: null
50550
50845
  }),
50551
- config = _useState4[0],
50552
- setConfig = _useState4[1];
50553
- const _useState5 = useState(true),
50554
- enabledLoader = _useState5[0],
50555
- setEnabledLoader = _useState5[1];
50846
+ rawFiles = _useState5[0],
50847
+ setRawFiles = _useState5[1];
50556
50848
  const _useState6 = useState(false),
50557
- isAppDetailsPage = _useState6[0];
50558
- const _useState7 = useState(false),
50559
- isEnableLoader = _useState7[0],
50560
- setIsEnableLoader = _useState7[1];
50561
- let tenantId = Digit.ULBService.getCurrentTenantId();
50562
- const applicationNumber = filters === null || filters === void 0 ? void 0 : filters.applicationNumber;
50563
- const serviceType = filters === null || filters === void 0 ? void 0 : filters.service;
50564
- const stateId = Digit.ULBService.getStateId();
50565
- let _Digit$Hooks$ws$useWS = Digit.Hooks.ws.useWSConfigMDMS.WSCreateConfig(stateId, {}),
50566
- newConfig = _Digit$Hooks$ws$useWS.data,
50567
- isConfigLoading = _Digit$Hooks$ws$useWS.isLoading;
50568
- let details = cloneDeep_1((_state = state) === null || _state === void 0 ? void 0 : _state.data);
50569
- let _Digit$Hooks$ws$useWS2 = Digit.Hooks.ws.useWSDetailsPage(t, tenantId, ((_details = details) === null || _details === void 0 ? void 0 : _details.applicationNo) || applicationNumber, (serviceType === null || serviceType === void 0 ? void 0 : serviceType.toUpperCase()) || ((_details2 = details) === null || _details2 === void 0 ? void 0 : (_details2$application = _details2.applicationData) === null || _details2$application === void 0 ? void 0 : _details2$application.serviceType)),
50570
- applicationDetails = _Digit$Hooks$ws$useWS2.data;
50571
- details = applicationDetails;
50572
- const _useState8 = useState(new URLSearchParams(useLocation().search).get("propertyId")),
50573
- propertyId = _useState8[0],
50574
- setPropertyId = _useState8[1];
50575
- const _Digit$Hooks$useSessi = Digit.Hooks.useSessionStorage("PT_CREATE_EMP_WS_NEW_FORM", {}),
50576
- sessionFormData = _Digit$Hooks$useSessi[0],
50577
- setSessionFormData = _Digit$Hooks$useSessi[1],
50578
- clearSessionFormData = _Digit$Hooks$useSessi[2];
50579
- const _Digit$Hooks$pt$usePr = Digit.Hooks.pt.usePropertySearch({
50580
- filters: {
50581
- propertyIds: propertyId
50582
- },
50583
- tenantId: tenantId
50584
- }, {
50585
- filters: {
50586
- propertyIds: propertyId
50587
- },
50588
- tenantId: tenantId,
50589
- enabled: propertyId && propertyId != "" ? true : false
50590
- }),
50591
- propertyDetails = _Digit$Hooks$pt$usePr.data;
50592
- useEffect(() => {
50593
- if (!isConfigLoading && newConfig && Array.isArray(newConfig)) {
50594
- const config = cloneDeep_1(newConfig.find(conf => conf.hideInCitizen && conf.isModify));
50595
- if (config) {
50596
- var _config$body;
50597
- config.head = "WS_WATER_AND_SEWERAGE_MUTATION_CONNECTION_LABEL";
50598
- let bodyDetails = [];
50599
- config === null || config === void 0 ? void 0 : (_config$body = config.body) === null || _config$body === void 0 ? void 0 : _config$body.forEach(data => {
50600
- if (data !== null && data !== void 0 && data.isModifyConnection) bodyDetails.push(data);
50601
- });
50602
- bodyDetails.forEach(bdyData => {
50603
- if ((bdyData === null || bdyData === void 0 ? void 0 : bdyData.head) === "WS_COMMON_PROPERTY_DETAILS") {
50604
- bdyData.head = "";
50605
- bdyData.className = "mutation-disabled-section";
50606
- } else if ((bdyData === null || bdyData === void 0 ? void 0 : bdyData.head) === "WS_COMMON_CONNECTION_HOLDER_DETAILS_HEADER") {
50607
- bdyData.head = "Specify ownership updates and transfer reason:";
50608
- bdyData.body = [{
50609
- type: "component",
50610
- key: "MutationApplicantDetails",
50611
- component: WSMutationApplicantDetails,
50612
- withoutLabel: true
50613
- }];
50614
- } else {
50615
- bdyData.head = "";
50616
- bdyData.className = "mutation-hidden-section";
50617
- }
50618
- });
50619
- config.body = bodyDetails;
50620
- setConfig(config);
50621
- }
50622
- }
50623
- }, [newConfig]);
50624
- useEffect(() => {
50625
- var _sessionFormData$cpt, _sessionFormData$cpt$, _sessionFormData$cpt2, _sessionFormData$cpt3;
50626
- !propertyId && (sessionFormData === null || sessionFormData === void 0 ? void 0 : (_sessionFormData$cpt = sessionFormData.cpt) === null || _sessionFormData$cpt === void 0 ? void 0 : (_sessionFormData$cpt$ = _sessionFormData$cpt.details) === null || _sessionFormData$cpt$ === void 0 ? void 0 : _sessionFormData$cpt$.propertyId) && setPropertyId(sessionFormData === null || sessionFormData === void 0 ? void 0 : (_sessionFormData$cpt2 = sessionFormData.cpt) === null || _sessionFormData$cpt2 === void 0 ? void 0 : (_sessionFormData$cpt3 = _sessionFormData$cpt2.details) === null || _sessionFormData$cpt3 === void 0 ? void 0 : _sessionFormData$cpt3.propertyId);
50627
- }, [sessionFormData === null || sessionFormData === void 0 ? void 0 : sessionFormData.cpt]);
50628
- useEffect(function () {
50849
+ isUploading = _useState6[0],
50850
+ setIsUploading = _useState6[1];
50851
+ const _useState7 = useState(null),
50852
+ showToast = _useState7[0],
50853
+ setShowToast = _useState7[1];
50854
+ const _useState8 = useState({}),
50855
+ fieldErrors = _useState8[0],
50856
+ setFieldErrors = _useState8[1];
50857
+ const _useState9 = useState(false),
50858
+ hasAttemptedSubmit = _useState9[0],
50859
+ setHasAttemptedSubmit = _useState9[1];
50860
+ const identityOptions = [{
50861
+ code: "AADHAAR",
50862
+ i18nKey: "Aadhaar Card"
50863
+ }, {
50864
+ code: "VOTER_ID",
50865
+ i18nKey: "Voter ID"
50866
+ }, {
50867
+ code: "PAN",
50868
+ i18nKey: "PAN Card"
50869
+ }, {
50870
+ code: "OTHER",
50871
+ i18nKey: "Any other document configured by DJB"
50872
+ }];
50873
+ const getReasonDocLabel = reasonCode => {
50874
+ switch (reasonCode) {
50875
+ case "SALE_PURCHASE":
50876
+ return "Upload Purchase of Property";
50877
+ case "DEVOLUTION_INHERITANCE":
50878
+ return "Upload Devolution/ Inheritance";
50879
+ case "OTHER":
50880
+ return "Upload Other (Gift Deed, Will registration, etc.)";
50881
+ default:
50882
+ return "Upload Supporting Document";
50883
+ }
50884
+ };
50885
+ const reasonCode = (defaultValues === null || defaultValues === void 0 ? void 0 : (_defaultValues$reason = defaultValues.reasonForNameChange) === null || _defaultValues$reason === void 0 ? void 0 : _defaultValues$reason.code) || (defaultValues === null || defaultValues === void 0 ? void 0 : defaultValues.reasonForNameChange);
50886
+ const reasonDocLabel = getReasonDocLabel(reasonCode);
50887
+ const validateDocumentNumber = (value, docType) => {
50888
+ if (!value || !value.trim()) return "Document number is required";
50889
+ const trimmed = value.trim();
50890
+ if ((docType === null || docType === void 0 ? void 0 : docType.code) === "AADHAAR") {
50891
+ if (!/^\d{12}$/.test(trimmed)) return "Aadhaar number must be exactly 12 digits";
50892
+ } else if ((docType === null || docType === void 0 ? void 0 : docType.code) === "PAN") {
50893
+ if (!/^[A-Z]{5}[0-9]{4}[A-Z]{1}$/.test(trimmed.toUpperCase())) return "PAN must be in format ABCDE1234F";
50894
+ } else if ((docType === null || docType === void 0 ? void 0 : docType.code) === "VOTER_ID") {
50895
+ if (!/^[A-Z]{3}\d{7}$/.test(trimmed.toUpperCase())) return "Voter ID must be in format ABC1234567";
50896
+ } else {
50897
+ if (trimmed.length < 3) return "Document number must be at least 3 characters";
50898
+ }
50899
+ return null;
50900
+ };
50901
+ const validateFileSize = file => {
50902
+ const maxSizeMB = 5;
50903
+ if (file.size > maxSizeMB * 1024 * 1024) {
50904
+ return "File size exceeds " + maxSizeMB + "MB limit. Please choose a smaller file.";
50905
+ }
50906
+ return null;
50907
+ };
50908
+ const validateFileType = file => {
50909
+ const allowedTypes = ["image/jpeg", "image/jpg", "image/png", "application/pdf"];
50910
+ if (!allowedTypes.includes(file.type)) {
50911
+ return "Only PDF, PNG, JPEG files are allowed.";
50912
+ }
50913
+ return null;
50914
+ };
50915
+ const handleFileUpload = function (file, type) {
50629
50916
  try {
50630
- const IsDetailsExists = sessionStorage.getItem("IsDetailsExists") ? JSON.parse(sessionStorage.getItem("IsDetailsExists")) : false;
50631
- const _temp = function (_details3, _details3$application) {
50632
- if ((_details3 = details) !== null && _details3 !== void 0 && (_details3$application = _details3.applicationData) !== null && _details3$application !== void 0 && _details3$application.id) {
50633
- var _details4, _details4$application;
50634
- return Promise.resolve(convertApplicationData(details, (serviceType === null || serviceType === void 0 ? void 0 : serviceType.toUpperCase()) || ((_details4 = details) === null || _details4 === void 0 ? void 0 : (_details4$application = _details4.applicationData) === null || _details4$application === void 0 ? void 0 : _details4$application.serviceType), true, undefined, t)).then(function (convertAppData) {
50635
- setSessionFormData(prev => _extends({}, prev, convertAppData));
50636
- setAppData(prev => _extends({}, prev, convertAppData));
50637
- sessionStorage.setItem("IsDetailsExists", JSON.stringify(true));
50917
+ const sizeError = validateFileSize(file);
50918
+ if (sizeError) {
50919
+ setShowToast({
50920
+ key: "error",
50921
+ message: sizeError
50922
+ });
50923
+ return Promise.resolve();
50924
+ }
50925
+ const typeError = validateFileType(file);
50926
+ if (typeError) {
50927
+ setShowToast({
50928
+ key: "error",
50929
+ message: typeError
50930
+ });
50931
+ return Promise.resolve();
50932
+ }
50933
+ const _temp = _finallyRethrows(function () {
50934
+ return _catch(function () {
50935
+ setIsUploading(true);
50936
+ return Promise.resolve(window.Digit.UploadServices.Filestorage("WS", file, window.Digit.ULBService.getStateId())).then(function (response) {
50937
+ var _response$data, _response$data$files;
50938
+ if ((response === null || response === void 0 ? void 0 : (_response$data = response.data) === null || _response$data === void 0 ? void 0 : (_response$data$files = _response$data.files) === null || _response$data$files === void 0 ? void 0 : _response$data$files.length) > 0) {
50939
+ const fileStoreId = response.data.files[0].fileStoreId;
50940
+ if (type === "identity") {
50941
+ setIdentityProofFile(fileStoreId);
50942
+ setFieldErrors(prev => _extends({}, prev, {
50943
+ identityFile: null
50944
+ }));
50945
+ }
50946
+ if (type === "mutation") {
50947
+ setMutationDocFile(fileStoreId);
50948
+ setFieldErrors(prev => _extends({}, prev, {
50949
+ mutationFile: null
50950
+ }));
50951
+ }
50952
+ setShowToast({
50953
+ key: "success",
50954
+ message: "Document uploaded successfully!"
50955
+ });
50956
+ }
50638
50957
  });
50639
- }
50640
- }();
50958
+ }, function (err) {
50959
+ console.error("File upload error", err);
50960
+ setShowToast({
50961
+ key: "error",
50962
+ message: "File upload failed. Please try again."
50963
+ });
50964
+ });
50965
+ }, function (_wasThrown, _result) {
50966
+ setIsUploading(false);
50967
+ if (_wasThrown) throw _result;
50968
+ return _result;
50969
+ });
50641
50970
  return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
50642
50971
  } catch (e) {
50643
50972
  return Promise.reject(e);
50644
50973
  }
50645
- }, [details, applicationDetails]);
50974
+ };
50975
+ useEffect(() => {
50976
+ if (rawFiles.identity) handleFileUpload(rawFiles.identity, "identity");
50977
+ }, [rawFiles.identity]);
50978
+ useEffect(() => {
50979
+ if (rawFiles.mutation) handleFileUpload(rawFiles.mutation, "mutation");
50980
+ }, [rawFiles.mutation]);
50981
+ useEffect(() => {
50982
+ if (hasAttemptedSubmit) {
50983
+ const newErrors = {};
50984
+ if (!identityProofType) newErrors.identityType = "Please select a document type";
50985
+ if (!identityProofFile) newErrors.identityFile = "Please upload your identity proof document";
50986
+ if (!mutationDocFile) newErrors.mutationFile = "Please upload the reason-based supporting document";
50987
+ const docError = validateDocumentNumber(documentNumber, identityProofType);
50988
+ if (docError) newErrors.documentNumber = docError;
50989
+ setFieldErrors(newErrors);
50990
+ }
50991
+ }, [identityProofType, documentNumber, identityProofFile, mutationDocFile, hasAttemptedSubmit]);
50992
+ const onProceed = () => {
50993
+ setHasAttemptedSubmit(true);
50994
+ const newErrors = {};
50995
+ if (!identityProofType) newErrors.identityType = "Please select a document type";
50996
+ const docError = validateDocumentNumber(documentNumber, identityProofType);
50997
+ if (docError) newErrors.documentNumber = docError;
50998
+ if (!identityProofFile) newErrors.identityFile = "Please upload your identity proof document";
50999
+ if (!mutationDocFile) newErrors.mutationFile = "Please upload the reason-based supporting document";
51000
+ setFieldErrors(newErrors);
51001
+ if (Object.keys(newErrors).length > 0) {
51002
+ const errorCount = Object.keys(newErrors).length;
51003
+ setShowToast({
51004
+ key: "warning",
51005
+ message: "Please fix " + errorCount + " issue" + (errorCount > 1 ? "s" : "") + " before proceeding."
51006
+ });
51007
+ return;
51008
+ }
51009
+ onNext({
51010
+ identityProofType,
51011
+ documentNumber: documentNumber.trim(),
51012
+ identityProofDocumentId: identityProofFile,
51013
+ saleDeedDocumentId: mutationDocFile
51014
+ });
51015
+ };
51016
+ const uploadBoxStyle = (hasError, hasFile) => ({
51017
+ border: hasError ? "2px dashed #d32f2f" : hasFile ? "2px dashed #28a745" : "1px dashed #ccc",
51018
+ padding: "20px",
51019
+ borderRadius: "8px",
51020
+ backgroundColor: hasError ? "#fef2f2" : hasFile ? "#f0fff4" : "#f4f9fc",
51021
+ textAlign: "center",
51022
+ marginTop: "8px",
51023
+ transition: "all 0.2s ease"
51024
+ });
51025
+ const errorTextStyle = {
51026
+ fontSize: "12px",
51027
+ color: "#d32f2f",
51028
+ marginTop: "4px"
51029
+ };
51030
+ const successTextStyle = {
51031
+ fontSize: "12px",
51032
+ color: "#28a745",
51033
+ marginTop: "4px",
51034
+ fontWeight: "500"
51035
+ };
51036
+ const mandatoryIndicator = /*#__PURE__*/React.createElement("span", {
51037
+ style: {
51038
+ color: "#d32f2f",
51039
+ marginLeft: "2px"
51040
+ }
51041
+ }, "*");
51042
+ const errorCount = Object.keys(fieldErrors).length;
51043
+ return /*#__PURE__*/React.createElement(Card, {
51044
+ style: {
51045
+ marginBottom: "20px"
51046
+ }
51047
+ }, /*#__PURE__*/React.createElement("div", {
51048
+ style: {
51049
+ display: "flex",
51050
+ alignItems: "center",
51051
+ marginBottom: "8px"
51052
+ }
51053
+ }, /*#__PURE__*/React.createElement("span", {
51054
+ style: {
51055
+ fontSize: "24px",
51056
+ marginRight: "8px"
51057
+ }
51058
+ }, "\uD83D\uDCC4"), /*#__PURE__*/React.createElement("h2", {
51059
+ style: {
51060
+ fontSize: "20px",
51061
+ fontWeight: "700",
51062
+ margin: 0
51063
+ }
51064
+ }, "3. Upload Verification Documents")), /*#__PURE__*/React.createElement("p", {
51065
+ style: {
51066
+ color: "#666",
51067
+ marginBottom: "20px"
51068
+ }
51069
+ }, "Please upload legible scanned copies or photos (PDF, PNG, JPEG - Max 5MB)."), hasAttemptedSubmit && errorCount > 0 && /*#__PURE__*/React.createElement("div", {
51070
+ style: {
51071
+ padding: "12px 16px",
51072
+ backgroundColor: "#fdecea",
51073
+ color: "#611a15",
51074
+ borderRadius: "8px",
51075
+ border: "1px solid #f5c6cb",
51076
+ marginBottom: "16px",
51077
+ display: "flex",
51078
+ alignItems: "center"
51079
+ }
51080
+ }, /*#__PURE__*/React.createElement("span", {
51081
+ style: {
51082
+ marginRight: "8px",
51083
+ fontSize: "18px"
51084
+ }
51085
+ }, "\u26A0\uFE0F"), /*#__PURE__*/React.createElement("span", {
51086
+ style: {
51087
+ fontWeight: "500",
51088
+ fontSize: "14px"
51089
+ }
51090
+ }, errorCount, " required item", errorCount > 1 ? "s" : "", " still need", errorCount === 1 ? "s" : "", " your attention before proceeding.")), /*#__PURE__*/React.createElement("div", {
51091
+ style: {
51092
+ display: "grid",
51093
+ gridTemplateColumns: "1fr 1fr",
51094
+ gap: "24px"
51095
+ }
51096
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(CardLabel, {
51097
+ style: {
51098
+ fontWeight: "bold"
51099
+ }
51100
+ }, "1. Address / Identity Proof ", mandatoryIndicator), /*#__PURE__*/React.createElement(Dropdown, {
51101
+ selected: identityProofType,
51102
+ option: identityOptions,
51103
+ select: val => {
51104
+ setIdentityProofType(val);
51105
+ setFieldErrors(prev => _extends({}, prev, {
51106
+ identityType: null
51107
+ }));
51108
+ },
51109
+ optionKey: "i18nKey",
51110
+ t: t,
51111
+ placeholder: "Select Document Type",
51112
+ style: {
51113
+ marginBottom: "12px"
51114
+ }
51115
+ }), fieldErrors.identityType && /*#__PURE__*/React.createElement("div", {
51116
+ style: errorTextStyle
51117
+ }, fieldErrors.identityType), /*#__PURE__*/React.createElement(CardLabel, {
51118
+ style: {
51119
+ fontWeight: "bold",
51120
+ marginTop: "8px"
51121
+ }
51122
+ }, "Document Number ", mandatoryIndicator), /*#__PURE__*/React.createElement(TextInput, {
51123
+ value: documentNumber,
51124
+ onChange: e => {
51125
+ setDocumentNumber(e.target.value);
51126
+ setFieldErrors(prev => _extends({}, prev, {
51127
+ documentNumber: null
51128
+ }));
51129
+ },
51130
+ onBlur: () => {
51131
+ if (hasAttemptedSubmit) {
51132
+ const err = validateDocumentNumber(documentNumber, identityProofType);
51133
+ if (err) setFieldErrors(prev => _extends({}, prev, {
51134
+ documentNumber: err
51135
+ }));
51136
+ }
51137
+ },
51138
+ placeholder: (identityProofType === null || identityProofType === void 0 ? void 0 : identityProofType.code) === "AADHAAR" ? "Enter 12-digit Aadhaar number" : (identityProofType === null || identityProofType === void 0 ? void 0 : identityProofType.code) === "PAN" ? "Enter PAN (e.g. ABCDE1234F)" : "Enter Document Number",
51139
+ style: _extends({
51140
+ marginBottom: "4px"
51141
+ }, fieldErrors.documentNumber ? {
51142
+ border: "1px solid #d32f2f"
51143
+ } : {})
51144
+ }), fieldErrors.documentNumber && /*#__PURE__*/React.createElement("div", {
51145
+ style: errorTextStyle
51146
+ }, fieldErrors.documentNumber), (identityProofType === null || identityProofType === void 0 ? void 0 : identityProofType.code) === "AADHAAR" && !fieldErrors.documentNumber && /*#__PURE__*/React.createElement("span", {
51147
+ style: {
51148
+ fontSize: "11px",
51149
+ color: "#999"
51150
+ }
51151
+ }, "Format: 12-digit numeric (e.g. 123456789012)"), (identityProofType === null || identityProofType === void 0 ? void 0 : identityProofType.code) === "PAN" && !fieldErrors.documentNumber && /*#__PURE__*/React.createElement("span", {
51152
+ style: {
51153
+ fontSize: "11px",
51154
+ color: "#999"
51155
+ }
51156
+ }, "Format: ABCDE1234F"), /*#__PURE__*/React.createElement("div", {
51157
+ style: uploadBoxStyle(!!fieldErrors.identityFile, !!identityProofFile)
51158
+ }, /*#__PURE__*/React.createElement(UploadFile, {
51159
+ id: "identity-upload",
51160
+ onUpload: e => setRawFiles(prev => _extends({}, prev, {
51161
+ identity: e.target.files[0]
51162
+ })),
51163
+ onDelete: () => {
51164
+ setIdentityProofFile(null);
51165
+ setRawFiles(prev => _extends({}, prev, {
51166
+ identity: null
51167
+ }));
51168
+ },
51169
+ message: identityProofFile ? "Uploaded" : "Click to Choose File",
51170
+ accept: "image/*, .pdf, .png, .jpeg, .jpg",
51171
+ uploadedFiles: identityProofFile && !rawFiles.identity ? [["Document", {
51172
+ fileStoreId: identityProofFile
51173
+ }]] : undefined,
51174
+ removeTargetedFile: () => {
51175
+ setIdentityProofFile(null);
51176
+ setRawFiles(prev => _extends({}, prev, {
51177
+ identity: null
51178
+ }));
51179
+ }
51180
+ })), fieldErrors.identityFile && /*#__PURE__*/React.createElement("div", {
51181
+ style: errorTextStyle
51182
+ }, fieldErrors.identityFile), identityProofFile && /*#__PURE__*/React.createElement("div", {
51183
+ style: successTextStyle
51184
+ }, "\u2713 Document uploaded successfully")), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(CardLabel, {
51185
+ style: {
51186
+ fontWeight: "bold"
51187
+ }
51188
+ }, "2. Reason-Based Supporting Document ", mandatoryIndicator), /*#__PURE__*/React.createElement("div", {
51189
+ style: {
51190
+ padding: "10px",
51191
+ backgroundColor: "#e9ecef",
51192
+ borderRadius: "4px",
51193
+ marginBottom: "12px",
51194
+ color: "#495057",
51195
+ fontSize: "14px",
51196
+ minHeight: "42px",
51197
+ display: "flex",
51198
+ alignItems: "center"
51199
+ }
51200
+ }, reasonDocLabel), /*#__PURE__*/React.createElement("div", {
51201
+ style: uploadBoxStyle(!!fieldErrors.mutationFile, !!mutationDocFile)
51202
+ }, /*#__PURE__*/React.createElement(UploadFile, {
51203
+ id: "mutation-upload",
51204
+ onUpload: e => setRawFiles(prev => _extends({}, prev, {
51205
+ mutation: e.target.files[0]
51206
+ })),
51207
+ onDelete: () => {
51208
+ setMutationDocFile(null);
51209
+ setRawFiles(prev => _extends({}, prev, {
51210
+ mutation: null
51211
+ }));
51212
+ },
51213
+ message: mutationDocFile ? "Uploaded" : "Click to Upload",
51214
+ accept: "image/*, .pdf, .png, .jpeg, .jpg",
51215
+ uploadedFiles: mutationDocFile && !rawFiles.mutation ? [["Document", {
51216
+ fileStoreId: mutationDocFile
51217
+ }]] : undefined,
51218
+ removeTargetedFile: () => {
51219
+ setMutationDocFile(null);
51220
+ setRawFiles(prev => _extends({}, prev, {
51221
+ mutation: null
51222
+ }));
51223
+ }
51224
+ })), fieldErrors.mutationFile && /*#__PURE__*/React.createElement("div", {
51225
+ style: errorTextStyle
51226
+ }, fieldErrors.mutationFile), mutationDocFile && /*#__PURE__*/React.createElement("div", {
51227
+ style: successTextStyle
51228
+ }, "\u2713 Document uploaded successfully"))), /*#__PURE__*/React.createElement("div", {
51229
+ style: {
51230
+ display: "flex",
51231
+ justifyContent: "space-between",
51232
+ alignItems: "center",
51233
+ marginTop: "32px"
51234
+ }
51235
+ }, /*#__PURE__*/React.createElement("button", {
51236
+ type: "button",
51237
+ onClick: onBack,
51238
+ style: {
51239
+ padding: "8px 24px",
51240
+ backgroundColor: "#e0e0e0",
51241
+ border: "none",
51242
+ borderRadius: "4px",
51243
+ cursor: "pointer",
51244
+ fontWeight: "bold"
51245
+ }
51246
+ }, "\u2190 Back"), /*#__PURE__*/React.createElement("div", {
51247
+ style: {
51248
+ display: "flex",
51249
+ alignItems: "center",
51250
+ gap: "12px"
51251
+ }
51252
+ }, /*#__PURE__*/React.createElement("span", {
51253
+ style: {
51254
+ fontSize: "12px",
51255
+ color: "#999"
51256
+ }
51257
+ }, "All documents are mandatory"), /*#__PURE__*/React.createElement("button", {
51258
+ type: "button",
51259
+ onClick: onProceed,
51260
+ disabled: isUploading,
51261
+ style: {
51262
+ padding: "10px 24px",
51263
+ backgroundColor: isUploading ? "#ccc" : "#00497e",
51264
+ color: "white",
51265
+ border: "none",
51266
+ borderRadius: "4px",
51267
+ cursor: isUploading ? "not-allowed" : "pointer",
51268
+ fontWeight: "bold"
51269
+ }
51270
+ }, isUploading ? "Uploading..." : "Proceed to Application Preview →"))), showToast && /*#__PURE__*/React.createElement(Toast, {
51271
+ error: showToast.key === "error",
51272
+ warning: showToast.key === "warning",
51273
+ success: showToast.key === "success",
51274
+ label: t(showToast.message),
51275
+ onClose: () => setShowToast(null),
51276
+ isDleteBtn: true
51277
+ }));
51278
+ };
51279
+
51280
+ const Step4_Preview = _ref => {
51281
+ var _appData$connectionHo, _appData$property, _address$locality;
51282
+ let formData = _ref.formData,
51283
+ applicationDetails = _ref.applicationDetails,
51284
+ onBack = _ref.onBack,
51285
+ onSubmit = _ref.onSubmit,
51286
+ isLoading = _ref.isLoading;
51287
+ const _useState = useState(false),
51288
+ agreed = _useState[0],
51289
+ setAgreed = _useState[1];
51290
+ const _useState2 = useState(0),
51291
+ fee = _useState2[0],
51292
+ setFee = _useState2[1];
51293
+ const _useState3 = useState("Calculating..."),
51294
+ slab = _useState3[0],
51295
+ setSlab = _useState3[1];
51296
+ const getMaskedName = name => {
51297
+ if (!name) return "NA";
51298
+ return name.split("").map((char, index) => index % 2 === 1 && char !== " " ? "*" : char).join("");
51299
+ };
51300
+ const getMaskedPhone = phone => {
51301
+ if (!phone || phone.length < 10) return "NA";
51302
+ return "******" + phone.slice(-4);
51303
+ };
51304
+ const appData = (applicationDetails === null || applicationDetails === void 0 ? void 0 : applicationDetails.applicationData) || {};
51305
+ const connectionNo = (appData === null || appData === void 0 ? void 0 : appData.connectionNo) || "NA";
51306
+ const meterId = (appData === null || appData === void 0 ? void 0 : appData.meterId) || "NA";
51307
+ const propertyId = (appData === null || appData === void 0 ? void 0 : appData.propertyId) || "NA";
51308
+ const oldHolder = (appData === null || appData === void 0 ? void 0 : (_appData$connectionHo = appData.connectionHolders) === null || _appData$connectionHo === void 0 ? void 0 : _appData$connectionHo[0]) || {};
51309
+ const oldName = getMaskedName(oldHolder === null || oldHolder === void 0 ? void 0 : oldHolder.name);
51310
+ const oldPhone = getMaskedPhone(oldHolder === null || oldHolder === void 0 ? void 0 : oldHolder.mobileNumber);
51311
+ const address = (appData === null || appData === void 0 ? void 0 : (_appData$property = appData.property) === null || _appData$property === void 0 ? void 0 : _appData$property.address) || {};
51312
+ const oldAddress = [address === null || address === void 0 ? void 0 : address.doorNo, address === null || address === void 0 ? void 0 : address.buildingName, address === null || address === void 0 ? void 0 : address.street, address === null || address === void 0 ? void 0 : (_address$locality = address.locality) === null || _address$locality === void 0 ? void 0 : _address$locality.name, address === null || address === void 0 ? void 0 : address.city].filter(Boolean).join(", ") || "NA";
51313
+ const proposedNewConsumerName = formData.proposedNewConsumerName,
51314
+ newOwnerMobileNumber = formData.newOwnerMobileNumber,
51315
+ relationshipWithExistingConsumer = formData.relationshipWithExistingConsumer,
51316
+ reasonForNameChange = formData.reasonForNameChange,
51317
+ identityProofType = formData.identityProofType,
51318
+ documentNumber = formData.documentNumber,
51319
+ identityProofDocumentId = formData.identityProofDocumentId,
51320
+ saleDeedDocumentId = formData.saleDeedDocumentId;
51321
+ const getRelationshipName = code => {
51322
+ if (code !== null && code !== void 0 && code.code) return code.i18nKey;
51323
+ const map = {
51324
+ "BLOOD_RELATION": "Blood Relation",
51325
+ "LEGAL_HEIR": "Legal Heir",
51326
+ "OTHER": "Other"
51327
+ };
51328
+ return map[code] || code;
51329
+ };
51330
+ const getReasonName = code => {
51331
+ if (code !== null && code !== void 0 && code.code) return code.i18nKey;
51332
+ const map = {
51333
+ "SALE_PURCHASE": "Sale / Purchase of Property",
51334
+ "DEVOLUTION_INHERITANCE": "Inheritance / Succession",
51335
+ "OTHER": "Other"
51336
+ };
51337
+ return map[code] || code;
51338
+ };
51339
+ const tenantId = Digit.ULBService.getCurrentTenantId();
51340
+ const viewDocument = function (fileStoreId) {
51341
+ try {
51342
+ if (!fileStoreId) return Promise.resolve();
51343
+ const _temp = _catch(function () {
51344
+ const stateId = Digit.ULBService.getStateId();
51345
+ return Promise.resolve(window.Digit.UploadServices.Filefetch([fileStoreId], stateId)).then(function (res) {
51346
+ var _res$data;
51347
+ if (res !== null && res !== void 0 && (_res$data = res.data) !== null && _res$data !== void 0 && _res$data[fileStoreId]) {
51348
+ const fileUrl = res.data[fileStoreId].split(",")[0];
51349
+ window.open(fileUrl, "_blank");
51350
+ }
51351
+ });
51352
+ }, function (err) {
51353
+ console.error("Failed to fetch document", err);
51354
+ });
51355
+ return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
51356
+ } catch (e) {
51357
+ return Promise.reject(e);
51358
+ }
51359
+ };
51360
+ useEffect(() => {
51361
+ const relationCode = (relationshipWithExistingConsumer === null || relationshipWithExistingConsumer === void 0 ? void 0 : relationshipWithExistingConsumer.code) || relationshipWithExistingConsumer;
51362
+ if (relationCode && relationCode !== "OTHER") {
51363
+ setFee(100);
51364
+ setSlab("Blood relation slab");
51365
+ } else {
51366
+ setFee(1350);
51367
+ setSlab("Other Slab");
51368
+ }
51369
+ }, [relationshipWithExistingConsumer]);
51370
+ const sectionStyle = {
51371
+ border: "1px solid #e0e0e0",
51372
+ borderRadius: "8px",
51373
+ padding: "16px",
51374
+ marginBottom: "16px"
51375
+ };
51376
+ const labelStyle = {
51377
+ color: "#666",
51378
+ fontSize: "14px",
51379
+ marginBottom: "4px"
51380
+ };
51381
+ const valueStyle = {
51382
+ fontWeight: "bold",
51383
+ fontSize: "16px"
51384
+ };
51385
+ const uploadDocStatusStyle = {
51386
+ fontSize: "14px",
51387
+ fontWeight: "bold"
51388
+ };
51389
+ return /*#__PURE__*/React.createElement(Card, {
51390
+ style: {
51391
+ marginBottom: "20px"
51392
+ }
51393
+ }, /*#__PURE__*/React.createElement("div", {
51394
+ style: {
51395
+ display: "flex",
51396
+ alignItems: "center",
51397
+ marginBottom: "16px"
51398
+ }
51399
+ }, /*#__PURE__*/React.createElement("span", {
51400
+ style: {
51401
+ fontSize: "24px",
51402
+ marginRight: "8px"
51403
+ }
51404
+ }, "\uD83D\uDCCB"), /*#__PURE__*/React.createElement("h2", {
51405
+ style: {
51406
+ fontSize: "20px",
51407
+ fontWeight: "700",
51408
+ margin: 0
51409
+ }
51410
+ }, "4. Application Preview & Final Declaration")), /*#__PURE__*/React.createElement("div", {
51411
+ style: _extends({}, sectionStyle, {
51412
+ borderLeft: "4px solid #00497e"
51413
+ })
51414
+ }, /*#__PURE__*/React.createElement("h3", {
51415
+ style: {
51416
+ fontSize: "16px",
51417
+ fontWeight: "bold",
51418
+ color: "#00497e",
51419
+ marginBottom: "12px"
51420
+ }
51421
+ }, "Property & Connection Summary"), /*#__PURE__*/React.createElement("div", {
51422
+ style: {
51423
+ display: "flex",
51424
+ justifyContent: "space-between"
51425
+ }
51426
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
51427
+ style: labelStyle
51428
+ }, "Connection No"), /*#__PURE__*/React.createElement("div", {
51429
+ style: valueStyle
51430
+ }, connectionNo)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
51431
+ style: labelStyle
51432
+ }, "Meter Number"), /*#__PURE__*/React.createElement("div", {
51433
+ style: valueStyle
51434
+ }, meterId)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
51435
+ style: labelStyle
51436
+ }, "Property ID"), /*#__PURE__*/React.createElement("div", {
51437
+ style: valueStyle
51438
+ }, propertyId)))), /*#__PURE__*/React.createElement("div", {
51439
+ style: _extends({}, sectionStyle, {
51440
+ borderLeft: "4px solid #f29c1f"
51441
+ })
51442
+ }, /*#__PURE__*/React.createElement("h3", {
51443
+ style: {
51444
+ fontSize: "16px",
51445
+ fontWeight: "bold",
51446
+ color: "#f29c1f",
51447
+ marginBottom: "12px"
51448
+ }
51449
+ }, "\uD83D\uDD12 Existing / Previous Owner Details (Masked Information)"), /*#__PURE__*/React.createElement("div", {
51450
+ style: {
51451
+ display: "flex",
51452
+ justifyContent: "space-between",
51453
+ marginBottom: "12px"
51454
+ }
51455
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
51456
+ style: labelStyle
51457
+ }, "Registered Name:"), /*#__PURE__*/React.createElement("div", {
51458
+ style: valueStyle
51459
+ }, oldName)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
51460
+ style: labelStyle
51461
+ }, "Meter Number:"), /*#__PURE__*/React.createElement("div", {
51462
+ style: valueStyle
51463
+ }, meterId)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
51464
+ style: labelStyle
51465
+ }, "Registered Phone:"), /*#__PURE__*/React.createElement("div", {
51466
+ style: valueStyle
51467
+ }, oldPhone))), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
51468
+ style: labelStyle
51469
+ }, "Registered Address:"), /*#__PURE__*/React.createElement("div", {
51470
+ style: valueStyle
51471
+ }, oldAddress))), /*#__PURE__*/React.createElement("div", {
51472
+ style: _extends({}, sectionStyle, {
51473
+ borderLeft: "4px solid #00497e"
51474
+ })
51475
+ }, /*#__PURE__*/React.createElement("h3", {
51476
+ style: {
51477
+ fontSize: "16px",
51478
+ fontWeight: "bold",
51479
+ color: "#00497e",
51480
+ marginBottom: "12px"
51481
+ }
51482
+ }, "\uD83D\uDC64 Transferee (New Owner) Summary"), /*#__PURE__*/React.createElement("div", {
51483
+ style: {
51484
+ display: "flex",
51485
+ justifyContent: "space-between"
51486
+ }
51487
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
51488
+ style: labelStyle
51489
+ }, "New Owner Name"), /*#__PURE__*/React.createElement("div", {
51490
+ style: valueStyle
51491
+ }, proposedNewConsumerName)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
51492
+ style: labelStyle
51493
+ }, "Mobile Number"), /*#__PURE__*/React.createElement("div", {
51494
+ style: valueStyle
51495
+ }, newOwnerMobileNumber)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
51496
+ style: labelStyle
51497
+ }, "Relation Type"), /*#__PURE__*/React.createElement("div", {
51498
+ style: valueStyle
51499
+ }, getRelationshipName(relationshipWithExistingConsumer))), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
51500
+ style: labelStyle
51501
+ }, "Transfer Reason"), /*#__PURE__*/React.createElement("div", {
51502
+ style: valueStyle
51503
+ }, getReasonName(reasonForNameChange))))), /*#__PURE__*/React.createElement("div", {
51504
+ style: _extends({}, sectionStyle, {
51505
+ borderLeft: "4px solid #17a2b8"
51506
+ })
51507
+ }, /*#__PURE__*/React.createElement("h3", {
51508
+ style: {
51509
+ fontSize: "16px",
51510
+ fontWeight: "bold",
51511
+ color: "#17a2b8",
51512
+ marginBottom: "12px"
51513
+ }
51514
+ }, "Uploaded Documents"), /*#__PURE__*/React.createElement("div", {
51515
+ style: {
51516
+ display: "grid",
51517
+ gridTemplateColumns: "1fr 1fr 1fr",
51518
+ gap: "16px"
51519
+ }
51520
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
51521
+ style: labelStyle
51522
+ }, "Address / Identity Proof"), /*#__PURE__*/React.createElement("div", {
51523
+ style: {
51524
+ display: "flex",
51525
+ alignItems: "center",
51526
+ gap: "8px"
51527
+ }
51528
+ }, /*#__PURE__*/React.createElement("span", {
51529
+ style: uploadDocStatusStyle
51530
+ }, "\u2713 ", (identityProofType === null || identityProofType === void 0 ? void 0 : identityProofType.i18nKey) || "Document"), identityProofDocumentId && /*#__PURE__*/React.createElement("button", {
51531
+ type: "button",
51532
+ onClick: () => viewDocument(identityProofDocumentId),
51533
+ style: {
51534
+ color: "#00497e",
51535
+ background: "none",
51536
+ border: "none",
51537
+ textDecoration: "underline",
51538
+ cursor: "pointer",
51539
+ fontSize: "14px",
51540
+ fontWeight: "bold"
51541
+ }
51542
+ }, "View"))), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
51543
+ style: labelStyle
51544
+ }, "Document Number"), /*#__PURE__*/React.createElement("div", {
51545
+ style: valueStyle
51546
+ }, documentNumber || "NA")), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
51547
+ style: labelStyle
51548
+ }, "Reason-Based Proof"), /*#__PURE__*/React.createElement("div", {
51549
+ style: {
51550
+ display: "flex",
51551
+ alignItems: "center",
51552
+ gap: "8px"
51553
+ }
51554
+ }, /*#__PURE__*/React.createElement("span", {
51555
+ style: uploadDocStatusStyle
51556
+ }, "\u2713 Uploaded"), saleDeedDocumentId && /*#__PURE__*/React.createElement("button", {
51557
+ type: "button",
51558
+ onClick: () => viewDocument(saleDeedDocumentId),
51559
+ style: {
51560
+ color: "#00497e",
51561
+ background: "none",
51562
+ border: "none",
51563
+ textDecoration: "underline",
51564
+ cursor: "pointer",
51565
+ fontSize: "14px",
51566
+ fontWeight: "bold"
51567
+ }
51568
+ }, "View"))))), /*#__PURE__*/React.createElement("div", {
51569
+ style: _extends({}, sectionStyle, {
51570
+ backgroundColor: "#f2fff5",
51571
+ border: "1px solid #c3e6cb",
51572
+ borderLeft: "4px solid #28a745"
51573
+ })
51574
+ }, /*#__PURE__*/React.createElement("h3", {
51575
+ style: {
51576
+ fontSize: "16px",
51577
+ fontWeight: "bold",
51578
+ color: "#28a745",
51579
+ marginBottom: "12px"
51580
+ }
51581
+ }, "\uD83D\uDCB5 Mutation Fee Details (Money to Pay in Mutation)"), /*#__PURE__*/React.createElement("div", {
51582
+ style: {
51583
+ display: "flex",
51584
+ justifyContent: "space-between"
51585
+ }
51586
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
51587
+ style: labelStyle
51588
+ }, "Mutation Money to Pay:"), /*#__PURE__*/React.createElement("div", {
51589
+ style: _extends({}, valueStyle, {
51590
+ color: "#28a745",
51591
+ fontSize: "20px"
51592
+ })
51593
+ }, "\u20B9 ", fee, ".00")), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
51594
+ style: labelStyle
51595
+ }, "Fee Status:"), /*#__PURE__*/React.createElement("span", {
51596
+ style: {
51597
+ padding: "4px 8px",
51598
+ backgroundColor: "#d1ecf1",
51599
+ color: "#0c5460",
51600
+ borderRadius: "16px",
51601
+ fontSize: "12px",
51602
+ fontWeight: "bold"
51603
+ }
51604
+ }, "PAYABLE POST VERIFICATION")), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
51605
+ style: labelStyle
51606
+ }, "Applicable Slab:"), /*#__PURE__*/React.createElement("div", {
51607
+ style: valueStyle
51608
+ }, slab)))), /*#__PURE__*/React.createElement("div", {
51609
+ style: {
51610
+ padding: "16px",
51611
+ backgroundColor: "#fffbeb",
51612
+ border: "1px solid #ffeeba",
51613
+ borderRadius: "8px",
51614
+ marginBottom: "24px"
51615
+ }
51616
+ }, /*#__PURE__*/React.createElement(CheckBox, {
51617
+ label: "I want to go ahead with submitting this application. I confirm that the details and information provided by me are true and correct to the best of my knowledge.",
51618
+ onChange: e => setAgreed(e.target.checked),
51619
+ checked: agreed
51620
+ })), /*#__PURE__*/React.createElement(ActionBar, null, /*#__PURE__*/React.createElement("button", {
51621
+ type: "button",
51622
+ onClick: onBack,
51623
+ style: {
51624
+ padding: "8px 24px",
51625
+ backgroundColor: "#e0e0e0",
51626
+ border: "none",
51627
+ borderRadius: "4px",
51628
+ cursor: "pointer",
51629
+ fontWeight: "bold",
51630
+ marginRight: "16px"
51631
+ }
51632
+ }, "\u2190 Edit Information"), /*#__PURE__*/React.createElement(SubmitBar, {
51633
+ label: isLoading ? "Submitting..." : "Submit Mutation Application",
51634
+ onSubmit: onSubmit,
51635
+ disabled: !agreed || isLoading
51636
+ })));
51637
+ };
51638
+
51639
+ const Step5_Submission = _ref => {
51640
+ let applicationNumber = _ref.applicationNumber,
51641
+ serviceType = _ref.serviceType,
51642
+ t = _ref.t;
51643
+ const history = useHistory();
51644
+ const _useState = useState(null),
51645
+ showToast = _useState[0],
51646
+ setShowToast = _useState[1];
51647
+ const _useState2 = useState(false);
51648
+ const _Digit$Hooks$ws$useWS = Digit.Hooks.ws.useWSApplicationActions(serviceType);
51649
+ const goHome = () => {
51650
+ history.push("/digit-ui/employee");
51651
+ };
51652
+ const bannerStyle = {
51653
+ backgroundColor: "#fff",
51654
+ border: "1px solid #d4edda",
51655
+ borderTop: "4px solid #28a745",
51656
+ borderRadius: "8px",
51657
+ padding: "20px",
51658
+ display: "flex",
51659
+ justifyContent: "space-between",
51660
+ alignItems: "center",
51661
+ marginBottom: "20px"
51662
+ };
51663
+ const statusPanelStyle = {
51664
+ backgroundColor: "#fff",
51665
+ border: "1px solid #e0e0e0",
51666
+ borderRadius: "8px",
51667
+ padding: "20px"
51668
+ };
51669
+ return /*#__PURE__*/React.createElement("div", {
51670
+ style: {
51671
+ padding: "20px 0"
51672
+ }
51673
+ }, /*#__PURE__*/React.createElement("div", {
51674
+ style: bannerStyle
51675
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h2", {
51676
+ style: {
51677
+ color: "#28a745",
51678
+ fontSize: "20px",
51679
+ fontWeight: "bold",
51680
+ margin: 0,
51681
+ display: "flex",
51682
+ alignItems: "center"
51683
+ }
51684
+ }, /*#__PURE__*/React.createElement("span", {
51685
+ style: {
51686
+ marginRight: "8px"
51687
+ }
51688
+ }, "\u2705"), " Application Submitted Successfully!"), /*#__PURE__*/React.createElement("div", {
51689
+ style: {
51690
+ color: "#666",
51691
+ marginTop: "4px"
51692
+ }
51693
+ }, "Application Reference No: ", /*#__PURE__*/React.createElement("strong", {
51694
+ style: {
51695
+ color: "#00497e"
51696
+ }
51697
+ }, applicationNumber))), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", {
51698
+ style: {
51699
+ padding: "6px 12px",
51700
+ backgroundColor: "#fff3cd",
51701
+ color: "#856404",
51702
+ borderRadius: "16px",
51703
+ fontSize: "12px",
51704
+ fontWeight: "bold"
51705
+ }
51706
+ }, "PENDING_APPROVAL_FOR_MUTATION"))), /*#__PURE__*/React.createElement("div", {
51707
+ style: statusPanelStyle
51708
+ }, /*#__PURE__*/React.createElement("h3", {
51709
+ style: {
51710
+ color: "#00497e",
51711
+ fontSize: "16px",
51712
+ fontWeight: "bold",
51713
+ margin: "0 0 16px 0",
51714
+ display: "flex",
51715
+ alignItems: "center"
51716
+ }
51717
+ }, /*#__PURE__*/React.createElement("span", {
51718
+ style: {
51719
+ marginRight: "8px"
51720
+ }
51721
+ }, "\uD83D\uDCCC"), " Current Workflow Status"), /*#__PURE__*/React.createElement("hr", {
51722
+ style: {
51723
+ border: "0",
51724
+ borderTop: "1px solid #e0e0e0",
51725
+ margin: "0 0 16px 0"
51726
+ }
51727
+ }), /*#__PURE__*/React.createElement("p", {
51728
+ style: {
51729
+ color: "#333",
51730
+ fontSize: "14px",
51731
+ margin: 0
51732
+ }
51733
+ }, "Application has been routed to ", /*#__PURE__*/React.createElement("strong", null, "Water Supply Department Verification Officer"), ".")), /*#__PURE__*/React.createElement("div", {
51734
+ style: {
51735
+ marginTop: "24px",
51736
+ textAlign: "center"
51737
+ }
51738
+ }, /*#__PURE__*/React.createElement("button", {
51739
+ onClick: goHome,
51740
+ style: {
51741
+ padding: "10px 24px",
51742
+ backgroundColor: "#00497e",
51743
+ color: "white",
51744
+ border: "none",
51745
+ borderRadius: "4px",
51746
+ cursor: "pointer",
51747
+ fontWeight: "bold"
51748
+ }
51749
+ }, "Go to Home")), showToast && /*#__PURE__*/React.createElement(Toast, {
51750
+ error: showToast.key === "error",
51751
+ warning: showToast.key === "warning",
51752
+ label: t(showToast.message),
51753
+ onClose: () => setShowToast(null)
51754
+ }));
51755
+ };
51756
+
51757
+ const MutationApplication = () => {
51758
+ var _state, _details$applicationD, _applicationDetails$a, _applicationDetails$a3, _applicationDetails$a4;
51759
+ const _useTranslation = useTranslation(),
51760
+ t = _useTranslation.t;
51761
+ let _useLocation = useLocation(),
51762
+ state = _useLocation.state;
51763
+ state = state ? typeof state === "string" ? JSON.parse(state) : state : {};
51764
+ const history = useHistory();
51765
+ let filters = getQueryStringParams(location.search);
51766
+ const _useState = useState(1),
51767
+ currentStep = _useState[0],
51768
+ setCurrentStep = _useState[1];
51769
+ const _useState2 = useState({}),
51770
+ formData = _useState2[0],
51771
+ setFormData = _useState2[1];
51772
+ const _useState3 = useState(null),
51773
+ showToast = _useState3[0],
51774
+ setShowToast = _useState3[1];
51775
+ const _useState4 = useState(null),
51776
+ generatedAppNo = _useState4[0],
51777
+ setGeneratedAppNo = _useState4[1];
51778
+ const _useState5 = useState(false),
51779
+ isSubmitting = _useState5[0],
51780
+ setIsSubmitting = _useState5[1];
51781
+ const _useState6 = useState(new Set()),
51782
+ setCompletedSteps = _useState6[1];
51783
+ let tenantId = Digit.ULBService.getCurrentTenantId();
51784
+ const applicationNumber = filters === null || filters === void 0 ? void 0 : filters.applicationNumber;
51785
+ const serviceType = filters === null || filters === void 0 ? void 0 : filters.service;
51786
+ let details = cloneDeep_1((_state = state) === null || _state === void 0 ? void 0 : _state.data);
51787
+ let _Digit$Hooks$ws$useWS = Digit.Hooks.ws.useWSDetailsPage(t, tenantId, (details === null || details === void 0 ? void 0 : details.applicationNo) || applicationNumber, (serviceType === null || serviceType === void 0 ? void 0 : serviceType.toUpperCase()) || (details === null || details === void 0 ? void 0 : (_details$applicationD = details.applicationData) === null || _details$applicationD === void 0 ? void 0 : _details$applicationD.serviceType)),
51788
+ isDetailsLoading = _Digit$Hooks$ws$useWS.isLoading,
51789
+ applicationDetails = _Digit$Hooks$ws$useWS.data;
51790
+ const _useState7 = useState(new URLSearchParams(useLocation().search).get("propertyId") || (applicationDetails === null || applicationDetails === void 0 ? void 0 : (_applicationDetails$a = applicationDetails.applicationData) === null || _applicationDetails$a === void 0 ? void 0 : _applicationDetails$a.propertyId)),
51791
+ propertyId = _useState7[0];
51792
+ const _Digit$Hooks$pt$usePr = Digit.Hooks.pt.usePropertySearch({
51793
+ filters: {
51794
+ propertyIds: propertyId
51795
+ },
51796
+ tenantId: tenantId
51797
+ }, {
51798
+ filters: {
51799
+ propertyIds: propertyId
51800
+ },
51801
+ tenantId: tenantId,
51802
+ enabled: !!propertyId
51803
+ }),
51804
+ propertyDetails = _Digit$Hooks$pt$usePr.data,
51805
+ isPropertyLoading = _Digit$Hooks$pt$usePr.isLoading;
51806
+ const _Digit$Hooks$useSessi = Digit.Hooks.useSessionStorage("PT_CREATE_EMP_WS_NEW_FORM", {}),
51807
+ sessionFormData = _Digit$Hooks$useSessi[0],
51808
+ setSessionFormData = _Digit$Hooks$useSessi[1],
51809
+ clearSessionFormData = _Digit$Hooks$useSessi[2];
51810
+ useEffect(() => {
51811
+ var _applicationDetails$a2;
51812
+ const fetchAppData = function () {
51813
+ try {
51814
+ const dataToConvert = applicationDetails || details;
51815
+ const _temp = function (_dataToConvert$applic) {
51816
+ if (dataToConvert !== null && dataToConvert !== void 0 && (_dataToConvert$applic = dataToConvert.applicationData) !== null && _dataToConvert$applic !== void 0 && _dataToConvert$applic.id) {
51817
+ var _dataToConvert$applic2;
51818
+ return Promise.resolve(convertApplicationData(dataToConvert, (serviceType === null || serviceType === void 0 ? void 0 : serviceType.toUpperCase()) || (dataToConvert === null || dataToConvert === void 0 ? void 0 : (_dataToConvert$applic2 = dataToConvert.applicationData) === null || _dataToConvert$applic2 === void 0 ? void 0 : _dataToConvert$applic2.serviceType), true, undefined, t)).then(function (convertAppData) {
51819
+ setSessionFormData(prev => _extends({}, prev, convertAppData));
51820
+ sessionStorage.setItem("IsDetailsExists", JSON.stringify(true));
51821
+ });
51822
+ }
51823
+ }();
51824
+ return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
51825
+ } catch (e) {
51826
+ return Promise.reject(e);
51827
+ }
51828
+ };
51829
+ if (applicationDetails !== null && applicationDetails !== void 0 && (_applicationDetails$a2 = applicationDetails.applicationData) !== null && _applicationDetails$a2 !== void 0 && _applicationDetails$a2.id && !(sessionFormData !== null && sessionFormData !== void 0 && sessionFormData.applicationData)) {
51830
+ fetchAppData();
51831
+ }
51832
+ }, [applicationDetails === null || applicationDetails === void 0 ? void 0 : (_applicationDetails$a3 = applicationDetails.applicationData) === null || _applicationDetails$a3 === void 0 ? void 0 : _applicationDetails$a3.id]);
50646
51833
  useEffect(() => {
50647
51834
  var _propertyDetails$Prop;
50648
51835
  if (propertyDetails !== null && propertyDetails !== void 0 && (_propertyDetails$Prop = propertyDetails.Properties) !== null && _propertyDetails$Prop !== void 0 && _propertyDetails$Prop[0]) {
@@ -50656,220 +51843,311 @@ const MutationApplication = () => {
50656
51843
  });
50657
51844
  }
50658
51845
  }, [propertyDetails]);
50659
- useEffect(() => {
50660
- var _sessionFormData$Conn, _sessionFormData$Conn2;
50661
- if (sessionFormData !== null && sessionFormData !== void 0 && (_sessionFormData$Conn = sessionFormData.ConnectionDetails) !== null && _sessionFormData$Conn !== void 0 && (_sessionFormData$Conn2 = _sessionFormData$Conn[0]) !== null && _sessionFormData$Conn2 !== void 0 && _sessionFormData$Conn2.applicationNo) {
50662
- setEnabledLoader(false);
50663
- }
50664
- }, [propertyDetails, sessionFormData, sessionFormData === null || sessionFormData === void 0 ? void 0 : sessionFormData.cpt]);
50665
- useEffect(() => {
50666
- const timer = setTimeout(() => {
50667
- var _sessionFormData$Conn3, _sessionFormData$Conn4, _sessionFormData$Conn5, _sessionFormData$Conn6, _sessionFormData$Conn7;
50668
- if (isAppDetailsPage) window.location.href = window.location.origin + "/digit-ui/employee/ws/application-details?applicationNumber=" + (sessionFormData === null || sessionFormData === void 0 ? void 0 : (_sessionFormData$Conn3 = sessionFormData.ConnectionDetails) === null || _sessionFormData$Conn3 === void 0 ? void 0 : (_sessionFormData$Conn4 = _sessionFormData$Conn3[0]) === null || _sessionFormData$Conn4 === void 0 ? void 0 : _sessionFormData$Conn4.applicationNo) + "&service=" + (sessionFormData === null || sessionFormData === void 0 ? void 0 : (_sessionFormData$Conn5 = sessionFormData.ConnectionDetails) === null || _sessionFormData$Conn5 === void 0 ? void 0 : (_sessionFormData$Conn6 = _sessionFormData$Conn5[0]) === null || _sessionFormData$Conn6 === void 0 ? void 0 : (_sessionFormData$Conn7 = _sessionFormData$Conn6.serviceName) === null || _sessionFormData$Conn7 === void 0 ? void 0 : _sessionFormData$Conn7.toUpperCase());
50669
- }, 3000);
50670
- return () => clearTimeout(timer);
50671
- }, [isAppDetailsPage]);
50672
51846
  const _Digit$Hooks$ws$useWa = Digit.Hooks.ws.useWaterCreateAPI("WATER"),
50673
51847
  waterMutation = _Digit$Hooks$ws$useWa.mutate;
50674
- const _Digit$Hooks$ws$useWS3 = Digit.Hooks.ws.useWSApplicationActions("WATER");
50675
51848
  const _Digit$Hooks$ws$useWa2 = Digit.Hooks.ws.useWaterCreateAPI("SEWERAGE"),
50676
51849
  sewerageMutation = _Digit$Hooks$ws$useWa2.mutate;
50677
- const _Digit$Hooks$ws$useWS4 = Digit.Hooks.ws.useWSApplicationActions("SEWERAGE");
50678
- const onFormValueChange = (setValue, formData, formState) => {
50679
- var _formData$cpt, _formData$cpt$details;
50680
- const updatedData = _extends({}, sessionFormData, formData);
50681
- if (!lodash.isEqual(sessionFormData, updatedData)) {
50682
- setSessionFormData(updatedData);
50683
- }
50684
- if (Object.keys(formState.errors).length > 0 && Object.keys(formState.errors).length == 1 && formState.errors["owners"] && Object.values(formState.errors["owners"].type).filter(ob => ob.type === "required").length == 0 && !(formData !== null && formData !== void 0 && (_formData$cpt = formData.cpt) !== null && _formData$cpt !== void 0 && (_formData$cpt$details = _formData$cpt.details) !== null && _formData$cpt$details !== void 0 && _formData$cpt$details.propertyId)) setSubmitValve(true);else setSubmitValve(!Object.keys(formState.errors).length);
51850
+ const _Digit$Hooks$ws$useWS2 = Digit.Hooks.ws.useWSApplicationActions("WATER"),
51851
+ waterUpdateMutation = _Digit$Hooks$ws$useWS2.mutate;
51852
+ const _Digit$Hooks$ws$useWS3 = Digit.Hooks.ws.useWSApplicationActions("SEWERAGE"),
51853
+ sewerageUpdateMutation = _Digit$Hooks$ws$useWS3.mutate;
51854
+ const handleNextStep2 = data => {
51855
+ setFormData(prev => _extends({}, prev, data));
51856
+ setCompletedSteps(prev => new Set([...prev, 2]));
51857
+ setCurrentStep(3);
50685
51858
  };
50686
- const onSubmit = function (data) {
51859
+ const handleNextStep3 = data => {
51860
+ setFormData(prev => _extends({}, prev, data));
51861
+ setCompletedSteps(prev => new Set([...prev, 3]));
51862
+ setCurrentStep(4);
51863
+ };
51864
+ const submitApplication = function () {
50687
51865
  try {
50688
- var _finalData$cpt, _propertyDetails$Prop3;
50689
- let finalData = _extends({}, sessionFormData, data);
50690
- if (!(finalData !== null && finalData !== void 0 && (_finalData$cpt = finalData.cpt) !== null && _finalData$cpt !== void 0 && _finalData$cpt.id) && !(propertyDetails !== null && propertyDetails !== void 0 && (_propertyDetails$Prop3 = propertyDetails.Properties) !== null && _propertyDetails$Prop3 !== void 0 && _propertyDetails$Prop3[0])) {
50691
- var _finalData$cpt2;
50692
- if (!(finalData !== null && finalData !== void 0 && (_finalData$cpt2 = finalData.cpt) !== null && _finalData$cpt2 !== void 0 && _finalData$cpt2.details) || !propertyDetails) {
50693
- setShowToast({
50694
- key: "error",
50695
- message: "ERR_INVALID_PROPERTY_ID"
50696
- });
50697
- return Promise.resolve();
51866
+ setIsSubmitting(true);
51867
+ const _temp2 = _catch(function () {
51868
+ var _finalData$cpt;
51869
+ let finalData = _extends({}, sessionFormData);
51870
+ if (!(finalData !== null && finalData !== void 0 && (_finalData$cpt = finalData.cpt) !== null && _finalData$cpt !== void 0 && _finalData$cpt.details)) {
51871
+ var _propertyDetails$Prop3;
51872
+ finalData.cpt = {
51873
+ details: propertyDetails === null || propertyDetails === void 0 ? void 0 : (_propertyDetails$Prop3 = propertyDetails.Properties) === null || _propertyDetails$Prop3 === void 0 ? void 0 : _propertyDetails$Prop3[0]
51874
+ };
50698
51875
  }
50699
- }
50700
- const _temp7 = function () {
50701
- if (!canSubmit) {
50702
- setShowToast({
50703
- warning: true,
50704
- message: "PLEASE_FILL_MANDATORY_DETAILS"
50705
- });
50706
- setTimeout(() => {
50707
- setShowToast(false);
50708
- }, 3000);
50709
- } else {
50710
- var _finalData$cpt3;
50711
- if (!(finalData !== null && finalData !== void 0 && (_finalData$cpt3 = finalData.cpt) !== null && _finalData$cpt3 !== void 0 && _finalData$cpt3.details)) {
50712
- var _propertyDetails$Prop4;
50713
- finalData.cpt = {
50714
- details: propertyDetails === null || propertyDetails === void 0 ? void 0 : (_propertyDetails$Prop4 = propertyDetails.Properties) === null || _propertyDetails$Prop4 === void 0 ? void 0 : _propertyDetails$Prop4[0]
50715
- };
51876
+ finalData.MutationApplicantDetails = {
51877
+ proposedNewConsumerName: formData.proposedNewConsumerName,
51878
+ newOwnerMobileNumber: formData.newOwnerMobileNumber,
51879
+ newOwnerEmailAddress: formData.newOwnerEmailAddress,
51880
+ reasonForNameChange: formData.reasonForNameChange,
51881
+ relationshipWithExistingConsumer: formData.relationshipWithExistingConsumer,
51882
+ saleDeedDocumentId: formData.saleDeedDocumentId,
51883
+ identityProofType: formData.identityProofType,
51884
+ identityProofDocumentId: formData.identityProofDocumentId,
51885
+ documentNumber: formData.documentNumber
51886
+ };
51887
+ if (finalData !== null && finalData !== void 0 && finalData.MutationApplicantDetails) {
51888
+ var _finalData$Connection;
51889
+ const mutDetails = finalData.MutationApplicantDetails;
51890
+ const existingHolder = (finalData === null || finalData === void 0 ? void 0 : (_finalData$Connection = finalData.ConnectionHolderDetails) === null || _finalData$Connection === void 0 ? void 0 : _finalData$Connection[0]) || {};
51891
+ finalData.ConnectionHolderDetails = [_extends({}, existingHolder, {
51892
+ name: mutDetails.proposedNewConsumerName || existingHolder.name,
51893
+ mobileNumber: mutDetails.newOwnerMobileNumber || existingHolder.mobileNumber,
51894
+ emailId: mutDetails.newOwnerEmailAddress || existingHolder.emailId,
51895
+ sameAsOwnerDetails: false
51896
+ })];
51897
+ }
51898
+ const sessionDetails = sessionStorage.getItem("WS_EDIT_APPLICATION_DETAILS") ? JSON.parse(sessionStorage.getItem("WS_EDIT_APPLICATION_DETAILS")) : {};
51899
+ return Promise.resolve(convertModifyApplicationDetails(finalData, sessionDetails, "INITIATE")).then(function (convertAppData) {
51900
+ if (!convertAppData.dateEffectiveFrom) {
51901
+ convertAppData.dateEffectiveFrom = Date.now();
50716
51902
  }
50717
51903
  if (finalData !== null && finalData !== void 0 && finalData.MutationApplicantDetails) {
50718
- var _finalData$Connection;
51904
+ var _mutDetails$reasonFor;
50719
51905
  const mutDetails = finalData.MutationApplicantDetails;
50720
- const existingHolder = (finalData === null || finalData === void 0 ? void 0 : (_finalData$Connection = finalData.ConnectionHolderDetails) === null || _finalData$Connection === void 0 ? void 0 : _finalData$Connection[0]) || {};
50721
- finalData.ConnectionHolderDetails = [_extends({}, existingHolder, {
50722
- name: mutDetails.proposedNewConsumerName || existingHolder.name,
50723
- mobileNumber: mutDetails.newOwnerMobileNumber || existingHolder.mobileNumber,
50724
- emailId: mutDetails.newOwnerEmailAddress || existingHolder.emailId,
50725
- sameAsOwnerDetails: false
50726
- })];
50727
- }
50728
- const details = sessionStorage.getItem("WS_EDIT_APPLICATION_DETAILS") ? JSON.parse(sessionStorage.getItem("WS_EDIT_APPLICATION_DETAILS")) : {};
50729
- return Promise.resolve(convertModifyApplicationDetails(finalData, details, "APPLY_MUTATION")).then(function (convertAppData) {
50730
- function _temp6() {
50731
- const _temp4 = function () {
50732
- if (serviceType !== "WATER") {
50733
- const _temp3 = function () {
50734
- if (sewerageMutation) {
50735
- setIsEnableLoader(true);
50736
- return Promise.resolve(sewerageMutation(reqDetails, {
50737
- onError: (error, variables) => {
50738
- var _error$response, _error$response$data, _error$response$data$, _error$response$data$2, _error$response2, _error$response2$data, _error$response2$data2, _error$response2$data3;
50739
- setIsEnableLoader(false);
50740
- setShowToast({
50741
- key: "error",
50742
- message: error !== null && error !== void 0 && (_error$response = error.response) !== null && _error$response !== void 0 && (_error$response$data = _error$response.data) !== null && _error$response$data !== void 0 && (_error$response$data$ = _error$response$data.Errors) !== null && _error$response$data$ !== void 0 && (_error$response$data$2 = _error$response$data$[0]) !== null && _error$response$data$2 !== void 0 && _error$response$data$2.message ? error === null || error === void 0 ? void 0 : (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : (_error$response2$data = _error$response2.data) === null || _error$response2$data === void 0 ? void 0 : (_error$response2$data2 = _error$response2$data.Errors) === null || _error$response2$data2 === void 0 ? void 0 : (_error$response2$data3 = _error$response2$data2[0]) === null || _error$response2$data3 === void 0 ? void 0 : _error$response2$data3.message : error
50743
- });
50744
- setTimeout(closeToastOfError, 5000);
50745
- },
50746
- onSuccess: function (data, variables) {
50747
- try {
50748
- var _data$SewerageConnect, _data$SewerageConnect2;
50749
- clearSessionFormData();
50750
- history.push("/digit-ui/employee/ws/ws-response?applicationNumber1=" + (data === null || data === void 0 ? void 0 : (_data$SewerageConnect = data.SewerageConnections) === null || _data$SewerageConnect === void 0 ? void 0 : (_data$SewerageConnect2 = _data$SewerageConnect[0]) === null || _data$SewerageConnect2 === void 0 ? void 0 : _data$SewerageConnect2.applicationNo));
50751
- return Promise.resolve();
50752
- } catch (e) {
50753
- return Promise.reject(e);
50754
- }
50755
- }
50756
- })).then(function () {});
50757
- }
50758
- }();
50759
- if (_temp3 && _temp3.then) return _temp3.then(function () {});
50760
- }
50761
- }();
50762
- if (_temp4 && _temp4.then) return _temp4.then(function () {});
51906
+ if (!convertAppData.additionalDetails) convertAppData.additionalDetails = {};
51907
+ if (mutDetails.reasonForNameChange) convertAppData.additionalDetails.reasonForNameChange = ((_mutDetails$reasonFor = mutDetails.reasonForNameChange) === null || _mutDetails$reasonFor === void 0 ? void 0 : _mutDetails$reasonFor.code) || mutDetails.reasonForNameChange;
51908
+ if (mutDetails.relationshipWithExistingConsumer) {
51909
+ var _mutDetails$relations;
51910
+ const relationCode = ((_mutDetails$relations = mutDetails.relationshipWithExistingConsumer) === null || _mutDetails$relations === void 0 ? void 0 : _mutDetails$relations.code) || mutDetails.relationshipWithExistingConsumer;
51911
+ convertAppData.additionalDetails.relationshipWithExistingConsumer = relationCode;
51912
+ convertAppData.additionalDetails.isBloodRelation = relationCode !== "OTHER";
50763
51913
  }
50764
- if (finalData !== null && finalData !== void 0 && finalData.MutationApplicantDetails) {
50765
- var _mutDetails$reasonFor;
50766
- const mutDetails = finalData.MutationApplicantDetails;
50767
- if (!convertAppData.additionalDetails) convertAppData.additionalDetails = {};
50768
- if (mutDetails.reasonForNameChange) convertAppData.additionalDetails.reasonForNameChange = ((_mutDetails$reasonFor = mutDetails.reasonForNameChange) === null || _mutDetails$reasonFor === void 0 ? void 0 : _mutDetails$reasonFor.code) || mutDetails.reasonForNameChange;
50769
- if (mutDetails.relationshipWithExistingConsumer) {
50770
- var _mutDetails$relations;
50771
- const relationCode = ((_mutDetails$relations = mutDetails.relationshipWithExistingConsumer) === null || _mutDetails$relations === void 0 ? void 0 : _mutDetails$relations.code) || mutDetails.relationshipWithExistingConsumer;
50772
- convertAppData.additionalDetails.relationshipWithExistingConsumer = relationCode;
50773
- convertAppData.additionalDetails.isBloodRelation = relationCode !== "OTHER";
50774
- }
50775
- if (mutDetails.saleDeedDocumentId) {
50776
- convertAppData.additionalDetails.saleDeedDocumentId = mutDetails.saleDeedDocumentId;
50777
- if (!convertAppData.documents) convertAppData.documents = [];
50778
- convertAppData.documents.push({
50779
- documentType: "REGISTERED_SALE_DEED",
50780
- fileStoreId: mutDetails.saleDeedDocumentId,
50781
- documentUid: mutDetails.saleDeedDocumentId
51914
+ if (mutDetails.saleDeedDocumentId) {
51915
+ convertAppData.additionalDetails.saleDeedDocumentId = mutDetails.saleDeedDocumentId;
51916
+ if (!convertAppData.documents) convertAppData.documents = [];
51917
+ convertAppData.documents.push({
51918
+ documentType: "REGISTERED_SALE_DEED",
51919
+ fileStoreId: mutDetails.saleDeedDocumentId,
51920
+ documentUid: mutDetails.saleDeedDocumentId,
51921
+ status: "ACTIVE"
51922
+ });
51923
+ }
51924
+ if (mutDetails.identityProofDocumentId) {
51925
+ var _mutDetails$identityP;
51926
+ if (!convertAppData.documents) convertAppData.documents = [];
51927
+ convertAppData.documents.push({
51928
+ documentType: ((_mutDetails$identityP = mutDetails.identityProofType) === null || _mutDetails$identityP === void 0 ? void 0 : _mutDetails$identityP.code) || "IDENTITY_PROOF",
51929
+ fileStoreId: mutDetails.identityProofDocumentId,
51930
+ documentUid: mutDetails.documentNumber || mutDetails.identityProofDocumentId,
51931
+ documentNumber: mutDetails.documentNumber,
51932
+ status: "ACTIVE"
51933
+ });
51934
+ }
51935
+ }
51936
+ convertAppData.applicationType = serviceType == "WATER" ? "MUTATION_WATER_CONNECTION" : "MUTATION_SEWERAGE_CONNECTION";
51937
+ const reqDetails = serviceType == "WATER" ? {
51938
+ WaterConnection: convertAppData,
51939
+ reconnectRequest: false,
51940
+ disconnectRequest: false
51941
+ } : {
51942
+ SewerageConnection: convertAppData,
51943
+ reconnectRequest: false,
51944
+ disconnectRequest: false
51945
+ };
51946
+ const mutation = serviceType == "WATER" ? waterMutation : sewerageMutation;
51947
+ return Promise.resolve(mutation(reqDetails, {
51948
+ onError: error => {
51949
+ var _error$response, _error$response$data, _error$response$data$, _error$response$data$2;
51950
+ setIsSubmitting(false);
51951
+ setShowToast({
51952
+ key: "error",
51953
+ message: (error === null || error === void 0 ? void 0 : (_error$response = error.response) === null || _error$response === void 0 ? void 0 : (_error$response$data = _error$response.data) === null || _error$response$data === void 0 ? void 0 : (_error$response$data$ = _error$response$data.Errors) === null || _error$response$data$ === void 0 ? void 0 : (_error$response$data$2 = _error$response$data$[0]) === null || _error$response$data$2 === void 0 ? void 0 : _error$response$data$2.message) || "Failed to submit application"
51954
+ });
51955
+ },
51956
+ onSuccess: data => {
51957
+ var _data$response, _data$response$data;
51958
+ if (data instanceof Error || data !== null && data !== void 0 && data.isAxiosError || data !== null && data !== void 0 && (_data$response = data.response) !== null && _data$response !== void 0 && (_data$response$data = _data$response.data) !== null && _data$response$data !== void 0 && _data$response$data.Errors) {
51959
+ var _data$response2, _data$response2$data, _apiErrors$;
51960
+ setIsSubmitting(false);
51961
+ const apiErrors = data === null || data === void 0 ? void 0 : (_data$response2 = data.response) === null || _data$response2 === void 0 ? void 0 : (_data$response2$data = _data$response2.data) === null || _data$response2$data === void 0 ? void 0 : _data$response2$data.Errors;
51962
+ const errorMessage = (apiErrors === null || apiErrors === void 0 ? void 0 : (_apiErrors$ = apiErrors[0]) === null || _apiErrors$ === void 0 ? void 0 : _apiErrors$.message) || (data === null || data === void 0 ? void 0 : data.message) || "Failed to submit application";
51963
+ setShowToast({
51964
+ key: "error",
51965
+ message: errorMessage
50782
51966
  });
51967
+ return;
50783
51968
  }
50784
- }
50785
- convertAppData.applicationType = serviceType == "WATER" ? "MUTATION_WATER_CONNECTION" : "MUTATION_SEWERAGE_CONNECTION";
50786
- const reqDetails = serviceType == "WATER" ? {
50787
- WaterConnection: convertAppData,
50788
- reconnectRequest: false,
50789
- disconnectRequest: false
50790
- } : {
50791
- SewerageConnection: convertAppData,
50792
- reconnectRequest: false,
50793
- disconnectRequest: false
50794
- };
50795
- const _temp5 = function () {
50796
- if (serviceType == "WATER") {
50797
- const _temp2 = function () {
50798
- if (waterMutation) {
50799
- setIsEnableLoader(true);
50800
- return Promise.resolve(waterMutation(reqDetails, {
50801
- onError: (error, variables) => {
50802
- var _error$response3, _error$response3$data, _error$response3$data2, _error$response4, _error$response4$data, _error$response4$data2;
50803
- setIsEnableLoader(false);
50804
- setShowToast({
50805
- key: "error",
50806
- message: error !== null && error !== void 0 && (_error$response3 = error.response) !== null && _error$response3 !== void 0 && (_error$response3$data = _error$response3.data) !== null && _error$response3$data !== void 0 && (_error$response3$data2 = _error$response3$data.Errors) !== null && _error$response3$data2 !== void 0 && _error$response3$data2[0].message ? error === null || error === void 0 ? void 0 : (_error$response4 = error.response) === null || _error$response4 === void 0 ? void 0 : (_error$response4$data = _error$response4.data) === null || _error$response4$data === void 0 ? void 0 : (_error$response4$data2 = _error$response4$data.Errors) === null || _error$response4$data2 === void 0 ? void 0 : _error$response4$data2[0].message : error
50807
- });
50808
- setTimeout(closeToastOfError, 5000);
50809
- },
50810
- onSuccess: function (data, variables) {
50811
- try {
50812
- var _data$WaterConnection, _data$WaterConnection2;
50813
- clearSessionFormData();
50814
- history.push("/digit-ui/employee/ws/ws-response?applicationNumber=" + (data === null || data === void 0 ? void 0 : (_data$WaterConnection = data.WaterConnection) === null || _data$WaterConnection === void 0 ? void 0 : (_data$WaterConnection2 = _data$WaterConnection[0]) === null || _data$WaterConnection2 === void 0 ? void 0 : _data$WaterConnection2.applicationNo));
50815
- return Promise.resolve();
50816
- } catch (e) {
50817
- return Promise.reject(e);
50818
- }
50819
- }
50820
- })).then(function () {});
51969
+ if (data !== null && data !== void 0 && data.Errors && data.Errors.length > 0) {
51970
+ setIsSubmitting(false);
51971
+ setShowToast({
51972
+ key: "error",
51973
+ message: data.Errors[0].message || "Failed to submit application"
51974
+ });
51975
+ } else {
51976
+ var _data$WaterConnection, _data$SewerageConnect, _Digit, _Digit$Customizations, _Digit$Customizations2;
51977
+ const updateMutation = serviceType == "WATER" ? waterUpdateMutation : sewerageUpdateMutation;
51978
+ const createdConnection = serviceType == "WATER" ? data === null || data === void 0 ? void 0 : (_data$WaterConnection = data.WaterConnection) === null || _data$WaterConnection === void 0 ? void 0 : _data$WaterConnection[0] : data === null || data === void 0 ? void 0 : (_data$SewerageConnect = data.SewerageConnections) === null || _data$SewerageConnect === void 0 ? void 0 : _data$SewerageConnect[0];
51979
+ let updatePayload = _extends({}, createdConnection, {
51980
+ dateEffectiveFrom: (createdConnection === null || createdConnection === void 0 ? void 0 : createdConnection.dateEffectiveFrom) || Date.now(),
51981
+ processInstance: _extends({}, createdConnection === null || createdConnection === void 0 ? void 0 : createdConnection.processInstance, {
51982
+ action: "APPLY_MUTATION"
51983
+ })
51984
+ });
51985
+ if ((_Digit = Digit) !== null && _Digit !== void 0 && (_Digit$Customizations = _Digit.Customizations) !== null && _Digit$Customizations !== void 0 && (_Digit$Customizations2 = _Digit$Customizations.WS) !== null && _Digit$Customizations2 !== void 0 && _Digit$Customizations2.customiseUpdatePayloadOfWS) {
51986
+ updatePayload = Digit.Customizations.WS.customiseUpdatePayloadOfWS(createdConnection, updatePayload, serviceType);
51987
+ }
51988
+ let reqDetailsUpdate = serviceType == "WATER" ? {
51989
+ WaterConnection: updatePayload,
51990
+ reconnectRequest: false,
51991
+ disconnectRequest: false
51992
+ } : {
51993
+ SewerageConnection: updatePayload,
51994
+ reconnectRequest: false,
51995
+ disconnectRequest: false
51996
+ };
51997
+ updateMutation(reqDetailsUpdate, {
51998
+ onError: error => {
51999
+ var _error$response2, _error$response2$data, _error$response2$data2, _error$response2$data3;
52000
+ setIsSubmitting(false);
52001
+ setShowToast({
52002
+ key: "error",
52003
+ message: (error === null || error === void 0 ? void 0 : (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : (_error$response2$data = _error$response2.data) === null || _error$response2$data === void 0 ? void 0 : (_error$response2$data2 = _error$response2$data.Errors) === null || _error$response2$data2 === void 0 ? void 0 : (_error$response2$data3 = _error$response2$data2[0]) === null || _error$response2$data3 === void 0 ? void 0 : _error$response2$data3.message) || "Failed to update workflow"
52004
+ });
52005
+ },
52006
+ onSuccess: updateData => {
52007
+ var _updateData$response, _updateData$response$, _updateData$WaterConn, _updateData$WaterConn2, _updateData$SewerageC, _updateData$SewerageC2;
52008
+ setIsSubmitting(false);
52009
+ if (updateData instanceof Error || updateData !== null && updateData !== void 0 && updateData.isAxiosError || updateData !== null && updateData !== void 0 && (_updateData$response = updateData.response) !== null && _updateData$response !== void 0 && (_updateData$response$ = _updateData$response.data) !== null && _updateData$response$ !== void 0 && _updateData$response$.Errors) {
52010
+ var _updateData$response2, _updateData$response3, _apiErrors$2;
52011
+ const apiErrors = updateData === null || updateData === void 0 ? void 0 : (_updateData$response2 = updateData.response) === null || _updateData$response2 === void 0 ? void 0 : (_updateData$response3 = _updateData$response2.data) === null || _updateData$response3 === void 0 ? void 0 : _updateData$response3.Errors;
52012
+ const errorMessage = (apiErrors === null || apiErrors === void 0 ? void 0 : (_apiErrors$2 = apiErrors[0]) === null || _apiErrors$2 === void 0 ? void 0 : _apiErrors$2.message) || (updateData === null || updateData === void 0 ? void 0 : updateData.message) || "Failed to update workflow";
52013
+ setShowToast({
52014
+ key: "error",
52015
+ message: errorMessage
52016
+ });
52017
+ return;
52018
+ }
52019
+ if (updateData !== null && updateData !== void 0 && updateData.Errors && updateData.Errors.length > 0) {
52020
+ setShowToast({
52021
+ key: "error",
52022
+ message: updateData.Errors[0].message || "Failed to update workflow"
52023
+ });
52024
+ return;
52025
+ }
52026
+ clearSessionFormData();
52027
+ const newAppNo = serviceType == "WATER" ? updateData === null || updateData === void 0 ? void 0 : (_updateData$WaterConn = updateData.WaterConnection) === null || _updateData$WaterConn === void 0 ? void 0 : (_updateData$WaterConn2 = _updateData$WaterConn[0]) === null || _updateData$WaterConn2 === void 0 ? void 0 : _updateData$WaterConn2.applicationNo : updateData === null || updateData === void 0 ? void 0 : (_updateData$SewerageC = updateData.SewerageConnections) === null || _updateData$SewerageC === void 0 ? void 0 : (_updateData$SewerageC2 = _updateData$SewerageC[0]) === null || _updateData$SewerageC2 === void 0 ? void 0 : _updateData$SewerageC2.applicationNo;
52028
+ setGeneratedAppNo(newAppNo);
52029
+ setCurrentStep(5);
50821
52030
  }
50822
- }();
50823
- if (_temp2 && _temp2.then) return _temp2.then(function () {});
52031
+ });
50824
52032
  }
50825
- }();
50826
- return _temp5 && _temp5.then ? _temp5.then(_temp6) : _temp6(_temp5);
50827
- });
50828
- }
50829
- }();
50830
- return Promise.resolve(_temp7 && _temp7.then ? _temp7.then(function () {}) : void 0);
52033
+ }
52034
+ })).then(function () {});
52035
+ });
52036
+ }, function (e) {
52037
+ console.error(e);
52038
+ setIsSubmitting(false);
52039
+ setShowToast({
52040
+ key: "error",
52041
+ message: "Failed to submit application"
52042
+ });
52043
+ });
52044
+ return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
50831
52045
  } catch (e) {
50832
52046
  return Promise.reject(e);
50833
52047
  }
50834
52048
  };
50835
- const closeToastOfError = () => {
50836
- setShowToast(null);
50837
- };
50838
- const closeToast = () => {
50839
- setShowToast(null);
52049
+ const handleTimelineSelect = (route, index) => {
52050
+ const targetStep = index + 1;
52051
+ if (targetStep < currentStep) {
52052
+ setCurrentStep(targetStep);
52053
+ return;
52054
+ }
52055
+ if (targetStep === currentStep) return;
52056
+ if (targetStep > currentStep) {
52057
+ setShowToast({
52058
+ key: "warning",
52059
+ message: "Please complete Step " + currentStep + " before proceeding to Step " + targetStep + "."
52060
+ });
52061
+ }
50840
52062
  };
50841
- if (enabledLoader || isEnableLoader || isConfigLoading) {
52063
+ const timelineConfig = [{
52064
+ sectionId: "application",
52065
+ route: "application-selection",
52066
+ actions: "Existing Connection"
52067
+ }, {
52068
+ sectionId: "applicant",
52069
+ route: "applicant-details",
52070
+ actions: "New Consumer Details"
52071
+ }, {
52072
+ sectionId: "documents",
52073
+ route: "documents",
52074
+ actions: "Documents"
52075
+ }, {
52076
+ sectionId: "Review",
52077
+ route: "review",
52078
+ actions: "Preview"
52079
+ }].map((step, index) => _extends({}, step, {
52080
+ timeLine: [{
52081
+ actions: step.actions,
52082
+ currentStep: index + 1
52083
+ }]
52084
+ }));
52085
+ if (isDetailsLoading || propertyId && isPropertyLoading) {
50842
52086
  return /*#__PURE__*/React.createElement(Loader, null);
50843
52087
  }
50844
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("style", null, "\n .mutation-disabled-section { pointer-events: none; opacity: 0.8; margin-top: -24px !important; }\n .mutation-hidden-section { display: none !important; margin: 0 !important; padding: 0 !important; height: 0 !important; overflow: hidden !important; border: 0 !important; }\n .mutation-hidden-section + hr { display: none !important; margin: 0 !important; }\n .mutation-hidden-section + .break-line { display: none !important; margin: 0 !important; }\n "), /*#__PURE__*/React.createElement(Header, null, t(config.head)), /*#__PURE__*/React.createElement(Card, null, /*#__PURE__*/React.createElement(CardSubHeader, null, t("WS_MUTATION_DETAILS")), /*#__PURE__*/React.createElement(StatusTable, null, /*#__PURE__*/React.createElement(Row, {
50845
- label: t("WS_MYCONNECTIONS_APPLICATION_NO"),
50846
- text: (applicationDetails === null || applicationDetails === void 0 ? void 0 : (_applicationDetails$a = applicationDetails.applicationData) === null || _applicationDetails$a === void 0 ? void 0 : _applicationDetails$a.applicationNo) || "NA"
50847
- }), /*#__PURE__*/React.createElement(Row, {
50848
- label: t("WS_CONNECTION_CATEGORY"),
50849
- text: (applicationDetails === null || applicationDetails === void 0 ? void 0 : (_applicationDetails$a2 = applicationDetails.applicationData) === null || _applicationDetails$a2 === void 0 ? void 0 : _applicationDetails$a2.connectionCategory) || "NA"
50850
- }), /*#__PURE__*/React.createElement(Row, {
50851
- label: t("WS_PROPERTY_ID_LABEL"),
50852
- text: (applicationDetails === null || applicationDetails === void 0 ? void 0 : (_applicationDetails$a3 = applicationDetails.applicationData) === null || _applicationDetails$a3 === void 0 ? void 0 : _applicationDetails$a3.propertyId) || propertyId || "NA"
50853
- }), /*#__PURE__*/React.createElement(Row, {
50854
- label: t("WS_APPLICATION_ID"),
50855
- text: (applicationDetails === null || applicationDetails === void 0 ? void 0 : (_applicationDetails$a4 = applicationDetails.applicationData) === null || _applicationDetails$a4 === void 0 ? void 0 : _applicationDetails$a4.id) || (applicationDetails === null || applicationDetails === void 0 ? void 0 : (_applicationDetails$a5 = applicationDetails.applicationData) === null || _applicationDetails$a5 === void 0 ? void 0 : _applicationDetails$a5.connectionNo) || "NA"
50856
- }), /*#__PURE__*/React.createElement(Row, {
50857
- label: t("WS_CONNECTION_DATE"),
50858
- text: applicationDetails !== null && applicationDetails !== void 0 && (_applicationDetails$a6 = applicationDetails.applicationData) !== null && _applicationDetails$a6 !== void 0 && _applicationDetails$a6.connectionExecutionDate ? Digit.DateUtils.ConvertEpochToDate(applicationDetails === null || applicationDetails === void 0 ? void 0 : (_applicationDetails$a7 = applicationDetails.applicationData) === null || _applicationDetails$a7 === void 0 ? void 0 : _applicationDetails$a7.connectionExecutionDate) : "NA"
50859
- }))), /*#__PURE__*/React.createElement(FormComposer, {
50860
- config: config.body,
50861
- userType: "employee",
50862
- onFormValueChange: onFormValueChange,
50863
- label: t("CS_COMMON_SUBMIT"),
50864
- onSubmit: onSubmit,
50865
- defaultValues: sessionFormData,
50866
- appData: appData
52088
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
52089
+ className: "employee-form-section-wrapper"
52090
+ }, currentStep !== 5 && /*#__PURE__*/React.createElement(VerticalTimeline, {
52091
+ config: timelineConfig,
52092
+ currentActiveIndex: currentStep - 1,
52093
+ showFinalStep: false,
52094
+ onSelect: handleTimelineSelect
52095
+ }), /*#__PURE__*/React.createElement("div", {
52096
+ style: {
52097
+ flex: "1",
52098
+ minWidth: 0
52099
+ }
52100
+ }, currentStep === 1 && /*#__PURE__*/React.createElement(Fragment$2, null, /*#__PURE__*/React.createElement(Step1_ExistingConnection, {
52101
+ t: t,
52102
+ applicationDetails: applicationDetails,
52103
+ propertyId: propertyId
52104
+ }), /*#__PURE__*/React.createElement("div", {
52105
+ style: {
52106
+ display: "flex",
52107
+ justifyContent: "flex-end"
52108
+ }
52109
+ }, /*#__PURE__*/React.createElement("button", {
52110
+ onClick: () => {
52111
+ setCompletedSteps(prev => new Set([...prev, 1]));
52112
+ setCurrentStep(2);
52113
+ },
52114
+ style: {
52115
+ padding: "10px 24px",
52116
+ backgroundColor: "#00497e",
52117
+ color: "white",
52118
+ border: "none",
52119
+ borderRadius: "4px",
52120
+ cursor: "pointer",
52121
+ fontWeight: "bold"
52122
+ }
52123
+ }, "Proceed to New Consumer Details \u2192"))), currentStep === 2 && /*#__PURE__*/React.createElement(Step2_NewConsumerDetails, {
52124
+ t: t,
52125
+ defaultValues: formData,
52126
+ onNext: handleNextStep2,
52127
+ onBack: () => setCurrentStep(1)
52128
+ }), currentStep === 3 && /*#__PURE__*/React.createElement(Step3_UploadDocuments, {
52129
+ t: t,
52130
+ defaultValues: formData,
52131
+ onNext: handleNextStep3,
52132
+ onBack: () => setCurrentStep(2)
52133
+ }), currentStep === 4 && /*#__PURE__*/React.createElement(Step4_Preview, {
52134
+ t: t,
52135
+ formData: formData,
52136
+ applicationDetails: applicationDetails,
52137
+ onBack: () => setCurrentStep(3),
52138
+ onSubmit: submitApplication,
52139
+ isLoading: isSubmitting
52140
+ }), currentStep === 5 && /*#__PURE__*/React.createElement(Step5_Submission, {
52141
+ t: t,
52142
+ applicationNumber: generatedAppNo,
52143
+ serviceType: serviceType || (applicationDetails === null || applicationDetails === void 0 ? void 0 : (_applicationDetails$a4 = applicationDetails.applicationData) === null || _applicationDetails$a4 === void 0 ? void 0 : _applicationDetails$a4.serviceType)
50867
52144
  }), showToast && /*#__PURE__*/React.createElement(Toast, {
50868
- isDleteBtn: true,
50869
- error: (showToast === null || showToast === void 0 ? void 0 : showToast.key) === "error" ? true : false,
52145
+ error: (showToast === null || showToast === void 0 ? void 0 : showToast.key) === "error",
52146
+ warning: (showToast === null || showToast === void 0 ? void 0 : showToast.key) === "warning",
50870
52147
  label: t(showToast === null || showToast === void 0 ? void 0 : showToast.message),
50871
- onClose: closeToast
50872
- }));
52148
+ onClose: () => setShowToast(null),
52149
+ isDleteBtn: true
52150
+ }))));
50873
52151
  };
50874
52152
 
50875
52153
  const getPath$5 = (path, params) => {