@djb25/digit-ui-module-wt 1.0.31 → 1.0.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { TickMark, ArrowDown, MobileNumber, CardLabelError, TextInput, Dropdown, DatePicker, SubmitBar, Card, Table, Loader, Toast, AppContainer, ModuleHeader, ArrowLeft, PrivateRoute, HomeIcon, KeyNote, Modal, CardHeader, FormStep, CardLabel, RadioButtons, UploadFile, TextArea, CheckBox, CardSubHeader, StatusTable, Row, GenericFileIcon, LinkButton, EditIcon, Banner, CHBIcon, EmployeeModuleCard, CloseSvg, Label, LinkLabel, ActionBar, DetailsCard, SearchAction, FilterAction, PopUp, ShippingTruck, CustomNameDropdown, MultiSelectDropdown, CollapsibleCardPage as CollapsibleCardPage$1, LabelFieldPair, AddIcon, Menu, Header, TelePhone, DisplayPhotos, CardSectionHeader, CheckPoint, ConnectingCheckPoints, MultiLink, Localities, RemoveableTag, FormComposer, PDFSvg, MultiUploadWrapper, Close as Close$g, BreakLine, InfoBannerIcon, ViewsIcon, ButtonSelector, LocationIcon, CitizenHomeCard, PTIcon, ApplicantDetails, AddressDetails } from '@djb25/digit-ui-react-components';
2
- import React, { useRef, useEffect, useState, useMemo, useCallback, Fragment } from 'react';
1
+ import { TickMark, ArrowDown, MobileNumber, CardLabelError, TextInput, Dropdown, DatePicker, SubmitBar, Card, Table, Loader, Toast, AppContainer, ModuleHeader, ArrowLeft, PrivateRoute, HomeIcon, KeyNote, Modal, CardHeader, FormStep, CardLabel, RadioButtons, UploadFile, TextArea, CheckBox, CardSubHeader, StatusTable, Row, GenericFileIcon, LinkButton, EditIcon, Banner, CHBIcon, EmployeeModuleCard, CloseSvg, Label, LinkLabel, ActionBar, DetailsCard, SearchAction, FilterAction, PopUp, ShippingTruck, CustomNameDropdown, MultiSelectDropdown, CollapsibleCardPage as CollapsibleCardPage$1, LabelFieldPair, AddIcon, Menu, CheckSvg, LayoutWrapper, Header, TelePhone, DisplayPhotos, CardSectionHeader, CheckPoint, ConnectingCheckPoints, MultiLink, Localities, RemoveableTag, FormComposer, PDFSvg, MultiUploadWrapper, Close as Close$g, BreakLine, InfoBannerIcon, ViewsIcon, ButtonSelector, LocationIcon, CitizenHomeCard, PTIcon, ApplicantDetails, AddressDetails } from '@djb25/digit-ui-react-components';
2
+ import React, { useRef, useEffect, useState, useMemo, useCallback, Fragment, useReducer } from 'react';
3
3
  import { useTranslation } from 'react-i18next';
4
4
  import { useLocation, useRouteMatch, useHistory, Switch, Route, Redirect, Link, useParams } from 'react-router-dom';
5
5
  import { useQueryClient } from 'react-query';
@@ -7578,69 +7578,238 @@ const SearchFillingPointAddress = () => {
7578
7578
  }));
7579
7579
  };
7580
7580
 
7581
- const SelectServiceType = ({
7582
- config,
7581
+ const VendorMultiSelectDropdown = ({
7582
+ options,
7583
+ optionsKey,
7584
+ selected: _selected = [],
7583
7585
  onSelect,
7584
- t,
7585
- userType,
7586
- formData
7586
+ defaultLabel: _defaultLabel = "",
7587
+ defaultUnit: _defaultUnit = "",
7588
+ BlockNumber: _BlockNumber = 1,
7589
+ isOBPSMultiple: _isOBPSMultiple = false,
7590
+ props: _props = {},
7591
+ isPropsNeeded: _isPropsNeeded = false,
7592
+ ServerStyle: _ServerStyle = {},
7593
+ isSurvey: _isSurvey = false,
7594
+ disable: _disable = false
7587
7595
  }) => {
7588
- const tenantId = Digit.ULBService.getCurrentTenantId();
7589
- const stateId = Digit.ULBService.getStateId();
7590
- const [serviceTypes, setserviceTypes] = useState(formData === null || formData === void 0 ? void 0 : formData.serviceType);
7591
- const [formattedServiceTypes, setFormattedServiceTypes] = useState([]);
7596
+ const [active, setActive] = useState(false);
7597
+ const [searchQuery, setSearchQuery] = useState();
7598
+ const [optionIndex, setOptionIndex] = useState(-1);
7599
+ const dropdownRef = useRef();
7592
7600
  const {
7593
- data: ServiceType,
7594
- isLoading
7595
- } = Digit.Hooks.useCustomMDMS(tenantId, "tenant", [{
7596
- name: "citymodule"
7597
- }], {
7598
- select: data => {
7599
- var _data$tenant;
7600
- return data === null || data === void 0 ? void 0 : (_data$tenant = data.tenant) === null || _data$tenant === void 0 ? void 0 : _data$tenant.citymodule;
7601
+ t
7602
+ } = useTranslation();
7603
+ function reducer(state, action) {
7604
+ var _action$payload, _action$payload$;
7605
+ switch (action.type) {
7606
+ case "ADD_TO_SELECTED_EVENT_QUEUE":
7607
+ return [...state, {
7608
+ [optionsKey]: (_action$payload = action.payload) === null || _action$payload === void 0 ? void 0 : (_action$payload$ = _action$payload[1]) === null || _action$payload$ === void 0 ? void 0 : _action$payload$[optionsKey],
7609
+ propsData: action.payload
7610
+ }];
7611
+ case "REMOVE_FROM_SELECTED_EVENT_QUEUE":
7612
+ return state.filter(e => {
7613
+ var _action$payload2, _action$payload2$;
7614
+ return (e === null || e === void 0 ? void 0 : e[optionsKey]) !== ((_action$payload2 = action.payload) === null || _action$payload2 === void 0 ? void 0 : (_action$payload2$ = _action$payload2[1]) === null || _action$payload2$ === void 0 ? void 0 : _action$payload2$[optionsKey]);
7615
+ });
7616
+ case "REPLACE_COMPLETE_STATE":
7617
+ return action.payload;
7618
+ default:
7619
+ return state;
7601
7620
  }
7602
- });
7621
+ }
7603
7622
  useEffect(() => {
7604
- if (ServiceType) {
7605
- const transformedData = ServiceType.map(services => ({
7606
- i18nKey: `${services.code}`,
7607
- code: `${services.code}`,
7608
- value: `${services.name}`
7609
- }));
7610
- setFormattedServiceTypes(transformedData);
7611
- if (!serviceTypes || serviceTypes.code === "WT") {
7612
- const defaultWT = transformedData.find(item => item.code === "WT");
7613
- if (defaultWT) {
7614
- setserviceTypes(defaultWT);
7615
- if ((userType === null || userType === void 0 ? void 0 : userType.toLowerCase()) === "employee") {
7616
- onSelect(config.key, defaultWT);
7617
- }
7618
- }
7623
+ dispatch({
7624
+ type: "REPLACE_COMPLETE_STATE",
7625
+ payload: fnToSelectOptionThroughProvidedSelection(_selected)
7626
+ });
7627
+ }, [_selected === null || _selected === void 0 ? void 0 : _selected.map(e => e === null || e === void 0 ? void 0 : e[optionsKey]).join(",")]);
7628
+ function fnToSelectOptionThroughProvidedSelection(selected) {
7629
+ return selected === null || selected === void 0 ? void 0 : selected.map(e => ({
7630
+ [optionsKey]: e === null || e === void 0 ? void 0 : e[optionsKey],
7631
+ propsData: [null, e]
7632
+ }));
7633
+ }
7634
+ const [alreadyQueuedSelectedState, dispatch] = useReducer(reducer, _selected, fnToSelectOptionThroughProvidedSelection);
7635
+ function handleOutsideClickAndSubmitSimultaneously() {
7636
+ setActive(false);
7637
+ }
7638
+ Digit.Hooks.useClickOutside(dropdownRef, handleOutsideClickAndSubmitSimultaneously, active, {
7639
+ capture: true
7640
+ });
7641
+ const filtOptns = (searchQuery === null || searchQuery === void 0 ? void 0 : searchQuery.length) > 0 ? options.filter(option => t(option[optionsKey] && typeof option[optionsKey] == "string" && option[optionsKey].toUpperCase()).toLowerCase().indexOf(searchQuery.toLowerCase()) >= 0) : options;
7642
+ function onSearch(e) {
7643
+ setSearchQuery(e.target.value);
7644
+ }
7645
+ function onSelectToAddToQueue(...args) {
7646
+ const isChecked = args[0].target.checked;
7647
+ const option = args[1];
7648
+ if (isChecked) {
7649
+ dispatch({
7650
+ type: "ADD_TO_SELECTED_EVENT_QUEUE",
7651
+ payload: [...args]
7652
+ });
7653
+ const newSelected = [...alreadyQueuedSelectedState, {
7654
+ [optionsKey]: option[optionsKey],
7655
+ propsData: args
7656
+ }];
7657
+ onSelect(newSelected.map(e => e.propsData), _props);
7658
+ } else {
7659
+ dispatch({
7660
+ type: "REMOVE_FROM_SELECTED_EVENT_QUEUE",
7661
+ payload: [...args]
7662
+ });
7663
+ const newSelected = alreadyQueuedSelectedState.filter(e => (e === null || e === void 0 ? void 0 : e[optionsKey]) !== option[optionsKey]);
7664
+ onSelect(newSelected.map(e => e.propsData), _props);
7665
+ }
7666
+ }
7667
+ const keyChange = e => {
7668
+ if (e.key == "ArrowDown") {
7669
+ setOptionIndex(state => state + 1 == filtOptns.length ? 0 : state + 1);
7670
+ if (optionIndex + 1 == filtOptns.length) {
7671
+ var _e$target, _e$target$parentEleme, _e$target$parentEleme2, _e$target$parentEleme3, _e$target$parentEleme4, _e$target$parentEleme5;
7672
+ e === null || e === void 0 ? void 0 : (_e$target = e.target) === null || _e$target === void 0 ? void 0 : (_e$target$parentEleme = _e$target.parentElement) === null || _e$target$parentEleme === void 0 ? void 0 : (_e$target$parentEleme2 = _e$target$parentEleme.parentElement) === null || _e$target$parentEleme2 === void 0 ? void 0 : (_e$target$parentEleme3 = _e$target$parentEleme2.children) === null || _e$target$parentEleme3 === void 0 ? void 0 : (_e$target$parentEleme4 = _e$target$parentEleme3.namedItem("jk-dropdown-unique")) === null || _e$target$parentEleme4 === void 0 ? void 0 : (_e$target$parentEleme5 = _e$target$parentEleme4.scrollTo) === null || _e$target$parentEleme5 === void 0 ? void 0 : _e$target$parentEleme5.call(_e$target$parentEleme4, 0, 0);
7673
+ } else {
7674
+ var _e$target2, _e$target2$parentElem, _e$target2$parentElem2, _e$target2$parentElem3, _e$target2$parentElem4, _e$target2$parentElem5;
7675
+ optionIndex > 2 && (e === null || e === void 0 ? void 0 : (_e$target2 = e.target) === null || _e$target2 === void 0 ? void 0 : (_e$target2$parentElem = _e$target2.parentElement) === null || _e$target2$parentElem === void 0 ? void 0 : (_e$target2$parentElem2 = _e$target2$parentElem.parentElement) === null || _e$target2$parentElem2 === void 0 ? void 0 : (_e$target2$parentElem3 = _e$target2$parentElem2.children) === null || _e$target2$parentElem3 === void 0 ? void 0 : (_e$target2$parentElem4 = _e$target2$parentElem3.namedItem("jk-dropdown-unique")) === null || _e$target2$parentElem4 === void 0 ? void 0 : (_e$target2$parentElem5 = _e$target2$parentElem4.scrollBy) === null || _e$target2$parentElem5 === void 0 ? void 0 : _e$target2$parentElem5.call(_e$target2$parentElem4, 0, 45));
7676
+ }
7677
+ e.preventDefault();
7678
+ } else if (e.key == "ArrowUp") {
7679
+ setOptionIndex(state => state !== 0 ? state - 1 : filtOptns.length - 1);
7680
+ if (optionIndex === 0) {
7681
+ var _e$target3, _e$target3$parentElem, _e$target3$parentElem2, _e$target3$parentElem3, _e$target3$parentElem4, _e$target3$parentElem5;
7682
+ e === null || e === void 0 ? void 0 : (_e$target3 = e.target) === null || _e$target3 === void 0 ? void 0 : (_e$target3$parentElem = _e$target3.parentElement) === null || _e$target3$parentElem === void 0 ? void 0 : (_e$target3$parentElem2 = _e$target3$parentElem.parentElement) === null || _e$target3$parentElem2 === void 0 ? void 0 : (_e$target3$parentElem3 = _e$target3$parentElem2.children) === null || _e$target3$parentElem3 === void 0 ? void 0 : (_e$target3$parentElem4 = _e$target3$parentElem3.namedItem("jk-dropdown-unique")) === null || _e$target3$parentElem4 === void 0 ? void 0 : (_e$target3$parentElem5 = _e$target3$parentElem4.scrollTo) === null || _e$target3$parentElem5 === void 0 ? void 0 : _e$target3$parentElem5.call(_e$target3$parentElem4, 100000, 100000);
7683
+ } else {
7684
+ var _e$target4, _e$target4$parentElem, _e$target4$parentElem2, _e$target4$parentElem3, _e$target4$parentElem4, _e$target4$parentElem5;
7685
+ optionIndex > 2 && (e === null || e === void 0 ? void 0 : (_e$target4 = e.target) === null || _e$target4 === void 0 ? void 0 : (_e$target4$parentElem = _e$target4.parentElement) === null || _e$target4$parentElem === void 0 ? void 0 : (_e$target4$parentElem2 = _e$target4$parentElem.parentElement) === null || _e$target4$parentElem2 === void 0 ? void 0 : (_e$target4$parentElem3 = _e$target4$parentElem2.children) === null || _e$target4$parentElem3 === void 0 ? void 0 : (_e$target4$parentElem4 = _e$target4$parentElem3.namedItem("jk-dropdown-unique")) === null || _e$target4$parentElem4 === void 0 ? void 0 : (_e$target4$parentElem5 = _e$target4$parentElem4.scrollBy) === null || _e$target4$parentElem5 === void 0 ? void 0 : _e$target4$parentElem5.call(_e$target4$parentElem4, 0, -45));
7619
7686
  }
7687
+ e.preventDefault();
7688
+ } else if (e.key == "Enter") {
7689
+ onSelectToAddToQueue(e, filtOptns[optionIndex]);
7620
7690
  }
7621
- }, [ServiceType]);
7622
- const selectServiceType = value => {
7623
- setserviceTypes(value);
7624
- if ((userType === null || userType === void 0 ? void 0 : userType.toLowerCase()) === "employee") {
7625
- onSelect(config.key, value);
7691
+ };
7692
+ const MenuItem = ({
7693
+ option,
7694
+ index
7695
+ }) => /*#__PURE__*/React.createElement("div", {
7696
+ key: index,
7697
+ style: _isOBPSMultiple ? index % 2 !== 0 ? {
7698
+ background: "#EEEEEE"
7699
+ } : {} : {}
7700
+ }, /*#__PURE__*/React.createElement("input", {
7701
+ type: "checkbox",
7702
+ value: option[optionsKey],
7703
+ checked: alreadyQueuedSelectedState.find(selectedOption => selectedOption[optionsKey] === option[optionsKey]) ? true : false,
7704
+ onChange: e => _isPropsNeeded ? onSelectToAddToQueue(e, option, _props) : _isOBPSMultiple ? onSelectToAddToQueue(e, option, _BlockNumber) : onSelectToAddToQueue(e, option),
7705
+ style: {
7706
+ minWidth: "24px",
7707
+ width: "100%"
7626
7708
  }
7709
+ }), /*#__PURE__*/React.createElement("div", {
7710
+ className: "custom-checkbox"
7711
+ }, /*#__PURE__*/React.createElement(CheckSvg, {
7712
+ style: {
7713
+ innerWidth: "24px",
7714
+ width: "24px"
7715
+ }
7716
+ })), /*#__PURE__*/React.createElement("p", {
7717
+ className: "label",
7718
+ style: index === optionIndex ? {
7719
+ opacity: 1,
7720
+ backgroundColor: "rgba(238, 238, 238, var(--bg-opacity))"
7721
+ } : {}
7722
+ }, t(option[optionsKey] && typeof option[optionsKey] == "string" && option[optionsKey])));
7723
+ const Menu = () => {
7724
+ const filteredOptions = (searchQuery === null || searchQuery === void 0 ? void 0 : searchQuery.length) > 0 ? options.filter(option => t(option[optionsKey] && typeof option[optionsKey] == "string" && option[optionsKey].toUpperCase()).toLowerCase().indexOf(searchQuery.toLowerCase()) >= 0) : options;
7725
+ const isAllSelected = (filteredOptions === null || filteredOptions === void 0 ? void 0 : filteredOptions.length) > 0 && (filteredOptions === null || filteredOptions === void 0 ? void 0 : filteredOptions.every(option => alreadyQueuedSelectedState.find(selectedOption => selectedOption[optionsKey] === option[optionsKey])));
7726
+ const onSelectAll = e => {
7727
+ const isChecked = e.target.checked;
7728
+ if (isChecked) {
7729
+ const allOptions = filteredOptions.map(option => ({
7730
+ [optionsKey]: option[optionsKey],
7731
+ propsData: [null, option]
7732
+ }));
7733
+ dispatch({
7734
+ type: "REPLACE_COMPLETE_STATE",
7735
+ payload: allOptions
7736
+ });
7737
+ onSelect(allOptions.map(e => e.propsData));
7738
+ } else {
7739
+ dispatch({
7740
+ type: "REPLACE_COMPLETE_STATE",
7741
+ payload: []
7742
+ });
7743
+ onSelect([]);
7744
+ }
7745
+ };
7746
+ return /*#__PURE__*/React.createElement(React.Fragment, null, (filteredOptions === null || filteredOptions === void 0 ? void 0 : filteredOptions.length) > 0 && /*#__PURE__*/React.createElement("div", {
7747
+ key: "select-all",
7748
+ style: {
7749
+ borderBottom: "1px solid #eee",
7750
+ display: "flex",
7751
+ alignItems: "center"
7752
+ }
7753
+ }, /*#__PURE__*/React.createElement("input", {
7754
+ type: "checkbox",
7755
+ checked: isAllSelected,
7756
+ onChange: onSelectAll,
7757
+ style: {
7758
+ minWidth: "24px"
7759
+ }
7760
+ }), /*#__PURE__*/React.createElement("div", {
7761
+ className: "custom-checkbox"
7762
+ }, /*#__PURE__*/React.createElement(CheckSvg, {
7763
+ style: {
7764
+ innerWidth: "24px",
7765
+ width: "24px"
7766
+ }
7767
+ })), /*#__PURE__*/React.createElement("p", {
7768
+ className: "label",
7769
+ style: {
7770
+ fontWeight: "bold",
7771
+ marginLeft: "8px"
7772
+ }
7773
+ }, t("WT_SELECT_ALL"))), filteredOptions === null || filteredOptions === void 0 ? void 0 : filteredOptions.map((option, index) => /*#__PURE__*/React.createElement(MenuItem, {
7774
+ option: option,
7775
+ key: index,
7776
+ index: index
7777
+ })));
7627
7778
  };
7628
- if (isLoading) {
7629
- return /*#__PURE__*/React.createElement(Loader, null);
7630
- }
7631
- if ((userType === null || userType === void 0 ? void 0 : userType.toLowerCase()) === "employee") {
7632
- return /*#__PURE__*/React.createElement(LabelFieldPair, null, /*#__PURE__*/React.createElement(CardLabel, null, config.label), /*#__PURE__*/React.createElement(Dropdown, {
7633
- className: "payment-form-text-input-correction",
7634
- isMandatory: config.isMandatory,
7635
- selected: serviceTypes,
7636
- option: formattedServiceTypes,
7637
- select: selectServiceType,
7638
- optionKey: "i18nKey",
7639
- disable: config.disable,
7640
- t: t
7641
- }));
7642
- }
7643
- return null;
7779
+ return /*#__PURE__*/React.createElement("div", {
7780
+ className: `multi-select-dropdown-wrap ${_disable ? "disabled" : ""}`,
7781
+ ref: dropdownRef,
7782
+ style: _disable ? {
7783
+ pointerEvents: "none",
7784
+ opacity: 0.5
7785
+ } : {}
7786
+ }, /*#__PURE__*/React.createElement("div", {
7787
+ className: `master${active ? `-active` : ``}`
7788
+ }, /*#__PURE__*/React.createElement("input", {
7789
+ className: "cursorPointer",
7790
+ type: "text",
7791
+ onKeyDown: keyChange,
7792
+ onFocus: () => !_disable && setActive(true),
7793
+ value: searchQuery,
7794
+ onChange: onSearch,
7795
+ disabled: _disable
7796
+ }), /*#__PURE__*/React.createElement("div", {
7797
+ className: "label"
7798
+ }, /*#__PURE__*/React.createElement("p", {
7799
+ title: (_selected === null || _selected === void 0 ? void 0 : _selected.length) > 0 ? _selected.map(ob => t(ob[optionsKey])).join(', ') : _defaultLabel,
7800
+ style: {
7801
+ whiteSpace: "normal",
7802
+ wordBreak: "break-word"
7803
+ }
7804
+ }, (_selected === null || _selected === void 0 ? void 0 : _selected.length) > 0 ? `${_isSurvey ? _selected === null || _selected === void 0 ? void 0 : _selected.filter(ob => (ob === null || ob === void 0 ? void 0 : ob.i18nKey) !== undefined).length : _selected.length} ${_defaultUnit}` : _defaultLabel), /*#__PURE__*/React.createElement(ArrowDown, null))), active ? /*#__PURE__*/React.createElement("div", {
7805
+ className: "server",
7806
+ id: "jk-dropdown-unique",
7807
+ style: {
7808
+ ..._ServerStyle,
7809
+ maxHeight: "300px",
7810
+ overflowY: "auto"
7811
+ }
7812
+ }, /*#__PURE__*/React.createElement(Menu, null)) : null);
7644
7813
  };
7645
7814
 
7646
7815
  const VendorAssign = ({
@@ -7672,9 +7841,22 @@ const VendorAssign = ({
7672
7841
  select: data => (data === null || data === void 0 ? void 0 : data.vendor) || []
7673
7842
  }
7674
7843
  });
7844
+ const [selectedFillingPoints, setSelectedFillingPoints] = useState([]);
7845
+ const {
7846
+ data: allFillingPointsData
7847
+ } = Digit.Hooks.wt.useFillPointSearch({
7848
+ tenantId,
7849
+ filters: {
7850
+ status: "ACTIVE"
7851
+ }
7852
+ });
7853
+ const allFillingPoints = (allFillingPointsData === null || allFillingPointsData === void 0 ? void 0 : allFillingPointsData.fillingPoints) || [];
7675
7854
  const {
7676
7855
  mutate: createWorkOrder
7677
7856
  } = Digit.Hooks.wt.useVendorWorkOrderCreate(tenantId);
7857
+ const {
7858
+ mutate: mapFixedFilling
7859
+ } = Digit.Hooks.wt.useVendorFillingMap(tenantId);
7678
7860
  useEffect(() => {
7679
7861
  (async () => {
7680
7862
  setError(null);
@@ -7698,9 +7880,6 @@ const VendorAssign = ({
7698
7880
  }
7699
7881
  })();
7700
7882
  }, [file]);
7701
- const onServiceTypeSelect = (key, value) => {
7702
- setSelectedServiceType(value);
7703
- };
7704
7883
  const handleSubmit = () => {
7705
7884
  const payload = {
7706
7885
  vendorWorkOrder: {
@@ -7712,24 +7891,49 @@ const VendorAssign = ({
7712
7891
  fileStoreId: uploadedFile
7713
7892
  }
7714
7893
  };
7715
- createWorkOrder(payload, {
7716
- onSuccess: result => {
7717
- setShowToast({
7718
- isError: false,
7719
- label: t("ES_COMMON_SAVE_SUCCESS")
7720
- });
7721
- setTimeout(() => {
7722
- history.push("/digit-ui/employee/vendor/search-vendor");
7723
- }, 3000);
7724
- },
7725
- onError: err => {
7726
- var _err$response, _err$response$data, _err$response$data$Er, _err$response$data$Er2;
7727
- setShowToast({
7728
- isError: true,
7729
- 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("ES_COMMON_ERROR_SAVING")
7730
- });
7731
- }
7732
- });
7894
+ const doCreateWorkOrder = () => {
7895
+ createWorkOrder(payload, {
7896
+ onSuccess: result => {
7897
+ setShowToast({
7898
+ isError: false,
7899
+ label: t("ES_COMMON_SAVE_SUCCESS")
7900
+ });
7901
+ setTimeout(() => {
7902
+ history.push("/digit-ui/employee/vendor/search-vendor");
7903
+ }, 3000);
7904
+ },
7905
+ onError: err => {
7906
+ var _err$response, _err$response$data, _err$response$data$Er, _err$response$data$Er2;
7907
+ setShowToast({
7908
+ isError: true,
7909
+ 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("ES_COMMON_ERROR_SAVING")
7910
+ });
7911
+ }
7912
+ });
7913
+ };
7914
+ if (selectedFillingPoints && selectedFillingPoints.length > 0) {
7915
+ const mapPayload = {
7916
+ mappings: selectedFillingPoints.map(val => ({
7917
+ tenantId: tenantId,
7918
+ fillingPointId: (val === null || val === void 0 ? void 0 : val.id) || (val === null || val === void 0 ? void 0 : val.bookingId) || (val === null || val === void 0 ? void 0 : val.fillingPointId),
7919
+ vendorId: (vendor === null || vendor === void 0 ? void 0 : vendor.code) || (vendor === null || vendor === void 0 ? void 0 : vendor.id)
7920
+ }))
7921
+ };
7922
+ mapFixedFilling(mapPayload, {
7923
+ onSuccess: () => {
7924
+ doCreateWorkOrder();
7925
+ },
7926
+ onError: err => {
7927
+ var _err$response2, _err$response2$data, _err$response2$data$E, _err$response2$data$E2;
7928
+ setShowToast({
7929
+ isError: true,
7930
+ label: (err === null || err === void 0 ? void 0 : (_err$response2 = err.response) === null || _err$response2 === void 0 ? void 0 : (_err$response2$data = _err$response2.data) === null || _err$response2$data === void 0 ? void 0 : (_err$response2$data$E = _err$response2$data.Errors) === null || _err$response2$data$E === void 0 ? void 0 : (_err$response2$data$E2 = _err$response2$data$E[0]) === null || _err$response2$data$E2 === void 0 ? void 0 : _err$response2$data$E2.message) || t("WT_FIXED_FILLING_MAPPING_FAIL")
7931
+ });
7932
+ }
7933
+ });
7934
+ } else {
7935
+ doCreateWorkOrder();
7936
+ }
7733
7937
  };
7734
7938
  const isMobile = window.Digit.Utils.browser.isMobile();
7735
7939
  const userType = Digit.UserService.getUser().info.type;
@@ -7737,7 +7941,7 @@ const VendorAssign = ({
7737
7941
  setUploadedFile(null);
7738
7942
  setFile(e.target.files[0]);
7739
7943
  }
7740
- const isFormDisabled = !vendor || !validFrom || !validTo || !selectedServiceType;
7944
+ const isFormDisabled = !vendor || !validFrom || !validTo;
7741
7945
  return /*#__PURE__*/React.createElement("div", {
7742
7946
  className: "employee-form-section-wrapper"
7743
7947
  }, /*#__PURE__*/React.createElement(VerticalTimeline, {
@@ -7813,18 +8017,80 @@ const VendorAssign = ({
7813
8017
  },
7814
8018
  message: uploadedFile ? `1 ${t(`WT_ACTION_FILEUPLOADED`)}` : t(`WT_ACTION_NO_FILEUPLOADED`),
7815
8019
  error: error
7816
- })), /*#__PURE__*/React.createElement(SelectServiceType, {
7817
- t: t,
7818
- config: {
7819
- key: "serviceType",
7820
- label: t("WT_SELECT_SERVICE_TYPE")
8020
+ })), /*#__PURE__*/React.createElement("div", {
8021
+ style: {
8022
+ display: "flex",
8023
+ flexDirection: "column"
8024
+ }
8025
+ }, /*#__PURE__*/React.createElement(Label, null, `${t("WT_FILLING_POINT")}`), /*#__PURE__*/React.createElement(VendorMultiSelectDropdown, {
8026
+ options: allFillingPoints,
8027
+ optionsKey: "fillingPointName",
8028
+ selected: selectedFillingPoints,
8029
+ onSelect: values => {
8030
+ const extractedValues = (values === null || values === void 0 ? void 0 : values.map(v => Array.isArray(v) ? v[1] : v)) || [];
8031
+ setSelectedFillingPoints(extractedValues);
7821
8032
  },
7822
- onSelect: onServiceTypeSelect,
7823
- userType: userType,
7824
- formData: {
7825
- serviceType: selectedServiceType
8033
+ defaultLabel: t("SELECT_FILLING_POINT"),
8034
+ defaultUnit: t("SELECTED"),
8035
+ ServerStyle: {
8036
+ textAlign: "left",
8037
+ width: "100%",
8038
+ minWidth: "250px",
8039
+ backgroundColor: "#fff"
8040
+ },
8041
+ isPropsNeeded: false
8042
+ }), selectedFillingPoints && selectedFillingPoints.length > 0 && /*#__PURE__*/React.createElement("div", {
8043
+ style: {
8044
+ display: "flex",
8045
+ flexWrap: "wrap",
8046
+ gap: "8px",
8047
+ marginTop: "12px",
8048
+ maxHeight: "120px",
8049
+ overflowY: "auto",
8050
+ padding: "4px"
7826
8051
  }
7827
- }))), /*#__PURE__*/React.createElement("div", {
8052
+ }, selectedFillingPoints.map((fp, index) => /*#__PURE__*/React.createElement("div", {
8053
+ key: index,
8054
+ style: {
8055
+ display: "flex",
8056
+ alignItems: "center",
8057
+ backgroundColor: "#f4f4f4",
8058
+ border: "1px solid #ddd",
8059
+ borderRadius: "16px",
8060
+ padding: "4px 12px",
8061
+ fontSize: "14px",
8062
+ fontWeight: "500"
8063
+ }
8064
+ }, /*#__PURE__*/React.createElement("span", {
8065
+ style: {
8066
+ marginRight: "8px",
8067
+ color: "#333",
8068
+ maxWidth: "200px",
8069
+ whiteSpace: "nowrap",
8070
+ overflow: "hidden",
8071
+ textOverflow: "ellipsis"
8072
+ }
8073
+ }, t((fp === null || fp === void 0 ? void 0 : fp.fillingPointName) || (fp === null || fp === void 0 ? void 0 : fp.id))), /*#__PURE__*/React.createElement("button", {
8074
+ type: "button",
8075
+ onClick: e => {
8076
+ e.preventDefault();
8077
+ e.stopPropagation();
8078
+ const fpId = fp.id || fp.fillingPointId;
8079
+ setSelectedFillingPoints(prev => prev.filter(p => (p.id || p.fillingPointId) !== fpId));
8080
+ },
8081
+ style: {
8082
+ background: "transparent",
8083
+ border: "none",
8084
+ color: "#888",
8085
+ cursor: "pointer",
8086
+ fontSize: "16px",
8087
+ display: "flex",
8088
+ alignItems: "center",
8089
+ justifyContent: "center",
8090
+ marginLeft: "auto",
8091
+ padding: "0"
8092
+ }
8093
+ }, "\xD7"))))))), /*#__PURE__*/React.createElement("div", {
7828
8094
  style: {
7829
8095
  display: "flex",
7830
8096
  marginTop: "24px",
@@ -7841,6 +8107,254 @@ const VendorAssign = ({
7841
8107
  }));
7842
8108
  };
7843
8109
 
8110
+ const Reports = ({
8111
+ isLoading: _isLoading = false,
8112
+ t,
8113
+ onSubmit: _onSubmit = () => {},
8114
+ data: _data = null,
8115
+ count: _count = 0,
8116
+ setShowToast: _setShowToast = false
8117
+ }) => {
8118
+ const isMobile = window.Digit.Utils.browser.isMobile();
8119
+ const user = Digit.UserService.getUser().info;
8120
+ const defaultValues = {
8121
+ offset: 0,
8122
+ limit: 10,
8123
+ sortBy: "commencementDate",
8124
+ sortOrder: "DESC",
8125
+ bookingNo: "",
8126
+ mobileNumber: "",
8127
+ applicantName: "",
8128
+ status: "",
8129
+ fromDate: "",
8130
+ toDate: ""
8131
+ };
8132
+ const {
8133
+ register,
8134
+ control,
8135
+ handleSubmit,
8136
+ setValue,
8137
+ getValues,
8138
+ reset,
8139
+ formState,
8140
+ watch
8141
+ } = useForm({
8142
+ defaultValues
8143
+ });
8144
+ const fromDateValue = watch("fromDate");
8145
+ const GetCell = value => /*#__PURE__*/React.createElement("span", {
8146
+ className: "cell-text"
8147
+ }, value);
8148
+ const columns = useMemo(() => [{
8149
+ Header: t("WT_BOOKING_NO"),
8150
+ accessor: "bookingNo",
8151
+ disableSortBy: true,
8152
+ Cell: ({
8153
+ row
8154
+ }) => {
8155
+ const bookingNo = row.original["bookingNo"];
8156
+ const userTypePath = user.type === "EMPLOYEE" ? "employee" : "citizen";
8157
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", {
8158
+ className: "link"
8159
+ }, /*#__PURE__*/React.createElement(Link, {
8160
+ to: `${APPLICATION_PATH}/${userTypePath}/wt/bookingsearch/booking-details/${bookingNo}`
8161
+ }, bookingNo)));
8162
+ }
8163
+ }, {
8164
+ Header: t("WT_APPLICANT_NAME"),
8165
+ disableSortBy: true,
8166
+ Cell: ({
8167
+ row
8168
+ }) => {
8169
+ var _row$original, _row$original$applica;
8170
+ return GetCell((_row$original = row.original) === null || _row$original === void 0 ? void 0 : (_row$original$applica = _row$original.applicantDetail) === null || _row$original$applica === void 0 ? void 0 : _row$original$applica["name"]);
8171
+ }
8172
+ }, {
8173
+ Header: t("WT_MOBILE_NUMBER"),
8174
+ disableSortBy: true,
8175
+ Cell: ({
8176
+ row
8177
+ }) => {
8178
+ var _row$original2, _row$original2$applic;
8179
+ return GetCell((_row$original2 = row.original) === null || _row$original2 === void 0 ? void 0 : (_row$original2$applic = _row$original2.applicantDetail) === null || _row$original2$applic === void 0 ? void 0 : _row$original2$applic["mobileNumber"]);
8180
+ }
8181
+ }, {
8182
+ Header: t("PT_COMMON_TABLE_COL_STATUS_LABEL"),
8183
+ disableSortBy: true,
8184
+ Cell: ({
8185
+ row
8186
+ }) => GetCell(t(row.original["bookingStatus"]))
8187
+ }], [t, user.type]);
8188
+ const onSort = useCallback(args => {
8189
+ if (args.length === 0) return;
8190
+ setValue("sortBy", args.id);
8191
+ setValue("sortOrder", args.desc ? "DESC" : "ASC");
8192
+ }, [setValue]);
8193
+ const onPageSizeChange = e => {
8194
+ setValue("limit", Number(e.target.value));
8195
+ handleSubmit(_onSubmit)();
8196
+ };
8197
+ const nextPage = () => {
8198
+ setValue("offset", getValues("offset") + getValues("limit"));
8199
+ handleSubmit(_onSubmit)();
8200
+ };
8201
+ const previousPage = () => {
8202
+ const currentOffset = getValues("offset");
8203
+ const limit = getValues("limit");
8204
+ if (currentOffset - limit >= 0) {
8205
+ setValue("offset", currentOffset - limit);
8206
+ handleSubmit(_onSubmit)();
8207
+ }
8208
+ };
8209
+ const handleClearSearch = () => {
8210
+ reset(defaultValues);
8211
+ _setShowToast(null);
8212
+ handleSubmit(_onSubmit)();
8213
+ };
8214
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
8215
+ className: (user === null || user === void 0 ? void 0 : user.type) === "CITIZEN" ? "citizen-wrapper" : "employee-wrapper"
8216
+ }, /*#__PURE__*/React.createElement(CollapsibleCardPage, {
8217
+ title: t("WT_SEARCH_FILTERS_LABEL") || "Search Filters",
8218
+ defaultOpen: true,
8219
+ tabs: [t("WT_SMART_SEARCH"), t("WT_ADVANCED_SEARCH")],
8220
+ defaultTab: t("WT_SMART_SEARCH")
8221
+ }, activeTab => {
8222
+ var _formState$errors, _formState$errors$mob, _formState$errors2, _formState$errors2$mo;
8223
+ return /*#__PURE__*/React.createElement("form", {
8224
+ onSubmit: handleSubmit(_onSubmit)
8225
+ }, activeTab === t("WT_SMART_SEARCH") && /*#__PURE__*/React.createElement("div", {
8226
+ className: "wt-search-grid",
8227
+ style: {
8228
+ display: "grid",
8229
+ gridTemplateColumns: isMobile ? "1fr" : "1fr 1fr",
8230
+ gap: "24px"
8231
+ }
8232
+ }, /*#__PURE__*/React.createElement("div", {
8233
+ className: "search-field-wrapper"
8234
+ }, /*#__PURE__*/React.createElement("label", null, t("WT_MOBILE_NUMBER")), /*#__PURE__*/React.createElement(MobileNumber, {
8235
+ name: "mobileNumber",
8236
+ inputRef: register({
8237
+ minLength: {
8238
+ value: 10,
8239
+ message: t("CORE_COMMON_MOBILE_ERROR")
8240
+ },
8241
+ maxLength: {
8242
+ value: 10,
8243
+ message: t("CORE_COMMON_MOBILE_ERROR")
8244
+ },
8245
+ pattern: {
8246
+ value: /[6789][0-9]{9}/,
8247
+ message: t("CORE_COMMON_MOBILE_ERROR")
8248
+ }
8249
+ }),
8250
+ type: "number",
8251
+ maxlength: 10
8252
+ }), /*#__PURE__*/React.createElement(CardLabelError, null, formState === null || formState === void 0 ? void 0 : (_formState$errors = formState.errors) === null || _formState$errors === void 0 ? void 0 : (_formState$errors$mob = _formState$errors["mobileNumber"]) === null || _formState$errors$mob === void 0 ? void 0 : _formState$errors$mob.message))), activeTab === t("WT_ADVANCED_SEARCH") && /*#__PURE__*/React.createElement("div", {
8253
+ className: "formcomposer-section-grid"
8254
+ }, /*#__PURE__*/React.createElement("div", {
8255
+ className: "search-field-wrapper"
8256
+ }, /*#__PURE__*/React.createElement("label", null, t("WT_BOOKING_NO")), /*#__PURE__*/React.createElement(TextInput, {
8257
+ name: "bookingNo",
8258
+ inputRef: register({})
8259
+ })), /*#__PURE__*/React.createElement("div", {
8260
+ className: "search-field-wrapper"
8261
+ }, /*#__PURE__*/React.createElement("label", null, t("WT_APPLICANT_NAME")), /*#__PURE__*/React.createElement(TextInput, {
8262
+ name: "applicantName",
8263
+ inputRef: register({})
8264
+ })), /*#__PURE__*/React.createElement("div", {
8265
+ className: "search-field-wrapper"
8266
+ }, /*#__PURE__*/React.createElement("label", null, t("WT_MOBILE_NUMBER")), /*#__PURE__*/React.createElement(MobileNumber, {
8267
+ name: "mobileNumber",
8268
+ inputRef: register({
8269
+ minLength: {
8270
+ value: 10,
8271
+ message: t("CORE_COMMON_MOBILE_ERROR")
8272
+ },
8273
+ maxLength: {
8274
+ value: 10,
8275
+ message: t("CORE_COMMON_MOBILE_ERROR")
8276
+ },
8277
+ pattern: {
8278
+ value: /[6789][0-9]{9}/,
8279
+ message: t("CORE_COMMON_MOBILE_ERROR")
8280
+ }
8281
+ }),
8282
+ type: "number",
8283
+ maxlength: 10
8284
+ }), /*#__PURE__*/React.createElement(CardLabelError, null, formState === null || formState === void 0 ? void 0 : (_formState$errors2 = formState.errors) === null || _formState$errors2 === void 0 ? void 0 : (_formState$errors2$mo = _formState$errors2["mobileNumber"]) === null || _formState$errors2$mo === void 0 ? void 0 : _formState$errors2$mo.message)), /*#__PURE__*/React.createElement("div", {
8285
+ className: "search-field-wrapper"
8286
+ }, /*#__PURE__*/React.createElement("label", null, t("FROM_DATE")), /*#__PURE__*/React.createElement(Controller, {
8287
+ render: props => /*#__PURE__*/React.createElement(DatePicker, {
8288
+ date: props.value,
8289
+ onChange: props.onChange,
8290
+ max: new Date().toISOString().split("T")[0]
8291
+ }),
8292
+ name: "fromDate",
8293
+ control: control
8294
+ })), /*#__PURE__*/React.createElement("div", {
8295
+ className: "search-field-wrapper"
8296
+ }, /*#__PURE__*/React.createElement("label", null, t("TO_DATE")), /*#__PURE__*/React.createElement(Controller, {
8297
+ render: props => /*#__PURE__*/React.createElement(DatePicker, {
8298
+ date: props.value,
8299
+ onChange: props.onChange,
8300
+ min: fromDateValue
8301
+ }),
8302
+ name: "toDate",
8303
+ control: control
8304
+ }))), /*#__PURE__*/React.createElement("div", {
8305
+ className: "wt-search-actions",
8306
+ style: {
8307
+ display: "flex",
8308
+ justifyContent: isMobile ? "center" : "flex-end",
8309
+ flexDirection: isMobile ? "column-reverse" : "row",
8310
+ gap: "24px",
8311
+ marginTop: "16px"
8312
+ }
8313
+ }, /*#__PURE__*/React.createElement("span", {
8314
+ className: "generic-button clear-search",
8315
+ onClick: handleClearSearch,
8316
+ style: {
8317
+ cursor: "pointer",
8318
+ alignSelf: "center"
8319
+ }
8320
+ }, t("ES_COMMON_CLEAR_ALL")), /*#__PURE__*/React.createElement("div", {
8321
+ style: {
8322
+ minWidth: isMobile ? "100%" : "160px"
8323
+ }
8324
+ }, /*#__PURE__*/React.createElement(SubmitBar, {
8325
+ label: t("ES_COMMON_SEARCH"),
8326
+ submit: true
8327
+ }))));
8328
+ }), _isLoading && /*#__PURE__*/React.createElement(Loader, null), _data === "" ? /*#__PURE__*/React.createElement("p", {
8329
+ style: {
8330
+ textAlign: "center"
8331
+ }
8332
+ }, "No data found") : _data ? /*#__PURE__*/React.createElement(Table, {
8333
+ t: t,
8334
+ data: _data,
8335
+ totalRecords: _count,
8336
+ columns: columns,
8337
+ getCellProps: cellInfo => ({
8338
+ style: {
8339
+ minWidth: cellInfo.column.Header === t("WT_INBOX_APPLICATION_NO") ? "240px" : "",
8340
+ padding: "20px 18px",
8341
+ fontSize: "16px"
8342
+ }
8343
+ }),
8344
+ onPageSizeChange: onPageSizeChange,
8345
+ currentPage: getValues("offset") / getValues("limit"),
8346
+ onNextPage: nextPage,
8347
+ onPrevPage: previousPage,
8348
+ pageSizeLimit: getValues("limit"),
8349
+ onSort: onSort,
8350
+ disableSort: false,
8351
+ sortParams: [{
8352
+ id: getValues("sortBy"),
8353
+ desc: getValues("sortOrder") === "DESC"
8354
+ }]
8355
+ }) : null));
8356
+ };
8357
+
7844
8358
  const EmployeeApp = ({
7845
8359
  path
7846
8360
  }) => {
@@ -8106,6 +8620,16 @@ const EmployeeApp = ({
8106
8620
  }), /*#__PURE__*/React.createElement(PrivateRoute, {
8107
8621
  path: `${path}/vendor-assignment`,
8108
8622
  component: VendorAssign
8623
+ }), /*#__PURE__*/React.createElement(PrivateRoute, {
8624
+ path: `${path}/reports`,
8625
+ component: props => /*#__PURE__*/React.createElement(LayoutWrapper, {
8626
+ layoutClass: "normal"
8627
+ }, /*#__PURE__*/React.createElement(Reports, Object.assign({
8628
+ t: t
8629
+ }, props, {
8630
+ parentRoute: path,
8631
+ moduleCode: "WT"
8632
+ })))
8109
8633
  }))))));
8110
8634
  };
8111
8635
 
@@ -15450,7 +15974,8 @@ const Filter = ({
15450
15974
  onClick: clearAll,
15451
15975
  style: {
15452
15976
  border: "1px solid #e0e0e0",
15453
- padding: "6px"
15977
+ padding: "6px",
15978
+ minWidth: "fit-content"
15454
15979
  }
15455
15980
  }, /*#__PURE__*/React.createElement("svg", {
15456
15981
  width: "17",