@djb25/digit-ui-module-wt 1.0.32 → 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, 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 } 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);
8032
+ },
8033
+ defaultLabel: t("SELECT_FILLING_POINT"),
8034
+ defaultUnit: t("SELECTED"),
8035
+ ServerStyle: {
8036
+ textAlign: "left",
8037
+ width: "100%",
8038
+ minWidth: "250px",
8039
+ backgroundColor: "#fff"
7821
8040
  },
7822
- onSelect: onServiceTypeSelect,
7823
- userType: userType,
7824
- formData: {
7825
- serviceType: selectedServiceType
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",