@djb25/digit-ui-module-vendor 1.0.26 → 1.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import React, { useEffect, useMemo, useCallback, useState } from 'react';
2
2
  import { useTranslation } from 'react-i18next';
3
3
  import { useParams, useLocation, Switch, useHistory, Link, useRouteMatch, Route, Redirect } from 'react-router-dom';
4
- import { Header, SearchForm, SearchField, Dropdown as Dropdown$2, MobileNumber, CardLabelError, DatePicker as DatePicker$3, SubmitBar, Card, Table, Loader, Toast, AppContainer, ModuleHeader, ArrowLeft, PrivateRoute, LayoutWrapper, HomeIcon, PropertyHouse, EmployeeModuleCard, VerticalTimeline, FormComposer, FormStep, LabelFieldPair, CardLabel, Tooltip, TextInput, UploadFile, ActionBar, RadioOrSelect, ShippingTruck, CheckBox, RadioButtons, CloseSvg, Localities, RemoveableTag, ApplyFilterBar, AddIcon, Menu, LinkLabel, ToggleSwitch, CardSectionHeader, Row, EditIcon, DeleteIcon, Modal, CardText, InfoIcon, CardHeader, CardSubHeader, StatusTable, LinkButton, Banner } from '@djb25/digit-ui-react-components';
4
+ import { Header, SearchForm, SearchField, Dropdown as Dropdown$4, MobileNumber, CardLabelError, DatePicker as DatePicker$5, SubmitBar, Card, Table, Loader, Toast, AppContainer, ModuleHeader, ArrowLeft, PrivateRoute, LayoutWrapper, HomeIcon, PropertyHouse, EmployeeModuleCard, VerticalTimeline, FormComposer, FormStep, LabelFieldPair, CardLabel, Tooltip, TextInput, UploadFile, ActionBar, RadioOrSelect, ShippingTruck, CheckBox, RadioButtons, CloseSvg, Localities, RemoveableTag, ApplyFilterBar, AddIcon, Menu, LinkLabel, ViewsIcon, ToggleSwitch, Modal, CardSectionHeader, Row, EditIcon, DeleteIcon, CardText, InfoIcon, CardHeader, CardSubHeader, StatusTable, LinkButton, Banner, MultiSelectDropdown } from '@djb25/digit-ui-react-components';
5
5
  import { useForm, Controller } from 'react-hook-form';
6
6
  import { useQueryClient } from 'react-query';
7
7
 
@@ -133,7 +133,7 @@ const VendorSearchApplication = ({
133
133
  name: "vendorName",
134
134
  render: field => {
135
135
  var _vendorData$vendor2;
136
- return /*#__PURE__*/React.createElement(Dropdown$2, {
136
+ return /*#__PURE__*/React.createElement(Dropdown$4, {
137
137
  selected: field.value || "",
138
138
  select: field.onChange,
139
139
  onBlur: field.onBlur,
@@ -167,7 +167,7 @@ const VendorSearchApplication = ({
167
167
  className: "employee-card-input employee-card-input--front"
168
168
  }, "+91")
169
169
  }), /*#__PURE__*/React.createElement(CardLabelError, null, formState === null || formState === void 0 ? void 0 : (_formState$errors = formState.errors) === null || _formState$errors === void 0 ? void 0 : (_formState$errors$mob = _formState$errors["mobileNumber"]) === null || _formState$errors$mob === void 0 ? void 0 : _formState$errors$mob.message)), /*#__PURE__*/React.createElement(SearchField, null, /*#__PURE__*/React.createElement("label", null, t("VENDOR_FROM_DATE")), /*#__PURE__*/React.createElement(Controller, {
170
- render: props => /*#__PURE__*/React.createElement(DatePicker$3, {
170
+ render: props => /*#__PURE__*/React.createElement(DatePicker$5, {
171
171
  date: props.value,
172
172
  disabled: false,
173
173
  onChange: props.onChange
@@ -175,7 +175,7 @@ const VendorSearchApplication = ({
175
175
  name: "fromDate",
176
176
  control: control
177
177
  })), /*#__PURE__*/React.createElement(SearchField, null, /*#__PURE__*/React.createElement("label", null, t("VENDOR_TO_DATE")), /*#__PURE__*/React.createElement(Controller, {
178
- render: props => /*#__PURE__*/React.createElement(DatePicker$3, {
178
+ render: props => /*#__PURE__*/React.createElement(DatePicker$5, {
179
179
  date: props.value,
180
180
  disabled: false,
181
181
  onChange: props.onChange
@@ -329,6 +329,10 @@ const EmployeeApp = ({
329
329
  const VendorCreate = Digit.ComponentRegistryService.getComponent("VENDORCreate");
330
330
  const DriverDetails = Digit.ComponentRegistryService.getComponent("DriverDetails");
331
331
  const VehicleDetails = Digit.ComponentRegistryService.getComponent("VehicleDetails");
332
+ const AddSupervisor = Digit.ComponentRegistryService.getComponent("AddSupervisor");
333
+ const SupervisorDetails = Digit.ComponentRegistryService.getComponent("SupervisorDetails");
334
+ const AddSurveyor = Digit.ComponentRegistryService.getComponent("AddSurveyor");
335
+ const SurveyorDetails = Digit.ComponentRegistryService.getComponent("SurveyorDetails");
332
336
  const getDynamicBreadcrumbs = () => {
333
337
  const pathname = location.pathname;
334
338
  let crumbs = [{
@@ -370,6 +374,22 @@ const EmployeeApp = ({
370
374
  crumbs.push({
371
375
  label: t("VENDOR_ADDITIONAL_DETAILS")
372
376
  });
377
+ } else if (pathname.includes("/registry/new-supervisor")) {
378
+ crumbs.push({
379
+ label: t("ES_FSM_REGISTRY_TITLE_NEW_SUPERVISOR")
380
+ });
381
+ } else if (pathname.includes("/registry/supervisor-details") || pathname.includes("/registry/modify-supervisor/")) {
382
+ crumbs.push({
383
+ label: t("VENDOR_SUPERVISOR_DETAILS")
384
+ });
385
+ } else if (pathname.includes("/registry/new-surveyor")) {
386
+ crumbs.push({
387
+ label: t("ES_FSM_REGISTRY_TITLE_NEW_SURVEYOR")
388
+ });
389
+ } else if (pathname.includes("/registry/surveyor-details") || pathname.includes("/registry/modify-surveyor/")) {
390
+ crumbs.push({
391
+ label: t("VENDOR_SURVEYOR_DETAILS")
392
+ });
373
393
  }
374
394
  return crumbs;
375
395
  };
@@ -447,6 +467,34 @@ const EmployeeApp = ({
447
467
  }, /*#__PURE__*/React.createElement(VehicleDetails, Object.assign({}, props, {
448
468
  parentRoute: path
449
469
  })))
470
+ }), /*#__PURE__*/React.createElement(PrivateRoute, {
471
+ path: `${path}/registry/new-supervisor`,
472
+ component: props => /*#__PURE__*/React.createElement(LayoutWrapper, {
473
+ layoutClass: "action"
474
+ }, /*#__PURE__*/React.createElement(AddSupervisor, Object.assign({}, props, {
475
+ parentRoute: path
476
+ })))
477
+ }), /*#__PURE__*/React.createElement(PrivateRoute, {
478
+ path: `${path}/registry/supervisor-details/:id`,
479
+ component: props => /*#__PURE__*/React.createElement(LayoutWrapper, {
480
+ layoutClass: "action"
481
+ }, /*#__PURE__*/React.createElement(SupervisorDetails, Object.assign({}, props, {
482
+ parentRoute: path
483
+ })))
484
+ }), /*#__PURE__*/React.createElement(PrivateRoute, {
485
+ path: `${path}/registry/new-surveyor`,
486
+ component: props => /*#__PURE__*/React.createElement(LayoutWrapper, {
487
+ layoutClass: "action"
488
+ }, /*#__PURE__*/React.createElement(AddSurveyor, Object.assign({}, props, {
489
+ parentRoute: path
490
+ })))
491
+ }), /*#__PURE__*/React.createElement(PrivateRoute, {
492
+ path: `${path}/registry/surveyor-details/:id`,
493
+ component: props => /*#__PURE__*/React.createElement(LayoutWrapper, {
494
+ layoutClass: "action"
495
+ }, /*#__PURE__*/React.createElement(SurveyorDetails, Object.assign({}, props, {
496
+ parentRoute: path
497
+ })))
450
498
  })))));
451
499
  };
452
500
 
@@ -1360,7 +1408,7 @@ const VendorDetails = ({
1360
1408
  rules: {
1361
1409
  required: t("CORE_COMMON_REQUIRED_ERRMSG")
1362
1410
  },
1363
- render: props => /*#__PURE__*/React.createElement(Dropdown$2, {
1411
+ render: props => /*#__PURE__*/React.createElement(Dropdown$4, {
1364
1412
  selected: VendorType,
1365
1413
  select: setVendorType,
1366
1414
  option: [{
@@ -1400,7 +1448,7 @@ const VendorDetails = ({
1400
1448
  rules: {
1401
1449
  required: t("CORE_COMMON_REQUIRED_ERRMSG")
1402
1450
  },
1403
- render: props => /*#__PURE__*/React.createElement(Dropdown$2, {
1451
+ render: props => /*#__PURE__*/React.createElement(Dropdown$4, {
1404
1452
  selected: VendorCategory,
1405
1453
  select: setVendorCategory,
1406
1454
  option: [{
@@ -1440,7 +1488,7 @@ const VendorDetails = ({
1440
1488
  rules: {
1441
1489
  required: t("CORE_COMMON_REQUIRED_ERRMSG")
1442
1490
  },
1443
- render: props => /*#__PURE__*/React.createElement(Dropdown$2, {
1491
+ render: props => /*#__PURE__*/React.createElement(Dropdown$4, {
1444
1492
  selected: Status,
1445
1493
  select: setStatus,
1446
1494
  option: [{
@@ -1734,7 +1782,7 @@ const VendorSelectAddress = ({
1734
1782
  });
1735
1783
  }
1736
1784
  if (userType === "employee") {
1737
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, null, t("MYCITY_CODE_LABEL"), config.isMandatory ? " * " : null), /*#__PURE__*/React.createElement(Dropdown$2, {
1785
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, null, t("MYCITY_CODE_LABEL"), config.isMandatory ? " * " : null), /*#__PURE__*/React.createElement(Dropdown$4, {
1738
1786
  className: "",
1739
1787
  isMandatory: true,
1740
1788
  selected: (cities === null || cities === void 0 ? void 0 : cities.length) === 1 ? cities[0] : selectedCity,
@@ -1743,7 +1791,7 @@ const VendorSelectAddress = ({
1743
1791
  select: selectCity,
1744
1792
  optionKey: "code",
1745
1793
  t: t
1746
- })), /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, null, t("ES_NEW_APPLICATION_LOCATION_MOHALLA"), config.isMandatory ? " * " : null), /*#__PURE__*/React.createElement(Dropdown$2, {
1794
+ })), /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, null, t("ES_NEW_APPLICATION_LOCATION_MOHALLA"), config.isMandatory ? " * " : null), /*#__PURE__*/React.createElement(Dropdown$4, {
1747
1795
  className: "",
1748
1796
  isMandatory: true,
1749
1797
  selected: selectedLocality,
@@ -7972,7 +8020,7 @@ const DropdownStatus = ({
7972
8020
  applicationStatuses,
7973
8021
  areApplicationStatus
7974
8022
  }) => {
7975
- return areApplicationStatus ? /*#__PURE__*/React.createElement(Dropdown$2, {
8023
+ return areApplicationStatus ? /*#__PURE__*/React.createElement(Dropdown$4, {
7976
8024
  option: applicationStatuses,
7977
8025
  optionKey: "name",
7978
8026
  selected: value,
@@ -8058,13 +8106,17 @@ const SearchApplication = ({
8058
8106
  return history.push("/digit-ui/employee/vendor/registry/new-vehicle");
8059
8107
  case "DRIVER":
8060
8108
  return history.push("/digit-ui/employee/vendor/registry/new-driver");
8109
+ case "SUPERVISOR":
8110
+ return history.push("/digit-ui/employee/vendor/registry/new-supervisor");
8111
+ case "SURVEYOR":
8112
+ return history.push("/digit-ui/employee/vendor/registry/new-surveyor");
8061
8113
  }
8062
8114
  }
8063
8115
  const getFields = input => {
8064
8116
  switch (input.type) {
8065
8117
  case "date":
8066
8118
  return /*#__PURE__*/React.createElement(Controller, {
8067
- render: props => /*#__PURE__*/React.createElement(DatePicker$3, {
8119
+ render: props => /*#__PURE__*/React.createElement(DatePicker$5, {
8068
8120
  date: props.value,
8069
8121
  onChange: props.onChange
8070
8122
  }),
@@ -8084,6 +8136,21 @@ const SearchApplication = ({
8084
8136
  control: control,
8085
8137
  defaultValue: null
8086
8138
  });
8139
+ case "dropdown":
8140
+ return /*#__PURE__*/React.createElement(Controller, {
8141
+ render: props => /*#__PURE__*/React.createElement(Dropdown$4, {
8142
+ option: input.options,
8143
+ optionKey: input.optionsKey,
8144
+ value: props.value,
8145
+ selected: props.value,
8146
+ select: props.onChange,
8147
+ t: t,
8148
+ placeholder: input.label
8149
+ }),
8150
+ name: input.name,
8151
+ control: control,
8152
+ defaultValue: null
8153
+ });
8087
8154
  default:
8088
8155
  return /*#__PURE__*/React.createElement(TextInput, Object.assign({}, input, {
8089
8156
  inputRef: register
@@ -8132,7 +8199,19 @@ const SearchApplication = ({
8132
8199
  clearSearch();
8133
8200
  onTabChange("DRIVER");
8134
8201
  }
8135
- }, t("ES_FSM_REGISTRY_INBOX_TAB_DRIVER"))), /*#__PURE__*/React.createElement("div", {
8202
+ }, t("ES_FSM_REGISTRY_INBOX_TAB_DRIVER")), /*#__PURE__*/React.createElement("button", {
8203
+ className: selectedTab === "SUPERVISOR" ? "search-tab-head-selected" : "search-tab-head",
8204
+ onClick: () => {
8205
+ clearSearch();
8206
+ onTabChange("SUPERVISOR");
8207
+ }
8208
+ }, t("ES_FSM_REGISTRY_INBOX_TAB_SUPERVISOR")), /*#__PURE__*/React.createElement("button", {
8209
+ className: selectedTab === "SURVEYOR" ? "search-tab-head-selected" : "search-tab-head",
8210
+ onClick: () => {
8211
+ clearSearch();
8212
+ onTabChange("SURVEYOR");
8213
+ }
8214
+ }, t("ES_FSM_REGISTRY_INBOX_TAB_SURVEYOR"))), /*#__PURE__*/React.createElement("div", {
8136
8215
  className: "action-bar-wrap-registry"
8137
8216
  }, /*#__PURE__*/React.createElement("div", {
8138
8217
  className: "search-add",
@@ -8143,7 +8222,7 @@ const SearchApplication = ({
8143
8222
  className: ""
8144
8223
  }))), showAddMenu && /*#__PURE__*/React.createElement(Menu, {
8145
8224
  localeKeyPrefix: "ES_FSM_ACTION_CREATE",
8146
- options: ["VENDOR", "DRIVER", "VEHICLE"],
8225
+ options: ["VENDOR", "DRIVER", "VEHICLE", "SUPERVISOR", "SURVEYOR"],
8147
8226
  t: t,
8148
8227
  onSelect: onActionSelect
8149
8228
  }))), /*#__PURE__*/React.createElement("form", {
@@ -8230,7 +8309,13 @@ const getDriverFillingPointIdentifiers = (driver = {}) => {
8230
8309
  return Array.from(new Set([driver === null || driver === void 0 ? void 0 : driver.fillingPointId, driver === null || driver === void 0 ? void 0 : driver.fillingStationId, driver === null || driver === void 0 ? void 0 : (_driver$additionalDet = driver.additionalDetails) === null || _driver$additionalDet === void 0 ? void 0 : _driver$additionalDet.fillingPointId, driver === null || driver === void 0 ? void 0 : (_driver$additionalDet2 = driver.additionalDetails) === null || _driver$additionalDet2 === void 0 ? void 0 : _driver$additionalDet2.fillingStationId, driver === null || driver === void 0 ? void 0 : (_driver$fillingpointm = driver.fillingpointmetadata) === null || _driver$fillingpointm === void 0 ? void 0 : _driver$fillingpointm.fillingPointId].filter(value => value !== undefined && value !== null && value !== "").map(String).concat(getFillingPointIdentifiers(driver === null || driver === void 0 ? void 0 : driver.fillingPoint), getFillingPointIdentifiers(driver === null || driver === void 0 ? void 0 : driver.fillingPointDetail), getFillingPointIdentifiers(driver === null || driver === void 0 ? void 0 : driver.fillingPointDetails))));
8231
8310
  };
8232
8311
  const getVendorDriversForFillingPoint = (vendor, fillingPoint) => {
8233
- const vendorDrivers = Array.isArray(vendor === null || vendor === void 0 ? void 0 : vendor.drivers) ? vendor.drivers.filter(Boolean) : [];
8312
+ const vendorDrivers = Array.isArray(vendor === null || vendor === void 0 ? void 0 : vendor.drivers) ? vendor.drivers.filter(Boolean).map(d => {
8313
+ var _d$owner;
8314
+ return {
8315
+ ...d,
8316
+ displayName: `${d.name} (${((_d$owner = d.owner) === null || _d$owner === void 0 ? void 0 : _d$owner.mobileNumber) || "N/A"})`
8317
+ };
8318
+ }) : [];
8234
8319
  if (!fillingPoint) return [];
8235
8320
  const selectedFillingPointIdentifiers = getFillingPointIdentifiers(fillingPoint);
8236
8321
  if (!selectedFillingPointIdentifiers.length) return vendorDrivers;
@@ -8257,6 +8342,7 @@ const normalizeFillingPointForVehicleUpdate = fillingPoint => {
8257
8342
  };
8258
8343
  };
8259
8344
  const VendorInbox = props => {
8345
+ var _selectedVendorForWor, _selectedVendorForWor2;
8260
8346
  const tenantId = Digit.ULBService.getCurrentTenantId();
8261
8347
  const {
8262
8348
  t
@@ -8270,6 +8356,78 @@ const VendorInbox = props => {
8270
8356
  const [showToast, setShowToast] = useState(null);
8271
8357
  const [vendors, setVendors] = useState([]);
8272
8358
  const [drivers, setDrivers] = useState([]);
8359
+ const [showWorkOrderModal, setShowWorkOrderModal] = useState(false);
8360
+ const [selectedVendorForWorkOrder, setSelectedVendorForWorkOrder] = useState(null);
8361
+ const openWorkOrderModal = vendorDetails => {
8362
+ setSelectedVendorForWorkOrder(vendorDetails);
8363
+ setShowWorkOrderModal(true);
8364
+ };
8365
+ const closeWorkOrderModal = () => {
8366
+ setSelectedVendorForWorkOrder(null);
8367
+ setShowWorkOrderModal(false);
8368
+ };
8369
+ const handleViewDocument = async fileStoreId => {
8370
+ if (!fileStoreId) return;
8371
+ try {
8372
+ var _response$data;
8373
+ const response = await Digit.UploadServices.Filefetch([fileStoreId], "dl");
8374
+ if (response !== null && response !== void 0 && (_response$data = response.data) !== null && _response$data !== void 0 && _response$data[fileStoreId]) {
8375
+ const fileUrl = response.data[fileStoreId].split(",")[0];
8376
+ window.open(fileUrl, "_blank");
8377
+ }
8378
+ } catch (e) {
8379
+ console.error(e);
8380
+ setShowToast({
8381
+ key: "error",
8382
+ action: "Failed to fetch document."
8383
+ });
8384
+ setTimeout(closeToast, 5000);
8385
+ }
8386
+ };
8387
+ const workOrderColumns = React.useMemo(() => [{
8388
+ Header: t("WT_NAME"),
8389
+ accessor: "name",
8390
+ Cell: ({
8391
+ row
8392
+ }) => GetCell(row.original.name)
8393
+ }, {
8394
+ Header: t("WT_MOBILE_NUMBER"),
8395
+ accessor: "mobileNumber",
8396
+ Cell: ({
8397
+ row
8398
+ }) => GetCell(row.original.mobileNumber)
8399
+ }, {
8400
+ Header: t("WT_EMAIL_ID"),
8401
+ accessor: "emailId",
8402
+ Cell: ({
8403
+ row
8404
+ }) => GetCell(row.original.emailId)
8405
+ }, {
8406
+ Header: t("WT_VALID_FROM"),
8407
+ accessor: "validFrom",
8408
+ Cell: ({
8409
+ row
8410
+ }) => row.original.validFrom ? Digit.DateUtils.ConvertEpochToDate(row.original.validFrom) : t("CS_NA")
8411
+ }, {
8412
+ Header: t("WT_VALID_TO"),
8413
+ accessor: "validTo",
8414
+ Cell: ({
8415
+ row
8416
+ }) => row.original.validTo ? Digit.DateUtils.ConvertEpochToDate(row.original.validTo) : t("CS_NA")
8417
+ }, {
8418
+ Header: t("WT_DOCUMENT"),
8419
+ accessor: "fileStoreId",
8420
+ Cell: ({
8421
+ row
8422
+ }) => row.original.fileStoreId ? /*#__PURE__*/React.createElement("div", {
8423
+ style: {
8424
+ color: "#f47738",
8425
+ cursor: "pointer",
8426
+ textDecoration: "underline"
8427
+ },
8428
+ onClick: () => handleViewDocument(row.original.fileStoreId)
8429
+ }, /*#__PURE__*/React.createElement(ViewsIcon, null)) : t("CS_NA")
8430
+ }], [t]);
8273
8431
  const queryClient = useQueryClient();
8274
8432
  const {
8275
8433
  data: vendorData,
@@ -8328,13 +8486,25 @@ const VendorInbox = props => {
8328
8486
  }, [props.selectedTab]);
8329
8487
  useEffect(() => {
8330
8488
  if (vendorData) {
8331
- let vendors = vendorData.map(data => data.dsoDetails);
8489
+ let vendors = vendorData.map(data => {
8490
+ var _data$dsoDetails$owne;
8491
+ return {
8492
+ ...data.dsoDetails,
8493
+ displayName: `${data.dsoDetails.name} (${data.dsoDetails.mobileNumber || ((_data$dsoDetails$owne = data.dsoDetails.owner) === null || _data$dsoDetails$owne === void 0 ? void 0 : _data$dsoDetails$owne.mobileNumber) || "N/A"})`
8494
+ };
8495
+ });
8332
8496
  setVendors(vendors);
8333
8497
  }
8334
8498
  }, [vendorData]);
8335
8499
  useEffect(() => {
8336
8500
  if (driverData) {
8337
- setDrivers(driverData.driver || []);
8501
+ setDrivers((driverData.driver || []).map(d => {
8502
+ var _d$owner2;
8503
+ return {
8504
+ ...d,
8505
+ displayName: `${d.name} (${((_d$owner2 = d.owner) === null || _d$owner2 === void 0 ? void 0 : _d$owner2.mobileNumber) || "N/A"})`
8506
+ };
8507
+ }));
8338
8508
  }
8339
8509
  }, [driverData]);
8340
8510
  const closeToast = () => {
@@ -8660,6 +8830,10 @@ const VendorInbox = props => {
8660
8830
  return history.push("/digit-ui/employee/fsm/registry/new-vehicle");
8661
8831
  case "DRIVER":
8662
8832
  return history.push("/digit-ui/employee/fsm/registry/new-driver");
8833
+ case "SUPERVISOR":
8834
+ return history.push("/digit-ui/employee/vendor/registry/new-supervisor");
8835
+ case "SURVEYOR":
8836
+ return history.push("/digit-ui/employee/vendor/registry/new-surveyor");
8663
8837
  }
8664
8838
  };
8665
8839
  const vendorIds = React.useMemo(() => {
@@ -8709,6 +8883,14 @@ const VendorInbox = props => {
8709
8883
  to: "/digit-ui/employee/vendor/registry/vendor-details/" + row.original["id"]
8710
8884
  }, /*#__PURE__*/React.createElement("div", null, row.original.name))));
8711
8885
  }
8886
+ }, {
8887
+ Header: t("WT_MOBILE_NUMBER"),
8888
+ accessor: "mobileNumber",
8889
+ Cell: ({
8890
+ row
8891
+ }) => {
8892
+ return /*#__PURE__*/React.createElement("div", null, row.original.mobileNumber);
8893
+ }
8712
8894
  }, {
8713
8895
  Header: t("ES_VENDOR_INBOX_DATE_VENDOR_CREATION"),
8714
8896
  accessor: "createdTime",
@@ -8792,6 +8974,21 @@ const VendorInbox = props => {
8792
8974
  }
8793
8975
  }, hasDetails ? "View Details" : "Add Details"));
8794
8976
  }
8977
+ }, {
8978
+ Header: t("VIEW_WORKORDER_DETAILS"),
8979
+ disableSortBy: true,
8980
+ Cell: ({
8981
+ row
8982
+ }) => {
8983
+ return /*#__PURE__*/React.createElement("button", {
8984
+ className: "submit-bar",
8985
+ style: {
8986
+ backgroundColor: "#417505",
8987
+ color: "white"
8988
+ },
8989
+ onClick: () => openWorkOrderModal(row.original)
8990
+ }, t("VIEW_WORKORDER_DETAILS"));
8991
+ }
8795
8992
  }];
8796
8993
  case "VEHICLE":
8797
8994
  return [{
@@ -8806,14 +9003,23 @@ const VendorInbox = props => {
8806
9003
  to: "/digit-ui/employee/vendor/registry/vehicle-details/" + row.original["registrationNumber"]
8807
9004
  }, /*#__PURE__*/React.createElement("div", null, row.original.registrationNumber))));
8808
9005
  }
9006
+ }, {
9007
+ Header: t("WT_MOBILE_NUMBER"),
9008
+ accessor: "mobileNumber",
9009
+ Cell: ({
9010
+ row
9011
+ }) => {
9012
+ var _row$original9, _row$original9$owner;
9013
+ return /*#__PURE__*/React.createElement("div", null, ((_row$original9 = row.original) === null || _row$original9 === void 0 ? void 0 : (_row$original9$owner = _row$original9.owner) === null || _row$original9$owner === void 0 ? void 0 : _row$original9$owner.mobileNumber) || "N/A");
9014
+ }
8809
9015
  }, {
8810
9016
  Header: t("ES_FSM_REGISTRY_INBOX_DATE_VEHICLE_CREATION"),
8811
9017
  accessor: "createdTime",
8812
9018
  Cell: ({
8813
9019
  row
8814
9020
  }) => {
8815
- var _row$original9, _row$original9$auditD, _row$original0, _row$original0$auditD;
8816
- return GetCell((_row$original9 = row.original) !== null && _row$original9 !== void 0 && (_row$original9$auditD = _row$original9.auditDetails) !== null && _row$original9$auditD !== void 0 && _row$original9$auditD.createdTime ? Digit.DateUtils.ConvertEpochToDate((_row$original0 = row.original) === null || _row$original0 === void 0 ? void 0 : (_row$original0$auditD = _row$original0.auditDetails) === null || _row$original0$auditD === void 0 ? void 0 : _row$original0$auditD.createdTime) : "");
9021
+ var _row$original0, _row$original0$auditD, _row$original1, _row$original1$auditD;
9022
+ return GetCell((_row$original0 = row.original) !== null && _row$original0 !== void 0 && (_row$original0$auditD = _row$original0.auditDetails) !== null && _row$original0$auditD !== void 0 && _row$original0$auditD.createdTime ? Digit.DateUtils.ConvertEpochToDate((_row$original1 = row.original) === null || _row$original1 === void 0 ? void 0 : (_row$original1$auditD = _row$original1.auditDetails) === null || _row$original1$auditD === void 0 ? void 0 : _row$original1$auditD.createdTime) : "");
8817
9023
  }
8818
9024
  }, {
8819
9025
  Header: "Map Vendor",
@@ -8825,7 +9031,7 @@ const VendorInbox = props => {
8825
9031
  Cell: ({
8826
9032
  row
8827
9033
  }) => {
8828
- return /*#__PURE__*/React.createElement(Dropdown$2, {
9034
+ return /*#__PURE__*/React.createElement(Dropdown$4, {
8829
9035
  className: "fsm-registry-dropdown",
8830
9036
  selected: getSelectedVendorOption(row.original, vendors),
8831
9037
  option: vendors,
@@ -8835,7 +9041,7 @@ const VendorInbox = props => {
8835
9041
  width: "100%",
8836
9042
  minWidth: "250px"
8837
9043
  },
8838
- optionKey: "name",
9044
+ optionKey: "displayName",
8839
9045
  t: t
8840
9046
  });
8841
9047
  }
@@ -8880,7 +9086,7 @@ const VendorInbox = props => {
8880
9086
  }) => {
8881
9087
  const selectedVendor = getSelectedVendorOption(row.original, vendors);
8882
9088
  const vendorFillingPoints = getVendorFillingPoints(selectedVendor);
8883
- return /*#__PURE__*/React.createElement(Dropdown$2, {
9089
+ return /*#__PURE__*/React.createElement(Dropdown$4, {
8884
9090
  className: "fsm-registry-dropdown",
8885
9091
  selected: getSelectedFillingPointOption(row.original, vendorFillingPoints),
8886
9092
  option: vendorFillingPoints,
@@ -8909,12 +9115,12 @@ const VendorInbox = props => {
8909
9115
  const selectedVendor = getSelectedVendorOption(row.original, vendors);
8910
9116
  const selectedFillingPoint = getSelectedFillingPointOption(row.original, getVendorFillingPoints(selectedVendor));
8911
9117
  const availableDrivers = getVendorDriversForFillingPoint(selectedVendor, selectedFillingPoint);
8912
- return /*#__PURE__*/React.createElement(Dropdown$2, {
9118
+ return /*#__PURE__*/React.createElement(Dropdown$4, {
8913
9119
  className: "fsm-registry-dropdown",
8914
9120
  selected: getSelectedDriverOption(row.original, availableDrivers),
8915
9121
  option: availableDrivers,
8916
9122
  select: value => onDriverSelect(row, value),
8917
- optionKey: "name",
9123
+ optionKey: "displayName",
8918
9124
  t: t,
8919
9125
  style: {
8920
9126
  textAlign: "left",
@@ -8931,13 +9137,13 @@ const VendorInbox = props => {
8931
9137
  Cell: ({
8932
9138
  row
8933
9139
  }) => {
8934
- var _row$original1;
9140
+ var _row$original10;
8935
9141
  return /*#__PURE__*/React.createElement(ToggleSwitch, {
8936
9142
  style: {
8937
9143
  display: "flex",
8938
9144
  justifyContent: "left"
8939
9145
  },
8940
- value: ((_row$original1 = row.original) === null || _row$original1 === void 0 ? void 0 : _row$original1.status) === "DISABLED" ? false : true,
9146
+ value: ((_row$original10 = row.original) === null || _row$original10 === void 0 ? void 0 : _row$original10.status) === "DISABLED" ? false : true,
8941
9147
  onChange: () => onVehicleUpdate(row),
8942
9148
  name: `switch-${row.id}`
8943
9149
  });
@@ -8971,7 +9177,16 @@ const VendorInbox = props => {
8971
9177
  className: "link"
8972
9178
  }, /*#__PURE__*/React.createElement(Link, {
8973
9179
  to: "/digit-ui/employee/vendor/registry/driver-details/" + row.original["id"]
8974
- }, /*#__PURE__*/React.createElement("div", null, row.original.name))));
9180
+ }, /*#__PURE__*/React.createElement("div", null, `${row.original.name || "N/A"}`))));
9181
+ }
9182
+ }, {
9183
+ Header: t("WT_MOBILE_NUMBER"),
9184
+ accessor: "mobileNumber",
9185
+ Cell: ({
9186
+ row
9187
+ }) => {
9188
+ var _row$original11, _row$original11$owner;
9189
+ return /*#__PURE__*/React.createElement("div", null, ((_row$original11 = row.original) === null || _row$original11 === void 0 ? void 0 : (_row$original11$owner = _row$original11.owner) === null || _row$original11$owner === void 0 ? void 0 : _row$original11$owner.mobileNumber) || "N/A");
8975
9190
  }
8976
9191
  }, {
8977
9192
  Header: t("ES_FSM_REGISTRY_INBOX_DATE_DRIVER_CREATION"),
@@ -8979,8 +9194,8 @@ const VendorInbox = props => {
8979
9194
  Cell: ({
8980
9195
  row
8981
9196
  }) => {
8982
- var _row$original10, _row$original10$audit, _row$original11, _row$original11$audit;
8983
- return GetCell((_row$original10 = row.original) !== null && _row$original10 !== void 0 && (_row$original10$audit = _row$original10.auditDetails) !== null && _row$original10$audit !== void 0 && _row$original10$audit.createdTime ? Digit.DateUtils.ConvertEpochToDate((_row$original11 = row.original) === null || _row$original11 === void 0 ? void 0 : (_row$original11$audit = _row$original11.auditDetails) === null || _row$original11$audit === void 0 ? void 0 : _row$original11$audit.createdTime) : "");
9197
+ var _row$original12, _row$original12$audit, _row$original13, _row$original13$audit;
9198
+ return GetCell((_row$original12 = row.original) !== null && _row$original12 !== void 0 && (_row$original12$audit = _row$original12.auditDetails) !== null && _row$original12$audit !== void 0 && _row$original12$audit.createdTime ? Digit.DateUtils.ConvertEpochToDate((_row$original13 = row.original) === null || _row$original13 === void 0 ? void 0 : (_row$original13$audit = _row$original13.auditDetails) === null || _row$original13$audit === void 0 ? void 0 : _row$original13$audit.createdTime) : "");
8984
9199
  }
8985
9200
  }, {
8986
9201
  Header: t("ES_FSM_REGISTRY_INBOX_VENDOR_NAME"),
@@ -8993,7 +9208,7 @@ const VendorInbox = props => {
8993
9208
  Cell: ({
8994
9209
  row
8995
9210
  }) => {
8996
- return /*#__PURE__*/React.createElement(Dropdown$2, {
9211
+ return /*#__PURE__*/React.createElement(Dropdown$4, {
8997
9212
  className: "fsm-registry-dropdown",
8998
9213
  selected: (vendors === null || vendors === void 0 ? void 0 : vendors.find(vendor => {
8999
9214
  var _row$original$vendorD, _row$original$vendor;
@@ -9006,7 +9221,7 @@ const VendorInbox = props => {
9006
9221
  width: "100%",
9007
9222
  minWidth: "250px"
9008
9223
  },
9009
- optionKey: "name",
9224
+ optionKey: "displayName",
9010
9225
  t: t
9011
9226
  });
9012
9227
  }
@@ -9017,18 +9232,120 @@ const VendorInbox = props => {
9017
9232
  Cell: ({
9018
9233
  row
9019
9234
  }) => {
9020
- var _row$original12;
9235
+ var _row$original14;
9021
9236
  return /*#__PURE__*/React.createElement(ToggleSwitch, {
9022
9237
  style: {
9023
9238
  display: "flex",
9024
9239
  justifyContent: "left"
9025
9240
  },
9026
- value: ((_row$original12 = row.original) === null || _row$original12 === void 0 ? void 0 : _row$original12.status) === "DISABLED" ? false : true,
9241
+ value: ((_row$original14 = row.original) === null || _row$original14 === void 0 ? void 0 : _row$original14.status) === "DISABLED" ? false : true,
9027
9242
  onChange: () => onDriverUpdate(row),
9028
9243
  name: `switch-${row.id}`
9029
9244
  });
9030
9245
  }
9031
9246
  }];
9247
+ case "SUPERVISOR":
9248
+ case "SURVEYOR":
9249
+ return [{
9250
+ Header: props.selectedTab === "SUPERVISOR" ? t("Supervisor's Mobile No.") : t("Surveyor's Mobile No."),
9251
+ id: "userName",
9252
+ accessor: row => {
9253
+ var _row$owner2;
9254
+ return ((_row$owner2 = row.owner) === null || _row$owner2 === void 0 ? void 0 : _row$owner2.userName) || "NA";
9255
+ },
9256
+ Cell: ({
9257
+ row
9258
+ }) => {
9259
+ var _row$original$owner2;
9260
+ const detailsPath = props.selectedTab === "SUPERVISOR" ? "supervisor-details" : "surveyor-details";
9261
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", {
9262
+ className: "link"
9263
+ }, /*#__PURE__*/React.createElement(Link, {
9264
+ to: `/digit-ui/employee/vendor/registry/${detailsPath}/` + row.original["id"]
9265
+ }, /*#__PURE__*/React.createElement("div", null, ((_row$original$owner2 = row.original.owner) === null || _row$original$owner2 === void 0 ? void 0 : _row$original$owner2.userName) || "NA"))));
9266
+ }
9267
+ }, {
9268
+ Header: props.selectedTab === "SUPERVISOR" ? t("ES_FSM_REGISTRY_INBOX_SUPERVISOR_NAME") : t("ES_FSM_REGISTRY_INBOX_SURVEYOR_NAME"),
9269
+ accessor: "name",
9270
+ Cell: ({
9271
+ row
9272
+ }) => {
9273
+ const detailsPath = props.selectedTab === "SUPERVISOR" ? "supervisor-details" : "surveyor-details";
9274
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", {
9275
+ className: "link"
9276
+ }, /*#__PURE__*/React.createElement(Link, {
9277
+ to: `/digit-ui/employee/vendor/registry/${detailsPath}/` + row.original["id"]
9278
+ }, /*#__PURE__*/React.createElement("div", null, `${row.original.name || "N/A"}`))));
9279
+ }
9280
+ }, {
9281
+ Header: t("WT_MOBILE_NUMBER"),
9282
+ accessor: "mobileNumber",
9283
+ Cell: ({
9284
+ row
9285
+ }) => {
9286
+ var _row$original15, _row$original15$owner;
9287
+ return /*#__PURE__*/React.createElement("div", null, ((_row$original15 = row.original) === null || _row$original15 === void 0 ? void 0 : (_row$original15$owner = _row$original15.owner) === null || _row$original15$owner === void 0 ? void 0 : _row$original15$owner.mobileNumber) || "N/A");
9288
+ }
9289
+ }, {
9290
+ Header: t("ES_FSM_REGISTRY_INBOX_DATE_CREATION"),
9291
+ accessor: "createdTime",
9292
+ Cell: ({
9293
+ row
9294
+ }) => {
9295
+ var _row$original16, _row$original16$audit, _row$original17, _row$original17$audit;
9296
+ return GetCell((_row$original16 = row.original) !== null && _row$original16 !== void 0 && (_row$original16$audit = _row$original16.auditDetails) !== null && _row$original16$audit !== void 0 && _row$original16$audit.createdTime ? Digit.DateUtils.ConvertEpochToDate((_row$original17 = row.original) === null || _row$original17 === void 0 ? void 0 : (_row$original17$audit = _row$original17.auditDetails) === null || _row$original17$audit === void 0 ? void 0 : _row$original17$audit.createdTime) : "");
9297
+ }
9298
+ }, {
9299
+ Header: t("ES_FSM_REGISTRY_INBOX_VENDOR_NAME"),
9300
+ id: "vendorName",
9301
+ accessor: row => {
9302
+ var _row$vendorData4, _row$vendor4;
9303
+ return ((_row$vendorData4 = row.vendorData) === null || _row$vendorData4 === void 0 ? void 0 : _row$vendorData4.name) || ((_row$vendor4 = row.vendor) === null || _row$vendor4 === void 0 ? void 0 : _row$vendor4.name) || "NA";
9304
+ },
9305
+ minWidth: 250,
9306
+ Cell: ({
9307
+ row
9308
+ }) => {
9309
+ return /*#__PURE__*/React.createElement(Dropdown$4, {
9310
+ className: "fsm-registry-dropdown",
9311
+ selected: (vendors === null || vendors === void 0 ? void 0 : vendors.find(vendor => {
9312
+ var _row$original$vendorD2, _row$original$vendor2;
9313
+ return (((_row$original$vendorD2 = row.original.vendorData) === null || _row$original$vendorD2 === void 0 ? void 0 : _row$original$vendorD2.id) || ((_row$original$vendor2 = row.original.vendor) === null || _row$original$vendor2 === void 0 ? void 0 : _row$original$vendor2.id)) === vendor.id;
9314
+ })) || row.original.vendorData || row.original.vendor,
9315
+ option: vendors,
9316
+ select: value => {
9317
+ console.log("Updating vendor for", props.selectedTab, value);
9318
+ },
9319
+ style: {
9320
+ textAlign: "left",
9321
+ width: "100%",
9322
+ minWidth: "250px"
9323
+ },
9324
+ optionKey: "displayName",
9325
+ t: t
9326
+ });
9327
+ }
9328
+ }, {
9329
+ Header: t("ES_FSM_REGISTRY_INBOX_ENABLED"),
9330
+ id: "status",
9331
+ accessor: row => row.status || "",
9332
+ Cell: ({
9333
+ row
9334
+ }) => {
9335
+ var _row$original18;
9336
+ return /*#__PURE__*/React.createElement(ToggleSwitch, {
9337
+ style: {
9338
+ display: "flex",
9339
+ justifyContent: "left"
9340
+ },
9341
+ value: ((_row$original18 = row.original) === null || _row$original18 === void 0 ? void 0 : _row$original18.status) === "DISABLED" ? false : true,
9342
+ onChange: () => {
9343
+ console.log("Updating status for", props.selectedTab, row.original.id);
9344
+ },
9345
+ name: `switch-${row.id}`
9346
+ });
9347
+ }
9348
+ }];
9032
9349
  default:
9033
9350
  return [];
9034
9351
  }
@@ -9039,8 +9356,8 @@ const VendorInbox = props => {
9039
9356
  return [{
9040
9357
  Header: t("ES_VENDOR_INBOX_VENDOR_NAME"),
9041
9358
  exportAccessor: row => {
9042
- var _row$dsoDetails0;
9043
- return (row === null || row === void 0 ? void 0 : row.name) || (row === null || row === void 0 ? void 0 : (_row$dsoDetails0 = row.dsoDetails) === null || _row$dsoDetails0 === void 0 ? void 0 : _row$dsoDetails0.name) || "NA";
9359
+ var _row$dsoDetails0, _row$owner3, _row$dsoDetails1, _row$dsoDetails10, _row$dsoDetails10$own;
9360
+ return `${(row === null || row === void 0 ? void 0 : row.name) || (row === null || row === void 0 ? void 0 : (_row$dsoDetails0 = row.dsoDetails) === null || _row$dsoDetails0 === void 0 ? void 0 : _row$dsoDetails0.name) || "NA"} (${(row === null || row === void 0 ? void 0 : row.mobileNumber) || (row === null || row === void 0 ? void 0 : (_row$owner3 = row.owner) === null || _row$owner3 === void 0 ? void 0 : _row$owner3.mobileNumber) || (row === null || row === void 0 ? void 0 : (_row$dsoDetails1 = row.dsoDetails) === null || _row$dsoDetails1 === void 0 ? void 0 : _row$dsoDetails1.mobileNumber) || (row === null || row === void 0 ? void 0 : (_row$dsoDetails10 = row.dsoDetails) === null || _row$dsoDetails10 === void 0 ? void 0 : (_row$dsoDetails10$own = _row$dsoDetails10.owner) === null || _row$dsoDetails10$own === void 0 ? void 0 : _row$dsoDetails10$own.mobileNumber) || "NA"})`;
9044
9361
  }
9045
9362
  }, {
9046
9363
  Header: t("ES_VENDOR_INBOX_DATE_VENDOR_CREATION"),
@@ -9054,14 +9371,14 @@ const VendorInbox = props => {
9054
9371
  }, {
9055
9372
  Header: t("ES_VENDOR_INBOX_SERVICE_TYPE"),
9056
9373
  exportAccessor: row => {
9057
- var _parseAdditionalDetai, _row$dsoDetails1;
9058
- return ((_parseAdditionalDetai = parseAdditionalDetails(row === null || row === void 0 ? void 0 : (_row$dsoDetails1 = row.dsoDetails) === null || _row$dsoDetails1 === void 0 ? void 0 : _row$dsoDetails1.additionalDetails)) === null || _parseAdditionalDetai === void 0 ? void 0 : _parseAdditionalDetai.serviceType) || "N/A";
9374
+ var _parseAdditionalDetai, _row$dsoDetails11;
9375
+ return ((_parseAdditionalDetai = parseAdditionalDetails(row === null || row === void 0 ? void 0 : (_row$dsoDetails11 = row.dsoDetails) === null || _row$dsoDetails11 === void 0 ? void 0 : _row$dsoDetails11.additionalDetails)) === null || _parseAdditionalDetai === void 0 ? void 0 : _parseAdditionalDetai.serviceType) || "N/A";
9059
9376
  }
9060
9377
  }, {
9061
9378
  Header: t("ES_VENDOR_REGISTRY_INBOX_ENABLED"),
9062
9379
  exportAccessor: row => {
9063
- var _row$dsoDetails10;
9064
- return (row === null || row === void 0 ? void 0 : (_row$dsoDetails10 = row.dsoDetails) === null || _row$dsoDetails10 === void 0 ? void 0 : _row$dsoDetails10.status) || "NA";
9380
+ var _row$dsoDetails12;
9381
+ return (row === null || row === void 0 ? void 0 : (_row$dsoDetails12 = row.dsoDetails) === null || _row$dsoDetails12 === void 0 ? void 0 : _row$dsoDetails12.status) || "NA";
9065
9382
  }
9066
9383
  }];
9067
9384
  case "VEHICLE":
@@ -9077,8 +9394,8 @@ const VendorInbox = props => {
9077
9394
  }, {
9078
9395
  Header: "Map Vendor",
9079
9396
  exportAccessor: row => {
9080
- var _row$vendor4, _row$vendorData4;
9081
- return (row === null || row === void 0 ? void 0 : (_row$vendor4 = row.vendor) === null || _row$vendor4 === void 0 ? void 0 : _row$vendor4.name) || (row === null || row === void 0 ? void 0 : (_row$vendorData4 = row.vendorData) === null || _row$vendorData4 === void 0 ? void 0 : _row$vendorData4.name) || "NA";
9397
+ var _row$vendor5, _row$vendorData5, _row$vendor6, _row$vendor7, _row$vendor7$owner, _row$vendorData6, _row$vendorData7, _row$vendorData7$owne;
9398
+ return `${(row === null || row === void 0 ? void 0 : (_row$vendor5 = row.vendor) === null || _row$vendor5 === void 0 ? void 0 : _row$vendor5.name) || (row === null || row === void 0 ? void 0 : (_row$vendorData5 = row.vendorData) === null || _row$vendorData5 === void 0 ? void 0 : _row$vendorData5.name) || "NA"} (${(row === null || row === void 0 ? void 0 : (_row$vendor6 = row.vendor) === null || _row$vendor6 === void 0 ? void 0 : _row$vendor6.mobileNumber) || (row === null || row === void 0 ? void 0 : (_row$vendor7 = row.vendor) === null || _row$vendor7 === void 0 ? void 0 : (_row$vendor7$owner = _row$vendor7.owner) === null || _row$vendor7$owner === void 0 ? void 0 : _row$vendor7$owner.mobileNumber) || (row === null || row === void 0 ? void 0 : (_row$vendorData6 = row.vendorData) === null || _row$vendorData6 === void 0 ? void 0 : _row$vendorData6.mobileNumber) || (row === null || row === void 0 ? void 0 : (_row$vendorData7 = row.vendorData) === null || _row$vendorData7 === void 0 ? void 0 : (_row$vendorData7$owne = _row$vendorData7.owner) === null || _row$vendorData7$owne === void 0 ? void 0 : _row$vendorData7$owne.mobileNumber) || "NA"})`;
9082
9399
  }
9083
9400
  }, {
9084
9401
  Header: t("ES_VENDOR_INBOX_SERVICE_TYPE"),
@@ -9092,8 +9409,8 @@ const VendorInbox = props => {
9092
9409
  }, {
9093
9410
  Header: t("ES_FSM_REGISTRY_SELECT_DRIVER"),
9094
9411
  exportAccessor: row => {
9095
- var _row$driverData3, _row$driver3;
9096
- return (row === null || row === void 0 ? void 0 : (_row$driverData3 = row.driverData) === null || _row$driverData3 === void 0 ? void 0 : _row$driverData3.name) || (row === null || row === void 0 ? void 0 : (_row$driver3 = row.driver) === null || _row$driver3 === void 0 ? void 0 : _row$driver3.name) || "NA";
9412
+ var _row$driverData3, _row$driver3, _row$driverData4, _row$driverData4$owne, _row$driver4, _row$driver4$owner;
9413
+ return `${(row === null || row === void 0 ? void 0 : (_row$driverData3 = row.driverData) === null || _row$driverData3 === void 0 ? void 0 : _row$driverData3.name) || (row === null || row === void 0 ? void 0 : (_row$driver3 = row.driver) === null || _row$driver3 === void 0 ? void 0 : _row$driver3.name) || "NA"} (${(row === null || row === void 0 ? void 0 : (_row$driverData4 = row.driverData) === null || _row$driverData4 === void 0 ? void 0 : (_row$driverData4$owne = _row$driverData4.owner) === null || _row$driverData4$owne === void 0 ? void 0 : _row$driverData4$owne.mobileNumber) || (row === null || row === void 0 ? void 0 : (_row$driver4 = row.driver) === null || _row$driver4 === void 0 ? void 0 : (_row$driver4$owner = _row$driver4.owner) === null || _row$driver4$owner === void 0 ? void 0 : _row$driver4$owner.mobileNumber) || "NA"})`;
9097
9414
  }
9098
9415
  }, {
9099
9416
  Header: t("ES_FSM_REGISTRY_INBOX_ENABLED"),
@@ -9103,12 +9420,15 @@ const VendorInbox = props => {
9103
9420
  return [{
9104
9421
  Header: t("ES_FSM_REGISTRY_INBOX_USERNAME"),
9105
9422
  exportAccessor: row => {
9106
- var _row$owner2;
9107
- return (row === null || row === void 0 ? void 0 : (_row$owner2 = row.owner) === null || _row$owner2 === void 0 ? void 0 : _row$owner2.userName) || "NA";
9423
+ var _row$owner4;
9424
+ return (row === null || row === void 0 ? void 0 : (_row$owner4 = row.owner) === null || _row$owner4 === void 0 ? void 0 : _row$owner4.userName) || "NA";
9108
9425
  }
9109
9426
  }, {
9110
9427
  Header: t("ES_FSM_REGISTRY_INBOX_DRIVER_NAME"),
9111
- exportAccessor: row => (row === null || row === void 0 ? void 0 : row.name) || "NA"
9428
+ exportAccessor: row => {
9429
+ var _row$owner5;
9430
+ return `${(row === null || row === void 0 ? void 0 : row.name) || "NA"} (${(row === null || row === void 0 ? void 0 : (_row$owner5 = row.owner) === null || _row$owner5 === void 0 ? void 0 : _row$owner5.mobileNumber) || "NA"})`;
9431
+ }
9112
9432
  }, {
9113
9433
  Header: t("ES_FSM_REGISTRY_INBOX_DATE_DRIVER_CREATION"),
9114
9434
  exportAccessor: row => {
@@ -9118,8 +9438,66 @@ const VendorInbox = props => {
9118
9438
  }, {
9119
9439
  Header: t("ES_FSM_REGISTRY_INBOX_VENDOR_NAME"),
9120
9440
  exportAccessor: row => {
9121
- var _row$vendorData5, _row$vendor5;
9122
- return (row === null || row === void 0 ? void 0 : (_row$vendorData5 = row.vendorData) === null || _row$vendorData5 === void 0 ? void 0 : _row$vendorData5.name) || (row === null || row === void 0 ? void 0 : (_row$vendor5 = row.vendor) === null || _row$vendor5 === void 0 ? void 0 : _row$vendor5.name) || "NA";
9441
+ var _row$vendorData8, _row$vendor8, _row$vendorData9, _row$vendorData0, _row$vendorData0$owne, _row$vendor9, _row$vendor0, _row$vendor0$owner;
9442
+ return `${(row === null || row === void 0 ? void 0 : (_row$vendorData8 = row.vendorData) === null || _row$vendorData8 === void 0 ? void 0 : _row$vendorData8.name) || (row === null || row === void 0 ? void 0 : (_row$vendor8 = row.vendor) === null || _row$vendor8 === void 0 ? void 0 : _row$vendor8.name) || "NA"} (${(row === null || row === void 0 ? void 0 : (_row$vendorData9 = row.vendorData) === null || _row$vendorData9 === void 0 ? void 0 : _row$vendorData9.mobileNumber) || (row === null || row === void 0 ? void 0 : (_row$vendorData0 = row.vendorData) === null || _row$vendorData0 === void 0 ? void 0 : (_row$vendorData0$owne = _row$vendorData0.owner) === null || _row$vendorData0$owne === void 0 ? void 0 : _row$vendorData0$owne.mobileNumber) || (row === null || row === void 0 ? void 0 : (_row$vendor9 = row.vendor) === null || _row$vendor9 === void 0 ? void 0 : _row$vendor9.mobileNumber) || (row === null || row === void 0 ? void 0 : (_row$vendor0 = row.vendor) === null || _row$vendor0 === void 0 ? void 0 : (_row$vendor0$owner = _row$vendor0.owner) === null || _row$vendor0$owner === void 0 ? void 0 : _row$vendor0$owner.mobileNumber) || "NA"})`;
9443
+ }
9444
+ }, {
9445
+ Header: t("ES_FSM_REGISTRY_INBOX_ENABLED"),
9446
+ exportAccessor: row => (row === null || row === void 0 ? void 0 : row.status) || "NA"
9447
+ }];
9448
+ case "SURVEYOR":
9449
+ return [{
9450
+ Header: t("ES_FSM_REGISTRY_INBOX_USERNAME"),
9451
+ exportAccessor: row => {
9452
+ var _row$owner6;
9453
+ return (row === null || row === void 0 ? void 0 : (_row$owner6 = row.owner) === null || _row$owner6 === void 0 ? void 0 : _row$owner6.userName) || "NA";
9454
+ }
9455
+ }, {
9456
+ Header: t("ES_FSM_REGISTRY_INBOX_DRIVER_NAME"),
9457
+ exportAccessor: row => {
9458
+ var _row$owner7;
9459
+ return `${(row === null || row === void 0 ? void 0 : row.name) || "NA"} (${(row === null || row === void 0 ? void 0 : (_row$owner7 = row.owner) === null || _row$owner7 === void 0 ? void 0 : _row$owner7.mobileNumber) || "NA"})`;
9460
+ }
9461
+ }, {
9462
+ Header: t("ES_FSM_REGISTRY_INBOX_DATE_DRIVER_CREATION"),
9463
+ exportAccessor: row => {
9464
+ var _row$auditDetails7, _row$auditDetails8;
9465
+ return row !== null && row !== void 0 && (_row$auditDetails7 = row.auditDetails) !== null && _row$auditDetails7 !== void 0 && _row$auditDetails7.createdTime ? Digit.DateUtils.ConvertEpochToDate(row === null || row === void 0 ? void 0 : (_row$auditDetails8 = row.auditDetails) === null || _row$auditDetails8 === void 0 ? void 0 : _row$auditDetails8.createdTime) : "";
9466
+ }
9467
+ }, {
9468
+ Header: t("ES_FSM_REGISTRY_INBOX_VENDOR_NAME"),
9469
+ exportAccessor: row => {
9470
+ var _row$vendorData1, _row$vendor1, _row$vendorData10, _row$vendorData11, _row$vendorData11$own, _row$vendor10, _row$vendor11, _row$vendor11$owner;
9471
+ return `${(row === null || row === void 0 ? void 0 : (_row$vendorData1 = row.vendorData) === null || _row$vendorData1 === void 0 ? void 0 : _row$vendorData1.name) || (row === null || row === void 0 ? void 0 : (_row$vendor1 = row.vendor) === null || _row$vendor1 === void 0 ? void 0 : _row$vendor1.name) || "NA"} ${(row === null || row === void 0 ? void 0 : (_row$vendorData10 = row.vendorData) === null || _row$vendorData10 === void 0 ? void 0 : _row$vendorData10.mobileNumber) || (row === null || row === void 0 ? void 0 : (_row$vendorData11 = row.vendorData) === null || _row$vendorData11 === void 0 ? void 0 : (_row$vendorData11$own = _row$vendorData11.owner) === null || _row$vendorData11$own === void 0 ? void 0 : _row$vendorData11$own.mobileNumber) || (row === null || row === void 0 ? void 0 : (_row$vendor10 = row.vendor) === null || _row$vendor10 === void 0 ? void 0 : _row$vendor10.mobileNumber) || (row === null || row === void 0 ? void 0 : (_row$vendor11 = row.vendor) === null || _row$vendor11 === void 0 ? void 0 : (_row$vendor11$owner = _row$vendor11.owner) === null || _row$vendor11$owner === void 0 ? void 0 : _row$vendor11$owner.mobileNumber) || "NA"}`;
9472
+ }
9473
+ }, {
9474
+ Header: t("ES_FSM_REGISTRY_INBOX_ENABLED"),
9475
+ exportAccessor: row => (row === null || row === void 0 ? void 0 : row.status) || "NA"
9476
+ }];
9477
+ case "SUPERVISOR":
9478
+ return [{
9479
+ Header: t("ES_FSM_REGISTRY_INBOX_USERNAME"),
9480
+ exportAccessor: row => {
9481
+ var _row$owner8;
9482
+ return (row === null || row === void 0 ? void 0 : (_row$owner8 = row.owner) === null || _row$owner8 === void 0 ? void 0 : _row$owner8.userName) || "NA";
9483
+ }
9484
+ }, {
9485
+ Header: t("ES_FSM_REGISTRY_INBOX_DRIVER_NAME"),
9486
+ exportAccessor: row => {
9487
+ var _row$owner9;
9488
+ return `${(row === null || row === void 0 ? void 0 : row.name) || "NA"} (${(row === null || row === void 0 ? void 0 : (_row$owner9 = row.owner) === null || _row$owner9 === void 0 ? void 0 : _row$owner9.mobileNumber) || "NA"})`;
9489
+ }
9490
+ }, {
9491
+ Header: t("ES_FSM_REGISTRY_INBOX_DATE_DRIVER_CREATION"),
9492
+ exportAccessor: row => {
9493
+ var _row$auditDetails9, _row$auditDetails0;
9494
+ return row !== null && row !== void 0 && (_row$auditDetails9 = row.auditDetails) !== null && _row$auditDetails9 !== void 0 && _row$auditDetails9.createdTime ? Digit.DateUtils.ConvertEpochToDate(row === null || row === void 0 ? void 0 : (_row$auditDetails0 = row.auditDetails) === null || _row$auditDetails0 === void 0 ? void 0 : _row$auditDetails0.createdTime) : "";
9495
+ }
9496
+ }, {
9497
+ Header: t("ES_FSM_REGISTRY_INBOX_VENDOR_NAME"),
9498
+ exportAccessor: row => {
9499
+ var _row$vendorData12, _row$vendor12, _row$vendorData13, _row$vendorData14, _row$vendorData14$own, _row$vendor13, _row$vendor14, _row$vendor14$owner;
9500
+ return `${(row === null || row === void 0 ? void 0 : (_row$vendorData12 = row.vendorData) === null || _row$vendorData12 === void 0 ? void 0 : _row$vendorData12.name) || (row === null || row === void 0 ? void 0 : (_row$vendor12 = row.vendor) === null || _row$vendor12 === void 0 ? void 0 : _row$vendor12.name) || "NA"} ${(row === null || row === void 0 ? void 0 : (_row$vendorData13 = row.vendorData) === null || _row$vendorData13 === void 0 ? void 0 : _row$vendorData13.mobileNumber) || (row === null || row === void 0 ? void 0 : (_row$vendorData14 = row.vendorData) === null || _row$vendorData14 === void 0 ? void 0 : (_row$vendorData14$own = _row$vendorData14.owner) === null || _row$vendorData14$own === void 0 ? void 0 : _row$vendorData14$own.mobileNumber) || (row === null || row === void 0 ? void 0 : (_row$vendor13 = row.vendor) === null || _row$vendor13 === void 0 ? void 0 : _row$vendor13.mobileNumber) || (row === null || row === void 0 ? void 0 : (_row$vendor14 = row.vendor) === null || _row$vendor14 === void 0 ? void 0 : (_row$vendor14$owner = _row$vendor14.owner) === null || _row$vendor14$owner === void 0 ? void 0 : _row$vendor14$owner.mobileNumber) || "NA"}`;
9123
9501
  }
9124
9502
  }, {
9125
9503
  Header: t("ES_FSM_REGISTRY_INBOX_ENABLED"),
@@ -9156,6 +9534,12 @@ const VendorInbox = props => {
9156
9534
  } else if (props.selectedTab === "VEHICLE") {
9157
9535
  emptyCardText = "ES_FSM_REGISTRY_EMPTY_CARD_VEHICLE";
9158
9536
  emptyButtonText = "ES_FSM_REGISTRY_EMPTY_BUTTON_VEHICLE";
9537
+ } else if (props.selectedTab === "SUPERVISOR") {
9538
+ emptyCardText = "ES_FSM_REGISTRY_EMPTY_CARD_SUPERVISOR";
9539
+ emptyButtonText = "ES_FSM_REGISTRY_EMPTY_BUTTON_SUPERVISOR";
9540
+ } else if (props.selectedTab === "SURVEYOR") {
9541
+ emptyCardText = "ES_FSM_REGISTRY_EMPTY_CARD_SURVEYOR";
9542
+ emptyButtonText = "ES_FSM_REGISTRY_EMPTY_BUTTON_SURVEYOR";
9159
9543
  } else {
9160
9544
  emptyCardText = "ES_FSM_REGISTRY_EMPTY_CARD_DRIVER";
9161
9545
  emptyButtonText = "ES_FSM_REGISTRY_EMPTY_BUTTON_DRIVER";
@@ -9251,11 +9635,62 @@ const VendorInbox = props => {
9251
9635
  error: showToast.key === "error" ? true : false,
9252
9636
  label: showToast.label ? t(showToast.label) : t(showToast.key === "success" ? `ES_FSM_REGISTRY_${showToast.action}_DISABLE_SUCCESS` : showToast.action),
9253
9637
  onClose: closeToast
9254
- }));
9638
+ }), showWorkOrderModal && /*#__PURE__*/React.createElement(Modal, {
9639
+ headerBarMain: /*#__PURE__*/React.createElement("h1", {
9640
+ className: "heading-m",
9641
+ style: {
9642
+ margin: 0
9643
+ }
9644
+ }, t("ES_VENDOR_WORKORDER_DETAILS_MODAL")),
9645
+ headerBarEnd: /*#__PURE__*/React.createElement("div", {
9646
+ className: "icon-bg-secondary",
9647
+ onClick: closeWorkOrderModal,
9648
+ style: {
9649
+ cursor: "pointer"
9650
+ }
9651
+ }, /*#__PURE__*/React.createElement("svg", {
9652
+ xmlns: "http://www.w3.org/2000/svg",
9653
+ viewBox: "0 0 24 24",
9654
+ fill: "#FFFFFF",
9655
+ width: "24",
9656
+ height: "24"
9657
+ }, /*#__PURE__*/React.createElement("path", {
9658
+ d: "M0 0h24v24H0V0z",
9659
+ fill: "none"
9660
+ }), /*#__PURE__*/React.createElement("path", {
9661
+ d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"
9662
+ }))),
9663
+ actionCancelLabel: t("CS_COMMON_CLOSE"),
9664
+ actionCancelOnSubmit: closeWorkOrderModal,
9665
+ hideSubmit: true,
9666
+ formId: "modal-action"
9667
+ }, /*#__PURE__*/React.createElement("div", {
9668
+ style: {
9669
+ padding: "16px"
9670
+ }
9671
+ }, (selectedVendorForWorkOrder === null || selectedVendorForWorkOrder === void 0 ? void 0 : (_selectedVendorForWor = selectedVendorForWorkOrder.dsoDetails) === null || _selectedVendorForWor === void 0 ? void 0 : (_selectedVendorForWor2 = _selectedVendorForWor.vendorWorkOrder) === null || _selectedVendorForWor2 === void 0 ? void 0 : _selectedVendorForWor2.length) > 0 ? /*#__PURE__*/React.createElement(Table, {
9672
+ t: t,
9673
+ data: selectedVendorForWorkOrder.dsoDetails.vendorWorkOrder,
9674
+ columns: workOrderColumns,
9675
+ getCellProps: cellInfo => {
9676
+ return {
9677
+ style: {
9678
+ minWidth: "150px",
9679
+ padding: "8px 12px",
9680
+ fontSize: "13.5px"
9681
+ }
9682
+ };
9683
+ }
9684
+ }) : /*#__PURE__*/React.createElement("p", {
9685
+ style: {
9686
+ textAlign: "center",
9687
+ marginTop: "20px"
9688
+ }
9689
+ }, t("ES_VENDOR_NO_WORKORDERS")))));
9255
9690
  };
9256
9691
 
9257
9692
  const SearchVendor = () => {
9258
- var _sortParams$, _sortParams$2;
9693
+ var _sortParams$, _sortParams$2, _searchParams$vendor, _searchParams$filling, _searchParams$vendor2, _allFillingPoints$fil;
9259
9694
  const {
9260
9695
  t
9261
9696
  } = useTranslation();
@@ -9274,6 +9709,23 @@ const SearchVendor = () => {
9274
9709
  const [vehicleIds, setVehicleIds] = useState("");
9275
9710
  const [driverIds, setDriverIds] = useState("");
9276
9711
  const [tableData, setTableData] = useState([]);
9712
+ const {
9713
+ data: allVendors
9714
+ } = Digit.Hooks.fsm.useDsoSearch(tenantId, {
9715
+ status: "ACTIVE"
9716
+ }, {
9717
+ staleTime: Infinity
9718
+ });
9719
+ const {
9720
+ data: allFillingPoints
9721
+ } = Digit.Hooks.wt.useFillPointSearch({
9722
+ tenantId,
9723
+ filters: {
9724
+ limit: 1000
9725
+ }
9726
+ }, {
9727
+ staleTime: Infinity
9728
+ });
9277
9729
  let paginationParms = {
9278
9730
  limit: pageSize,
9279
9731
  offset: pageOffset,
@@ -9291,7 +9743,9 @@ const SearchVendor = () => {
9291
9743
  filters: {
9292
9744
  ...paginationParms,
9293
9745
  registrationNumber: searchParams === null || searchParams === void 0 ? void 0 : searchParams.registrationNumber,
9294
- status: "ACTIVE,DISABLED"
9746
+ status: "ACTIVE,DISABLED",
9747
+ vendorId: searchParams === null || searchParams === void 0 ? void 0 : (_searchParams$vendor = searchParams.vendor) === null || _searchParams$vendor === void 0 ? void 0 : _searchParams$vendor.id,
9748
+ fillingPointId: searchParams === null || searchParams === void 0 ? void 0 : (_searchParams$filling = searchParams.fillingPoint) === null || _searchParams$filling === void 0 ? void 0 : _searchParams$filling.id
9295
9749
  },
9296
9750
  config: {
9297
9751
  enabled: false
@@ -9301,16 +9755,27 @@ const SearchVendor = () => {
9301
9755
  filters: {
9302
9756
  ...paginationParms,
9303
9757
  name: searchParams === null || searchParams === void 0 ? void 0 : searchParams.name,
9304
- status: "ACTIVE,DISABLED"
9758
+ status: "ACTIVE,DISABLED",
9759
+ vendorId: searchParams === null || searchParams === void 0 ? void 0 : (_searchParams$vendor2 = searchParams.vendor) === null || _searchParams$vendor2 === void 0 ? void 0 : _searchParams$vendor2.id
9305
9760
  },
9306
9761
  config: {
9307
9762
  enabled: false
9308
9763
  }
9309
- }) : Digit.Hooks.fsm.useVendorSearch({
9310
- tenantId,
9311
- filters: {
9312
- ...paginationParms,
9313
- name: searchParams === null || searchParams === void 0 ? void 0 : searchParams.name,
9764
+ }) : tab === "SUPERVISOR" ? Digit.Hooks.fsm.useSupervisorDetails(tenantId, {
9765
+ ...paginationParms,
9766
+ status: "ACTIVE,DISABLED"
9767
+ }, {
9768
+ enabled: false
9769
+ }) : tab === "SURVEYOR" ? Digit.Hooks.fsm.useSurveyorDetails(tenantId, {
9770
+ ...paginationParms,
9771
+ status: "ACTIVE,DISABLED"
9772
+ }, {
9773
+ enabled: false
9774
+ }) : Digit.Hooks.fsm.useVendorSearch({
9775
+ tenantId,
9776
+ filters: {
9777
+ ...paginationParms,
9778
+ name: searchParams === null || searchParams === void 0 ? void 0 : searchParams.name,
9314
9779
  status: "ACTIVE,DISABLED"
9315
9780
  },
9316
9781
  config: {
@@ -9351,14 +9816,12 @@ const SearchVendor = () => {
9351
9816
  }, [searchParams, sortParams, pageOffset, pageSize]);
9352
9817
  useEffect(() => {
9353
9818
  if (dsoData !== null && dsoData !== void 0 && dsoData.vehicle && tab === "VEHICLE") {
9354
- let vehicleIds = "";
9355
- dsoData.vehicle.map(data => vehicleIds += `${data.id},`);
9819
+ const vehicleIds = dsoData.vehicle.map(data => data.id).filter(Boolean).join(",");
9356
9820
  setVehicleIds(vehicleIds);
9357
9821
  setTableData(dsoData.vehicle);
9358
9822
  }
9359
9823
  if (dsoData !== null && dsoData !== void 0 && dsoData.driver && tab === "DRIVER") {
9360
- let driverIds = "";
9361
- dsoData.driver.map(data => driverIds += `${data.id},`);
9824
+ const driverIds = dsoData.driver.map(data => data.id).filter(Boolean).join(",");
9362
9825
  setDriverIds(driverIds);
9363
9826
  setTableData(dsoData === null || dsoData === void 0 ? void 0 : dsoData.driver);
9364
9827
  }
@@ -9389,7 +9852,75 @@ const SearchVendor = () => {
9389
9852
  });
9390
9853
  setTableData(tableData);
9391
9854
  }
9392
- }, [dsoData]);
9855
+ if (tab === "SUPERVISOR") {
9856
+ const staticSupervisors = [{
9857
+ id: "SUP1",
9858
+ name: "Amit Kumar",
9859
+ employeeId: "EMP001",
9860
+ status: "ACTIVE",
9861
+ owner: {
9862
+ mobileNumber: "9876543210",
9863
+ userName: "9876543210"
9864
+ },
9865
+ auditDetails: {
9866
+ createdTime: new Date().getTime()
9867
+ },
9868
+ vendorData: {
9869
+ name: "Clean City Agency"
9870
+ }
9871
+ }, {
9872
+ id: "SUP2",
9873
+ name: "Rajesh Singh",
9874
+ employeeId: "EMP002",
9875
+ status: "ACTIVE",
9876
+ owner: {
9877
+ mobileNumber: "9876543211",
9878
+ userName: "9876543211"
9879
+ },
9880
+ auditDetails: {
9881
+ createdTime: new Date().getTime()
9882
+ },
9883
+ vendorData: {
9884
+ name: "Green Environment"
9885
+ }
9886
+ }];
9887
+ setTableData((dsoData === null || dsoData === void 0 ? void 0 : dsoData.supervisor) || staticSupervisors);
9888
+ }
9889
+ if (tab === "SURVEYOR") {
9890
+ const staticSurveyors = [{
9891
+ id: "SUR1",
9892
+ name: "Suresh Raina",
9893
+ employeeId: "EMP101",
9894
+ status: "ACTIVE",
9895
+ owner: {
9896
+ mobileNumber: "9123456780",
9897
+ userName: "9123456780"
9898
+ },
9899
+ auditDetails: {
9900
+ createdTime: new Date().getTime()
9901
+ },
9902
+ vendorData: {
9903
+ name: "Clean City Agency"
9904
+ }
9905
+ }, {
9906
+ id: "SUR2",
9907
+ name: "Mahesh Babu",
9908
+ employeeId: "EMP102",
9909
+ status: "ACTIVE",
9910
+ owner: {
9911
+ mobileNumber: "9123456781",
9912
+ userName: "9123456781"
9913
+ },
9914
+ auditDetails: {
9915
+ createdTime: new Date().getTime()
9916
+ },
9917
+ vendorData: {
9918
+ name: "Green Environment"
9919
+ }
9920
+ }];
9921
+ setTableData((dsoData === null || dsoData === void 0 ? void 0 : dsoData.surveyor) || staticSurveyors);
9922
+ }
9923
+ }, [dsoData, tab]);
9393
9924
  useEffect(() => {
9394
9925
  if (vehicleIds !== "" || driverIds !== "") refetchVendor();
9395
9926
  }, [vehicleIds, driverIds]);
@@ -9403,11 +9934,15 @@ const SearchVendor = () => {
9403
9934
  });
9404
9935
  if (vendor) {
9405
9936
  var _vendor$dsoDetails, _vendor$dsoDetails$ve;
9406
- data.vendor = vendor.dsoDetails;
9937
+ let updatedData = {
9938
+ ...data,
9939
+ vendor: vendor.dsoDetails
9940
+ };
9407
9941
  const vehicleInVendor = (_vendor$dsoDetails = vendor.dsoDetails) === null || _vendor$dsoDetails === void 0 ? void 0 : (_vendor$dsoDetails$ve = _vendor$dsoDetails.vehicles) === null || _vendor$dsoDetails$ve === void 0 ? void 0 : _vendor$dsoDetails$ve.find(vehicle => vehicle.id === data.id);
9408
9942
  if (vehicleInVendor) {
9409
- data.driverData = vehicleInVendor.driverData || vehicleInVendor.driver || data.driverData;
9943
+ updatedData.driverData = vehicleInVendor.driverData || vehicleInVendor.driver || updatedData.driverData;
9410
9944
  }
9945
+ return updatedData;
9411
9946
  }
9412
9947
  return data;
9413
9948
  });
@@ -9421,7 +9956,10 @@ const SearchVendor = () => {
9421
9956
  return (_ele$dsoDetails2 = ele.dsoDetails) === null || _ele$dsoDetails2 === void 0 ? void 0 : (_ele$dsoDetails2$driv = _ele$dsoDetails2.drivers) === null || _ele$dsoDetails2$driv === void 0 ? void 0 : _ele$dsoDetails2$driv.find(driver => driver.id === data.id);
9422
9957
  });
9423
9958
  if (vendor) {
9424
- data.vendor = vendor.dsoDetails;
9959
+ return {
9960
+ ...data,
9961
+ vendor: vendor.dsoDetails
9962
+ };
9425
9963
  }
9426
9964
  return data;
9427
9965
  });
@@ -9446,13 +9984,61 @@ const SearchVendor = () => {
9446
9984
  };
9447
9985
  const handleFilterChange = () => {};
9448
9986
  const searchFields = tab === "VEHICLE" ? [{
9987
+ label: t("ES_VENDOR_SEARCH_VENDOR_NAME"),
9988
+ name: "vendor",
9989
+ type: "dropdown",
9990
+ options: allVendors === null || allVendors === void 0 ? void 0 : allVendors.map(data => {
9991
+ var _data$dsoDetails$owne;
9992
+ return {
9993
+ ...data.dsoDetails,
9994
+ displayName: `${data.dsoDetails.name} (${data.dsoDetails.mobileNumber || ((_data$dsoDetails$owne = data.dsoDetails.owner) === null || _data$dsoDetails$owne === void 0 ? void 0 : _data$dsoDetails$owne.mobileNumber) || "N/A"})`
9995
+ };
9996
+ }),
9997
+ optionsKey: "displayName"
9998
+ }, {
9999
+ label: t("ES_FSM_REGISTRY_SEARCH_FILLING_POINT"),
10000
+ name: "fillingPoint",
10001
+ type: "dropdown",
10002
+ options: allFillingPoints === null || allFillingPoints === void 0 ? void 0 : (_allFillingPoints$fil = allFillingPoints.fillingPoints) === null || _allFillingPoints$fil === void 0 ? void 0 : _allFillingPoints$fil.map(fp => ({
10003
+ ...fp,
10004
+ name: (fp === null || fp === void 0 ? void 0 : fp.name) || (fp === null || fp === void 0 ? void 0 : fp.fillingPointName) || (fp === null || fp === void 0 ? void 0 : fp.fillingStationId)
10005
+ })),
10006
+ optionsKey: "name"
10007
+ }, {
9449
10008
  label: t("ES_VEHICLE_SEARCH_VEHICLE_NUMBER"),
9450
10009
  name: "registrationNumber",
9451
10010
  pattern: "[A-Z]{2}[- ]?[0-9]{2}[- ]?[A-Z]{1,2}[- ]?[0-9]{4}",
9452
10011
  title: t("ES_FSM_VEHICLE_FORMAT_TIP")
9453
10012
  }] : tab === "DRIVER" ? [{
10013
+ label: t("ES_VENDOR_SEARCH_VENDOR_NAME"),
10014
+ name: "vendor",
10015
+ type: "dropdown",
10016
+ options: allVendors === null || allVendors === void 0 ? void 0 : allVendors.map(data => {
10017
+ var _data$dsoDetails$owne2;
10018
+ return {
10019
+ ...data.dsoDetails,
10020
+ displayName: `${data.dsoDetails.name} (${data.dsoDetails.mobileNumber || ((_data$dsoDetails$owne2 = data.dsoDetails.owner) === null || _data$dsoDetails$owne2 === void 0 ? void 0 : _data$dsoDetails$owne2.mobileNumber) || "N/A"})`
10021
+ };
10022
+ }),
10023
+ optionsKey: "displayName"
10024
+ }, {
9454
10025
  label: t("ES_DRIVER_SEARCH_DRIVER_NAME"),
9455
10026
  name: "name"
10027
+ }] : tab === "SUPERVISOR" || tab === "SURVEYOR" ? [{
10028
+ label: t("ES_VENDOR_SEARCH_VENDOR_NAME"),
10029
+ name: "vendor",
10030
+ type: "dropdown",
10031
+ options: allVendors === null || allVendors === void 0 ? void 0 : allVendors.map(data => {
10032
+ var _data$dsoDetails$owne3;
10033
+ return {
10034
+ ...data.dsoDetails,
10035
+ displayName: `${data.dsoDetails.name} (${data.dsoDetails.mobileNumber || ((_data$dsoDetails$owne3 = data.dsoDetails.owner) === null || _data$dsoDetails$owne3 === void 0 ? void 0 : _data$dsoDetails$owne3.mobileNumber) || "N/A"})`
10036
+ };
10037
+ }),
10038
+ optionsKey: "displayName"
10039
+ }, {
10040
+ label: tab === "SUPERVISOR" ? t("ES_SUPERVISOR_SEARCH_NAME") : t("ES_SURVEYOR_SEARCH_NAME"),
10041
+ name: "name"
9456
10042
  }] : [{
9457
10043
  label: t("ES_VENDOR_SEARCH_VENDOR_NAME"),
9458
10044
  name: "name"
@@ -9548,7 +10134,7 @@ const SelectServiceType = ({
9548
10134
  return /*#__PURE__*/React.createElement(Loader, null);
9549
10135
  }
9550
10136
  if (userType === "employee") {
9551
- return /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, null, t(config.label)), /*#__PURE__*/React.createElement(Dropdown$2, {
10137
+ return /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, null, t(config.label)), /*#__PURE__*/React.createElement(Dropdown$4, {
9552
10138
  className: "payment-form-text-input-correction",
9553
10139
  isMandatory: config.isMandatory,
9554
10140
  selected: serviceTypes,
@@ -10144,7 +10730,7 @@ const EditVendorDetails = props => {
10144
10730
  });
10145
10731
  }
10146
10732
  if (selectedAction === "ADD_VEHICLE") {
10147
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CardText, null, t(`ES_FSM_REGISTRY_SELECT_VEHICLE`)), /*#__PURE__*/React.createElement(Dropdown$2, {
10733
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CardText, null, t(`ES_FSM_REGISTRY_SELECT_VEHICLE`)), /*#__PURE__*/React.createElement(Dropdown$4, {
10148
10734
  t: t,
10149
10735
  option: vehicles,
10150
10736
  value: selectedOption,
@@ -10154,7 +10740,7 @@ const EditVendorDetails = props => {
10154
10740
  }));
10155
10741
  }
10156
10742
  if (selectedAction === "ADD_DRIVER") {
10157
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CardText, null, t(`ES_FSM_REGISTRY_SELECT_DRIVER`)), /*#__PURE__*/React.createElement(Dropdown$2, {
10743
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CardText, null, t(`ES_FSM_REGISTRY_SELECT_DRIVER`)), /*#__PURE__*/React.createElement(Dropdown$4, {
10158
10744
  t: t,
10159
10745
  option: drivers,
10160
10746
  value: selectedOption,
@@ -11439,7 +12025,7 @@ const DriverDetails = props => {
11439
12025
  });
11440
12026
  }
11441
12027
  if (selectedAction === "ADD_VENDOR") {
11442
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CardText, null, t(`ES_FSM_REGISTRY_SELECT_VENODOR`)), /*#__PURE__*/React.createElement(Dropdown$2, {
12028
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CardText, null, t(`ES_FSM_REGISTRY_SELECT_VENODOR`)), /*#__PURE__*/React.createElement(Dropdown$4, {
11443
12029
  t: t,
11444
12030
  option: vendors,
11445
12031
  value: selectedOption,
@@ -11449,7 +12035,7 @@ const DriverDetails = props => {
11449
12035
  }));
11450
12036
  }
11451
12037
  if (selectedAction === "EDIT_VENDOR") {
11452
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CardText, null, t(`ES_FSM_REGISTRY_SELECT_VENODOR`)), /*#__PURE__*/React.createElement(Dropdown$2, {
12038
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CardText, null, t(`ES_FSM_REGISTRY_SELECT_VENODOR`)), /*#__PURE__*/React.createElement(Dropdown$4, {
11453
12039
  t: t,
11454
12040
  option: vendors,
11455
12041
  value: selectedOption,
@@ -11844,7 +12430,7 @@ const VehicleDetails = props => {
11844
12430
  });
11845
12431
  }
11846
12432
  if (selectedAction === "ADD_VENDOR") {
11847
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CardText, null, t(`ES_FSM_REGISTRY_SELECT_VENODOR`)), /*#__PURE__*/React.createElement(Dropdown$2, {
12433
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CardText, null, t(`ES_FSM_REGISTRY_SELECT_VENODOR`)), /*#__PURE__*/React.createElement(Dropdown$4, {
11848
12434
  t: t,
11849
12435
  option: vendors,
11850
12436
  value: selectedOption,
@@ -11854,7 +12440,7 @@ const VehicleDetails = props => {
11854
12440
  }));
11855
12441
  }
11856
12442
  if (selectedAction === "EDIT_VENDOR") {
11857
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CardText, null, t(`ES_FSM_REGISTRY_SELECT_VENODOR`)), /*#__PURE__*/React.createElement(Dropdown$2, {
12443
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CardText, null, t(`ES_FSM_REGISTRY_SELECT_VENODOR`)), /*#__PURE__*/React.createElement(Dropdown$4, {
11858
12444
  t: t,
11859
12445
  option: vendors,
11860
12446
  value: selectedOption,
@@ -11910,7 +12496,6 @@ const VehicleDetails = props => {
11910
12496
  }, t(value.title)), /*#__PURE__*/React.createElement("div", {
11911
12497
  className: "additional-value",
11912
12498
  style: {
11913
- color: "#a82227",
11914
12499
  display: "flex",
11915
12500
  alignItems: "center",
11916
12501
  gap: "8px"
@@ -11927,13 +12512,15 @@ const VehicleDetails = props => {
11927
12512
  }, /*#__PURE__*/React.createElement(AddIcon, {
11928
12513
  className: "",
11929
12514
  fill: "#a82227"
11930
- }), " ", t(value.value) || "N/A"), value.value !== "ES_FSM_REGISTRY_DETAILS_ADD_VENDOR" && /*#__PURE__*/React.createElement("div", {
12515
+ }), " ", t(value.value) || "N/A"), value.value !== "ES_FSM_REGISTRY_DETAILS_ADD_VENDOR" && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", null, value.value), /*#__PURE__*/React.createElement("div", {
11931
12516
  className: "add-details-link hover-button",
11932
12517
  onClick: () => onActionSelect("EDIT_VENDOR"),
11933
12518
  style: {
11934
12519
  cursor: "pointer"
11935
12520
  }
11936
- }, /*#__PURE__*/React.createElement(EditIcon, null)), value.value !== "ES_FSM_REGISTRY_DETAILS_ADD_VENDOR" && /*#__PURE__*/React.createElement("div", {
12521
+ }, /*#__PURE__*/React.createElement(EditIcon, {
12522
+ fill: "#a82227"
12523
+ })), /*#__PURE__*/React.createElement("div", {
11937
12524
  className: "add-details-link hover-button",
11938
12525
  onClick: () => onActionSelect("DELETE_VENDOR"),
11939
12526
  style: {
@@ -11942,7 +12529,7 @@ const VehicleDetails = props => {
11942
12529
  }, /*#__PURE__*/React.createElement(DeleteIcon, {
11943
12530
  className: "delete",
11944
12531
  fill: "#a82227"
11945
- })))) : /*#__PURE__*/React.createElement(React.Fragment, {
12532
+ }))))) : /*#__PURE__*/React.createElement(React.Fragment, {
11946
12533
  key: index
11947
12534
  }, /*#__PURE__*/React.createElement("div", {
11948
12535
  className: "additional-label"
@@ -12078,14 +12665,14 @@ const SelectVehicleType = ({
12078
12665
  if (!vehicleData || !serviceTypeData) {
12079
12666
  return /*#__PURE__*/React.createElement("div", null, t("ERROR_FETCHING_DATA"));
12080
12667
  }
12081
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, null, t("ES_FSM_REGISTRY_VEHICLE_MODEL")), /*#__PURE__*/React.createElement(Dropdown$2, {
12668
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, null, t("ES_FSM_REGISTRY_VEHICLE_MODEL")), /*#__PURE__*/React.createElement(Dropdown$4, {
12082
12669
  className: "form-field",
12083
12670
  selected: selectedModal,
12084
12671
  option: modals,
12085
12672
  select: selectModal,
12086
12673
  optionKey: "name",
12087
12674
  t: t
12088
- })), /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, null, t("ES_FSM_REGISTRY_VEHICLE_TYPE")), /*#__PURE__*/React.createElement(Dropdown$2, {
12675
+ })), /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, null, t("ES_FSM_REGISTRY_VEHICLE_TYPE")), /*#__PURE__*/React.createElement(Dropdown$4, {
12089
12676
  className: "form-field",
12090
12677
  selected: selectedType,
12091
12678
  option: types,
@@ -12209,6 +12796,1477 @@ const BankDetailsComponent = ({
12209
12796
  }));
12210
12797
  };
12211
12798
 
12799
+ const SupervisorAreaAssignment = ({
12800
+ config,
12801
+ onSelect,
12802
+ t,
12803
+ userType,
12804
+ formData
12805
+ }) => {
12806
+ var _formData$areaAssignm, _formData$areaAssignm2, _formData$areaAssignm3, _formData$areaAssignm4;
12807
+ const tenantId = Digit.ULBService.getCurrentTenantId();
12808
+ const [selectedZone, setSelectedZone] = useState((formData === null || formData === void 0 ? void 0 : (_formData$areaAssignm = formData.areaAssignment) === null || _formData$areaAssignm === void 0 ? void 0 : _formData$areaAssignm.zone) || null);
12809
+ const [selectedCluster, setSelectedCluster] = useState((formData === null || formData === void 0 ? void 0 : (_formData$areaAssignm2 = formData.areaAssignment) === null || _formData$areaAssignm2 === void 0 ? void 0 : _formData$areaAssignm2.cluster) || null);
12810
+ const [selectedWard, setSelectedWard] = useState((formData === null || formData === void 0 ? void 0 : (_formData$areaAssignm3 = formData.areaAssignment) === null || _formData$areaAssignm3 === void 0 ? void 0 : _formData$areaAssignm3.ward) || null);
12811
+ const [selectedAreas, setSelectedAreas] = useState((formData === null || formData === void 0 ? void 0 : (_formData$areaAssignm4 = formData.areaAssignment) === null || _formData$areaAssignm4 === void 0 ? void 0 : _formData$areaAssignm4.areas) || []);
12812
+ const [zones, setZones] = useState([]);
12813
+ const [clusters, setClusters] = useState([]);
12814
+ const [wards, setWards] = useState([]);
12815
+ const [areas, setAreas] = useState([]);
12816
+ const {
12817
+ data: boundaryData,
12818
+ isLoading
12819
+ } = Digit.Hooks.useCommonMDMS(tenantId, "egov-location", ["TenantBoundary"]);
12820
+ useEffect(() => {
12821
+ if (boundaryData) {
12822
+ var _boundaryData$MdmsRes, _boundaryData$MdmsRes2, _boundaryData$MdmsRes3, _boundaryData$MdmsRes4;
12823
+ const tenantBoundary = boundaryData === null || boundaryData === void 0 ? void 0 : (_boundaryData$MdmsRes = boundaryData.MdmsRes) === null || _boundaryData$MdmsRes === void 0 ? void 0 : (_boundaryData$MdmsRes2 = _boundaryData$MdmsRes["egov-location"]) === null || _boundaryData$MdmsRes2 === void 0 ? void 0 : (_boundaryData$MdmsRes3 = _boundaryData$MdmsRes2.TenantBoundary) === null || _boundaryData$MdmsRes3 === void 0 ? void 0 : (_boundaryData$MdmsRes4 = _boundaryData$MdmsRes3[0]) === null || _boundaryData$MdmsRes4 === void 0 ? void 0 : _boundaryData$MdmsRes4.boundary;
12824
+ if (tenantBoundary && tenantBoundary.children) {
12825
+ setZones(tenantBoundary.children);
12826
+ }
12827
+ }
12828
+ }, [boundaryData]);
12829
+ useEffect(() => {
12830
+ if (selectedZone) {
12831
+ var _formData$areaAssignm5, _formData$areaAssignm6;
12832
+ setClusters(selectedZone.children || []);
12833
+ if (selectedZone.code !== (formData === null || formData === void 0 ? void 0 : (_formData$areaAssignm5 = formData.areaAssignment) === null || _formData$areaAssignm5 === void 0 ? void 0 : (_formData$areaAssignm6 = _formData$areaAssignm5.zone) === null || _formData$areaAssignm6 === void 0 ? void 0 : _formData$areaAssignm6.code)) {
12834
+ setSelectedCluster(null);
12835
+ setSelectedWard(null);
12836
+ setSelectedAreas([]);
12837
+ }
12838
+ } else {
12839
+ setClusters([]);
12840
+ }
12841
+ }, [selectedZone]);
12842
+ useEffect(() => {
12843
+ if (selectedCluster) {
12844
+ var _formData$areaAssignm7, _formData$areaAssignm8;
12845
+ setWards(selectedCluster.children || []);
12846
+ if (selectedCluster.code !== (formData === null || formData === void 0 ? void 0 : (_formData$areaAssignm7 = formData.areaAssignment) === null || _formData$areaAssignm7 === void 0 ? void 0 : (_formData$areaAssignm8 = _formData$areaAssignm7.cluster) === null || _formData$areaAssignm8 === void 0 ? void 0 : _formData$areaAssignm8.code)) {
12847
+ setSelectedWard(null);
12848
+ setSelectedAreas([]);
12849
+ }
12850
+ } else {
12851
+ setWards([]);
12852
+ }
12853
+ }, [selectedCluster]);
12854
+ useEffect(() => {
12855
+ if (selectedWard) {
12856
+ var _formData$areaAssignm9, _formData$areaAssignm0;
12857
+ setAreas(selectedWard.children || []);
12858
+ if (selectedWard.code !== (formData === null || formData === void 0 ? void 0 : (_formData$areaAssignm9 = formData.areaAssignment) === null || _formData$areaAssignm9 === void 0 ? void 0 : (_formData$areaAssignm0 = _formData$areaAssignm9.ward) === null || _formData$areaAssignm0 === void 0 ? void 0 : _formData$areaAssignm0.code)) {
12859
+ setSelectedAreas([]);
12860
+ }
12861
+ } else {
12862
+ setAreas([]);
12863
+ }
12864
+ }, [selectedWard]);
12865
+ const handleSelect = (key, value) => {
12866
+ const updatedData = {
12867
+ ...(formData === null || formData === void 0 ? void 0 : formData.areaAssignment),
12868
+ [key]: value
12869
+ };
12870
+ if (key === "zone") {
12871
+ updatedData.cluster = null;
12872
+ updatedData.ward = null;
12873
+ updatedData.areas = [];
12874
+ } else if (key === "cluster") {
12875
+ updatedData.ward = null;
12876
+ updatedData.areas = [];
12877
+ } else if (key === "ward") {
12878
+ updatedData.areas = [];
12879
+ }
12880
+ onSelect(config.key, updatedData);
12881
+ };
12882
+ if (isLoading) return /*#__PURE__*/React.createElement(Loader, null);
12883
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, null, t("ES_VENDOR_SUPERVISOR_ZONE") + " *"), /*#__PURE__*/React.createElement(Dropdown$4, {
12884
+ selected: selectedZone,
12885
+ option: zones,
12886
+ select: val => {
12887
+ setSelectedZone(val);
12888
+ handleSelect("zone", val);
12889
+ },
12890
+ optionKey: "name",
12891
+ t: t
12892
+ })), /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, null, t("ES_VENDOR_SUPERVISOR_CLUSTER") + " *"), /*#__PURE__*/React.createElement(Dropdown$4, {
12893
+ selected: selectedCluster,
12894
+ option: clusters,
12895
+ select: val => {
12896
+ setSelectedCluster(val);
12897
+ handleSelect("cluster", val);
12898
+ },
12899
+ optionKey: "name",
12900
+ t: t,
12901
+ disable: !selectedZone
12902
+ })), /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, null, t("ES_VENDOR_SUPERVISOR_WARD") + " *"), /*#__PURE__*/React.createElement(Dropdown$4, {
12903
+ selected: selectedWard,
12904
+ option: wards,
12905
+ select: val => {
12906
+ setSelectedWard(val);
12907
+ handleSelect("ward", val);
12908
+ },
12909
+ optionKey: "name",
12910
+ t: t,
12911
+ disable: !selectedCluster
12912
+ })), /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, null, t("ES_VENDOR_SUPERVISOR_AREA") + " *"), /*#__PURE__*/React.createElement(MultiSelectDropdown, {
12913
+ options: areas,
12914
+ selected: selectedAreas,
12915
+ onSelect: val => {
12916
+ setSelectedAreas(val);
12917
+ handleSelect("areas", val);
12918
+ },
12919
+ optionsKey: "name",
12920
+ t: t,
12921
+ disable: !selectedWard
12922
+ })));
12923
+ };
12924
+
12925
+ const {
12926
+ DatePicker: DatePicker$3,
12927
+ Dropdown: Dropdown$2
12928
+ } = require("@djb25/digit-ui-react-components");
12929
+ const SupervisorConfig = (t, agencies = [], reportingManagers = [], disabled = false) => {
12930
+ return [{
12931
+ head: "ES_VENDOR_SUPERVISOR_BASIC_DETAILS",
12932
+ body: [{
12933
+ label: "ES_VENDOR_SUPERVISOR_FULL_NAME",
12934
+ isMandatory: true,
12935
+ type: "text",
12936
+ disable: disabled,
12937
+ populators: {
12938
+ name: "fullName",
12939
+ validation: {
12940
+ required: true,
12941
+ pattern: {
12942
+ value: /^[A-Za-z\s]+$/,
12943
+ message: t("ES_VENDOR_INVALID_NAME")
12944
+ }
12945
+ },
12946
+ error: t("ES_VENDOR_INVALID_NAME"),
12947
+ defaultValue: "",
12948
+ className: "payment-form-text-input-correction"
12949
+ }
12950
+ }, {
12951
+ label: "ES_VENDOR_SUPERVISOR_MOBILE_NUMBER",
12952
+ isMandatory: true,
12953
+ type: "mobileNumber",
12954
+ disable: disabled,
12955
+ populators: {
12956
+ name: "mobileNumber",
12957
+ validation: {
12958
+ required: true,
12959
+ pattern: /^[6-9]\d{9}$/
12960
+ },
12961
+ error: t("ES_VENDOR_INVALID_MOBILE"),
12962
+ defaultValue: "",
12963
+ className: "payment-form-text-input-correction"
12964
+ }
12965
+ }, {
12966
+ label: "ES_VENDOR_SUPERVISOR_EMAIL_ID",
12967
+ isMandatory: true,
12968
+ type: "text",
12969
+ populators: {
12970
+ name: "emailId",
12971
+ validation: {
12972
+ required: true,
12973
+ pattern: /^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9.-]+$/
12974
+ },
12975
+ error: t("ES_VENDOR_INVALID_EMAIL"),
12976
+ defaultValue: "",
12977
+ className: "payment-form-text-input-correction"
12978
+ }
12979
+ }, {
12980
+ label: "ES_VENDOR_SUPERVISOR_EMPLOYEE_ID",
12981
+ isMandatory: true,
12982
+ type: "text",
12983
+ populators: {
12984
+ name: "employeeId",
12985
+ validation: {
12986
+ required: true
12987
+ },
12988
+ defaultValue: "",
12989
+ className: "payment-form-text-input-correction"
12990
+ }
12991
+ }, {
12992
+ label: "ES_VENDOR_SUPERVISOR_GENDER",
12993
+ isMandatory: false,
12994
+ type: "component",
12995
+ key: "gender",
12996
+ component: "SelectGender",
12997
+ texts: {
12998
+ headerCaption: "",
12999
+ header: "CS_COMMON_CHOOSE_GENDER",
13000
+ cardText: "CS_COMMON_SELECT_GENDER",
13001
+ submitBarLabel: "CS_COMMON_NEXT",
13002
+ skipText: "CORE_COMMON_SKIP_CONTINUE"
13003
+ }
13004
+ }]
13005
+ }, {
13006
+ head: "ES_VENDOR_SUPERVISOR_ROLE_ACCESS",
13007
+ body: [{
13008
+ label: "ES_VENDOR_SUPERVISOR_ROLE",
13009
+ isMandatory: true,
13010
+ type: "custom",
13011
+ populators: {
13012
+ name: "role",
13013
+ component: (props, customProps) => /*#__PURE__*/React.createElement(Dropdown$2, {
13014
+ option: [{
13015
+ code: "SUPERVISOR",
13016
+ name: "Supervisor"
13017
+ }],
13018
+ optionKey: "name",
13019
+ select: props.onChange,
13020
+ selected: props.value,
13021
+ t: t,
13022
+ disable: true
13023
+ }),
13024
+ defaultValue: {
13025
+ code: "SUPERVISOR",
13026
+ name: "Supervisor"
13027
+ }
13028
+ }
13029
+ }, {
13030
+ label: "ES_VENDOR_SUPERVISOR_AGENCY_NAME",
13031
+ isMandatory: true,
13032
+ type: "custom",
13033
+ populators: {
13034
+ name: "agencyName",
13035
+ component: (props, customProps) => /*#__PURE__*/React.createElement(Dropdown$2, {
13036
+ option: agencies,
13037
+ optionKey: "name",
13038
+ select: props.onChange,
13039
+ selected: props.value,
13040
+ t: t
13041
+ })
13042
+ }
13043
+ }, {
13044
+ label: "ES_VENDOR_SUPERVISOR_REPORTING_MANAGER",
13045
+ isMandatory: false,
13046
+ type: "custom",
13047
+ populators: {
13048
+ name: "reportingManager",
13049
+ component: (props, customProps) => /*#__PURE__*/React.createElement(Dropdown$2, {
13050
+ option: reportingManagers,
13051
+ optionKey: "name",
13052
+ select: props.onChange,
13053
+ selected: props.value,
13054
+ t: t
13055
+ })
13056
+ }
13057
+ }]
13058
+ }, {
13059
+ head: "ES_VENDOR_SUPERVISOR_AREA_ASSIGNMENT",
13060
+ body: [{
13061
+ type: "component",
13062
+ component: "SupervisorAreaAssignment",
13063
+ key: "areaAssignment",
13064
+ withoutLabel: true
13065
+ }]
13066
+ }];
13067
+ };
13068
+
13069
+ const AddSupervisor = ({
13070
+ parentUrl,
13071
+ heading
13072
+ }) => {
13073
+ var _vendorsData$vendor;
13074
+ const tenantId = Digit.ULBService.getCurrentTenantId();
13075
+ const {
13076
+ t
13077
+ } = useTranslation();
13078
+ const [showToast, setShowToast] = useState(null);
13079
+ const [currentStep, setCurrentStep] = useState(1);
13080
+ const queryClient = useQueryClient();
13081
+ const [canSubmit, setCanSubmit] = useState(false);
13082
+ const {
13083
+ isLoading: isMutationLoading,
13084
+ mutate
13085
+ } = Digit.Hooks.fsm.useSupervisorCreate(tenantId);
13086
+ const {
13087
+ data: vendorsData,
13088
+ isLoading: isVendorsLoading
13089
+ } = Digit.Hooks.fsm.useVendorSearch(tenantId, {
13090
+ status: "ACTIVE"
13091
+ });
13092
+ const agencies = (vendorsData === null || vendorsData === void 0 ? void 0 : (_vendorsData$vendor = vendorsData.vendor) === null || _vendorsData$vendor === void 0 ? void 0 : _vendorsData$vendor.map(v => ({
13093
+ code: v.id,
13094
+ name: v.name,
13095
+ ...v
13096
+ }))) || [];
13097
+ const reportingManagers = [{
13098
+ code: "MGR1",
13099
+ name: "John Doe (Agency Admin)"
13100
+ }, {
13101
+ code: "MGR2",
13102
+ name: "Jane Smith (Agency Admin)"
13103
+ }];
13104
+ const Config = SupervisorConfig(t, agencies, reportingManagers);
13105
+ const defaultValues = {
13106
+ role: {
13107
+ code: "SUPERVISOR",
13108
+ name: "Supervisor"
13109
+ }
13110
+ };
13111
+ const onFormValueChange = (setValue, formData) => {
13112
+ var _formData$areaAssignm, _formData$areaAssignm2, _formData$areaAssignm3, _formData$areaAssignm4, _formData$areaAssignm5;
13113
+ const isBasicDetailsFilled = (formData === null || formData === void 0 ? void 0 : formData.fullName) && (formData === null || formData === void 0 ? void 0 : formData.mobileNumber) && (formData === null || formData === void 0 ? void 0 : formData.emailId) && (formData === null || formData === void 0 ? void 0 : formData.employeeId);
13114
+ const isRoleAccessFilled = formData === null || formData === void 0 ? void 0 : formData.agencyName;
13115
+ const isAreaAssignmentFilled = (formData === null || formData === void 0 ? void 0 : (_formData$areaAssignm = formData.areaAssignment) === null || _formData$areaAssignm === void 0 ? void 0 : _formData$areaAssignm.zone) && (formData === null || formData === void 0 ? void 0 : (_formData$areaAssignm2 = formData.areaAssignment) === null || _formData$areaAssignm2 === void 0 ? void 0 : _formData$areaAssignm2.cluster) && (formData === null || formData === void 0 ? void 0 : (_formData$areaAssignm3 = formData.areaAssignment) === null || _formData$areaAssignm3 === void 0 ? void 0 : _formData$areaAssignm3.ward) && (formData === null || formData === void 0 ? void 0 : (_formData$areaAssignm4 = formData.areaAssignment) === null || _formData$areaAssignm4 === void 0 ? void 0 : (_formData$areaAssignm5 = _formData$areaAssignm4.areas) === null || _formData$areaAssignm5 === void 0 ? void 0 : _formData$areaAssignm5.length) > 0;
13116
+ if (isBasicDetailsFilled && isRoleAccessFilled && isAreaAssignmentFilled) {
13117
+ setCanSubmit(true);
13118
+ } else {
13119
+ setCanSubmit(false);
13120
+ }
13121
+ };
13122
+ const closeToast = () => {
13123
+ setShowToast(null);
13124
+ };
13125
+ const onSubmit = data => {
13126
+ var _data$gender, _data$agencyName, _data$reportingManage;
13127
+ const formData = {
13128
+ supervisor: {
13129
+ tenantId: tenantId,
13130
+ name: data === null || data === void 0 ? void 0 : data.fullName,
13131
+ employeeId: data === null || data === void 0 ? void 0 : data.employeeId,
13132
+ status: "ACTIVE",
13133
+ owner: {
13134
+ tenantId: tenantId,
13135
+ name: data === null || data === void 0 ? void 0 : data.fullName,
13136
+ gender: (data === null || data === void 0 ? void 0 : (_data$gender = data.gender) === null || _data$gender === void 0 ? void 0 : _data$gender.code) || "OTHERS",
13137
+ emailId: data === null || data === void 0 ? void 0 : data.emailId,
13138
+ mobileNumber: data === null || data === void 0 ? void 0 : data.mobileNumber
13139
+ },
13140
+ vendorSupervisorStatus: "ACTIVE",
13141
+ additionalDetails: {
13142
+ agencyId: data === null || data === void 0 ? void 0 : (_data$agencyName = data.agencyName) === null || _data$agencyName === void 0 ? void 0 : _data$agencyName.code,
13143
+ reportingManager: data === null || data === void 0 ? void 0 : (_data$reportingManage = data.reportingManager) === null || _data$reportingManage === void 0 ? void 0 : _data$reportingManage.code,
13144
+ areaAssignment: data === null || data === void 0 ? void 0 : data.areaAssignment
13145
+ }
13146
+ }
13147
+ };
13148
+ mutate(formData, {
13149
+ onError: error => {
13150
+ setShowToast({
13151
+ key: "error",
13152
+ action: error
13153
+ });
13154
+ setTimeout(closeToast, 5000);
13155
+ },
13156
+ onSuccess: () => {
13157
+ setShowToast({
13158
+ key: "success",
13159
+ action: "ADD_SUPERVISOR"
13160
+ });
13161
+ queryClient.invalidateQueries("SUPERVISOR_SEARCH");
13162
+ setTimeout(closeToast, 5000);
13163
+ }
13164
+ });
13165
+ };
13166
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(VerticalTimeline, {
13167
+ config: [{
13168
+ route: "supervisor-details",
13169
+ timeLine: [{
13170
+ actions: t("ES_VENDOR_SUPERVISOR_DETAILS"),
13171
+ currentStep: 1
13172
+ }]
13173
+ }],
13174
+ currentActiveIndex: currentStep - 1,
13175
+ showFinalStep: false
13176
+ }), /*#__PURE__*/React.createElement("div", {
13177
+ style: {
13178
+ flex: "1",
13179
+ overflowY: "auto"
13180
+ }
13181
+ }, /*#__PURE__*/React.createElement(FormComposer, {
13182
+ isDisabled: !canSubmit,
13183
+ label: t("ES_COMMON_APPLICATION_SUBMIT"),
13184
+ config: Config.map(config => ({
13185
+ ...config,
13186
+ isCollapsible: true,
13187
+ isDefaultOpen: true
13188
+ })),
13189
+ fieldStyle: {
13190
+ marginRight: 0
13191
+ },
13192
+ onSubmit: onSubmit,
13193
+ defaultValues: defaultValues,
13194
+ onFormValueChange: onFormValueChange,
13195
+ noBreakLine: true,
13196
+ mode: "onChange",
13197
+ noCard: true
13198
+ }), showToast && /*#__PURE__*/React.createElement(Toast, {
13199
+ error: showToast.key === "error",
13200
+ label: t(showToast.key === "success" ? `ES_VENDOR_${showToast.action}_SUCCESS` : showToast.action),
13201
+ onClose: closeToast
13202
+ })));
13203
+ };
13204
+
13205
+ const Heading$3 = props => {
13206
+ return /*#__PURE__*/React.createElement("h1", {
13207
+ className: "heading-m"
13208
+ }, props.label);
13209
+ };
13210
+ const Close$3 = () => /*#__PURE__*/React.createElement("svg", {
13211
+ xmlns: "http://www.w3.org/2000/svg",
13212
+ viewBox: "0 0 24 24",
13213
+ fill: "#FFFFFF"
13214
+ }, /*#__PURE__*/React.createElement("path", {
13215
+ d: "M0 0h24v24H0V0z",
13216
+ fill: "none"
13217
+ }), /*#__PURE__*/React.createElement("path", {
13218
+ d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"
13219
+ }));
13220
+ const CloseBtn$3 = props => {
13221
+ return /*#__PURE__*/React.createElement("div", {
13222
+ className: "icon-bg-secondary",
13223
+ onClick: props.onClick
13224
+ }, /*#__PURE__*/React.createElement(Close$3, null));
13225
+ };
13226
+ const SupervisorDetails = props => {
13227
+ var _supervisorData$5, _supervisorData$5$emp;
13228
+ const tenantId = Digit.ULBService.getCurrentTenantId();
13229
+ const {
13230
+ t
13231
+ } = useTranslation();
13232
+ const history = useHistory();
13233
+ const queryClient = useQueryClient();
13234
+ const {
13235
+ id: supervisorId
13236
+ } = useParams();
13237
+ const [displayMenu, setDisplayMenu] = useState(false);
13238
+ const [selectedAction, setSelectedAction] = useState(null);
13239
+ const [showModal, setShowModal] = useState(false);
13240
+ const [showToast, setShowToast] = useState(null);
13241
+ const [vendors, setVendors] = useState([]);
13242
+ const [selectedOption, setSelectedOption] = useState({});
13243
+ const {
13244
+ data: supervisorData,
13245
+ isLoading: isLoading,
13246
+ refetch
13247
+ } = Digit.Hooks.fsm.useSupervisorDetails(tenantId, {
13248
+ ids: supervisorId
13249
+ }, {
13250
+ staleTime: Infinity
13251
+ });
13252
+ const {
13253
+ data: vendorData
13254
+ } = Digit.Hooks.fsm.useDsoSearch(tenantId, {
13255
+ sortBy: "name",
13256
+ sortOrder: "ASC",
13257
+ status: "ACTIVE"
13258
+ }, {});
13259
+ const {
13260
+ mutate: mutateSupervisor
13261
+ } = Digit.Hooks.fsm.useSupervisorUpdate(tenantId);
13262
+ const {
13263
+ mutate: mutateVendor
13264
+ } = Digit.Hooks.fsm.useVendorUpdate(tenantId);
13265
+ useEffect(() => {
13266
+ if (vendorData) {
13267
+ let vendors = vendorData.map(data => data.dsoDetails);
13268
+ setVendors(vendors);
13269
+ }
13270
+ }, [vendorData]);
13271
+ useEffect(() => {
13272
+ refetch();
13273
+ }, []);
13274
+ useEffect(() => {
13275
+ switch (selectedAction) {
13276
+ case "DELETE":
13277
+ case "ADD_VENDOR":
13278
+ case "EDIT_VENDOR":
13279
+ case "DELETE_VENDOR":
13280
+ return setShowModal(true);
13281
+ case "EDIT":
13282
+ return history.push("/digit-ui/employee/vendor/modify-supervisor/" + supervisorId);
13283
+ case "HOME":
13284
+ return history.push("/digit-ui/employee/vendor/search-vendor?selectedTabs=SUPERVISOR");
13285
+ }
13286
+ }, [selectedAction]);
13287
+ const closeToast = () => {
13288
+ setShowToast(null);
13289
+ };
13290
+ const handleModalAction = () => {
13291
+ switch (selectedAction) {
13292
+ case "DELETE":
13293
+ return handleDeleteSupervisor();
13294
+ case "DELETE_VENDOR":
13295
+ return handleDeleteVendor();
13296
+ case "ADD_VENDOR":
13297
+ return handleAddVendor();
13298
+ case "EDIT_VENDOR":
13299
+ return handleEditVendor();
13300
+ }
13301
+ };
13302
+ const handleDeleteSupervisor = () => {
13303
+ var _supervisorData$;
13304
+ let details = supervisorData === null || supervisorData === void 0 ? void 0 : (_supervisorData$ = supervisorData[0]) === null || _supervisorData$ === void 0 ? void 0 : _supervisorData$.supervisorData;
13305
+ const formData = {
13306
+ supervisor: {
13307
+ ...details,
13308
+ status: "INACTIVE"
13309
+ }
13310
+ };
13311
+ mutateSupervisor(formData, {
13312
+ onError: error => {
13313
+ setShowToast({
13314
+ key: "error",
13315
+ action: error
13316
+ });
13317
+ setTimeout(closeToast, 5000);
13318
+ },
13319
+ onSuccess: () => {
13320
+ setShowToast({
13321
+ key: "success",
13322
+ action: "DELETE_SUPERVISOR"
13323
+ });
13324
+ queryClient.invalidateQueries("SUPERVISOR_SEARCH");
13325
+ setTimeout(() => {
13326
+ closeToast();
13327
+ history.push(`/digit-ui/employee/vendor/search-vendor`);
13328
+ }, 5000);
13329
+ }
13330
+ });
13331
+ setShowModal(false);
13332
+ };
13333
+ const handleDeleteVendor = () => {
13334
+ var _supervisorData$2, _supervisorData$2$ven, _supervisorData$2$ven2;
13335
+ let dsoDetails = supervisorData === null || supervisorData === void 0 ? void 0 : (_supervisorData$2 = supervisorData[0]) === null || _supervisorData$2 === void 0 ? void 0 : (_supervisorData$2$ven = _supervisorData$2.vendorDetails) === null || _supervisorData$2$ven === void 0 ? void 0 : (_supervisorData$2$ven2 = _supervisorData$2$ven.vendor) === null || _supervisorData$2$ven2 === void 0 ? void 0 : _supervisorData$2$ven2[0];
13336
+ let getSupervisorVendorDetails = (dsoDetails === null || dsoDetails === void 0 ? void 0 : dsoDetails.supervisors) || [];
13337
+ getSupervisorVendorDetails = getSupervisorVendorDetails.map(data => {
13338
+ if (data.id === supervisorId) {
13339
+ data.vendorSupervisorStatus = "INACTIVE";
13340
+ }
13341
+ return data;
13342
+ });
13343
+ const formData = {
13344
+ vendor: {
13345
+ ...dsoDetails,
13346
+ supervisors: getSupervisorVendorDetails
13347
+ }
13348
+ };
13349
+ mutateVendor(formData, {
13350
+ onError: error => {
13351
+ setShowToast({
13352
+ key: "error",
13353
+ action: error
13354
+ });
13355
+ setTimeout(closeToast, 5000);
13356
+ },
13357
+ onSuccess: () => {
13358
+ setShowToast({
13359
+ key: "success",
13360
+ action: "DELETE_VENDOR"
13361
+ });
13362
+ queryClient.invalidateQueries("FSM_VENDOR_SEARCH");
13363
+ refetch();
13364
+ setTimeout(closeToast, 5000);
13365
+ }
13366
+ });
13367
+ setShowModal(false);
13368
+ };
13369
+ const handleAddVendor = () => {
13370
+ var _supervisorData$3;
13371
+ let dsoDetails = selectedOption;
13372
+ let details = supervisorData === null || supervisorData === void 0 ? void 0 : (_supervisorData$3 = supervisorData[0]) === null || _supervisorData$3 === void 0 ? void 0 : _supervisorData$3.supervisorData;
13373
+ details.vendorSupervisorStatus = "ACTIVE";
13374
+ const formData = {
13375
+ vendor: {
13376
+ ...dsoDetails,
13377
+ supervisors: dsoDetails.supervisors ? [...dsoDetails.supervisors, details] : [details]
13378
+ }
13379
+ };
13380
+ mutateVendor(formData, {
13381
+ onError: error => {
13382
+ setShowToast({
13383
+ key: "error",
13384
+ action: error
13385
+ });
13386
+ refetch();
13387
+ setTimeout(closeToast, 5000);
13388
+ },
13389
+ onSuccess: () => {
13390
+ setShowToast({
13391
+ key: "success",
13392
+ action: "ADD_VENDOR"
13393
+ });
13394
+ queryClient.invalidateQueries("SUPERVISOR_SEARCH");
13395
+ refetch();
13396
+ setTimeout(closeToast, 5000);
13397
+ }
13398
+ });
13399
+ setShowModal(false);
13400
+ setSelectedAction(null);
13401
+ };
13402
+ const handleEditVendor = () => {
13403
+ var _supervisorData$4;
13404
+ let dsoDetails = selectedOption;
13405
+ let details = supervisorData === null || supervisorData === void 0 ? void 0 : (_supervisorData$4 = supervisorData[0]) === null || _supervisorData$4 === void 0 ? void 0 : _supervisorData$4.supervisorData;
13406
+ details.vendorSupervisorStatus = "ACTIVE";
13407
+ const formData = {
13408
+ vendor: {
13409
+ ...dsoDetails,
13410
+ supervisors: dsoDetails.supervisors ? [...dsoDetails.supervisors, details] : [details]
13411
+ }
13412
+ };
13413
+ mutateVendor(formData, {
13414
+ onError: error => {
13415
+ setShowToast({
13416
+ key: "error",
13417
+ action: error
13418
+ });
13419
+ setTimeout(closeToast, 5000);
13420
+ },
13421
+ onSuccess: () => {
13422
+ setShowToast({
13423
+ key: "success",
13424
+ action: "EDIT_VENDOR"
13425
+ });
13426
+ refetch();
13427
+ queryClient.invalidateQueries("SUPERVISOR_SEARCH");
13428
+ setTimeout(closeToast, 5000);
13429
+ }
13430
+ });
13431
+ setShowModal(false);
13432
+ setSelectedAction(null);
13433
+ };
13434
+ const closeModal = () => {
13435
+ setSelectedAction(null);
13436
+ setSelectedOption({});
13437
+ setShowModal(false);
13438
+ };
13439
+ const modalHeading = () => {
13440
+ switch (selectedAction) {
13441
+ case "DELETE":
13442
+ case "DELETE_VENDOR":
13443
+ return "ES_VENDOR_SUPERVISOR_DELETE_POPUP_HEADER";
13444
+ case "ADD_VENDOR":
13445
+ case "EDIT_VENDOR":
13446
+ return "ES_VENDOR_SUPERVISOR_ADD_VENDOR_POPUP_HEADER";
13447
+ }
13448
+ };
13449
+ const renderModalContent = () => {
13450
+ if (selectedAction === "DELETE" || selectedAction === "DELETE_VENDOR") {
13451
+ return /*#__PURE__*/React.createElement(ConfirmationBox, {
13452
+ t: t,
13453
+ title: "ES_VENDOR_SUPERVISOR_DELETE_TEXT"
13454
+ });
13455
+ }
13456
+ if (selectedAction === "ADD_VENDOR" || selectedAction === "EDIT_VENDOR") {
13457
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CardText, null, t(`ES_FSM_REGISTRY_SELECT_VENODOR`)), /*#__PURE__*/React.createElement(Dropdown$4, {
13458
+ t: t,
13459
+ option: vendors,
13460
+ value: selectedOption,
13461
+ selected: selectedOption,
13462
+ select: setSelectedOption,
13463
+ optionKey: "name"
13464
+ }));
13465
+ }
13466
+ };
13467
+ if (isLoading) {
13468
+ return /*#__PURE__*/React.createElement(Loader, null);
13469
+ }
13470
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
13471
+ className: "employee-form-content"
13472
+ }, /*#__PURE__*/React.createElement(Card, {
13473
+ style: {
13474
+ position: "relative",
13475
+ backgroundColor: "#fff"
13476
+ }
13477
+ }, supervisorData === null || supervisorData === void 0 ? void 0 : (_supervisorData$5 = supervisorData[0]) === null || _supervisorData$5 === void 0 ? void 0 : (_supervisorData$5$emp = _supervisorData$5.employeeResponse) === null || _supervisorData$5$emp === void 0 ? void 0 : _supervisorData$5$emp.map((detail, index) => {
13478
+ var _detail$values, _detail$child;
13479
+ return /*#__PURE__*/React.createElement(React.Fragment, {
13480
+ key: index
13481
+ }, index > 0 && /*#__PURE__*/React.createElement(CardSectionHeader, {
13482
+ style: {
13483
+ marginBottom: "16px",
13484
+ marginTop: "32px"
13485
+ }
13486
+ }, t(detail.title)), /*#__PURE__*/React.createElement(Card, {
13487
+ className: "card-with-background",
13488
+ style: {
13489
+ margin: "10px 16px",
13490
+ padding: "20px"
13491
+ }
13492
+ }, /*#__PURE__*/React.createElement("div", {
13493
+ className: "additional-grid"
13494
+ }, detail === null || detail === void 0 ? void 0 : (_detail$values = detail.values) === null || _detail$values === void 0 ? void 0 : _detail$values.map((value, index) => {
13495
+ return (value === null || value === void 0 ? void 0 : value.type) === "custom" ? /*#__PURE__*/React.createElement(React.Fragment, {
13496
+ key: index
13497
+ }, /*#__PURE__*/React.createElement("div", {
13498
+ className: "additional-label"
13499
+ }, t(value.title)), /*#__PURE__*/React.createElement("div", {
13500
+ className: "additional-value",
13501
+ style: {
13502
+ color: "#a82227",
13503
+ display: "flex",
13504
+ gap: "20px",
13505
+ alignItems: "center"
13506
+ }
13507
+ }, t(value.value) || "N/A", value.value === "ES_FSM_REGISTRY_DETAILS_ADD_VENDOR" && /*#__PURE__*/React.createElement("span", {
13508
+ className: "add-details-link hover-button",
13509
+ onClick: () => setSelectedAction("ADD_VENDOR"),
13510
+ style: {
13511
+ cursor: "pointer"
13512
+ }
13513
+ }, /*#__PURE__*/React.createElement(AddIcon, {
13514
+ fill: "#a82227"
13515
+ })), value.value !== "ES_FSM_REGISTRY_DETAILS_ADD_VENDOR" && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
13516
+ className: "add-details-link hover-button",
13517
+ onClick: () => setSelectedAction("EDIT_VENDOR"),
13518
+ style: {
13519
+ cursor: "pointer"
13520
+ }
13521
+ }, /*#__PURE__*/React.createElement(EditIcon, null)), /*#__PURE__*/React.createElement("div", {
13522
+ className: "add-details-link hover-button",
13523
+ onClick: () => setSelectedAction("DELETE_VENDOR"),
13524
+ style: {
13525
+ cursor: "pointer"
13526
+ }
13527
+ }, /*#__PURE__*/React.createElement(DeleteIcon, {
13528
+ fill: "#a82227"
13529
+ }))))) : /*#__PURE__*/React.createElement(React.Fragment, {
13530
+ key: index
13531
+ }, /*#__PURE__*/React.createElement("div", {
13532
+ className: "additional-label"
13533
+ }, t(value.title)), /*#__PURE__*/React.createElement("div", {
13534
+ className: "additional-value"
13535
+ }, t(value.value) || "N/A"));
13536
+ }))), detail === null || detail === void 0 ? void 0 : (_detail$child = detail.child) === null || _detail$child === void 0 ? void 0 : _detail$child.map((data, index) => {
13537
+ var _data$values;
13538
+ return /*#__PURE__*/React.createElement(Card, {
13539
+ className: "card-with-background",
13540
+ key: data.id || index,
13541
+ style: {
13542
+ margin: "10px 16px",
13543
+ padding: "20px"
13544
+ }
13545
+ }, /*#__PURE__*/React.createElement("div", {
13546
+ className: "card-head",
13547
+ style: {
13548
+ display: "flex",
13549
+ justifyContent: "space-between",
13550
+ alignItems: "center",
13551
+ marginBottom: "10px"
13552
+ }
13553
+ }, /*#__PURE__*/React.createElement("h2", {
13554
+ style: {
13555
+ fontSize: "18px",
13556
+ fontWeight: "bold"
13557
+ }
13558
+ }, t(detail.type), " ", index + 1), /*#__PURE__*/React.createElement("div", {
13559
+ style: {
13560
+ display: "flex",
13561
+ gap: "15px"
13562
+ }
13563
+ }, /*#__PURE__*/React.createElement("span", {
13564
+ onClick: () => history.push(`/digit-ui/employee/vendor/registry/modify-surveyor/${data.id}`)
13565
+ }, /*#__PURE__*/React.createElement(EditIcon, {
13566
+ fill: "#a82227",
13567
+ style: {
13568
+ cursor: "pointer"
13569
+ }
13570
+ })))), /*#__PURE__*/React.createElement("div", {
13571
+ className: "additional-grid"
13572
+ }, data === null || data === void 0 ? void 0 : (_data$values = data.values) === null || _data$values === void 0 ? void 0 : _data$values.map((value, idx) => /*#__PURE__*/React.createElement(React.Fragment, {
13573
+ key: idx
13574
+ }, /*#__PURE__*/React.createElement("div", {
13575
+ className: "additional-label"
13576
+ }, t(value.title)), /*#__PURE__*/React.createElement("div", {
13577
+ className: "additional-value"
13578
+ }, t(value.value) || "N/A")))));
13579
+ }), detail.type && /*#__PURE__*/React.createElement("div", {
13580
+ className: "add-details-link hover-button",
13581
+ style: {
13582
+ margin: "10px 16px",
13583
+ color: "#a82227",
13584
+ cursor: "pointer",
13585
+ display: "flex",
13586
+ alignItems: "center",
13587
+ gap: "5px",
13588
+ fontWeight: "bold"
13589
+ },
13590
+ onClick: () => history.push(`/digit-ui/employee/vendor/registry/new-surveyor?supervisorId=${supervisorId}`)
13591
+ }, /*#__PURE__*/React.createElement(AddIcon, {
13592
+ fill: "#a82227"
13593
+ }), t(`${detail.type}_ADD`)));
13594
+ }))), showModal && /*#__PURE__*/React.createElement(Modal, {
13595
+ headerBarMain: /*#__PURE__*/React.createElement(Heading$3, {
13596
+ label: t(modalHeading())
13597
+ }),
13598
+ headerBarEnd: /*#__PURE__*/React.createElement(CloseBtn$3, {
13599
+ onClick: closeModal
13600
+ }),
13601
+ actionCancelLabel: t("CS_COMMON_CANCEL"),
13602
+ actionCancelOnSubmit: closeModal,
13603
+ actionSaveLabel: t(selectedAction === "DELETE" || selectedAction === "DELETE_VENDOR" ? "ES_EVENT_DELETE" : "CS_COMMON_SUBMIT"),
13604
+ actionSaveOnSubmit: handleModalAction
13605
+ }, /*#__PURE__*/React.createElement(Card, {
13606
+ style: {
13607
+ boxShadow: "none"
13608
+ }
13609
+ }, renderModalContent())), showToast && /*#__PURE__*/React.createElement(Toast, {
13610
+ error: showToast.key === "error",
13611
+ label: t(showToast.key === "success" ? `ES_VENDOR_${showToast.action}_SUCCESS` : showToast.action),
13612
+ onClose: closeToast
13613
+ }), /*#__PURE__*/React.createElement(ActionBar, {
13614
+ style: {
13615
+ zIndex: "19"
13616
+ }
13617
+ }, displayMenu ? /*#__PURE__*/React.createElement(Menu, {
13618
+ localeKeyPrefix: "ES_VENDOR_SUPERVISOR_ACTION",
13619
+ options: ["EDIT", "DELETE"],
13620
+ t: t,
13621
+ onSelect: a => {
13622
+ setDisplayMenu(false);
13623
+ setSelectedAction(a);
13624
+ }
13625
+ }) : null, /*#__PURE__*/React.createElement(SubmitBar, {
13626
+ label: t("ES_COMMON_TAKE_ACTION"),
13627
+ onSubmit: () => setDisplayMenu(!displayMenu)
13628
+ })));
13629
+ };
13630
+
13631
+ const {
13632
+ DatePicker: DatePicker$4,
13633
+ Dropdown: Dropdown$3
13634
+ } = require("@djb25/digit-ui-react-components");
13635
+ const SurveyorConfig = (t, agencies = [], reportingManagers = [], disabled = false) => {
13636
+ return [{
13637
+ head: "ES_VENDOR_SURVEYOR_BASIC_DETAILS",
13638
+ body: [{
13639
+ label: "ES_VENDOR_SURVEYOR_FULL_NAME",
13640
+ isMandatory: true,
13641
+ type: "text",
13642
+ populators: {
13643
+ name: "fullName",
13644
+ validation: {
13645
+ required: true,
13646
+ pattern: /^[A-Za-z\s]+$/
13647
+ },
13648
+ error: t("ES_VENDOR_INVALID_NAME")
13649
+ }
13650
+ }, {
13651
+ label: "ES_VENDOR_SURVEYOR_MOBILE_NUMBER",
13652
+ isMandatory: true,
13653
+ type: "mobileNumber",
13654
+ populators: {
13655
+ name: "mobileNumber",
13656
+ validation: {
13657
+ required: true,
13658
+ pattern: /^[6-9]\d{9}$/
13659
+ },
13660
+ error: t("ES_VENDOR_INVALID_MOBILE")
13661
+ }
13662
+ }, {
13663
+ label: "ES_VENDOR_SURVEYOR_EMAIL_ID",
13664
+ isMandatory: true,
13665
+ type: "text",
13666
+ populators: {
13667
+ name: "emailId",
13668
+ validation: {
13669
+ required: true,
13670
+ pattern: /^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9.-]+$/
13671
+ },
13672
+ error: t("ES_VENDOR_INVALID_EMAIL")
13673
+ }
13674
+ }, {
13675
+ label: "ES_VENDOR_SURVEYOR_STAFF_CODE",
13676
+ isMandatory: true,
13677
+ type: "text",
13678
+ populators: {
13679
+ name: "employeeId",
13680
+ validation: {
13681
+ required: true
13682
+ }
13683
+ }
13684
+ }, {
13685
+ label: "ES_VENDOR_SURVEYOR_GENDER",
13686
+ isMandatory: false,
13687
+ type: "component",
13688
+ key: "selectGender",
13689
+ component: "SelectGender",
13690
+ texts: {
13691
+ header: "CS_COMMON_CHOOSE_GENDER",
13692
+ cardText: "CS_COMMON_SELECT_GENDER",
13693
+ submitBarLabel: "CS_COMMON_NEXT"
13694
+ }
13695
+ }]
13696
+ }, {
13697
+ head: "ES_VENDOR_SURVEYOR_ROLE_ACCESS",
13698
+ body: [{
13699
+ label: "ES_VENDOR_SURVEYOR_ROLE",
13700
+ isMandatory: true,
13701
+ type: "custom",
13702
+ populators: {
13703
+ name: "role",
13704
+ component: (props, customProps) => /*#__PURE__*/React.createElement(Dropdown$3, {
13705
+ option: [{
13706
+ code: "SURVEYOR",
13707
+ name: "Surveyor"
13708
+ }],
13709
+ optionKey: "name",
13710
+ select: props.onChange,
13711
+ selected: props.value,
13712
+ t: t,
13713
+ disable: true
13714
+ }),
13715
+ defaultValue: {
13716
+ code: "SURVEYOR",
13717
+ name: "Surveyor"
13718
+ }
13719
+ }
13720
+ }, {
13721
+ label: "ES_VENDOR_SURVEYOR_AGENCY_NAME",
13722
+ isMandatory: true,
13723
+ type: "custom",
13724
+ populators: {
13725
+ name: "agencyName",
13726
+ component: (props, customProps) => /*#__PURE__*/React.createElement(Dropdown$3, {
13727
+ option: agencies,
13728
+ optionKey: "name",
13729
+ select: props.onChange,
13730
+ selected: props.value,
13731
+ t: t
13732
+ })
13733
+ }
13734
+ }, {
13735
+ label: "ES_VENDOR_SURVEYOR_REPORTING_MANAGER",
13736
+ isMandatory: false,
13737
+ type: "custom",
13738
+ populators: {
13739
+ name: "reportingManager",
13740
+ component: (props, customProps) => /*#__PURE__*/React.createElement(Dropdown$3, {
13741
+ option: reportingManagers,
13742
+ optionKey: "name",
13743
+ select: props.onChange,
13744
+ selected: props.value,
13745
+ t: t
13746
+ })
13747
+ }
13748
+ }]
13749
+ }, {
13750
+ head: "ES_VENDOR_SURVEYOR_AREA_ASSIGNMENT",
13751
+ body: [{
13752
+ isMandatory: true,
13753
+ type: "component",
13754
+ key: "areaAssignment",
13755
+ component: "SupervisorAreaAssignment",
13756
+ withoutLabel: true
13757
+ }]
13758
+ }];
13759
+ };
13760
+
13761
+ const AddSurveyor = ({
13762
+ parentUrl,
13763
+ heading
13764
+ }) => {
13765
+ var _vendorsData$vendor;
13766
+ const tenantId = Digit.ULBService.getCurrentTenantId();
13767
+ const {
13768
+ t
13769
+ } = useTranslation();
13770
+ const [showToast, setShowToast] = useState(null);
13771
+ const [currentStep, setCurrentStep] = useState(1);
13772
+ const queryClient = useQueryClient();
13773
+ const [canSubmit, setCanSubmit] = useState(false);
13774
+ const {
13775
+ isLoading: isMutationLoading,
13776
+ mutate
13777
+ } = Digit.Hooks.fsm.useSurveyorCreate(tenantId);
13778
+ const {
13779
+ data: vendorsData,
13780
+ isLoading: isVendorsLoading
13781
+ } = Digit.Hooks.fsm.useVendorSearch(tenantId, {
13782
+ status: "ACTIVE"
13783
+ });
13784
+ const agencies = (vendorsData === null || vendorsData === void 0 ? void 0 : (_vendorsData$vendor = vendorsData.vendor) === null || _vendorsData$vendor === void 0 ? void 0 : _vendorsData$vendor.map(v => ({
13785
+ code: v.id,
13786
+ name: v.name,
13787
+ ...v
13788
+ }))) || [];
13789
+ const reportingManagers = [{
13790
+ code: "MGR1",
13791
+ name: "John Doe (Agency Admin)"
13792
+ }, {
13793
+ code: "SUP1",
13794
+ name: "Jane Smith (Supervisor)"
13795
+ }];
13796
+ const Config = SurveyorConfig(t, agencies, reportingManagers);
13797
+ const {
13798
+ supervisorId
13799
+ } = Digit.Hooks.useQueryParams();
13800
+ const defaultValues = {
13801
+ role: {
13802
+ code: "SURVEYOR",
13803
+ name: "Surveyor"
13804
+ },
13805
+ reportingManager: reportingManagers.find(m => m.code === supervisorId) || null
13806
+ };
13807
+ const onFormValueChange = (setValue, formData) => {
13808
+ var _formData$areaAssignm, _formData$areaAssignm2, _formData$areaAssignm3, _formData$areaAssignm4;
13809
+ const isBasicDetailsFilled = (formData === null || formData === void 0 ? void 0 : formData.fullName) && (formData === null || formData === void 0 ? void 0 : formData.mobileNumber) && (formData === null || formData === void 0 ? void 0 : formData.emailId) && (formData === null || formData === void 0 ? void 0 : formData.employeeId);
13810
+ const isRoleAccessFilled = formData === null || formData === void 0 ? void 0 : formData.agencyName;
13811
+ const isAreaAssignmentFilled = (formData === null || formData === void 0 ? void 0 : (_formData$areaAssignm = formData.areaAssignment) === null || _formData$areaAssignm === void 0 ? void 0 : _formData$areaAssignm.zone) && (formData === null || formData === void 0 ? void 0 : (_formData$areaAssignm2 = formData.areaAssignment) === null || _formData$areaAssignm2 === void 0 ? void 0 : _formData$areaAssignm2.ward) && (formData === null || formData === void 0 ? void 0 : (_formData$areaAssignm3 = formData.areaAssignment) === null || _formData$areaAssignm3 === void 0 ? void 0 : (_formData$areaAssignm4 = _formData$areaAssignm3.areas) === null || _formData$areaAssignm4 === void 0 ? void 0 : _formData$areaAssignm4.length) > 0;
13812
+ if (isBasicDetailsFilled && isRoleAccessFilled && isAreaAssignmentFilled) {
13813
+ setCanSubmit(true);
13814
+ } else {
13815
+ setCanSubmit(false);
13816
+ }
13817
+ };
13818
+ const closeToast = () => {
13819
+ setShowToast(null);
13820
+ };
13821
+ const onSubmit = data => {
13822
+ var _data$gender, _data$agencyName, _data$reportingManage;
13823
+ const formData = {
13824
+ surveyor: {
13825
+ tenantId: tenantId,
13826
+ name: data === null || data === void 0 ? void 0 : data.fullName,
13827
+ employeeId: data === null || data === void 0 ? void 0 : data.employeeId,
13828
+ status: "ACTIVE",
13829
+ owner: {
13830
+ tenantId: tenantId,
13831
+ name: data === null || data === void 0 ? void 0 : data.fullName,
13832
+ gender: (data === null || data === void 0 ? void 0 : (_data$gender = data.gender) === null || _data$gender === void 0 ? void 0 : _data$gender.code) || "OTHERS",
13833
+ emailId: data === null || data === void 0 ? void 0 : data.emailId,
13834
+ mobileNumber: data === null || data === void 0 ? void 0 : data.mobileNumber
13835
+ },
13836
+ vendorSurveyorStatus: "ACTIVE",
13837
+ additionalDetails: {
13838
+ agencyId: data === null || data === void 0 ? void 0 : (_data$agencyName = data.agencyName) === null || _data$agencyName === void 0 ? void 0 : _data$agencyName.code,
13839
+ reportingManager: data === null || data === void 0 ? void 0 : (_data$reportingManage = data.reportingManager) === null || _data$reportingManage === void 0 ? void 0 : _data$reportingManage.code,
13840
+ areaAssignment: data === null || data === void 0 ? void 0 : data.areaAssignment
13841
+ }
13842
+ }
13843
+ };
13844
+ mutate(formData, {
13845
+ onError: error => {
13846
+ setShowToast({
13847
+ key: "error",
13848
+ action: error
13849
+ });
13850
+ setTimeout(closeToast, 5000);
13851
+ },
13852
+ onSuccess: () => {
13853
+ setShowToast({
13854
+ key: "success",
13855
+ action: "ADD_SURVEYOR"
13856
+ });
13857
+ queryClient.invalidateQueries("SURVEYOR_SEARCH");
13858
+ setTimeout(closeToast, 5000);
13859
+ }
13860
+ });
13861
+ };
13862
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(VerticalTimeline, {
13863
+ config: [{
13864
+ route: "surveyor-details",
13865
+ timeLine: [{
13866
+ actions: t("ES_VENDOR_SURVEYOR_DETAILS"),
13867
+ currentStep: 1
13868
+ }]
13869
+ }],
13870
+ currentActiveIndex: currentStep - 1,
13871
+ showFinalStep: false
13872
+ }), /*#__PURE__*/React.createElement("div", {
13873
+ style: {
13874
+ flex: "1",
13875
+ overflowY: "auto"
13876
+ }
13877
+ }, /*#__PURE__*/React.createElement(FormComposer, {
13878
+ isDisabled: !canSubmit,
13879
+ label: t("ES_COMMON_APPLICATION_SUBMIT"),
13880
+ config: Config.map(config => ({
13881
+ ...config,
13882
+ isCollapsible: true,
13883
+ isDefaultOpen: true
13884
+ })),
13885
+ fieldStyle: {
13886
+ marginRight: 0
13887
+ },
13888
+ onSubmit: onSubmit,
13889
+ defaultValues: defaultValues,
13890
+ onFormValueChange: onFormValueChange,
13891
+ noBreakLine: true,
13892
+ mode: "onChange",
13893
+ noCard: true
13894
+ }), showToast && /*#__PURE__*/React.createElement(Toast, {
13895
+ error: showToast.key === "error",
13896
+ label: t(showToast.key === "success" ? `ES_VENDOR_${showToast.action}_SUCCESS` : showToast.action),
13897
+ onClose: closeToast
13898
+ })));
13899
+ };
13900
+
13901
+ const Heading$4 = props => {
13902
+ return /*#__PURE__*/React.createElement("h1", {
13903
+ className: "heading-m"
13904
+ }, props.label);
13905
+ };
13906
+ const Close$4 = () => /*#__PURE__*/React.createElement("svg", {
13907
+ xmlns: "http://www.w3.org/2000/svg",
13908
+ viewBox: "0 0 24 24",
13909
+ fill: "#FFFFFF"
13910
+ }, /*#__PURE__*/React.createElement("path", {
13911
+ d: "M0 0h24v24H0V0z",
13912
+ fill: "none"
13913
+ }), /*#__PURE__*/React.createElement("path", {
13914
+ d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"
13915
+ }));
13916
+ const CloseBtn$4 = props => {
13917
+ return /*#__PURE__*/React.createElement("div", {
13918
+ className: "icon-bg-secondary",
13919
+ onClick: props.onClick
13920
+ }, /*#__PURE__*/React.createElement(Close$4, null));
13921
+ };
13922
+ const SurveyorDetails = props => {
13923
+ var _surveyorData$5, _surveyorData$5$emplo;
13924
+ const tenantId = Digit.ULBService.getCurrentTenantId();
13925
+ const {
13926
+ t
13927
+ } = useTranslation();
13928
+ const history = useHistory();
13929
+ const queryClient = useQueryClient();
13930
+ const {
13931
+ id: surveyorId
13932
+ } = useParams();
13933
+ const [displayMenu, setDisplayMenu] = useState(false);
13934
+ const [selectedAction, setSelectedAction] = useState(null);
13935
+ const [showModal, setShowModal] = useState(false);
13936
+ const [showToast, setShowToast] = useState(null);
13937
+ const [vendors, setVendors] = useState([]);
13938
+ const [selectedOption, setSelectedOption] = useState({});
13939
+ const {
13940
+ data: surveyorData,
13941
+ isLoading: isLoading,
13942
+ refetch
13943
+ } = Digit.Hooks.fsm.useSurveyorDetails(tenantId, {
13944
+ ids: surveyorId
13945
+ }, {
13946
+ staleTime: Infinity
13947
+ });
13948
+ const {
13949
+ data: vendorData
13950
+ } = Digit.Hooks.fsm.useDsoSearch(tenantId, {
13951
+ sortBy: "name",
13952
+ sortOrder: "ASC",
13953
+ status: "ACTIVE"
13954
+ }, {});
13955
+ const {
13956
+ mutate: mutateSurveyor
13957
+ } = Digit.Hooks.fsm.useSurveyorUpdate(tenantId);
13958
+ const {
13959
+ mutate: mutateVendor
13960
+ } = Digit.Hooks.fsm.useVendorUpdate(tenantId);
13961
+ useEffect(() => {
13962
+ if (vendorData) {
13963
+ let vendors = vendorData.map(data => data.dsoDetails);
13964
+ setVendors(vendors);
13965
+ }
13966
+ }, [vendorData]);
13967
+ useEffect(() => {
13968
+ refetch();
13969
+ }, []);
13970
+ useEffect(() => {
13971
+ switch (selectedAction) {
13972
+ case "DELETE":
13973
+ case "ADD_VENDOR":
13974
+ case "EDIT_VENDOR":
13975
+ case "DELETE_VENDOR":
13976
+ return setShowModal(true);
13977
+ case "EDIT":
13978
+ return history.push("/digit-ui/employee/vendor/modify-surveyor/" + surveyorId);
13979
+ case "HOME":
13980
+ return history.push("/digit-ui/employee/vendor/search-vendor?selectedTabs=SURVEYOR");
13981
+ }
13982
+ }, [selectedAction]);
13983
+ const closeToast = () => {
13984
+ setShowToast(null);
13985
+ };
13986
+ const handleModalAction = () => {
13987
+ switch (selectedAction) {
13988
+ case "DELETE":
13989
+ return handleDeleteSurveyor();
13990
+ case "DELETE_VENDOR":
13991
+ return handleDeleteVendor();
13992
+ case "ADD_VENDOR":
13993
+ return handleAddVendor();
13994
+ case "EDIT_VENDOR":
13995
+ return handleEditVendor();
13996
+ }
13997
+ };
13998
+ const handleDeleteSurveyor = () => {
13999
+ var _surveyorData$;
14000
+ let details = surveyorData === null || surveyorData === void 0 ? void 0 : (_surveyorData$ = surveyorData[0]) === null || _surveyorData$ === void 0 ? void 0 : _surveyorData$.surveyorData;
14001
+ const formData = {
14002
+ surveyor: {
14003
+ ...details,
14004
+ status: "INACTIVE"
14005
+ }
14006
+ };
14007
+ mutateSurveyor(formData, {
14008
+ onError: error => {
14009
+ setShowToast({
14010
+ key: "error",
14011
+ action: error
14012
+ });
14013
+ setTimeout(closeToast, 5000);
14014
+ },
14015
+ onSuccess: () => {
14016
+ setShowToast({
14017
+ key: "success",
14018
+ action: "DELETE_SURVEYOR"
14019
+ });
14020
+ queryClient.invalidateQueries("SURVEYOR_SEARCH");
14021
+ setTimeout(() => {
14022
+ closeToast();
14023
+ history.push(`/digit-ui/employee/vendor/search-vendor`);
14024
+ }, 5000);
14025
+ }
14026
+ });
14027
+ setShowModal(false);
14028
+ };
14029
+ const handleDeleteVendor = () => {
14030
+ var _surveyorData$2, _surveyorData$2$vendo, _surveyorData$2$vendo2;
14031
+ let dsoDetails = surveyorData === null || surveyorData === void 0 ? void 0 : (_surveyorData$2 = surveyorData[0]) === null || _surveyorData$2 === void 0 ? void 0 : (_surveyorData$2$vendo = _surveyorData$2.vendorDetails) === null || _surveyorData$2$vendo === void 0 ? void 0 : (_surveyorData$2$vendo2 = _surveyorData$2$vendo.vendor) === null || _surveyorData$2$vendo2 === void 0 ? void 0 : _surveyorData$2$vendo2[0];
14032
+ let getSurveyorVendorDetails = (dsoDetails === null || dsoDetails === void 0 ? void 0 : dsoDetails.surveyors) || [];
14033
+ getSurveyorVendorDetails = getSurveyorVendorDetails.map(data => {
14034
+ if (data.id === surveyorId) {
14035
+ data.vendorSurveyorStatus = "INACTIVE";
14036
+ }
14037
+ return data;
14038
+ });
14039
+ const formData = {
14040
+ vendor: {
14041
+ ...dsoDetails,
14042
+ surveyors: getSurveyorVendorDetails
14043
+ }
14044
+ };
14045
+ mutateVendor(formData, {
14046
+ onError: error => {
14047
+ setShowToast({
14048
+ key: "error",
14049
+ action: error
14050
+ });
14051
+ setTimeout(closeToast, 5000);
14052
+ },
14053
+ onSuccess: () => {
14054
+ setShowToast({
14055
+ key: "success",
14056
+ action: "DELETE_VENDOR"
14057
+ });
14058
+ queryClient.invalidateQueries("FSM_VENDOR_SEARCH");
14059
+ refetch();
14060
+ setTimeout(closeToast, 5000);
14061
+ }
14062
+ });
14063
+ setShowModal(false);
14064
+ };
14065
+ const handleAddVendor = () => {
14066
+ var _surveyorData$3;
14067
+ let dsoDetails = selectedOption;
14068
+ let details = surveyorData === null || surveyorData === void 0 ? void 0 : (_surveyorData$3 = surveyorData[0]) === null || _surveyorData$3 === void 0 ? void 0 : _surveyorData$3.surveyorData;
14069
+ details.vendorSurveyorStatus = "ACTIVE";
14070
+ const formData = {
14071
+ vendor: {
14072
+ ...dsoDetails,
14073
+ surveyors: dsoDetails.surveyors ? [...dsoDetails.surveyors, details] : [details]
14074
+ }
14075
+ };
14076
+ mutateVendor(formData, {
14077
+ onError: error => {
14078
+ setShowToast({
14079
+ key: "error",
14080
+ action: error
14081
+ });
14082
+ refetch();
14083
+ setTimeout(closeToast, 5000);
14084
+ },
14085
+ onSuccess: () => {
14086
+ setShowToast({
14087
+ key: "success",
14088
+ action: "ADD_VENDOR"
14089
+ });
14090
+ queryClient.invalidateQueries("SURVEYOR_SEARCH");
14091
+ refetch();
14092
+ setTimeout(closeToast, 5000);
14093
+ }
14094
+ });
14095
+ setShowModal(false);
14096
+ setSelectedAction(null);
14097
+ };
14098
+ const handleEditVendor = () => {
14099
+ var _surveyorData$4;
14100
+ let dsoDetails = selectedOption;
14101
+ let details = surveyorData === null || surveyorData === void 0 ? void 0 : (_surveyorData$4 = surveyorData[0]) === null || _surveyorData$4 === void 0 ? void 0 : _surveyorData$4.surveyorData;
14102
+ details.vendorSurveyorStatus = "ACTIVE";
14103
+ const formData = {
14104
+ vendor: {
14105
+ ...dsoDetails,
14106
+ surveyors: dsoDetails.surveyors ? [...dsoDetails.surveyors, details] : [details]
14107
+ }
14108
+ };
14109
+ mutateVendor(formData, {
14110
+ onError: error => {
14111
+ setShowToast({
14112
+ key: "error",
14113
+ action: error
14114
+ });
14115
+ setTimeout(closeToast, 5000);
14116
+ },
14117
+ onSuccess: () => {
14118
+ setShowToast({
14119
+ key: "success",
14120
+ action: "EDIT_VENDOR"
14121
+ });
14122
+ refetch();
14123
+ queryClient.invalidateQueries("SURVEYOR_SEARCH");
14124
+ setTimeout(closeToast, 5000);
14125
+ }
14126
+ });
14127
+ setShowModal(false);
14128
+ setSelectedAction(null);
14129
+ };
14130
+ const closeModal = () => {
14131
+ setSelectedAction(null);
14132
+ setSelectedOption({});
14133
+ setShowModal(false);
14134
+ };
14135
+ const modalHeading = () => {
14136
+ switch (selectedAction) {
14137
+ case "DELETE":
14138
+ case "DELETE_VENDOR":
14139
+ return "ES_VENDOR_SURVEYOR_DELETE_POPUP_HEADER";
14140
+ case "ADD_VENDOR":
14141
+ case "EDIT_VENDOR":
14142
+ return "ES_VENDOR_SURVEYOR_ADD_VENDOR_POPUP_HEADER";
14143
+ }
14144
+ };
14145
+ const renderModalContent = () => {
14146
+ if (selectedAction === "DELETE" || selectedAction === "DELETE_VENDOR") {
14147
+ return /*#__PURE__*/React.createElement(ConfirmationBox, {
14148
+ t: t,
14149
+ title: "ES_VENDOR_SURVEYOR_DELETE_TEXT"
14150
+ });
14151
+ }
14152
+ if (selectedAction === "ADD_VENDOR" || selectedAction === "EDIT_VENDOR") {
14153
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CardText, null, t(`ES_FSM_REGISTRY_SELECT_VENODOR`)), /*#__PURE__*/React.createElement(Dropdown$4, {
14154
+ t: t,
14155
+ option: vendors,
14156
+ value: selectedOption,
14157
+ selected: selectedOption,
14158
+ select: setSelectedOption,
14159
+ optionKey: "name"
14160
+ }));
14161
+ }
14162
+ };
14163
+ if (isLoading) {
14164
+ return /*#__PURE__*/React.createElement(Loader, null);
14165
+ }
14166
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
14167
+ className: "employee-form-content"
14168
+ }, /*#__PURE__*/React.createElement(Card, {
14169
+ style: {
14170
+ position: "relative",
14171
+ backgroundColor: "#fff"
14172
+ }
14173
+ }, surveyorData === null || surveyorData === void 0 ? void 0 : (_surveyorData$5 = surveyorData[0]) === null || _surveyorData$5 === void 0 ? void 0 : (_surveyorData$5$emplo = _surveyorData$5.employeeResponse) === null || _surveyorData$5$emplo === void 0 ? void 0 : _surveyorData$5$emplo.map((detail, index) => {
14174
+ var _detail$values;
14175
+ return /*#__PURE__*/React.createElement(React.Fragment, {
14176
+ key: index
14177
+ }, index > 0 && /*#__PURE__*/React.createElement(CardSectionHeader, {
14178
+ style: {
14179
+ marginBottom: "16px",
14180
+ marginTop: "32px"
14181
+ }
14182
+ }, t(detail.title)), /*#__PURE__*/React.createElement(Card, {
14183
+ className: "card-with-background",
14184
+ style: {
14185
+ margin: "10px 16px",
14186
+ padding: "20px"
14187
+ }
14188
+ }, /*#__PURE__*/React.createElement("div", {
14189
+ className: "additional-grid"
14190
+ }, detail === null || detail === void 0 ? void 0 : (_detail$values = detail.values) === null || _detail$values === void 0 ? void 0 : _detail$values.map((value, index) => {
14191
+ return (value === null || value === void 0 ? void 0 : value.type) === "custom" ? /*#__PURE__*/React.createElement(React.Fragment, {
14192
+ key: index
14193
+ }, /*#__PURE__*/React.createElement("div", {
14194
+ className: "additional-label"
14195
+ }, t(value.title)), /*#__PURE__*/React.createElement("div", {
14196
+ className: "additional-value",
14197
+ style: {
14198
+ color: "#a82227",
14199
+ display: "flex",
14200
+ gap: "20px",
14201
+ alignItems: "center"
14202
+ }
14203
+ }, t(value.value) || "N/A", value.value === "ES_FSM_REGISTRY_DETAILS_ADD_VENDOR" && /*#__PURE__*/React.createElement("span", {
14204
+ className: "add-details-link hover-button",
14205
+ onClick: () => setSelectedAction("ADD_VENDOR"),
14206
+ style: {
14207
+ cursor: "pointer"
14208
+ }
14209
+ }, /*#__PURE__*/React.createElement(AddIcon, {
14210
+ fill: "#a82227"
14211
+ })), value.value !== "ES_FSM_REGISTRY_DETAILS_ADD_VENDOR" && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
14212
+ className: "add-details-link hover-button",
14213
+ onClick: () => setSelectedAction("EDIT_VENDOR"),
14214
+ style: {
14215
+ cursor: "pointer"
14216
+ }
14217
+ }, /*#__PURE__*/React.createElement(EditIcon, null)), /*#__PURE__*/React.createElement("div", {
14218
+ className: "add-details-link hover-button",
14219
+ onClick: () => setSelectedAction("DELETE_VENDOR"),
14220
+ style: {
14221
+ cursor: "pointer"
14222
+ }
14223
+ }, /*#__PURE__*/React.createElement(DeleteIcon, {
14224
+ fill: "#a82227"
14225
+ }))))) : /*#__PURE__*/React.createElement(React.Fragment, {
14226
+ key: index
14227
+ }, /*#__PURE__*/React.createElement("div", {
14228
+ className: "additional-label"
14229
+ }, t(value.title)), /*#__PURE__*/React.createElement("div", {
14230
+ className: "additional-value"
14231
+ }, t(value.value) || "N/A"));
14232
+ }))));
14233
+ }))), showModal && /*#__PURE__*/React.createElement(Modal, {
14234
+ headerBarMain: /*#__PURE__*/React.createElement(Heading$4, {
14235
+ label: t(modalHeading())
14236
+ }),
14237
+ headerBarEnd: /*#__PURE__*/React.createElement(CloseBtn$4, {
14238
+ onClick: closeModal
14239
+ }),
14240
+ actionCancelLabel: t("CS_COMMON_CANCEL"),
14241
+ actionCancelOnSubmit: closeModal,
14242
+ actionSaveLabel: t(selectedAction === "DELETE" || selectedAction === "DELETE_VENDOR" ? "ES_EVENT_DELETE" : "CS_COMMON_SUBMIT"),
14243
+ actionSaveOnSubmit: handleModalAction
14244
+ }, /*#__PURE__*/React.createElement(Card, {
14245
+ style: {
14246
+ boxShadow: "none"
14247
+ }
14248
+ }, renderModalContent())), showToast && /*#__PURE__*/React.createElement(Toast, {
14249
+ error: showToast.key === "error",
14250
+ label: t(showToast.key === "success" ? `ES_VENDOR_${showToast.action}_SUCCESS` : showToast.action),
14251
+ onClose: closeToast
14252
+ }), /*#__PURE__*/React.createElement(ActionBar, {
14253
+ style: {
14254
+ zIndex: "19"
14255
+ }
14256
+ }, displayMenu ? /*#__PURE__*/React.createElement(Menu, {
14257
+ localeKeyPrefix: "ES_VENDOR_SURVEYOR_ACTION",
14258
+ options: ["EDIT", "DELETE"],
14259
+ t: t,
14260
+ onSelect: a => {
14261
+ setDisplayMenu(false);
14262
+ setSelectedAction(a);
14263
+ }
14264
+ }) : null, /*#__PURE__*/React.createElement(SubmitBar, {
14265
+ label: t("ES_COMMON_TAKE_ACTION"),
14266
+ onSubmit: () => setDisplayMenu(!displayMenu)
14267
+ })));
14268
+ };
14269
+
12212
14270
  const componentsToRegister = {
12213
14271
  VendorDetails,
12214
14272
  VendorDocuments,
@@ -12227,7 +14285,12 @@ const componentsToRegister = {
12227
14285
  VENDORCheckPage: CheckPage,
12228
14286
  NewResponse,
12229
14287
  DriverDetails,
12230
- VehicleDetails
14288
+ VehicleDetails,
14289
+ AddSupervisor,
14290
+ SupervisorDetails,
14291
+ SupervisorAreaAssignment,
14292
+ AddSurveyor,
14293
+ SurveyorDetails
12231
14294
  };
12232
14295
  const addComponentsToRegistry = () => {
12233
14296
  Object.entries(componentsToRegister).forEach(([key, value]) => {