@djb25/digit-ui-module-vendor 1.0.38 → 1.0.40

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.
@@ -26,8 +26,10 @@ const EmployeeApp = ({
26
26
  const VehicleDetails = Digit.ComponentRegistryService.getComponent("VehicleDetails");
27
27
  const AddSupervisor = Digit.ComponentRegistryService.getComponent("AddSupervisor");
28
28
  const SupervisorDetails = Digit.ComponentRegistryService.getComponent("SupervisorDetails");
29
+ const EditSupervisor = Digit.ComponentRegistryService.getComponent("EditSupervisor");
29
30
  const AddSurveyor = Digit.ComponentRegistryService.getComponent("AddSurveyor");
30
31
  const SurveyorDetails = Digit.ComponentRegistryService.getComponent("SurveyorDetails");
32
+ const EditSurveyor = Digit.ComponentRegistryService.getComponent("EditSurveyor");
31
33
  const EditDriver = Digit.ComponentRegistryService.getComponent("EditDriver");
32
34
  const EditVehicle = Digit.ComponentRegistryService.getComponent("EditVehicle");
33
35
  const getDynamicBreadcrumbs = () => {
@@ -192,6 +194,13 @@ const EmployeeApp = ({
192
194
  }, /*#__PURE__*/React.createElement(SupervisorDetails, Object.assign({}, props, {
193
195
  parentRoute: path
194
196
  })))
197
+ }), /*#__PURE__*/React.createElement(PrivateRoute, {
198
+ path: `${path}/registry/modify-supervisor/:id`,
199
+ component: props => /*#__PURE__*/React.createElement(LayoutWrapper, {
200
+ layoutClass: "action"
201
+ }, /*#__PURE__*/React.createElement(EditSupervisor, Object.assign({}, props, {
202
+ parentRoute: path
203
+ })))
195
204
  }), /*#__PURE__*/React.createElement(PrivateRoute, {
196
205
  path: `${path}/registry/new-surveyor`,
197
206
  component: props => /*#__PURE__*/React.createElement(LayoutWrapper, {
@@ -206,6 +215,13 @@ const EmployeeApp = ({
206
215
  }, /*#__PURE__*/React.createElement(SurveyorDetails, Object.assign({}, props, {
207
216
  parentRoute: path
208
217
  })))
218
+ }), /*#__PURE__*/React.createElement(PrivateRoute, {
219
+ path: `${path}/registry/modify-surveyor/:id`,
220
+ component: props => /*#__PURE__*/React.createElement(LayoutWrapper, {
221
+ layoutClass: "action"
222
+ }, /*#__PURE__*/React.createElement(EditSurveyor, Object.assign({}, props, {
223
+ parentRoute: path
224
+ })))
209
225
  })))));
210
226
  };
211
227
 
@@ -215,7 +231,10 @@ const VENDORCard = () => {
215
231
  } = useTranslation();
216
232
  const history = useHistory();
217
233
  const isCitizen = window.location.pathname.toLowerCase().includes("citizen");
218
- const hasAccess = Digit.Utils.vendorAccess() || Digit.UserService.hasAccess(["WT_VENDOR", "MT_VENDOR"]);
234
+ let hasAccess = Digit.Utils.vendorAccess() || Digit.UserService.hasAccess(["WT_VENDOR", "MT_VENDOR"]);
235
+ if (isCitizen) {
236
+ hasAccess = Digit.UserService.hasAccess(["WT_VENDOR", "EKYC_VENDOR", "EKYC_SUPERVISOR"]);
237
+ }
219
238
  if (!hasAccess) {
220
239
  return null;
221
240
  }
@@ -3415,7 +3434,6 @@ const VendorInbox = props => {
3415
3434
  ekyc: matchedEkycRoles,
3416
3435
  wt: matchedWtRoles
3417
3436
  };
3418
- console.log(matchedRoles);
3419
3437
  return /*#__PURE__*/React.createElement("div", {
3420
3438
  className: "inbox-container"
3421
3439
  }, props.userRole !== "FSM_EMP_FSTPO" && props.userRole !== "FSM_ADMIN" && !props.isSearch && /*#__PURE__*/React.createElement("div", {
@@ -5901,7 +5919,8 @@ const AddSupervisor = ({
5901
5919
  setShowToast(null);
5902
5920
  };
5903
5921
  const onSubmit = data => {
5904
- var _data$assignedZone, _data$relationship, _data$gender;
5922
+ var _userInfo$roles, _Digit$UserService$ge2, _data$assignedZone, _data$relationship, _data$gender;
5923
+ const isVendor = userInfo === null || userInfo === void 0 ? void 0 : (_userInfo$roles = userInfo.roles) === null || _userInfo$roles === void 0 ? void 0 : _userInfo$roles.some(role => role.code === "EKYC_VENDOR");
5905
5924
  const formData = {
5906
5925
  RequestInfo: {
5907
5926
  apiId: "Rainmaker",
@@ -5909,16 +5928,18 @@ const AddSupervisor = ({
5909
5928
  ts: null,
5910
5929
  action: "_create",
5911
5930
  msgId: `${Date.now()}|en_IN`,
5912
- authToken: userInfo === null || userInfo === void 0 ? void 0 : userInfo.authToken,
5913
- userInfo: {
5914
- id: userInfo === null || userInfo === void 0 ? void 0 : userInfo.id,
5915
- uuid: userInfo === null || userInfo === void 0 ? void 0 : userInfo.uuid,
5916
- userName: userInfo === null || userInfo === void 0 ? void 0 : userInfo.userName,
5917
- name: userInfo === null || userInfo === void 0 ? void 0 : userInfo.name,
5918
- type: userInfo === null || userInfo === void 0 ? void 0 : userInfo.type,
5919
- tenantId: tenantId,
5920
- roles: userInfo === null || userInfo === void 0 ? void 0 : userInfo.roles
5921
- }
5931
+ authToken: ((_Digit$UserService$ge2 = Digit.UserService.getUser()) === null || _Digit$UserService$ge2 === void 0 ? void 0 : _Digit$UserService$ge2.access_token) || (userInfo === null || userInfo === void 0 ? void 0 : userInfo.authToken),
5932
+ ...(isVendor && {
5933
+ userInfo: {
5934
+ id: userInfo === null || userInfo === void 0 ? void 0 : userInfo.id,
5935
+ uuid: userInfo === null || userInfo === void 0 ? void 0 : userInfo.uuid,
5936
+ userName: userInfo === null || userInfo === void 0 ? void 0 : userInfo.userName,
5937
+ name: userInfo === null || userInfo === void 0 ? void 0 : userInfo.name,
5938
+ type: userInfo === null || userInfo === void 0 ? void 0 : userInfo.type,
5939
+ tenantId: (userInfo === null || userInfo === void 0 ? void 0 : userInfo.tenantId) || rawTenantId,
5940
+ roles: userInfo === null || userInfo === void 0 ? void 0 : userInfo.roles
5941
+ }
5942
+ })
5922
5943
  },
5923
5944
  supervisor: {
5924
5945
  tenantId: tenantId,
@@ -5995,310 +6016,44 @@ const AddSupervisor = ({
5995
6016
  })));
5996
6017
  };
5997
6018
 
5998
- const {
5999
- Dropdown: Dropdown$2,
6000
- DatePicker: DatePicker$2
6001
- } = require("@djb25/digit-ui-react-components");
6002
- const SurveyorConfig = (t, agencies = [], reportingManagers = [], disabled = false) => {
6003
- return [{
6004
- head: "ES_VENDOR_SURVEYOR_BASIC_DETAILS",
6005
- body: [{
6006
- label: "ES_VENDOR_SURVEYOR_FULL_NAME",
6007
- isMandatory: true,
6008
- type: "text",
6009
- populators: {
6010
- name: "fullName",
6011
- validation: {
6012
- required: true,
6013
- pattern: /^[A-Za-z\s]+$/
6014
- },
6015
- error: t("ES_VENDOR_INVALID_NAME")
6016
- }
6017
- }, {
6018
- label: "ES_VENDOR_SURVEYOR_MOBILE_NUMBER",
6019
- isMandatory: true,
6020
- type: "mobileNumber",
6021
- populators: {
6022
- name: "mobileNumber",
6023
- validation: {
6024
- required: true,
6025
- pattern: /^[6-9]\d{9}$/
6026
- },
6027
- error: t("ES_VENDOR_INVALID_MOBILE")
6028
- }
6029
- }, {
6030
- label: "ES_VENDOR_SURVEYOR_EMAIL_ID",
6031
- isMandatory: true,
6032
- type: "text",
6033
- populators: {
6034
- name: "emailId",
6035
- validation: {
6036
- required: true,
6037
- pattern: /^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9.-]+$/
6038
- },
6039
- error: t("ES_VENDOR_INVALID_EMAIL")
6040
- }
6041
- }, {
6042
- label: "ES_VENDOR_SURVEYOR_STAFF_CODE",
6043
- isMandatory: true,
6044
- type: "text",
6045
- populators: {
6046
- name: "employeeId",
6047
- validation: {
6048
- required: true
6049
- }
6050
- }
6051
- }, {
6052
- label: t("ES_VENDOR_SURVEYOR_GENDER"),
6053
- isMandatory: true,
6054
- type: "component",
6055
- key: "gender",
6056
- component: "SelectGender"
6057
- }, {
6058
- label: t("ES_FSM_REGISTRY_NEW_FATHER_NAME"),
6059
- isMandatory: true,
6060
- type: "text",
6061
- populators: {
6062
- name: "fatherOrHusbandName",
6063
- validation: {
6064
- required: true
6065
- },
6066
- className: "payment-form-text-input-correction"
6067
- }
6068
- }, {
6069
- label: t("ES_FSM_REGISTRY_NEW_RELATIONSHIP"),
6070
- isMandatory: true,
6071
- type: "component",
6072
- key: "relationship",
6073
- component: "SelectEkycDropdown",
6074
- populators: {
6075
- name: "relationship",
6076
- options: [{
6077
- code: "FATHER",
6078
- name: "ES_COMMON_RELATION_FATHER"
6079
- }, {
6080
- code: "HUSBAND",
6081
- name: "ES_COMMON_RELATION_HUSBAND"
6082
- }, {
6083
- code: "OTHER",
6084
- name: "ES_COMMON_RELATION_OTHER"
6085
- }],
6086
- optionsKey: "name"
6087
- }
6088
- }, {
6089
- label: t("ES_FSM_REGISTRY_NEW_DOB"),
6090
- isMandatory: true,
6091
- type: "custom",
6092
- key: "dob",
6093
- populators: {
6094
- name: "dob",
6095
- validation: {
6096
- required: true
6097
- },
6098
- component: (props, customProps) => /*#__PURE__*/React.createElement(DatePicker$2, Object.assign({
6099
- onChange: props.onChange,
6100
- date: props.value
6101
- }, customProps))
6102
- }
6103
- }, {
6104
- label: t("ES_FSM_REGISTRY_NEW_CORRESPONDENCE_ADDRESS"),
6105
- isMandatory: true,
6106
- type: "text",
6107
- populators: {
6108
- name: "correspondenceAddress",
6109
- validation: {
6110
- required: true
6111
- },
6112
- className: "payment-form-text-input-correction"
6113
- }
6114
- }, {
6115
- label: t("ES_VENDOR_SURVEYOR_DESCRIPTION"),
6116
- isMandatory: false,
6117
- type: "text",
6118
- populators: {
6119
- name: "description",
6120
- className: "payment-form-text-input-correction"
6121
- }
6122
- }]
6123
- }];
6019
+ const Heading$1 = props => {
6020
+ return /*#__PURE__*/React.createElement("h1", {
6021
+ className: "heading-m"
6022
+ }, props.label);
6124
6023
  };
6125
-
6126
- const AddSurveyor = ({
6127
- parentUrl,
6128
- heading
6129
- }) => {
6130
- var _Digit$UserService$ge;
6024
+ const Close$1 = () => /*#__PURE__*/React.createElement("svg", {
6025
+ xmlns: "http://www.w3.org/2000/svg",
6026
+ viewBox: "0 0 24 24",
6027
+ fill: "#FFFFFF"
6028
+ }, /*#__PURE__*/React.createElement("path", {
6029
+ d: "M0 0h24v24H0V0z",
6030
+ fill: "none"
6031
+ }), /*#__PURE__*/React.createElement("path", {
6032
+ 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"
6033
+ }));
6034
+ const CloseBtn$1 = props => {
6035
+ return /*#__PURE__*/React.createElement("div", {
6036
+ className: "icon-bg-secondary",
6037
+ onClick: props.onClick
6038
+ }, /*#__PURE__*/React.createElement(Close$1, null));
6039
+ };
6040
+ const SupervisorDetails = props => {
6041
+ var _supervisorData$5, _supervisorData$5$emp;
6042
+ const tenantId = Digit.ULBService.getCurrentTenantId();
6131
6043
  const {
6132
6044
  t
6133
6045
  } = useTranslation();
6134
- const userInfo = (_Digit$UserService$ge = Digit.UserService.getUser()) === null || _Digit$UserService$ge === void 0 ? void 0 : _Digit$UserService$ge.info;
6135
- const rawTenantId = Digit.ULBService.getCurrentTenantId();
6136
- const tenantId = rawTenantId !== null && rawTenantId !== void 0 && rawTenantId.includes(".") ? rawTenantId : `${rawTenantId}.djb`;
6137
- const [showToast, setShowToast] = useState(null);
6046
+ const history = useHistory();
6138
6047
  const queryClient = useQueryClient();
6139
- const [canSubmit, setCanSubmit] = useState(false);
6140
6048
  const {
6141
- mutate
6142
- } = Digit.Hooks.fsm.useSurveyorCreate(tenantId);
6143
- const {
6144
- search
6145
- } = useLocation();
6146
- const queryParams = new URLSearchParams(search);
6147
- const vendorIdParam = queryParams.get("vendorId");
6148
- const Config = SurveyorConfig(t);
6149
- const defaultValues = {
6150
- role: {
6151
- code: "SURVEYOR",
6152
- name: "Surveyor"
6153
- }
6154
- };
6155
- const onFormValueChange = (setValue, formData) => {
6156
- 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) && (formData === null || formData === void 0 ? void 0 : formData.fatherOrHusbandName) && (formData === null || formData === void 0 ? void 0 : formData.relationship) && (formData === null || formData === void 0 ? void 0 : formData.dob) && (formData === null || formData === void 0 ? void 0 : formData.correspondenceAddress);
6157
- if (isBasicDetailsFilled) {
6158
- setCanSubmit(true);
6159
- } else {
6160
- setCanSubmit(false);
6161
- }
6162
- };
6163
- const closeToast = () => {
6164
- setShowToast(null);
6165
- };
6166
- const onSubmit = data => {
6167
- var _data$agencyName, _data$agencyName2, _data$reportingManage, _data$reportingManage2, _data$relationship, _data$gender;
6168
- const formData = {
6169
- RequestInfo: {
6170
- apiId: "Rainmaker",
6171
- ver: "1.0",
6172
- ts: null,
6173
- action: "_create",
6174
- msgId: `${Date.now()}|en_IN`,
6175
- authToken: userInfo === null || userInfo === void 0 ? void 0 : userInfo.authToken,
6176
- userInfo: {
6177
- id: userInfo === null || userInfo === void 0 ? void 0 : userInfo.id,
6178
- uuid: userInfo === null || userInfo === void 0 ? void 0 : userInfo.uuid,
6179
- userName: userInfo === null || userInfo === void 0 ? void 0 : userInfo.userName,
6180
- name: userInfo === null || userInfo === void 0 ? void 0 : userInfo.name,
6181
- type: userInfo === null || userInfo === void 0 ? void 0 : userInfo.type,
6182
- tenantId: tenantId,
6183
- roles: userInfo === null || userInfo === void 0 ? void 0 : userInfo.roles
6184
- }
6185
- },
6186
- surveyor: {
6187
- tenantId: tenantId,
6188
- vendorId: vendorIdParam || (data === null || data === void 0 ? void 0 : (_data$agencyName = data.agencyName) === null || _data$agencyName === void 0 ? void 0 : _data$agencyName.code) || (data === null || data === void 0 ? void 0 : (_data$agencyName2 = data.agencyName) === null || _data$agencyName2 === void 0 ? void 0 : _data$agencyName2.id) || (userInfo === null || userInfo === void 0 ? void 0 : userInfo.uuid),
6189
- supervisorId: (data === null || data === void 0 ? void 0 : (_data$reportingManage = data.reportingManager) === null || _data$reportingManage === void 0 ? void 0 : _data$reportingManage.code) || (data === null || data === void 0 ? void 0 : (_data$reportingManage2 = data.reportingManager) === null || _data$reportingManage2 === void 0 ? void 0 : _data$reportingManage2.id) || null,
6190
- description: (data === null || data === void 0 ? void 0 : data.description) || "",
6191
- additionalDetails: {
6192
- serviceType: "ekyc"
6193
- },
6194
- owner: {
6195
- tenantId: tenantId,
6196
- name: data === null || data === void 0 ? void 0 : data.fullName,
6197
- fatherOrHusbandName: data === null || data === void 0 ? void 0 : data.fatherOrHusbandName,
6198
- relationship: data === null || data === void 0 ? void 0 : (_data$relationship = data.relationship) === null || _data$relationship === void 0 ? void 0 : _data$relationship.code,
6199
- gender: (data === null || data === void 0 ? void 0 : (_data$gender = data.gender) === null || _data$gender === void 0 ? void 0 : _data$gender.code) || "OTHERS",
6200
- dob: data !== null && data !== void 0 && data.dob ? new Date(data.dob).getTime() : null,
6201
- emailId: data === null || data === void 0 ? void 0 : data.emailId,
6202
- mobileNumber: data === null || data === void 0 ? void 0 : data.mobileNumber,
6203
- correspondenceAddress: data === null || data === void 0 ? void 0 : data.correspondenceAddress
6204
- }
6205
- }
6206
- };
6207
- mutate(formData, {
6208
- onError: error => {
6209
- setShowToast({
6210
- key: "error",
6211
- action: error
6212
- });
6213
- setTimeout(closeToast, 5000);
6214
- },
6215
- onSuccess: () => {
6216
- setShowToast({
6217
- key: "success",
6218
- action: "ADD_SURVEYOR"
6219
- });
6220
- queryClient.invalidateQueries("SURVEYOR_SEARCH");
6221
- setTimeout(closeToast, 5000);
6222
- }
6223
- });
6224
- };
6225
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(VerticalTimeline, {
6226
- config: [{
6227
- route: "surveyor-details",
6228
- timeLine: [{
6229
- actions: t("ES_VENDOR_SURVEYOR_DETAILS"),
6230
- currentStep: 1
6231
- }]
6232
- }],
6233
- currentActiveIndex: 0,
6234
- showFinalStep: false
6235
- }), /*#__PURE__*/React.createElement("div", {
6236
- style: {
6237
- flex: "1",
6238
- overflowY: "auto"
6239
- }
6240
- }, /*#__PURE__*/React.createElement(FormComposer, {
6241
- isDisabled: !canSubmit,
6242
- label: t("ES_COMMON_APPLICATION_SUBMIT"),
6243
- config: Config.map(config => ({
6244
- ...config,
6245
- isCollapsible: true,
6246
- isDefaultOpen: true
6247
- })),
6248
- fieldStyle: {
6249
- marginRight: 0
6250
- },
6251
- onSubmit: onSubmit,
6252
- defaultValues: defaultValues,
6253
- onFormValueChange: onFormValueChange,
6254
- noBreakLine: true,
6255
- mode: "onChange",
6256
- noCard: true
6257
- }), showToast && /*#__PURE__*/React.createElement(Toast, {
6258
- error: showToast.key === "error",
6259
- label: t(showToast.key === "success" ? `ES_VENDOR_${showToast.action}_SUCCESS` : showToast.action),
6260
- onClose: closeToast
6261
- })));
6262
- };
6263
-
6264
- const Heading$1 = props => {
6265
- return /*#__PURE__*/React.createElement("h1", {
6266
- className: "heading-m"
6267
- }, props.label);
6268
- };
6269
- const Close$1 = () => /*#__PURE__*/React.createElement("svg", {
6270
- xmlns: "http://www.w3.org/2000/svg",
6271
- viewBox: "0 0 24 24",
6272
- fill: "#FFFFFF"
6273
- }, /*#__PURE__*/React.createElement("path", {
6274
- d: "M0 0h24v24H0V0z",
6275
- fill: "none"
6276
- }), /*#__PURE__*/React.createElement("path", {
6277
- 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"
6278
- }));
6279
- const CloseBtn$1 = props => {
6280
- return /*#__PURE__*/React.createElement("div", {
6281
- className: "icon-bg-secondary",
6282
- onClick: props.onClick
6283
- }, /*#__PURE__*/React.createElement(Close$1, null));
6284
- };
6285
- const SurveyorDetails = props => {
6286
- var _surveyorData$5, _surveyorData$5$emplo;
6287
- const tenantId = Digit.ULBService.getCurrentTenantId();
6288
- const {
6289
- t
6290
- } = useTranslation();
6291
- const history = useHistory();
6292
- const queryClient = useQueryClient();
6293
- const {
6294
- id: surveyorId
6295
- } = useParams();
6296
- const [displayMenu, setDisplayMenu] = useState(false);
6297
- const [selectedAction, setSelectedAction] = useState(null);
6298
- const [showModal, setShowModal] = useState(false);
6299
- const [showToast, setShowToast] = useState(null);
6300
- const [vendors, setVendors] = useState([]);
6301
- const [selectedOption, setSelectedOption] = useState({});
6049
+ id: supervisorId
6050
+ } = useParams();
6051
+ const [displayMenu, setDisplayMenu] = useState(false);
6052
+ const [selectedAction, setSelectedAction] = useState(null);
6053
+ const [showModal, setShowModal] = useState(false);
6054
+ const [showToast, setShowToast] = useState(null);
6055
+ const [vendors, setVendors] = useState([]);
6056
+ const [selectedOption, setSelectedOption] = useState({});
6302
6057
  const {
6303
6058
  data: vendorData
6304
6059
  } = Digit.Hooks.fsm.useDsoSearch(tenantId, {
@@ -6307,18 +6062,18 @@ const SurveyorDetails = props => {
6307
6062
  status: "ACTIVE"
6308
6063
  }, {});
6309
6064
  const {
6310
- data: surveyorSearchResponse,
6065
+ data: supervisorSearchResponse,
6311
6066
  isLoading,
6312
6067
  refetch
6313
- } = Digit.Hooks.fsm.useSurveyorSearch(tenantId, {
6314
- ids: surveyorId
6068
+ } = Digit.Hooks.fsm.useSupervisorSearch(tenantId, {
6069
+ ids: supervisorId
6315
6070
  }, {
6316
6071
  staleTime: Infinity
6317
6072
  });
6318
- const surveyorData = React.useMemo(() => {
6319
- var _surveyorSearchRespon;
6320
- if (!(surveyorSearchResponse !== null && surveyorSearchResponse !== void 0 && (_surveyorSearchRespon = surveyorSearchResponse.surveyors) !== null && _surveyorSearchRespon !== void 0 && _surveyorSearchRespon.length)) return [];
6321
- return surveyorSearchResponse.surveyors.map(data => {
6073
+ const supervisorData = React.useMemo(() => {
6074
+ var _supervisorSearchResp;
6075
+ if (!(supervisorSearchResponse !== null && supervisorSearchResponse !== void 0 && (_supervisorSearchResp = supervisorSearchResponse.supervisors) !== null && _supervisorSearchResp !== void 0 && _supervisorSearchResp.length)) return [];
6076
+ return supervisorSearchResponse.supervisors.map(data => {
6322
6077
  var _mappedVendor$dsoDeta, _data$owner, _data$owner2, _data$owner3;
6323
6078
  const mappedVendor = vendorData === null || vendorData === void 0 ? void 0 : vendorData.find(v => {
6324
6079
  var _v$dsoDetails, _v$dsoDetails2;
@@ -6326,39 +6081,43 @@ const SurveyorDetails = props => {
6326
6081
  });
6327
6082
  const vendorName = (mappedVendor === null || mappedVendor === void 0 ? void 0 : (_mappedVendor$dsoDeta = mappedVendor.dsoDetails) === null || _mappedVendor$dsoDeta === void 0 ? void 0 : _mappedVendor$dsoDeta.name) || data.vendorId || "ES_FSM_REGISTRY_DETAILS_ADD_VENDOR";
6328
6083
  return {
6329
- surveyorData: data,
6084
+ supervisorData: data,
6330
6085
  vendorDetails: {
6331
6086
  vendor: mappedVendor ? [mappedVendor.dsoDetails] : []
6332
6087
  },
6333
6088
  employeeResponse: [{
6334
- title: "ES_VENDOR_SURVEYOR_BASIC_DETAILS",
6089
+ title: "ES_VENDOR_SUPERVISOR_BASIC_DETAILS",
6335
6090
  values: [{
6336
- title: "ES_VENDOR_SURVEYOR_FULL_NAME",
6091
+ title: "ES_VENDOR_SUPERVISOR_FULL_NAME",
6337
6092
  value: data === null || data === void 0 ? void 0 : data.name
6338
6093
  }, {
6339
- title: "ES_VENDOR_SURVEYOR_MOBILE_NUMBER",
6094
+ title: "ES_VENDOR_SUPERVISOR_MOBILE_NUMBER",
6340
6095
  value: (data === null || data === void 0 ? void 0 : (_data$owner = data.owner) === null || _data$owner === void 0 ? void 0 : _data$owner.mobileNumber) || (data === null || data === void 0 ? void 0 : data.mobileNo)
6341
6096
  }, {
6342
- title: "ES_VENDOR_SURVEYOR_EMAIL_ID",
6097
+ title: "ES_VENDOR_SUPERVISOR_EMAIL_ID",
6343
6098
  value: data === null || data === void 0 ? void 0 : (_data$owner2 = data.owner) === null || _data$owner2 === void 0 ? void 0 : _data$owner2.emailId
6344
6099
  }, {
6345
- title: "ES_VENDOR_SURVEYOR_STAFF_CODE",
6100
+ title: "ES_VENDOR_SUPERVISOR_STAFF_CODE",
6346
6101
  value: (data === null || data === void 0 ? void 0 : data.employeeId) || "N/A"
6347
6102
  }, {
6348
- title: "ES_VENDOR_SURVEYOR_GENDER",
6103
+ title: "ES_VENDOR_SUPERVISOR_GENDER",
6349
6104
  value: data === null || data === void 0 ? void 0 : (_data$owner3 = data.owner) === null || _data$owner3 === void 0 ? void 0 : _data$owner3.gender
6350
6105
  }, {
6351
- title: "ES_VENDOR_SURVEYOR_AGENCY_NAME",
6106
+ title: "ES_VENDOR_SUPERVISOR_AGENCY_NAME",
6352
6107
  value: vendorName,
6353
6108
  type: "custom"
6354
6109
  }]
6110
+ }, {
6111
+ title: "ES_VENDOR_SUPERVISOR_MAPPED_SURVEYORS",
6112
+ type: "ES_FSM_REGISTRY_DETAILS_TYPE_SURVEYOR",
6113
+ child: []
6355
6114
  }]
6356
6115
  };
6357
6116
  });
6358
- }, [surveyorSearchResponse, vendorData]);
6117
+ }, [supervisorSearchResponse, vendorData]);
6359
6118
  const {
6360
- mutate: mutateSurveyor
6361
- } = Digit.Hooks.fsm.useSurveyorUpdate(tenantId);
6119
+ mutate: mutateSupervisor
6120
+ } = Digit.Hooks.fsm.useSupervisorUpdate(tenantId);
6362
6121
  const {
6363
6122
  mutate: mutateVendor
6364
6123
  } = Digit.Hooks.fsm.useVendorUpdate(tenantId);
@@ -6379,9 +6138,9 @@ const SurveyorDetails = props => {
6379
6138
  case "DELETE_VENDOR":
6380
6139
  return setShowModal(true);
6381
6140
  case "EDIT":
6382
- return history.push("/digit-ui/employee/vendor/modify-surveyor/" + surveyorId);
6141
+ return history.push("/digit-ui/employee/vendor/registry/modify-supervisor/" + supervisorId);
6383
6142
  case "HOME":
6384
- return history.push("/digit-ui/employee/vendor/search-vendor?selectedTabs=SURVEYOR");
6143
+ return history.push("/digit-ui/employee/vendor/search-vendor?selectedTabs=SUPERVISOR");
6385
6144
  }
6386
6145
  }, [selectedAction]);
6387
6146
  const closeToast = () => {
@@ -6390,7 +6149,7 @@ const SurveyorDetails = props => {
6390
6149
  const handleModalAction = () => {
6391
6150
  switch (selectedAction) {
6392
6151
  case "DELETE":
6393
- return handleDeleteSurveyor();
6152
+ return handleDeleteSupervisor();
6394
6153
  case "DELETE_VENDOR":
6395
6154
  return handleDeleteVendor();
6396
6155
  case "ADD_VENDOR":
@@ -6399,16 +6158,16 @@ const SurveyorDetails = props => {
6399
6158
  return handleEditVendor();
6400
6159
  }
6401
6160
  };
6402
- const handleDeleteSurveyor = () => {
6403
- var _surveyorData$;
6404
- let details = surveyorData === null || surveyorData === void 0 ? void 0 : (_surveyorData$ = surveyorData[0]) === null || _surveyorData$ === void 0 ? void 0 : _surveyorData$.surveyorData;
6161
+ const handleDeleteSupervisor = () => {
6162
+ var _supervisorData$;
6163
+ let details = supervisorData === null || supervisorData === void 0 ? void 0 : (_supervisorData$ = supervisorData[0]) === null || _supervisorData$ === void 0 ? void 0 : _supervisorData$.supervisorData;
6405
6164
  const formData = {
6406
- surveyor: {
6165
+ supervisor: {
6407
6166
  ...details,
6408
6167
  status: "INACTIVE"
6409
6168
  }
6410
6169
  };
6411
- mutateSurveyor(formData, {
6170
+ mutateSupervisor(formData, {
6412
6171
  onError: error => {
6413
6172
  setShowToast({
6414
6173
  key: "error",
@@ -6419,9 +6178,9 @@ const SurveyorDetails = props => {
6419
6178
  onSuccess: () => {
6420
6179
  setShowToast({
6421
6180
  key: "success",
6422
- action: "DELETE_SURVEYOR"
6181
+ action: "DELETE_SUPERVISOR"
6423
6182
  });
6424
- queryClient.invalidateQueries("SURVEYOR_SEARCH");
6183
+ queryClient.invalidateQueries("SUPERVISOR_SEARCH");
6425
6184
  setTimeout(() => {
6426
6185
  closeToast();
6427
6186
  history.push(`/digit-ui/employee/vendor/search-vendor`);
@@ -6431,19 +6190,19 @@ const SurveyorDetails = props => {
6431
6190
  setShowModal(false);
6432
6191
  };
6433
6192
  const handleDeleteVendor = () => {
6434
- var _surveyorData$2, _surveyorData$2$vendo, _surveyorData$2$vendo2;
6435
- 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];
6436
- let getSurveyorVendorDetails = (dsoDetails === null || dsoDetails === void 0 ? void 0 : dsoDetails.surveyors) || [];
6437
- getSurveyorVendorDetails = getSurveyorVendorDetails.map(data => {
6438
- if (data.id === surveyorId) {
6439
- data.vendorSurveyorStatus = "INACTIVE";
6193
+ var _supervisorData$2, _supervisorData$2$ven, _supervisorData$2$ven2;
6194
+ 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];
6195
+ let getSupervisorVendorDetails = (dsoDetails === null || dsoDetails === void 0 ? void 0 : dsoDetails.supervisors) || [];
6196
+ getSupervisorVendorDetails = getSupervisorVendorDetails.map(data => {
6197
+ if (data.id === supervisorId) {
6198
+ data.vendorSupervisorStatus = "INACTIVE";
6440
6199
  }
6441
6200
  return data;
6442
6201
  });
6443
6202
  const formData = {
6444
6203
  vendor: {
6445
6204
  ...dsoDetails,
6446
- surveyors: getSurveyorVendorDetails
6205
+ supervisors: getSupervisorVendorDetails
6447
6206
  }
6448
6207
  };
6449
6208
  mutateVendor(formData, {
@@ -6467,14 +6226,14 @@ const SurveyorDetails = props => {
6467
6226
  setShowModal(false);
6468
6227
  };
6469
6228
  const handleAddVendor = () => {
6470
- var _surveyorData$3;
6229
+ var _supervisorData$3;
6471
6230
  let dsoDetails = selectedOption;
6472
- let details = surveyorData === null || surveyorData === void 0 ? void 0 : (_surveyorData$3 = surveyorData[0]) === null || _surveyorData$3 === void 0 ? void 0 : _surveyorData$3.surveyorData;
6473
- details.vendorSurveyorStatus = "ACTIVE";
6231
+ let details = supervisorData === null || supervisorData === void 0 ? void 0 : (_supervisorData$3 = supervisorData[0]) === null || _supervisorData$3 === void 0 ? void 0 : _supervisorData$3.supervisorData;
6232
+ details.vendorSupervisorStatus = "ACTIVE";
6474
6233
  const formData = {
6475
6234
  vendor: {
6476
6235
  ...dsoDetails,
6477
- surveyors: dsoDetails.surveyors ? [...dsoDetails.surveyors, details] : [details]
6236
+ supervisors: dsoDetails.supervisors ? [...dsoDetails.supervisors, details] : [details]
6478
6237
  }
6479
6238
  };
6480
6239
  mutateVendor(formData, {
@@ -6491,7 +6250,7 @@ const SurveyorDetails = props => {
6491
6250
  key: "success",
6492
6251
  action: "ADD_VENDOR"
6493
6252
  });
6494
- queryClient.invalidateQueries("SURVEYOR_SEARCH");
6253
+ queryClient.invalidateQueries("SUPERVISOR_SEARCH");
6495
6254
  refetch();
6496
6255
  setTimeout(closeToast, 5000);
6497
6256
  }
@@ -6500,14 +6259,14 @@ const SurveyorDetails = props => {
6500
6259
  setSelectedAction(null);
6501
6260
  };
6502
6261
  const handleEditVendor = () => {
6503
- var _surveyorData$4;
6262
+ var _supervisorData$4;
6504
6263
  let dsoDetails = selectedOption;
6505
- let details = surveyorData === null || surveyorData === void 0 ? void 0 : (_surveyorData$4 = surveyorData[0]) === null || _surveyorData$4 === void 0 ? void 0 : _surveyorData$4.surveyorData;
6506
- details.vendorSurveyorStatus = "ACTIVE";
6264
+ let details = supervisorData === null || supervisorData === void 0 ? void 0 : (_supervisorData$4 = supervisorData[0]) === null || _supervisorData$4 === void 0 ? void 0 : _supervisorData$4.supervisorData;
6265
+ details.vendorSupervisorStatus = "ACTIVE";
6507
6266
  const formData = {
6508
6267
  vendor: {
6509
6268
  ...dsoDetails,
6510
- surveyors: dsoDetails.surveyors ? [...dsoDetails.surveyors, details] : [details]
6269
+ supervisors: dsoDetails.supervisors ? [...dsoDetails.supervisors, details] : [details]
6511
6270
  }
6512
6271
  };
6513
6272
  mutateVendor(formData, {
@@ -6524,7 +6283,7 @@ const SurveyorDetails = props => {
6524
6283
  action: "EDIT_VENDOR"
6525
6284
  });
6526
6285
  refetch();
6527
- queryClient.invalidateQueries("SURVEYOR_SEARCH");
6286
+ queryClient.invalidateQueries("SUPERVISOR_SEARCH");
6528
6287
  setTimeout(closeToast, 5000);
6529
6288
  }
6530
6289
  });
@@ -6540,17 +6299,17 @@ const SurveyorDetails = props => {
6540
6299
  switch (selectedAction) {
6541
6300
  case "DELETE":
6542
6301
  case "DELETE_VENDOR":
6543
- return "ES_VENDOR_SURVEYOR_DELETE_POPUP_HEADER";
6302
+ return "ES_VENDOR_SUPERVISOR_DELETE_POPUP_HEADER";
6544
6303
  case "ADD_VENDOR":
6545
6304
  case "EDIT_VENDOR":
6546
- return "ES_VENDOR_SURVEYOR_ADD_VENDOR_POPUP_HEADER";
6305
+ return "ES_VENDOR_SUPERVISOR_ADD_VENDOR_POPUP_HEADER";
6547
6306
  }
6548
6307
  };
6549
6308
  const renderModalContent = () => {
6550
6309
  if (selectedAction === "DELETE" || selectedAction === "DELETE_VENDOR") {
6551
6310
  return /*#__PURE__*/React.createElement(ConfirmationBox, {
6552
6311
  t: t,
6553
- title: "ES_VENDOR_SURVEYOR_DELETE_TEXT"
6312
+ title: "ES_VENDOR_SUPERVISOR_DELETE_TEXT"
6554
6313
  });
6555
6314
  }
6556
6315
  if (selectedAction === "ADD_VENDOR" || selectedAction === "EDIT_VENDOR") {
@@ -6574,8 +6333,8 @@ const SurveyorDetails = props => {
6574
6333
  position: "relative",
6575
6334
  backgroundColor: "#fff"
6576
6335
  }
6577
- }, 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) => {
6578
- var _detail$values;
6336
+ }, 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) => {
6337
+ var _detail$values, _detail$child;
6579
6338
  return /*#__PURE__*/React.createElement(React.Fragment, {
6580
6339
  key: index
6581
6340
  }, index > 0 && /*#__PURE__*/React.createElement(CardSectionHeader, {
@@ -6633,7 +6392,64 @@ const SurveyorDetails = props => {
6633
6392
  }, t(value.title)), /*#__PURE__*/React.createElement("div", {
6634
6393
  className: "additional-value"
6635
6394
  }, t(value.value) || "N/A"));
6636
- }))));
6395
+ }))), detail === null || detail === void 0 ? void 0 : (_detail$child = detail.child) === null || _detail$child === void 0 ? void 0 : _detail$child.map((data, index) => {
6396
+ var _data$values;
6397
+ return /*#__PURE__*/React.createElement(Card, {
6398
+ className: "card-with-background",
6399
+ key: data.id || index,
6400
+ style: {
6401
+ margin: "10px 16px",
6402
+ padding: "20px"
6403
+ }
6404
+ }, /*#__PURE__*/React.createElement("div", {
6405
+ className: "card-head",
6406
+ style: {
6407
+ display: "flex",
6408
+ justifyContent: "space-between",
6409
+ alignItems: "center",
6410
+ marginBottom: "10px"
6411
+ }
6412
+ }, /*#__PURE__*/React.createElement("h2", {
6413
+ style: {
6414
+ fontSize: "18px",
6415
+ fontWeight: "bold"
6416
+ }
6417
+ }, t(detail.type), " ", index + 1), /*#__PURE__*/React.createElement("div", {
6418
+ style: {
6419
+ display: "flex",
6420
+ gap: "15px"
6421
+ }
6422
+ }, /*#__PURE__*/React.createElement("span", {
6423
+ onClick: () => history.push(`/digit-ui/employee/vendor/registry/modify-surveyor/${data.id}`)
6424
+ }, /*#__PURE__*/React.createElement(EditIcon, {
6425
+ fill: "#a82227",
6426
+ style: {
6427
+ cursor: "pointer"
6428
+ }
6429
+ })))), /*#__PURE__*/React.createElement("div", {
6430
+ className: "additional-grid"
6431
+ }, 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, {
6432
+ key: idx
6433
+ }, /*#__PURE__*/React.createElement("div", {
6434
+ className: "additional-label"
6435
+ }, t(value.title)), /*#__PURE__*/React.createElement("div", {
6436
+ className: "additional-value"
6437
+ }, t(value.value) || "N/A")))));
6438
+ }), detail.type && /*#__PURE__*/React.createElement("div", {
6439
+ className: "add-details-link hover-button",
6440
+ style: {
6441
+ margin: "10px 16px",
6442
+ color: "#a82227",
6443
+ cursor: "pointer",
6444
+ display: "flex",
6445
+ alignItems: "center",
6446
+ gap: "5px",
6447
+ fontWeight: "bold"
6448
+ },
6449
+ onClick: () => history.push(`/digit-ui/employee/vendor/registry/new-surveyor?supervisorId=${supervisorId}`)
6450
+ }, /*#__PURE__*/React.createElement(AddIcon, {
6451
+ fill: "#a82227"
6452
+ }), t(`${detail.type}_ADD`)));
6637
6453
  }))), showModal && /*#__PURE__*/React.createElement(Modal, {
6638
6454
  headerBarMain: /*#__PURE__*/React.createElement(Heading$1, {
6639
6455
  label: t(modalHeading())
@@ -6658,7 +6474,7 @@ const SurveyorDetails = props => {
6658
6474
  zIndex: "19"
6659
6475
  }
6660
6476
  }, displayMenu ? /*#__PURE__*/React.createElement(Menu, {
6661
- localeKeyPrefix: "ES_VENDOR_SURVEYOR_ACTION",
6477
+ localeKeyPrefix: "ES_VENDOR_SUPERVISOR_ACTION",
6662
6478
  options: ["EDIT", "DELETE"],
6663
6479
  t: t,
6664
6480
  onSelect: a => {
@@ -6671,6 +6487,444 @@ const SurveyorDetails = props => {
6671
6487
  })));
6672
6488
  };
6673
6489
 
6490
+ const EditSupervisor = () => {
6491
+ var _Digit$UserService$ge;
6492
+ const {
6493
+ t
6494
+ } = useTranslation();
6495
+ const history = useHistory();
6496
+ const queryClient = useQueryClient();
6497
+ const {
6498
+ id: supervisorId
6499
+ } = useParams();
6500
+ const userInfo = (_Digit$UserService$ge = Digit.UserService.getUser()) === null || _Digit$UserService$ge === void 0 ? void 0 : _Digit$UserService$ge.info;
6501
+ const rawTenantId = Digit.ULBService.getCurrentTenantId();
6502
+ const tenantId = rawTenantId !== null && rawTenantId !== void 0 && rawTenantId.includes(".") ? rawTenantId : `${rawTenantId}.djb`;
6503
+ const [showToast, setShowToast] = useState(null);
6504
+ const [canSubmit, setCanSubmit] = useState(false);
6505
+ const [defaultValues, setDefaultValues] = useState({});
6506
+ const [supervisorDetails, setSupervisorDetails] = useState({});
6507
+ const {
6508
+ data: supervisorSearchResponse,
6509
+ isLoading
6510
+ } = Digit.Hooks.fsm.useSupervisorSearch(tenantId, {
6511
+ ids: supervisorId
6512
+ }, {
6513
+ staleTime: Infinity
6514
+ });
6515
+ const {
6516
+ mutate
6517
+ } = Digit.Hooks.fsm.useSupervisorUpdate(tenantId);
6518
+ const Config = SupervisorConfig(t);
6519
+ useEffect(() => {
6520
+ if (supervisorSearchResponse && supervisorSearchResponse.supervisors && supervisorSearchResponse.supervisors.length > 0) {
6521
+ var _details$owner, _details$owner2, _details$owner3, _details$owner4, _details$owner5, _details$owner6, _details$owner7, _details$owner8, _details$owner9;
6522
+ let details = supervisorSearchResponse.supervisors[0];
6523
+ setSupervisorDetails(details);
6524
+ let values = {
6525
+ fullName: (details === null || details === void 0 ? void 0 : (_details$owner = details.owner) === null || _details$owner === void 0 ? void 0 : _details$owner.name) || (details === null || details === void 0 ? void 0 : details.name),
6526
+ mobileNumber: (details === null || details === void 0 ? void 0 : (_details$owner2 = details.owner) === null || _details$owner2 === void 0 ? void 0 : _details$owner2.mobileNumber) || (details === null || details === void 0 ? void 0 : details.mobileNo),
6527
+ emailId: details === null || details === void 0 ? void 0 : (_details$owner3 = details.owner) === null || _details$owner3 === void 0 ? void 0 : _details$owner3.emailId,
6528
+ employeeId: details === null || details === void 0 ? void 0 : details.employeeId,
6529
+ gender: details !== null && details !== void 0 && (_details$owner4 = details.owner) !== null && _details$owner4 !== void 0 && _details$owner4.gender ? {
6530
+ code: details.owner.gender,
6531
+ name: `COMMON_GENDER_${details.owner.gender}`
6532
+ } : null,
6533
+ fatherOrHusbandName: details === null || details === void 0 ? void 0 : (_details$owner5 = details.owner) === null || _details$owner5 === void 0 ? void 0 : _details$owner5.fatherOrHusbandName,
6534
+ relationship: details !== null && details !== void 0 && (_details$owner6 = details.owner) !== null && _details$owner6 !== void 0 && _details$owner6.relationship ? {
6535
+ code: details.owner.relationship,
6536
+ name: `ES_COMMON_RELATION_${details.owner.relationship}`
6537
+ } : null,
6538
+ dob: (details === null || details === void 0 ? void 0 : (_details$owner7 = details.owner) === null || _details$owner7 === void 0 ? void 0 : _details$owner7.dob) && Digit.DateUtils.ConvertTimestampToDate(details === null || details === void 0 ? void 0 : (_details$owner8 = details.owner) === null || _details$owner8 === void 0 ? void 0 : _details$owner8.dob, "yyyy-MM-dd"),
6539
+ correspondenceAddress: details === null || details === void 0 ? void 0 : (_details$owner9 = details.owner) === null || _details$owner9 === void 0 ? void 0 : _details$owner9.correspondenceAddress,
6540
+ description: details === null || details === void 0 ? void 0 : details.description,
6541
+ assignedZone: details !== null && details !== void 0 && details.assignedZoneId ? {
6542
+ code: details.assignedZoneId,
6543
+ name: details.assignedZoneId
6544
+ } : null
6545
+ };
6546
+ setDefaultValues(values);
6547
+ }
6548
+ }, [supervisorSearchResponse]);
6549
+ const onFormValueChange = (setValue, formData) => {
6550
+ 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.fatherOrHusbandName) && (formData === null || formData === void 0 ? void 0 : formData.relationship) && (formData === null || formData === void 0 ? void 0 : formData.dob) && (formData === null || formData === void 0 ? void 0 : formData.gender) && (formData === null || formData === void 0 ? void 0 : formData.correspondenceAddress) && (formData === null || formData === void 0 ? void 0 : formData.assignedZone);
6551
+ if (isBasicDetailsFilled) {
6552
+ setCanSubmit(true);
6553
+ } else {
6554
+ setCanSubmit(false);
6555
+ }
6556
+ };
6557
+ const closeToast = () => {
6558
+ setShowToast(null);
6559
+ };
6560
+ const onSubmit = data => {
6561
+ var _data$assignedZone, _supervisorDetails$ow, _supervisorDetails$ow2, _data$relationship, _supervisorDetails$ow3, _data$gender, _supervisorDetails$ow4, _supervisorDetails$ow5, _supervisorDetails$ow6, _supervisorDetails$ow7, _supervisorDetails$ow8;
6562
+ const formData = {
6563
+ RequestInfo: {
6564
+ apiId: "Rainmaker",
6565
+ ver: "1.0",
6566
+ ts: null,
6567
+ action: "_update",
6568
+ msgId: `${Date.now()}|en_IN`,
6569
+ authToken: userInfo === null || userInfo === void 0 ? void 0 : userInfo.authToken,
6570
+ userInfo: {
6571
+ id: userInfo === null || userInfo === void 0 ? void 0 : userInfo.id,
6572
+ uuid: userInfo === null || userInfo === void 0 ? void 0 : userInfo.uuid,
6573
+ userName: userInfo === null || userInfo === void 0 ? void 0 : userInfo.userName,
6574
+ name: userInfo === null || userInfo === void 0 ? void 0 : userInfo.name,
6575
+ type: userInfo === null || userInfo === void 0 ? void 0 : userInfo.type,
6576
+ tenantId: tenantId,
6577
+ roles: userInfo === null || userInfo === void 0 ? void 0 : userInfo.roles
6578
+ }
6579
+ },
6580
+ supervisor: {
6581
+ ...supervisorDetails,
6582
+ description: (data === null || data === void 0 ? void 0 : data.description) || (supervisorDetails === null || supervisorDetails === void 0 ? void 0 : supervisorDetails.description) || "",
6583
+ assignedZoneId: (data === null || data === void 0 ? void 0 : (_data$assignedZone = data.assignedZone) === null || _data$assignedZone === void 0 ? void 0 : _data$assignedZone.code) || (supervisorDetails === null || supervisorDetails === void 0 ? void 0 : supervisorDetails.assignedZoneId) || null,
6584
+ owner: {
6585
+ ...supervisorDetails.owner,
6586
+ name: (data === null || data === void 0 ? void 0 : data.fullName) || ((_supervisorDetails$ow = supervisorDetails.owner) === null || _supervisorDetails$ow === void 0 ? void 0 : _supervisorDetails$ow.name),
6587
+ fatherOrHusbandName: (data === null || data === void 0 ? void 0 : data.fatherOrHusbandName) || ((_supervisorDetails$ow2 = supervisorDetails.owner) === null || _supervisorDetails$ow2 === void 0 ? void 0 : _supervisorDetails$ow2.fatherOrHusbandName),
6588
+ relationship: (data === null || data === void 0 ? void 0 : (_data$relationship = data.relationship) === null || _data$relationship === void 0 ? void 0 : _data$relationship.code) || ((_supervisorDetails$ow3 = supervisorDetails.owner) === null || _supervisorDetails$ow3 === void 0 ? void 0 : _supervisorDetails$ow3.relationship),
6589
+ gender: (data === null || data === void 0 ? void 0 : (_data$gender = data.gender) === null || _data$gender === void 0 ? void 0 : _data$gender.code) || ((_supervisorDetails$ow4 = supervisorDetails.owner) === null || _supervisorDetails$ow4 === void 0 ? void 0 : _supervisorDetails$ow4.gender) || "OTHERS",
6590
+ dob: data !== null && data !== void 0 && data.dob ? new Date(data.dob).getTime() : (_supervisorDetails$ow5 = supervisorDetails.owner) === null || _supervisorDetails$ow5 === void 0 ? void 0 : _supervisorDetails$ow5.dob,
6591
+ emailId: (data === null || data === void 0 ? void 0 : data.emailId) || ((_supervisorDetails$ow6 = supervisorDetails.owner) === null || _supervisorDetails$ow6 === void 0 ? void 0 : _supervisorDetails$ow6.emailId),
6592
+ mobileNumber: (data === null || data === void 0 ? void 0 : data.mobileNumber) || ((_supervisorDetails$ow7 = supervisorDetails.owner) === null || _supervisorDetails$ow7 === void 0 ? void 0 : _supervisorDetails$ow7.mobileNumber),
6593
+ correspondenceAddress: (data === null || data === void 0 ? void 0 : data.correspondenceAddress) || ((_supervisorDetails$ow8 = supervisorDetails.owner) === null || _supervisorDetails$ow8 === void 0 ? void 0 : _supervisorDetails$ow8.correspondenceAddress)
6594
+ }
6595
+ }
6596
+ };
6597
+ mutate(formData, {
6598
+ onError: error => {
6599
+ setShowToast({
6600
+ key: "error",
6601
+ action: error
6602
+ });
6603
+ setTimeout(closeToast, 5000);
6604
+ },
6605
+ onSuccess: () => {
6606
+ setShowToast({
6607
+ key: "success",
6608
+ action: "UPDATE_SUPERVISOR"
6609
+ });
6610
+ queryClient.invalidateQueries("SUPERVISOR_SEARCH");
6611
+ setTimeout(() => {
6612
+ closeToast();
6613
+ history.push(`/digit-ui/employee/vendor/registry/supervisor-details/${supervisorId}`);
6614
+ }, 5000);
6615
+ }
6616
+ });
6617
+ };
6618
+ if (isLoading || Object.keys(defaultValues).length === 0) {
6619
+ return /*#__PURE__*/React.createElement(Loader, null);
6620
+ }
6621
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(VerticalTimeline, {
6622
+ config: [{
6623
+ timeLine: [{
6624
+ actions: t("ES_VENDOR_SUPERVISOR_DETAILS"),
6625
+ currentStep: 1
6626
+ }]
6627
+ }],
6628
+ currentActiveIndex: 0,
6629
+ showFinalStep: false
6630
+ }), /*#__PURE__*/React.createElement("div", {
6631
+ style: {
6632
+ flex: "1",
6633
+ overflowY: "auto"
6634
+ }
6635
+ }, /*#__PURE__*/React.createElement(FormComposer, {
6636
+ isDisabled: !canSubmit,
6637
+ label: t("ES_COMMON_APPLICATION_SUBMIT"),
6638
+ config: Config.map(config => ({
6639
+ ...config,
6640
+ isCollapsible: true,
6641
+ isDefaultOpen: true
6642
+ })),
6643
+ fieldStyle: {
6644
+ marginRight: 0
6645
+ },
6646
+ onSubmit: onSubmit,
6647
+ defaultValues: defaultValues,
6648
+ onFormValueChange: onFormValueChange,
6649
+ noBreakLine: true,
6650
+ mode: "onChange",
6651
+ noCard: true
6652
+ }), showToast && /*#__PURE__*/React.createElement(Toast, {
6653
+ error: showToast.key === "error",
6654
+ label: t(showToast.key === "success" ? `ES_VENDOR_${showToast.action}_SUCCESS` : showToast.action),
6655
+ onClose: closeToast
6656
+ })));
6657
+ };
6658
+
6659
+ const {
6660
+ Dropdown: Dropdown$2,
6661
+ DatePicker: DatePicker$2
6662
+ } = require("@djb25/digit-ui-react-components");
6663
+ const SurveyorConfig = (t, agencies = [], reportingManagers = [], disabled = false) => {
6664
+ return [{
6665
+ head: "ES_VENDOR_SURVEYOR_BASIC_DETAILS",
6666
+ body: [{
6667
+ label: "ES_VENDOR_SURVEYOR_FULL_NAME",
6668
+ isMandatory: true,
6669
+ type: "text",
6670
+ populators: {
6671
+ name: "fullName",
6672
+ validation: {
6673
+ required: true,
6674
+ pattern: /^[A-Za-z\s]+$/
6675
+ },
6676
+ error: t("ES_VENDOR_INVALID_NAME")
6677
+ }
6678
+ }, {
6679
+ label: "ES_VENDOR_SURVEYOR_MOBILE_NUMBER",
6680
+ isMandatory: true,
6681
+ type: "mobileNumber",
6682
+ populators: {
6683
+ name: "mobileNumber",
6684
+ validation: {
6685
+ required: true,
6686
+ pattern: /^[6-9]\d{9}$/
6687
+ },
6688
+ error: t("ES_VENDOR_INVALID_MOBILE")
6689
+ }
6690
+ }, {
6691
+ label: "ES_VENDOR_SURVEYOR_EMAIL_ID",
6692
+ isMandatory: true,
6693
+ type: "text",
6694
+ populators: {
6695
+ name: "emailId",
6696
+ validation: {
6697
+ required: true,
6698
+ pattern: /^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9.-]+$/
6699
+ },
6700
+ error: t("ES_VENDOR_INVALID_EMAIL")
6701
+ }
6702
+ }, {
6703
+ label: "ES_VENDOR_SURVEYOR_STAFF_CODE",
6704
+ isMandatory: true,
6705
+ type: "text",
6706
+ populators: {
6707
+ name: "employeeId",
6708
+ validation: {
6709
+ required: true
6710
+ }
6711
+ }
6712
+ }, {
6713
+ label: t("ES_VENDOR_SURVEYOR_GENDER"),
6714
+ isMandatory: true,
6715
+ type: "component",
6716
+ key: "gender",
6717
+ component: "SelectGender"
6718
+ }, {
6719
+ label: t("ES_FSM_REGISTRY_NEW_FATHER_NAME"),
6720
+ isMandatory: true,
6721
+ type: "text",
6722
+ populators: {
6723
+ name: "fatherOrHusbandName",
6724
+ validation: {
6725
+ required: true
6726
+ },
6727
+ className: "payment-form-text-input-correction"
6728
+ }
6729
+ }, {
6730
+ label: t("ES_FSM_REGISTRY_NEW_RELATIONSHIP"),
6731
+ isMandatory: true,
6732
+ type: "component",
6733
+ key: "relationship",
6734
+ component: "SelectEkycDropdown",
6735
+ populators: {
6736
+ name: "relationship",
6737
+ options: [{
6738
+ code: "FATHER",
6739
+ name: "ES_COMMON_RELATION_FATHER"
6740
+ }, {
6741
+ code: "HUSBAND",
6742
+ name: "ES_COMMON_RELATION_HUSBAND"
6743
+ }, {
6744
+ code: "OTHER",
6745
+ name: "ES_COMMON_RELATION_OTHER"
6746
+ }],
6747
+ optionsKey: "name"
6748
+ }
6749
+ }, {
6750
+ label: t("ES_FSM_REGISTRY_NEW_DOB"),
6751
+ isMandatory: true,
6752
+ type: "custom",
6753
+ key: "dob",
6754
+ populators: {
6755
+ name: "dob",
6756
+ validation: {
6757
+ required: true
6758
+ },
6759
+ component: (props, customProps) => /*#__PURE__*/React.createElement(DatePicker$2, Object.assign({
6760
+ onChange: props.onChange,
6761
+ date: props.value
6762
+ }, customProps))
6763
+ }
6764
+ }, {
6765
+ label: t("ES_FSM_REGISTRY_NEW_CORRESPONDENCE_ADDRESS"),
6766
+ isMandatory: true,
6767
+ type: "text",
6768
+ populators: {
6769
+ name: "correspondenceAddress",
6770
+ validation: {
6771
+ required: true
6772
+ },
6773
+ className: "payment-form-text-input-correction"
6774
+ }
6775
+ }, {
6776
+ label: t("ES_VENDOR_SURVEYOR_DESCRIPTION"),
6777
+ isMandatory: false,
6778
+ type: "text",
6779
+ populators: {
6780
+ name: "description",
6781
+ className: "payment-form-text-input-correction"
6782
+ }
6783
+ }]
6784
+ }];
6785
+ };
6786
+
6787
+ const AddSurveyor = ({
6788
+ parentUrl,
6789
+ heading
6790
+ }) => {
6791
+ var _Digit$UserService$ge;
6792
+ const {
6793
+ t
6794
+ } = useTranslation();
6795
+ const userInfo = (_Digit$UserService$ge = Digit.UserService.getUser()) === null || _Digit$UserService$ge === void 0 ? void 0 : _Digit$UserService$ge.info;
6796
+ const rawTenantId = Digit.ULBService.getCurrentTenantId();
6797
+ const tenantId = rawTenantId !== null && rawTenantId !== void 0 && rawTenantId.includes(".") ? rawTenantId : `${rawTenantId}.djb`;
6798
+ const [showToast, setShowToast] = useState(null);
6799
+ const queryClient = useQueryClient();
6800
+ const [canSubmit, setCanSubmit] = useState(false);
6801
+ const {
6802
+ mutate
6803
+ } = Digit.Hooks.fsm.useSurveyorCreate(tenantId);
6804
+ const {
6805
+ search
6806
+ } = useLocation();
6807
+ const queryParams = new URLSearchParams(search);
6808
+ const vendorIdParam = queryParams.get("vendorId");
6809
+ const Config = SurveyorConfig(t);
6810
+ const defaultValues = {
6811
+ role: {
6812
+ code: "SURVEYOR",
6813
+ name: "Surveyor"
6814
+ }
6815
+ };
6816
+ const onFormValueChange = (setValue, formData) => {
6817
+ 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) && (formData === null || formData === void 0 ? void 0 : formData.fatherOrHusbandName) && (formData === null || formData === void 0 ? void 0 : formData.relationship) && (formData === null || formData === void 0 ? void 0 : formData.dob) && (formData === null || formData === void 0 ? void 0 : formData.correspondenceAddress);
6818
+ if (isBasicDetailsFilled) {
6819
+ setCanSubmit(true);
6820
+ } else {
6821
+ setCanSubmit(false);
6822
+ }
6823
+ };
6824
+ const closeToast = () => {
6825
+ setShowToast(null);
6826
+ };
6827
+ const onSubmit = data => {
6828
+ var _userInfo$roles, _Digit$UserService$ge2, _data$agencyName, _data$agencyName2, _data$reportingManage, _data$reportingManage2, _data$relationship, _data$gender;
6829
+ const isSupervisor = userInfo === null || userInfo === void 0 ? void 0 : (_userInfo$roles = userInfo.roles) === null || _userInfo$roles === void 0 ? void 0 : _userInfo$roles.some(role => role.code === "EKYC_SUPERVISOR");
6830
+ const formData = {
6831
+ RequestInfo: {
6832
+ apiId: "Rainmaker",
6833
+ ver: "1.0",
6834
+ ts: null,
6835
+ action: "_create",
6836
+ msgId: `${Date.now()}|en_IN`,
6837
+ authToken: ((_Digit$UserService$ge2 = Digit.UserService.getUser()) === null || _Digit$UserService$ge2 === void 0 ? void 0 : _Digit$UserService$ge2.access_token) || (userInfo === null || userInfo === void 0 ? void 0 : userInfo.authToken),
6838
+ ...(isSupervisor && {
6839
+ userInfo: {
6840
+ id: userInfo === null || userInfo === void 0 ? void 0 : userInfo.id,
6841
+ uuid: userInfo === null || userInfo === void 0 ? void 0 : userInfo.uuid,
6842
+ userName: userInfo === null || userInfo === void 0 ? void 0 : userInfo.userName,
6843
+ name: userInfo === null || userInfo === void 0 ? void 0 : userInfo.name,
6844
+ type: userInfo === null || userInfo === void 0 ? void 0 : userInfo.type,
6845
+ tenantId: (userInfo === null || userInfo === void 0 ? void 0 : userInfo.tenantId) || rawTenantId,
6846
+ roles: userInfo === null || userInfo === void 0 ? void 0 : userInfo.roles
6847
+ }
6848
+ })
6849
+ },
6850
+ surveyor: {
6851
+ tenantId: tenantId,
6852
+ vendorId: vendorIdParam || (data === null || data === void 0 ? void 0 : (_data$agencyName = data.agencyName) === null || _data$agencyName === void 0 ? void 0 : _data$agencyName.code) || (data === null || data === void 0 ? void 0 : (_data$agencyName2 = data.agencyName) === null || _data$agencyName2 === void 0 ? void 0 : _data$agencyName2.id) || (userInfo === null || userInfo === void 0 ? void 0 : userInfo.uuid),
6853
+ supervisorId: (data === null || data === void 0 ? void 0 : (_data$reportingManage = data.reportingManager) === null || _data$reportingManage === void 0 ? void 0 : _data$reportingManage.code) || (data === null || data === void 0 ? void 0 : (_data$reportingManage2 = data.reportingManager) === null || _data$reportingManage2 === void 0 ? void 0 : _data$reportingManage2.id) || null,
6854
+ description: (data === null || data === void 0 ? void 0 : data.description) || "",
6855
+ additionalDetails: {
6856
+ serviceType: "ekyc"
6857
+ },
6858
+ owner: {
6859
+ tenantId: tenantId,
6860
+ name: data === null || data === void 0 ? void 0 : data.fullName,
6861
+ fatherOrHusbandName: data === null || data === void 0 ? void 0 : data.fatherOrHusbandName,
6862
+ relationship: data === null || data === void 0 ? void 0 : (_data$relationship = data.relationship) === null || _data$relationship === void 0 ? void 0 : _data$relationship.code,
6863
+ gender: (data === null || data === void 0 ? void 0 : (_data$gender = data.gender) === null || _data$gender === void 0 ? void 0 : _data$gender.code) || "OTHERS",
6864
+ dob: data !== null && data !== void 0 && data.dob ? new Date(data.dob).getTime() : null,
6865
+ emailId: data === null || data === void 0 ? void 0 : data.emailId,
6866
+ mobileNumber: data === null || data === void 0 ? void 0 : data.mobileNumber,
6867
+ correspondenceAddress: data === null || data === void 0 ? void 0 : data.correspondenceAddress
6868
+ }
6869
+ }
6870
+ };
6871
+ mutate(formData, {
6872
+ onError: error => {
6873
+ setShowToast({
6874
+ key: "error",
6875
+ action: error
6876
+ });
6877
+ setTimeout(closeToast, 5000);
6878
+ },
6879
+ onSuccess: () => {
6880
+ setShowToast({
6881
+ key: "success",
6882
+ action: "ADD_SURVEYOR"
6883
+ });
6884
+ queryClient.invalidateQueries("SURVEYOR_SEARCH");
6885
+ setTimeout(closeToast, 5000);
6886
+ }
6887
+ });
6888
+ };
6889
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(VerticalTimeline, {
6890
+ config: [{
6891
+ route: "surveyor-details",
6892
+ timeLine: [{
6893
+ actions: t("ES_VENDOR_SURVEYOR_DETAILS"),
6894
+ currentStep: 1
6895
+ }]
6896
+ }],
6897
+ currentActiveIndex: 0,
6898
+ showFinalStep: false
6899
+ }), /*#__PURE__*/React.createElement("div", {
6900
+ style: {
6901
+ flex: "1",
6902
+ overflowY: "auto"
6903
+ }
6904
+ }, /*#__PURE__*/React.createElement(FormComposer, {
6905
+ isDisabled: !canSubmit,
6906
+ label: t("ES_COMMON_APPLICATION_SUBMIT"),
6907
+ config: Config.map(config => ({
6908
+ ...config,
6909
+ isCollapsible: true,
6910
+ isDefaultOpen: true
6911
+ })),
6912
+ fieldStyle: {
6913
+ marginRight: 0
6914
+ },
6915
+ onSubmit: onSubmit,
6916
+ defaultValues: defaultValues,
6917
+ onFormValueChange: onFormValueChange,
6918
+ noBreakLine: true,
6919
+ mode: "onChange",
6920
+ noCard: true
6921
+ }), showToast && /*#__PURE__*/React.createElement(Toast, {
6922
+ error: showToast.key === "error",
6923
+ label: t(showToast.key === "success" ? `ES_VENDOR_${showToast.action}_SUCCESS` : showToast.action),
6924
+ onClose: closeToast
6925
+ })));
6926
+ };
6927
+
6674
6928
  const Heading$2 = props => {
6675
6929
  return /*#__PURE__*/React.createElement("h1", {
6676
6930
  className: "heading-m"
@@ -6692,8 +6946,8 @@ const CloseBtn$2 = props => {
6692
6946
  onClick: props.onClick
6693
6947
  }, /*#__PURE__*/React.createElement(Close$2, null));
6694
6948
  };
6695
- const SupervisorDetails = props => {
6696
- var _supervisorData$5, _supervisorData$5$emp;
6949
+ const SurveyorDetails = props => {
6950
+ var _surveyorData$5, _surveyorData$5$emplo;
6697
6951
  const tenantId = Digit.ULBService.getCurrentTenantId();
6698
6952
  const {
6699
6953
  t
@@ -6701,7 +6955,7 @@ const SupervisorDetails = props => {
6701
6955
  const history = useHistory();
6702
6956
  const queryClient = useQueryClient();
6703
6957
  const {
6704
- id: supervisorId
6958
+ id: surveyorId
6705
6959
  } = useParams();
6706
6960
  const [displayMenu, setDisplayMenu] = useState(false);
6707
6961
  const [selectedAction, setSelectedAction] = useState(null);
@@ -6717,18 +6971,18 @@ const SupervisorDetails = props => {
6717
6971
  status: "ACTIVE"
6718
6972
  }, {});
6719
6973
  const {
6720
- data: supervisorSearchResponse,
6974
+ data: surveyorSearchResponse,
6721
6975
  isLoading,
6722
6976
  refetch
6723
- } = Digit.Hooks.fsm.useSupervisorSearch(tenantId, {
6724
- ids: supervisorId
6977
+ } = Digit.Hooks.fsm.useSurveyorSearch(tenantId, {
6978
+ ids: surveyorId
6725
6979
  }, {
6726
6980
  staleTime: Infinity
6727
6981
  });
6728
- const supervisorData = React.useMemo(() => {
6729
- var _supervisorSearchResp;
6730
- if (!(supervisorSearchResponse !== null && supervisorSearchResponse !== void 0 && (_supervisorSearchResp = supervisorSearchResponse.supervisors) !== null && _supervisorSearchResp !== void 0 && _supervisorSearchResp.length)) return [];
6731
- return supervisorSearchResponse.supervisors.map(data => {
6982
+ const surveyorData = React.useMemo(() => {
6983
+ var _surveyorSearchRespon;
6984
+ if (!(surveyorSearchResponse !== null && surveyorSearchResponse !== void 0 && (_surveyorSearchRespon = surveyorSearchResponse.surveyors) !== null && _surveyorSearchRespon !== void 0 && _surveyorSearchRespon.length)) return [];
6985
+ return surveyorSearchResponse.surveyors.map(data => {
6732
6986
  var _mappedVendor$dsoDeta, _data$owner, _data$owner2, _data$owner3;
6733
6987
  const mappedVendor = vendorData === null || vendorData === void 0 ? void 0 : vendorData.find(v => {
6734
6988
  var _v$dsoDetails, _v$dsoDetails2;
@@ -6736,43 +6990,39 @@ const SupervisorDetails = props => {
6736
6990
  });
6737
6991
  const vendorName = (mappedVendor === null || mappedVendor === void 0 ? void 0 : (_mappedVendor$dsoDeta = mappedVendor.dsoDetails) === null || _mappedVendor$dsoDeta === void 0 ? void 0 : _mappedVendor$dsoDeta.name) || data.vendorId || "ES_FSM_REGISTRY_DETAILS_ADD_VENDOR";
6738
6992
  return {
6739
- supervisorData: data,
6993
+ surveyorData: data,
6740
6994
  vendorDetails: {
6741
6995
  vendor: mappedVendor ? [mappedVendor.dsoDetails] : []
6742
6996
  },
6743
6997
  employeeResponse: [{
6744
- title: "ES_VENDOR_SUPERVISOR_BASIC_DETAILS",
6998
+ title: "ES_VENDOR_SURVEYOR_BASIC_DETAILS",
6745
6999
  values: [{
6746
- title: "ES_VENDOR_SUPERVISOR_FULL_NAME",
7000
+ title: "ES_VENDOR_SURVEYOR_FULL_NAME",
6747
7001
  value: data === null || data === void 0 ? void 0 : data.name
6748
7002
  }, {
6749
- title: "ES_VENDOR_SUPERVISOR_MOBILE_NUMBER",
7003
+ title: "ES_VENDOR_SURVEYOR_MOBILE_NUMBER",
6750
7004
  value: (data === null || data === void 0 ? void 0 : (_data$owner = data.owner) === null || _data$owner === void 0 ? void 0 : _data$owner.mobileNumber) || (data === null || data === void 0 ? void 0 : data.mobileNo)
6751
7005
  }, {
6752
- title: "ES_VENDOR_SUPERVISOR_EMAIL_ID",
7006
+ title: "ES_VENDOR_SURVEYOR_EMAIL_ID",
6753
7007
  value: data === null || data === void 0 ? void 0 : (_data$owner2 = data.owner) === null || _data$owner2 === void 0 ? void 0 : _data$owner2.emailId
6754
7008
  }, {
6755
- title: "ES_VENDOR_SUPERVISOR_STAFF_CODE",
7009
+ title: "ES_VENDOR_SURVEYOR_STAFF_CODE",
6756
7010
  value: (data === null || data === void 0 ? void 0 : data.employeeId) || "N/A"
6757
7011
  }, {
6758
- title: "ES_VENDOR_SUPERVISOR_GENDER",
7012
+ title: "ES_VENDOR_SURVEYOR_GENDER",
6759
7013
  value: data === null || data === void 0 ? void 0 : (_data$owner3 = data.owner) === null || _data$owner3 === void 0 ? void 0 : _data$owner3.gender
6760
7014
  }, {
6761
- title: "ES_VENDOR_SUPERVISOR_AGENCY_NAME",
7015
+ title: "ES_VENDOR_SURVEYOR_AGENCY_NAME",
6762
7016
  value: vendorName,
6763
7017
  type: "custom"
6764
7018
  }]
6765
- }, {
6766
- title: "ES_VENDOR_SUPERVISOR_MAPPED_SURVEYORS",
6767
- type: "ES_FSM_REGISTRY_DETAILS_TYPE_SURVEYOR",
6768
- child: []
6769
7019
  }]
6770
7020
  };
6771
7021
  });
6772
- }, [supervisorSearchResponse, vendorData]);
7022
+ }, [surveyorSearchResponse, vendorData]);
6773
7023
  const {
6774
- mutate: mutateSupervisor
6775
- } = Digit.Hooks.fsm.useSupervisorUpdate(tenantId);
7024
+ mutate: mutateSurveyor
7025
+ } = Digit.Hooks.fsm.useSurveyorUpdate(tenantId);
6776
7026
  const {
6777
7027
  mutate: mutateVendor
6778
7028
  } = Digit.Hooks.fsm.useVendorUpdate(tenantId);
@@ -6793,9 +7043,9 @@ const SupervisorDetails = props => {
6793
7043
  case "DELETE_VENDOR":
6794
7044
  return setShowModal(true);
6795
7045
  case "EDIT":
6796
- return history.push("/digit-ui/employee/vendor/modify-supervisor/" + supervisorId);
7046
+ return history.push("/digit-ui/employee/vendor/registry/modify-surveyor/" + surveyorId);
6797
7047
  case "HOME":
6798
- return history.push("/digit-ui/employee/vendor/search-vendor?selectedTabs=SUPERVISOR");
7048
+ return history.push("/digit-ui/employee/vendor/search-vendor?selectedTabs=SURVEYOR");
6799
7049
  }
6800
7050
  }, [selectedAction]);
6801
7051
  const closeToast = () => {
@@ -6804,7 +7054,7 @@ const SupervisorDetails = props => {
6804
7054
  const handleModalAction = () => {
6805
7055
  switch (selectedAction) {
6806
7056
  case "DELETE":
6807
- return handleDeleteSupervisor();
7057
+ return handleDeleteSurveyor();
6808
7058
  case "DELETE_VENDOR":
6809
7059
  return handleDeleteVendor();
6810
7060
  case "ADD_VENDOR":
@@ -6813,16 +7063,16 @@ const SupervisorDetails = props => {
6813
7063
  return handleEditVendor();
6814
7064
  }
6815
7065
  };
6816
- const handleDeleteSupervisor = () => {
6817
- var _supervisorData$;
6818
- let details = supervisorData === null || supervisorData === void 0 ? void 0 : (_supervisorData$ = supervisorData[0]) === null || _supervisorData$ === void 0 ? void 0 : _supervisorData$.supervisorData;
7066
+ const handleDeleteSurveyor = () => {
7067
+ var _surveyorData$;
7068
+ let details = surveyorData === null || surveyorData === void 0 ? void 0 : (_surveyorData$ = surveyorData[0]) === null || _surveyorData$ === void 0 ? void 0 : _surveyorData$.surveyorData;
6819
7069
  const formData = {
6820
- supervisor: {
7070
+ surveyor: {
6821
7071
  ...details,
6822
7072
  status: "INACTIVE"
6823
7073
  }
6824
7074
  };
6825
- mutateSupervisor(formData, {
7075
+ mutateSurveyor(formData, {
6826
7076
  onError: error => {
6827
7077
  setShowToast({
6828
7078
  key: "error",
@@ -6833,9 +7083,9 @@ const SupervisorDetails = props => {
6833
7083
  onSuccess: () => {
6834
7084
  setShowToast({
6835
7085
  key: "success",
6836
- action: "DELETE_SUPERVISOR"
7086
+ action: "DELETE_SURVEYOR"
6837
7087
  });
6838
- queryClient.invalidateQueries("SUPERVISOR_SEARCH");
7088
+ queryClient.invalidateQueries("SURVEYOR_SEARCH");
6839
7089
  setTimeout(() => {
6840
7090
  closeToast();
6841
7091
  history.push(`/digit-ui/employee/vendor/search-vendor`);
@@ -6845,19 +7095,19 @@ const SupervisorDetails = props => {
6845
7095
  setShowModal(false);
6846
7096
  };
6847
7097
  const handleDeleteVendor = () => {
6848
- var _supervisorData$2, _supervisorData$2$ven, _supervisorData$2$ven2;
6849
- 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];
6850
- let getSupervisorVendorDetails = (dsoDetails === null || dsoDetails === void 0 ? void 0 : dsoDetails.supervisors) || [];
6851
- getSupervisorVendorDetails = getSupervisorVendorDetails.map(data => {
6852
- if (data.id === supervisorId) {
6853
- data.vendorSupervisorStatus = "INACTIVE";
7098
+ var _surveyorData$2, _surveyorData$2$vendo, _surveyorData$2$vendo2;
7099
+ 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];
7100
+ let getSurveyorVendorDetails = (dsoDetails === null || dsoDetails === void 0 ? void 0 : dsoDetails.surveyors) || [];
7101
+ getSurveyorVendorDetails = getSurveyorVendorDetails.map(data => {
7102
+ if (data.id === surveyorId) {
7103
+ data.vendorSurveyorStatus = "INACTIVE";
6854
7104
  }
6855
7105
  return data;
6856
7106
  });
6857
7107
  const formData = {
6858
7108
  vendor: {
6859
7109
  ...dsoDetails,
6860
- supervisors: getSupervisorVendorDetails
7110
+ surveyors: getSurveyorVendorDetails
6861
7111
  }
6862
7112
  };
6863
7113
  mutateVendor(formData, {
@@ -6881,14 +7131,14 @@ const SupervisorDetails = props => {
6881
7131
  setShowModal(false);
6882
7132
  };
6883
7133
  const handleAddVendor = () => {
6884
- var _supervisorData$3;
7134
+ var _surveyorData$3;
6885
7135
  let dsoDetails = selectedOption;
6886
- let details = supervisorData === null || supervisorData === void 0 ? void 0 : (_supervisorData$3 = supervisorData[0]) === null || _supervisorData$3 === void 0 ? void 0 : _supervisorData$3.supervisorData;
6887
- details.vendorSupervisorStatus = "ACTIVE";
7136
+ let details = surveyorData === null || surveyorData === void 0 ? void 0 : (_surveyorData$3 = surveyorData[0]) === null || _surveyorData$3 === void 0 ? void 0 : _surveyorData$3.surveyorData;
7137
+ details.vendorSurveyorStatus = "ACTIVE";
6888
7138
  const formData = {
6889
7139
  vendor: {
6890
7140
  ...dsoDetails,
6891
- supervisors: dsoDetails.supervisors ? [...dsoDetails.supervisors, details] : [details]
7141
+ surveyors: dsoDetails.surveyors ? [...dsoDetails.surveyors, details] : [details]
6892
7142
  }
6893
7143
  };
6894
7144
  mutateVendor(formData, {
@@ -6905,7 +7155,7 @@ const SupervisorDetails = props => {
6905
7155
  key: "success",
6906
7156
  action: "ADD_VENDOR"
6907
7157
  });
6908
- queryClient.invalidateQueries("SUPERVISOR_SEARCH");
7158
+ queryClient.invalidateQueries("SURVEYOR_SEARCH");
6909
7159
  refetch();
6910
7160
  setTimeout(closeToast, 5000);
6911
7161
  }
@@ -6914,14 +7164,14 @@ const SupervisorDetails = props => {
6914
7164
  setSelectedAction(null);
6915
7165
  };
6916
7166
  const handleEditVendor = () => {
6917
- var _supervisorData$4;
7167
+ var _surveyorData$4;
6918
7168
  let dsoDetails = selectedOption;
6919
- let details = supervisorData === null || supervisorData === void 0 ? void 0 : (_supervisorData$4 = supervisorData[0]) === null || _supervisorData$4 === void 0 ? void 0 : _supervisorData$4.supervisorData;
6920
- details.vendorSupervisorStatus = "ACTIVE";
7169
+ let details = surveyorData === null || surveyorData === void 0 ? void 0 : (_surveyorData$4 = surveyorData[0]) === null || _surveyorData$4 === void 0 ? void 0 : _surveyorData$4.surveyorData;
7170
+ details.vendorSurveyorStatus = "ACTIVE";
6921
7171
  const formData = {
6922
7172
  vendor: {
6923
7173
  ...dsoDetails,
6924
- supervisors: dsoDetails.supervisors ? [...dsoDetails.supervisors, details] : [details]
7174
+ surveyors: dsoDetails.surveyors ? [...dsoDetails.surveyors, details] : [details]
6925
7175
  }
6926
7176
  };
6927
7177
  mutateVendor(formData, {
@@ -6938,7 +7188,7 @@ const SupervisorDetails = props => {
6938
7188
  action: "EDIT_VENDOR"
6939
7189
  });
6940
7190
  refetch();
6941
- queryClient.invalidateQueries("SUPERVISOR_SEARCH");
7191
+ queryClient.invalidateQueries("SURVEYOR_SEARCH");
6942
7192
  setTimeout(closeToast, 5000);
6943
7193
  }
6944
7194
  });
@@ -6954,17 +7204,17 @@ const SupervisorDetails = props => {
6954
7204
  switch (selectedAction) {
6955
7205
  case "DELETE":
6956
7206
  case "DELETE_VENDOR":
6957
- return "ES_VENDOR_SUPERVISOR_DELETE_POPUP_HEADER";
7207
+ return "ES_VENDOR_SURVEYOR_DELETE_POPUP_HEADER";
6958
7208
  case "ADD_VENDOR":
6959
7209
  case "EDIT_VENDOR":
6960
- return "ES_VENDOR_SUPERVISOR_ADD_VENDOR_POPUP_HEADER";
7210
+ return "ES_VENDOR_SURVEYOR_ADD_VENDOR_POPUP_HEADER";
6961
7211
  }
6962
7212
  };
6963
7213
  const renderModalContent = () => {
6964
7214
  if (selectedAction === "DELETE" || selectedAction === "DELETE_VENDOR") {
6965
7215
  return /*#__PURE__*/React.createElement(ConfirmationBox, {
6966
7216
  t: t,
6967
- title: "ES_VENDOR_SUPERVISOR_DELETE_TEXT"
7217
+ title: "ES_VENDOR_SURVEYOR_DELETE_TEXT"
6968
7218
  });
6969
7219
  }
6970
7220
  if (selectedAction === "ADD_VENDOR" || selectedAction === "EDIT_VENDOR") {
@@ -6983,13 +7233,8 @@ const SupervisorDetails = props => {
6983
7233
  }
6984
7234
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
6985
7235
  className: "employee-form-content"
6986
- }, /*#__PURE__*/React.createElement(Card, {
6987
- style: {
6988
- position: "relative",
6989
- backgroundColor: "#fff"
6990
- }
6991
- }, 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) => {
6992
- var _detail$values, _detail$child;
7236
+ }, /*#__PURE__*/React.createElement(Card, null, 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) => {
7237
+ var _detail$values;
6993
7238
  return /*#__PURE__*/React.createElement(React.Fragment, {
6994
7239
  key: index
6995
7240
  }, index > 0 && /*#__PURE__*/React.createElement(CardSectionHeader, {
@@ -6998,11 +7243,7 @@ const SupervisorDetails = props => {
6998
7243
  marginTop: "32px"
6999
7244
  }
7000
7245
  }, t(detail.title)), /*#__PURE__*/React.createElement(Card, {
7001
- className: "card-with-background",
7002
- style: {
7003
- margin: "10px 16px",
7004
- padding: "20px"
7005
- }
7246
+ className: "card-with-background"
7006
7247
  }, /*#__PURE__*/React.createElement("div", {
7007
7248
  className: "additional-grid"
7008
7249
  }, detail === null || detail === void 0 ? void 0 : (_detail$values = detail.values) === null || _detail$values === void 0 ? void 0 : _detail$values.map((value, index) => {
@@ -7047,64 +7288,7 @@ const SupervisorDetails = props => {
7047
7288
  }, t(value.title)), /*#__PURE__*/React.createElement("div", {
7048
7289
  className: "additional-value"
7049
7290
  }, t(value.value) || "N/A"));
7050
- }))), detail === null || detail === void 0 ? void 0 : (_detail$child = detail.child) === null || _detail$child === void 0 ? void 0 : _detail$child.map((data, index) => {
7051
- var _data$values;
7052
- return /*#__PURE__*/React.createElement(Card, {
7053
- className: "card-with-background",
7054
- key: data.id || index,
7055
- style: {
7056
- margin: "10px 16px",
7057
- padding: "20px"
7058
- }
7059
- }, /*#__PURE__*/React.createElement("div", {
7060
- className: "card-head",
7061
- style: {
7062
- display: "flex",
7063
- justifyContent: "space-between",
7064
- alignItems: "center",
7065
- marginBottom: "10px"
7066
- }
7067
- }, /*#__PURE__*/React.createElement("h2", {
7068
- style: {
7069
- fontSize: "18px",
7070
- fontWeight: "bold"
7071
- }
7072
- }, t(detail.type), " ", index + 1), /*#__PURE__*/React.createElement("div", {
7073
- style: {
7074
- display: "flex",
7075
- gap: "15px"
7076
- }
7077
- }, /*#__PURE__*/React.createElement("span", {
7078
- onClick: () => history.push(`/digit-ui/employee/vendor/registry/modify-surveyor/${data.id}`)
7079
- }, /*#__PURE__*/React.createElement(EditIcon, {
7080
- fill: "#a82227",
7081
- style: {
7082
- cursor: "pointer"
7083
- }
7084
- })))), /*#__PURE__*/React.createElement("div", {
7085
- className: "additional-grid"
7086
- }, 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, {
7087
- key: idx
7088
- }, /*#__PURE__*/React.createElement("div", {
7089
- className: "additional-label"
7090
- }, t(value.title)), /*#__PURE__*/React.createElement("div", {
7091
- className: "additional-value"
7092
- }, t(value.value) || "N/A")))));
7093
- }), detail.type && /*#__PURE__*/React.createElement("div", {
7094
- className: "add-details-link hover-button",
7095
- style: {
7096
- margin: "10px 16px",
7097
- color: "#a82227",
7098
- cursor: "pointer",
7099
- display: "flex",
7100
- alignItems: "center",
7101
- gap: "5px",
7102
- fontWeight: "bold"
7103
- },
7104
- onClick: () => history.push(`/digit-ui/employee/vendor/registry/new-surveyor?supervisorId=${supervisorId}`)
7105
- }, /*#__PURE__*/React.createElement(AddIcon, {
7106
- fill: "#a82227"
7107
- }), t(`${detail.type}_ADD`)));
7291
+ }))));
7108
7292
  }))), showModal && /*#__PURE__*/React.createElement(Modal, {
7109
7293
  headerBarMain: /*#__PURE__*/React.createElement(Heading$2, {
7110
7294
  label: t(modalHeading())
@@ -7129,7 +7313,7 @@ const SupervisorDetails = props => {
7129
7313
  zIndex: "19"
7130
7314
  }
7131
7315
  }, displayMenu ? /*#__PURE__*/React.createElement(Menu, {
7132
- localeKeyPrefix: "ES_VENDOR_SUPERVISOR_ACTION",
7316
+ localeKeyPrefix: "ES_VENDOR_SURVEYOR_ACTION",
7133
7317
  options: ["EDIT", "DELETE"],
7134
7318
  t: t,
7135
7319
  onSelect: a => {
@@ -7142,6 +7326,173 @@ const SupervisorDetails = props => {
7142
7326
  })));
7143
7327
  };
7144
7328
 
7329
+ const EditSurveyor = () => {
7330
+ var _Digit$UserService$ge;
7331
+ const {
7332
+ t
7333
+ } = useTranslation();
7334
+ const history = useHistory();
7335
+ const queryClient = useQueryClient();
7336
+ const {
7337
+ id: surveyorId
7338
+ } = useParams();
7339
+ const userInfo = (_Digit$UserService$ge = Digit.UserService.getUser()) === null || _Digit$UserService$ge === void 0 ? void 0 : _Digit$UserService$ge.info;
7340
+ const rawTenantId = Digit.ULBService.getCurrentTenantId();
7341
+ const tenantId = rawTenantId !== null && rawTenantId !== void 0 && rawTenantId.includes(".") ? rawTenantId : `${rawTenantId}.djb`;
7342
+ const [showToast, setShowToast] = useState(null);
7343
+ const [canSubmit, setCanSubmit] = useState(false);
7344
+ const [defaultValues, setDefaultValues] = useState({});
7345
+ const [surveyorDetails, setSurveyorDetails] = useState({});
7346
+ const {
7347
+ data: surveyorSearchResponse,
7348
+ isLoading
7349
+ } = Digit.Hooks.fsm.useSurveyorSearch(tenantId, {
7350
+ ids: surveyorId
7351
+ }, {
7352
+ staleTime: Infinity
7353
+ });
7354
+ const {
7355
+ mutate
7356
+ } = Digit.Hooks.fsm.useSurveyorUpdate(tenantId);
7357
+ const Config = SurveyorConfig(t);
7358
+ useEffect(() => {
7359
+ if (surveyorSearchResponse && surveyorSearchResponse.surveyors && surveyorSearchResponse.surveyors.length > 0) {
7360
+ var _details$owner, _details$owner2, _details$owner3, _details$owner4, _details$owner5, _details$owner6, _details$owner7, _details$owner8, _details$owner9;
7361
+ let details = surveyorSearchResponse.surveyors[0];
7362
+ setSurveyorDetails(details);
7363
+ let values = {
7364
+ fullName: (details === null || details === void 0 ? void 0 : (_details$owner = details.owner) === null || _details$owner === void 0 ? void 0 : _details$owner.name) || (details === null || details === void 0 ? void 0 : details.name),
7365
+ mobileNumber: (details === null || details === void 0 ? void 0 : (_details$owner2 = details.owner) === null || _details$owner2 === void 0 ? void 0 : _details$owner2.mobileNumber) || (details === null || details === void 0 ? void 0 : details.mobileNo),
7366
+ emailId: details === null || details === void 0 ? void 0 : (_details$owner3 = details.owner) === null || _details$owner3 === void 0 ? void 0 : _details$owner3.emailId,
7367
+ employeeId: details === null || details === void 0 ? void 0 : details.employeeId,
7368
+ gender: details !== null && details !== void 0 && (_details$owner4 = details.owner) !== null && _details$owner4 !== void 0 && _details$owner4.gender ? {
7369
+ code: details.owner.gender,
7370
+ name: `COMMON_GENDER_${details.owner.gender}`
7371
+ } : null,
7372
+ fatherOrHusbandName: details === null || details === void 0 ? void 0 : (_details$owner5 = details.owner) === null || _details$owner5 === void 0 ? void 0 : _details$owner5.fatherOrHusbandName,
7373
+ relationship: details !== null && details !== void 0 && (_details$owner6 = details.owner) !== null && _details$owner6 !== void 0 && _details$owner6.relationship ? {
7374
+ code: details.owner.relationship,
7375
+ name: `ES_COMMON_RELATION_${details.owner.relationship}`
7376
+ } : null,
7377
+ dob: (details === null || details === void 0 ? void 0 : (_details$owner7 = details.owner) === null || _details$owner7 === void 0 ? void 0 : _details$owner7.dob) && Digit.DateUtils.ConvertTimestampToDate(details === null || details === void 0 ? void 0 : (_details$owner8 = details.owner) === null || _details$owner8 === void 0 ? void 0 : _details$owner8.dob, "yyyy-MM-dd"),
7378
+ correspondenceAddress: details === null || details === void 0 ? void 0 : (_details$owner9 = details.owner) === null || _details$owner9 === void 0 ? void 0 : _details$owner9.correspondenceAddress,
7379
+ description: details === null || details === void 0 ? void 0 : details.description
7380
+ };
7381
+ setDefaultValues(values);
7382
+ }
7383
+ }, [surveyorSearchResponse]);
7384
+ const onFormValueChange = (setValue, formData) => {
7385
+ 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) && (formData === null || formData === void 0 ? void 0 : formData.fatherOrHusbandName) && (formData === null || formData === void 0 ? void 0 : formData.relationship) && (formData === null || formData === void 0 ? void 0 : formData.dob) && (formData === null || formData === void 0 ? void 0 : formData.correspondenceAddress);
7386
+ if (isBasicDetailsFilled) {
7387
+ setCanSubmit(true);
7388
+ } else {
7389
+ setCanSubmit(false);
7390
+ }
7391
+ };
7392
+ const closeToast = () => {
7393
+ setShowToast(null);
7394
+ };
7395
+ const onSubmit = data => {
7396
+ var _surveyorDetails$owne, _surveyorDetails$owne2, _data$relationship, _surveyorDetails$owne3, _data$gender, _surveyorDetails$owne4, _surveyorDetails$owne5, _surveyorDetails$owne6, _surveyorDetails$owne7, _surveyorDetails$owne8;
7397
+ const formData = {
7398
+ RequestInfo: {
7399
+ apiId: "Rainmaker",
7400
+ ver: "1.0",
7401
+ ts: null,
7402
+ action: "_update",
7403
+ msgId: `${Date.now()}|en_IN`,
7404
+ authToken: userInfo === null || userInfo === void 0 ? void 0 : userInfo.authToken,
7405
+ userInfo: {
7406
+ id: userInfo === null || userInfo === void 0 ? void 0 : userInfo.id,
7407
+ uuid: userInfo === null || userInfo === void 0 ? void 0 : userInfo.uuid,
7408
+ userName: userInfo === null || userInfo === void 0 ? void 0 : userInfo.userName,
7409
+ name: userInfo === null || userInfo === void 0 ? void 0 : userInfo.name,
7410
+ type: userInfo === null || userInfo === void 0 ? void 0 : userInfo.type,
7411
+ tenantId: tenantId,
7412
+ roles: userInfo === null || userInfo === void 0 ? void 0 : userInfo.roles
7413
+ }
7414
+ },
7415
+ surveyor: {
7416
+ ...surveyorDetails,
7417
+ description: (data === null || data === void 0 ? void 0 : data.description) || (surveyorDetails === null || surveyorDetails === void 0 ? void 0 : surveyorDetails.description) || "",
7418
+ name: (data === null || data === void 0 ? void 0 : data.fullName) || (surveyorDetails === null || surveyorDetails === void 0 ? void 0 : surveyorDetails.name),
7419
+ mobileNo: (data === null || data === void 0 ? void 0 : data.mobileNumber) || (surveyorDetails === null || surveyorDetails === void 0 ? void 0 : surveyorDetails.mobileNo),
7420
+ employeeId: (data === null || data === void 0 ? void 0 : data.employeeId) || (surveyorDetails === null || surveyorDetails === void 0 ? void 0 : surveyorDetails.employeeId),
7421
+ owner: {
7422
+ ...surveyorDetails.owner,
7423
+ name: (data === null || data === void 0 ? void 0 : data.fullName) || ((_surveyorDetails$owne = surveyorDetails.owner) === null || _surveyorDetails$owne === void 0 ? void 0 : _surveyorDetails$owne.name),
7424
+ fatherOrHusbandName: (data === null || data === void 0 ? void 0 : data.fatherOrHusbandName) || ((_surveyorDetails$owne2 = surveyorDetails.owner) === null || _surveyorDetails$owne2 === void 0 ? void 0 : _surveyorDetails$owne2.fatherOrHusbandName),
7425
+ relationship: (data === null || data === void 0 ? void 0 : (_data$relationship = data.relationship) === null || _data$relationship === void 0 ? void 0 : _data$relationship.code) || ((_surveyorDetails$owne3 = surveyorDetails.owner) === null || _surveyorDetails$owne3 === void 0 ? void 0 : _surveyorDetails$owne3.relationship),
7426
+ gender: (data === null || data === void 0 ? void 0 : (_data$gender = data.gender) === null || _data$gender === void 0 ? void 0 : _data$gender.code) || ((_surveyorDetails$owne4 = surveyorDetails.owner) === null || _surveyorDetails$owne4 === void 0 ? void 0 : _surveyorDetails$owne4.gender) || "OTHERS",
7427
+ dob: data !== null && data !== void 0 && data.dob ? new Date(data.dob).getTime() : (_surveyorDetails$owne5 = surveyorDetails.owner) === null || _surveyorDetails$owne5 === void 0 ? void 0 : _surveyorDetails$owne5.dob,
7428
+ emailId: (data === null || data === void 0 ? void 0 : data.emailId) || ((_surveyorDetails$owne6 = surveyorDetails.owner) === null || _surveyorDetails$owne6 === void 0 ? void 0 : _surveyorDetails$owne6.emailId),
7429
+ mobileNumber: (data === null || data === void 0 ? void 0 : data.mobileNumber) || ((_surveyorDetails$owne7 = surveyorDetails.owner) === null || _surveyorDetails$owne7 === void 0 ? void 0 : _surveyorDetails$owne7.mobileNumber),
7430
+ correspondenceAddress: (data === null || data === void 0 ? void 0 : data.correspondenceAddress) || ((_surveyorDetails$owne8 = surveyorDetails.owner) === null || _surveyorDetails$owne8 === void 0 ? void 0 : _surveyorDetails$owne8.correspondenceAddress)
7431
+ }
7432
+ }
7433
+ };
7434
+ mutate(formData, {
7435
+ onError: error => {
7436
+ setShowToast({
7437
+ key: "error",
7438
+ action: error
7439
+ });
7440
+ setTimeout(closeToast, 5000);
7441
+ },
7442
+ onSuccess: () => {
7443
+ setShowToast({
7444
+ key: "success",
7445
+ action: "UPDATE_SURVEYOR"
7446
+ });
7447
+ queryClient.invalidateQueries("SURVEYOR_SEARCH");
7448
+ setTimeout(() => {
7449
+ closeToast();
7450
+ history.push(`/digit-ui/employee/vendor/registry/surveyor-details/${surveyorId}`);
7451
+ }, 5000);
7452
+ }
7453
+ });
7454
+ };
7455
+ if (isLoading || Object.keys(defaultValues).length === 0) {
7456
+ return /*#__PURE__*/React.createElement(Loader, null);
7457
+ }
7458
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(VerticalTimeline, {
7459
+ config: [{
7460
+ timeLine: [{
7461
+ actions: t("ES_VENDOR_SURVEYOR_DETAILS"),
7462
+ currentStep: 1
7463
+ }]
7464
+ }],
7465
+ currentActiveIndex: 0,
7466
+ showFinalStep: false
7467
+ }), /*#__PURE__*/React.createElement("div", {
7468
+ style: {
7469
+ flex: "1",
7470
+ overflowY: "auto"
7471
+ }
7472
+ }, /*#__PURE__*/React.createElement(FormComposer, {
7473
+ isDisabled: !canSubmit,
7474
+ label: t("ES_COMMON_APPLICATION_SUBMIT"),
7475
+ config: Config.map(config => ({
7476
+ ...config,
7477
+ isCollapsible: true,
7478
+ isDefaultOpen: true
7479
+ })),
7480
+ fieldStyle: {
7481
+ marginRight: 0
7482
+ },
7483
+ onSubmit: onSubmit,
7484
+ defaultValues: defaultValues,
7485
+ onFormValueChange: onFormValueChange,
7486
+ noBreakLine: true,
7487
+ mode: "onChange",
7488
+ noCard: true
7489
+ }), showToast && /*#__PURE__*/React.createElement(Toast, {
7490
+ error: showToast.key === "error",
7491
+ label: t(showToast.key === "success" ? `ES_VENDOR_${showToast.action}_SUCCESS` : showToast.action),
7492
+ onClose: closeToast
7493
+ })));
7494
+ };
7495
+
7145
7496
  const ActionButton = ({
7146
7497
  jumpTo
7147
7498
  }) => {
@@ -8686,25 +9037,39 @@ const AddVehicle = ({
8686
9037
  };
8687
9038
  mutate(formData, {
8688
9039
  onError: (error, variables) => {
9040
+ var _error$response, _error$response$data, _error$response$data$, _error$response$data$2;
9041
+ const errorMessage = (error === null || error === void 0 ? void 0 : (_error$response = error.response) === null || _error$response === void 0 ? void 0 : (_error$response$data = _error$response.data) === null || _error$response$data === void 0 ? void 0 : (_error$response$data$ = _error$response$data.Errors) === null || _error$response$data$ === void 0 ? void 0 : (_error$response$data$2 = _error$response$data$[0]) === null || _error$response$data$2 === void 0 ? void 0 : _error$response$data$2.message) || (error === null || error === void 0 ? void 0 : error.message) || "An error occurred";
8689
9042
  setShowToast({
8690
9043
  key: "error",
8691
- action: error
9044
+ action: errorMessage
8692
9045
  });
8693
9046
  setTimeout(closeToast, 5000);
8694
9047
  },
8695
9048
  onSuccess: (data, variables) => {
8696
- var _vendorData$;
9049
+ var _data$Errors, _data$data, _data$data$Errors, _vendorData$;
9050
+ const isError = (data === null || data === void 0 ? void 0 : data.error) === true || (data === null || data === void 0 ? void 0 : (_data$Errors = data.Errors) === null || _data$Errors === void 0 ? void 0 : _data$Errors.length) > 0 || (data === null || data === void 0 ? void 0 : (_data$data = data.data) === null || _data$data === void 0 ? void 0 : (_data$data$Errors = _data$data.Errors) === null || _data$data$Errors === void 0 ? void 0 : _data$data$Errors.length) > 0;
9051
+ if (isError) {
9052
+ var _data$data2, _data$data2$Errors, _data$data2$Errors$, _data$Errors2, _data$Errors2$;
9053
+ const errorMessage = (data === null || data === void 0 ? void 0 : (_data$data2 = data.data) === null || _data$data2 === void 0 ? void 0 : (_data$data2$Errors = _data$data2.Errors) === null || _data$data2$Errors === void 0 ? void 0 : (_data$data2$Errors$ = _data$data2$Errors[0]) === null || _data$data2$Errors$ === void 0 ? void 0 : _data$data2$Errors$.message) || (data === null || data === void 0 ? void 0 : (_data$Errors2 = data.Errors) === null || _data$Errors2 === void 0 ? void 0 : (_data$Errors2$ = _data$Errors2[0]) === null || _data$Errors2$ === void 0 ? void 0 : _data$Errors2$.message) || (data === null || data === void 0 ? void 0 : data.message) || "An error occurred";
9054
+ setShowToast({
9055
+ key: "error",
9056
+ action: errorMessage
9057
+ });
9058
+ setTimeout(closeToast, 5000);
9059
+ return;
9060
+ }
8697
9061
  setShowToast({
8698
9062
  key: "success",
8699
9063
  action: "ADD_VEHICLE"
8700
9064
  });
8701
9065
  queryClient.invalidateQueries("FSM_VEICLES_SEARCH");
8702
9066
  if (isCitizen && vendorData !== null && vendorData !== void 0 && (_vendorData$ = vendorData[0]) !== null && _vendorData$ !== void 0 && _vendorData$.dsoDetails) {
8703
- const newVehicle = data.vehicle.map(v => ({
9067
+ var _data$vehicle4;
9068
+ const newVehicle = (data === null || data === void 0 ? void 0 : (_data$vehicle4 = data.vehicle) === null || _data$vehicle4 === void 0 ? void 0 : _data$vehicle4.map(v => ({
8704
9069
  ...v,
8705
9070
  vendorVehicleStatus: "ACTIVE",
8706
9071
  status: "ACTIVE"
8707
- }));
9072
+ }))) || [];
8708
9073
  const vendor = vendorData[0].dsoDetails;
8709
9074
  const updatedVendor = {
8710
9075
  vendor: {
@@ -8714,13 +9079,27 @@ const AddVehicle = ({
8714
9079
  };
8715
9080
  mutateVendor(updatedVendor, {
8716
9081
  onError: error => {
9082
+ var _error$response2, _error$response2$data, _error$response2$data2, _error$response2$data3;
9083
+ const errorMessage = (error === null || error === void 0 ? void 0 : (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : (_error$response2$data = _error$response2.data) === null || _error$response2$data === void 0 ? void 0 : (_error$response2$data2 = _error$response2$data.Errors) === null || _error$response2$data2 === void 0 ? void 0 : (_error$response2$data3 = _error$response2$data2[0]) === null || _error$response2$data3 === void 0 ? void 0 : _error$response2$data3.message) || (error === null || error === void 0 ? void 0 : error.message) || "An error occurred";
8717
9084
  setShowToast({
8718
9085
  key: "error",
8719
- action: error
9086
+ action: errorMessage
8720
9087
  });
9088
+ setTimeout(closeToast, 5000);
8721
9089
  },
8722
- onSuccess: () => {
8723
- var _Digit$UserService$ge3, _Digit$UserService$ge4, _Digit$UserService$ge5;
9090
+ onSuccess: vendorDataRes => {
9091
+ var _vendorDataRes$Errors, _vendorDataRes$data, _vendorDataRes$data$E, _Digit$UserService$ge3, _Digit$UserService$ge4, _Digit$UserService$ge5;
9092
+ const isError = (vendorDataRes === null || vendorDataRes === void 0 ? void 0 : vendorDataRes.error) === true || (vendorDataRes === null || vendorDataRes === void 0 ? void 0 : (_vendorDataRes$Errors = vendorDataRes.Errors) === null || _vendorDataRes$Errors === void 0 ? void 0 : _vendorDataRes$Errors.length) > 0 || (vendorDataRes === null || vendorDataRes === void 0 ? void 0 : (_vendorDataRes$data = vendorDataRes.data) === null || _vendorDataRes$data === void 0 ? void 0 : (_vendorDataRes$data$E = _vendorDataRes$data.Errors) === null || _vendorDataRes$data$E === void 0 ? void 0 : _vendorDataRes$data$E.length) > 0;
9093
+ if (isError) {
9094
+ var _vendorDataRes$data2, _vendorDataRes$data2$, _vendorDataRes$data2$2, _vendorDataRes$Errors2, _vendorDataRes$Errors3;
9095
+ const errorMessage = (vendorDataRes === null || vendorDataRes === void 0 ? void 0 : (_vendorDataRes$data2 = vendorDataRes.data) === null || _vendorDataRes$data2 === void 0 ? void 0 : (_vendorDataRes$data2$ = _vendorDataRes$data2.Errors) === null || _vendorDataRes$data2$ === void 0 ? void 0 : (_vendorDataRes$data2$2 = _vendorDataRes$data2$[0]) === null || _vendorDataRes$data2$2 === void 0 ? void 0 : _vendorDataRes$data2$2.message) || (vendorDataRes === null || vendorDataRes === void 0 ? void 0 : (_vendorDataRes$Errors2 = vendorDataRes.Errors) === null || _vendorDataRes$Errors2 === void 0 ? void 0 : (_vendorDataRes$Errors3 = _vendorDataRes$Errors2[0]) === null || _vendorDataRes$Errors3 === void 0 ? void 0 : _vendorDataRes$Errors3.message) || (vendorDataRes === null || vendorDataRes === void 0 ? void 0 : vendorDataRes.message) || "An error occurred";
9096
+ setShowToast({
9097
+ key: "error",
9098
+ action: errorMessage
9099
+ });
9100
+ setTimeout(closeToast, 5000);
9101
+ return;
9102
+ }
8724
9103
  setShowToast({
8725
9104
  key: "success",
8726
9105
  action: "ADD_VEHICLE"
@@ -9395,9 +9774,11 @@ const componentsToRegister = {
9395
9774
  VehicleDetails,
9396
9775
  AddSupervisor,
9397
9776
  SupervisorDetails,
9777
+ EditSupervisor,
9398
9778
  SupervisorAreaAssignment,
9399
9779
  AddSurveyor,
9400
9780
  SurveyorDetails,
9781
+ EditSurveyor,
9401
9782
  SelectEkycZones,
9402
9783
  SelectEkycClusters,
9403
9784
  SelectEkycDropdown