@djb25/digit-ui-module-ekyc 1.0.48 → 1.0.50

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.
package/dist/index.js CHANGED
@@ -78,6 +78,9 @@ const EKYCCard = () => {
78
78
  count: totalCount,
79
79
  label: t("EKYC_INBOX"),
80
80
  link: prefix + "/inbox"
81
+ }, {
82
+ label: t("EKYC_WORK_ORDER"),
83
+ link: prefix + "/work-order"
81
84
  }, ...(!roles.includes("EMPLOYEE") ? [{
82
85
  label: t("EKYC_ASSIGN"),
83
86
  link: prefix + "/assign"
@@ -6658,6 +6661,211 @@ const SurveyorDetailsDashboard = () => {
6658
6661
  }));
6659
6662
  };
6660
6663
 
6664
+ const WorkOrder = () => {
6665
+ const tenantId = Digit.ULBService.getCurrentTenantId();
6666
+ const _useTranslation = reactI18next.useTranslation(),
6667
+ t = _useTranslation.t;
6668
+ const history = reactRouterDom.useHistory();
6669
+ const _useState = React.useState(null),
6670
+ showToast = _useState[0],
6671
+ setShowToast = _useState[1];
6672
+ const _useState2 = React.useState(null),
6673
+ vendor = _useState2[0],
6674
+ setVendor = _useState2[1];
6675
+ const _useState3 = React.useState(""),
6676
+ validFrom = _useState3[0],
6677
+ setValidFrom = _useState3[1];
6678
+ const _useState4 = React.useState(""),
6679
+ validTo = _useState4[0],
6680
+ setValidTo = _useState4[1];
6681
+ const _useState5 = React.useState(null),
6682
+ uploadedFile = _useState5[0],
6683
+ setUploadedFile = _useState5[1];
6684
+ const _useState6 = React.useState(null),
6685
+ file = _useState6[0],
6686
+ setFile = _useState6[1];
6687
+ const _useState7 = React.useState(null),
6688
+ error = _useState7[0],
6689
+ setError = _useState7[1];
6690
+ const _Digit$Hooks$fsm$useV = Digit.Hooks.fsm.useVendorSearch({
6691
+ tenantId,
6692
+ filters: {
6693
+ status: "ACTIVE"
6694
+ },
6695
+ config: {
6696
+ select: data => (data === null || data === void 0 ? void 0 : data.vendor) || []
6697
+ }
6698
+ }),
6699
+ vendorOptions = _Digit$Hooks$fsm$useV.data;
6700
+ const _Digit$Hooks$wt$useVe = Digit.Hooks.wt.useVendorWorkOrderCreate(tenantId),
6701
+ createWorkOrder = _Digit$Hooks$wt$useVe.mutate;
6702
+ React.useEffect(() => {
6703
+ (function () {
6704
+ try {
6705
+ setError(null);
6706
+ const _temp3 = function () {
6707
+ if (file) {
6708
+ const _temp2 = function () {
6709
+ if (file.size >= 10000000) {
6710
+ setError(t("EKYC_MAXIMUM_UPLOAD_SIZE_EXCEEDED") || "File size exceeds 10MB");
6711
+ } else {
6712
+ const _temp = _catch(function () {
6713
+ return Promise.resolve(Digit.UploadServices.Filestorage("EKYC", file, Digit.ULBService.getStateId())).then(function (response) {
6714
+ var _response$data, _response$data$files;
6715
+ if ((response === null || response === void 0 ? void 0 : (_response$data = response.data) === null || _response$data === void 0 ? void 0 : (_response$data$files = _response$data.files) === null || _response$data$files === void 0 ? void 0 : _response$data$files.length) > 0) {
6716
+ var _response$data2, _response$data2$files;
6717
+ setUploadedFile(response === null || response === void 0 ? void 0 : (_response$data2 = response.data) === null || _response$data2 === void 0 ? void 0 : (_response$data2$files = _response$data2.files[0]) === null || _response$data2$files === void 0 ? void 0 : _response$data2$files.fileStoreId);
6718
+ } else {
6719
+ setError(t("EKYC_FILE_UPLOAD_ERROR"));
6720
+ }
6721
+ });
6722
+ }, function () {
6723
+ setError(t("EKYC_FILE_UPLOAD_ERROR"));
6724
+ });
6725
+ if (_temp && _temp.then) return _temp.then(function () {});
6726
+ }
6727
+ }();
6728
+ if (_temp2 && _temp2.then) return _temp2.then(function () {});
6729
+ }
6730
+ }();
6731
+ return _temp3 && _temp3.then ? _temp3.then(function () {}) : void 0;
6732
+ } catch (e) {
6733
+ Promise.reject(e);
6734
+ }
6735
+ })();
6736
+ }, [file]);
6737
+ const handleSubmit = () => {
6738
+ var _vendor$owner, _vendor$owner2;
6739
+ const payload = {
6740
+ vendorWorkOrder: {
6741
+ tenantId,
6742
+ name: vendor === null || vendor === void 0 ? void 0 : vendor.name,
6743
+ mobileNumber: vendor === null || vendor === void 0 ? void 0 : (_vendor$owner = vendor.owner) === null || _vendor$owner === void 0 ? void 0 : _vendor$owner.mobileNumber,
6744
+ emailId: vendor === null || vendor === void 0 ? void 0 : (_vendor$owner2 = vendor.owner) === null || _vendor$owner2 === void 0 ? void 0 : _vendor$owner2.emailId,
6745
+ vendorId: (vendor === null || vendor === void 0 ? void 0 : vendor.code) || (vendor === null || vendor === void 0 ? void 0 : vendor.id),
6746
+ validFrom: new Date(validFrom).getTime(),
6747
+ validTo: new Date(validTo).getTime(),
6748
+ serviceType: "EKYC",
6749
+ fileStoreId: uploadedFile
6750
+ }
6751
+ };
6752
+ createWorkOrder(payload, {
6753
+ onSuccess: result => {
6754
+ setShowToast({
6755
+ isError: false,
6756
+ label: t("EKYC_WORK_ORDER_SAVE_SUCCESS")
6757
+ });
6758
+ setTimeout(() => {
6759
+ history.push("/digit-ui/employee/module/details");
6760
+ }, 3000);
6761
+ },
6762
+ onError: err => {
6763
+ var _err$response, _err$response$data, _err$response$data$Er, _err$response$data$Er2;
6764
+ setShowToast({
6765
+ isError: true,
6766
+ label: (err === null || err === void 0 ? void 0 : (_err$response = err.response) === null || _err$response === void 0 ? void 0 : (_err$response$data = _err$response.data) === null || _err$response$data === void 0 ? void 0 : (_err$response$data$Er = _err$response$data.Errors) === null || _err$response$data$Er === void 0 ? void 0 : (_err$response$data$Er2 = _err$response$data$Er[0]) === null || _err$response$data$Er2 === void 0 ? void 0 : _err$response$data$Er2.message) || t("EKYC_WORK_ORDER_SAVE_ERROR")
6767
+ });
6768
+ }
6769
+ });
6770
+ };
6771
+ function selectfile(e) {
6772
+ setUploadedFile(null);
6773
+ setFile(e.target.files[0]);
6774
+ }
6775
+ const isFormDisabled = !vendor || !validFrom || !validTo || !uploadedFile;
6776
+ const isMobile = window.Digit.Utils.browser.isMobile();
6777
+ return /*#__PURE__*/React__default.createElement("div", {
6778
+ className: "employee-form-section-wrapper"
6779
+ }, /*#__PURE__*/React__default.createElement(digitUiReactComponents.VerticalTimeline, {
6780
+ config: [{
6781
+ timeLine: [{
6782
+ actions: t("EKYC_WORK_ORDER_ASSIGN"),
6783
+ currentStep: 1
6784
+ }]
6785
+ }],
6786
+ showFinalStep: false
6787
+ }), /*#__PURE__*/React__default.createElement("div", {
6788
+ style: {
6789
+ flex: 1
6790
+ }
6791
+ }, /*#__PURE__*/React__default.createElement(digitUiReactComponents.CollapsibleCardPage, {
6792
+ title: t("EKYC_UPLOAD_WORK_ORDER"),
6793
+ defaultOpen: true
6794
+ }, /*#__PURE__*/React__default.createElement("div", {
6795
+ className: "formcomposer-section-grid"
6796
+ }, /*#__PURE__*/React__default.createElement("div", {
6797
+ style: {
6798
+ display: "flex",
6799
+ flexDirection: "column"
6800
+ }
6801
+ }, /*#__PURE__*/React__default.createElement(digitUiReactComponents.Label, null, "" + t("EKYC_VENDOR_NAME"), " ", /*#__PURE__*/React__default.createElement("span", {
6802
+ className: "check-page-link-button"
6803
+ }, "*")), /*#__PURE__*/React__default.createElement(digitUiReactComponents.Dropdown, {
6804
+ t: t,
6805
+ option: vendorOptions,
6806
+ optionKey: "name",
6807
+ select: setVendor,
6808
+ selected: vendor,
6809
+ placeholder: t("EKYC_SELECT_VENDOR")
6810
+ })), /*#__PURE__*/React__default.createElement("div", {
6811
+ style: {
6812
+ display: "flex",
6813
+ flexDirection: "column"
6814
+ }
6815
+ }, /*#__PURE__*/React__default.createElement(digitUiReactComponents.Label, null, "" + t("COMMON_VALID_FROM_DATE"), " ", /*#__PURE__*/React__default.createElement("span", {
6816
+ className: "check-page-link-button"
6817
+ }, "*")), /*#__PURE__*/React__default.createElement(digitUiReactComponents.DatePicker, {
6818
+ date: validFrom,
6819
+ onChange: date => setValidFrom(date),
6820
+ style: {
6821
+ width: "100%"
6822
+ }
6823
+ })), /*#__PURE__*/React__default.createElement("div", {
6824
+ style: {
6825
+ display: "flex",
6826
+ flexDirection: "column"
6827
+ }
6828
+ }, /*#__PURE__*/React__default.createElement(digitUiReactComponents.Label, null, "" + t("COMMON_VALID_TO_DATE"), " ", /*#__PURE__*/React__default.createElement("span", {
6829
+ className: "check-page-link-button"
6830
+ }, "*")), /*#__PURE__*/React__default.createElement(digitUiReactComponents.DatePicker, {
6831
+ date: validTo,
6832
+ min: validFrom,
6833
+ onChange: date => setValidTo(date),
6834
+ style: {
6835
+ width: "100%"
6836
+ }
6837
+ })), /*#__PURE__*/React__default.createElement("div", {
6838
+ style: {
6839
+ display: "flex",
6840
+ flexDirection: "column"
6841
+ }
6842
+ }, /*#__PURE__*/React__default.createElement(digitUiReactComponents.Label, null, "" + t("EKYC_UPLOAD_DOCUMENT"), " ", /*#__PURE__*/React__default.createElement("span", {
6843
+ className: "check-page-link-button"
6844
+ }, "*")), /*#__PURE__*/React__default.createElement(digitUiReactComponents.UploadFile, {
6845
+ id: "ekyc-doc",
6846
+ extraStyleName: "propertyCreate",
6847
+ accept: "image/*, .pdf, .png, .jpeg, .jpg",
6848
+ onUpload: selectfile,
6849
+ onDelete: () => setUploadedFile(null),
6850
+ message: uploadedFile ? "1 " + t("EKYC_ACTION_FILEUPLOADED") : t("EKYC_ACTION_NO_FILEUPLOADED"),
6851
+ error: error
6852
+ })))), /*#__PURE__*/React__default.createElement("div", {
6853
+ style: {
6854
+ display: "flex",
6855
+ marginTop: "24px",
6856
+ justifyContent: isMobile ? "center" : "flex-end"
6857
+ }
6858
+ }, /*#__PURE__*/React__default.createElement(digitUiReactComponents.SubmitBar, {
6859
+ label: t("ES_COMMON_SAVE"),
6860
+ onSubmit: isFormDisabled ? null : handleSubmit,
6861
+ disabled: isFormDisabled
6862
+ }))), showToast && /*#__PURE__*/React__default.createElement(digitUiReactComponents.Toast, {
6863
+ error: showToast.isError,
6864
+ label: showToast.label,
6865
+ onClose: () => setShowToast(null)
6866
+ }));
6867
+ };
6868
+
6661
6869
  function formReducer(state, payload) {
6662
6870
  const storageKey = "EKYC.SW.INBOX";
6663
6871
  switch (payload.action) {
@@ -7020,6 +7228,11 @@ const getEkycRoutes = userType => [{
7020
7228
  component: AdminDashboard,
7021
7229
  layout: "normal",
7022
7230
  breadcrumb: "EKYC_ADMIN_DASHBOARD"
7231
+ }, {
7232
+ path: "/work-order",
7233
+ component: WorkOrder,
7234
+ layout: "normal",
7235
+ breadcrumb: "EKYC_WORK_ORDER"
7023
7236
  }, {
7024
7237
  path: "/consumer-details",
7025
7238
  component: EKYCForm,
@@ -7190,6 +7403,11 @@ const EmployeeApp = _ref => {
7190
7403
  component: () => /*#__PURE__*/React__default.createElement(digitUiReactComponents.LayoutWrapper, {
7191
7404
  layoutClass: "normal"
7192
7405
  }, /*#__PURE__*/React__default.createElement(SurveyorDetailsDashboard, null))
7406
+ }), /*#__PURE__*/React__default.createElement(digitUiReactComponents.PrivateRoute, {
7407
+ path: path + "/work-order",
7408
+ component: () => /*#__PURE__*/React__default.createElement(digitUiReactComponents.LayoutWrapper, {
7409
+ layoutClass: "normal"
7410
+ }, /*#__PURE__*/React__default.createElement(WorkOrder, null))
7193
7411
  })))));
7194
7412
  };
7195
7413