@djb25/digit-ui-module-wt 1.0.32 → 1.0.34

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, CitizenHomeCard, CHBIcon, PropertyHouse, HomeIcon, KeyNote, Modal, CardHeader, FormStep, CardLabel, RadioButtons, UploadFile, TextArea, CheckBox, CardSubHeader, StatusTable, Row, GenericFileIcon, LinkButton, EditIcon, Banner, 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, 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';
@@ -1219,6 +1219,7 @@ const App = () => {
1219
1219
  t
1220
1220
  } = useTranslation();
1221
1221
  const location = useLocation();
1222
+ const history = useHistory();
1222
1223
  const {
1223
1224
  path,
1224
1225
  url,
@@ -1230,8 +1231,6 @@ const App = () => {
1230
1231
  const TPApplicationDetails = (_Digit4 = Digit) === null || _Digit4 === void 0 ? void 0 : (_Digit4$ComponentRegi = _Digit4.ComponentRegistryService) === null || _Digit4$ComponentRegi === void 0 ? void 0 : _Digit4$ComponentRegi.getComponent("TPApplicationDetails");
1231
1232
  const WTMyApplications = (_Digit5 = Digit) === null || _Digit5 === void 0 ? void 0 : (_Digit5$ComponentRegi = _Digit5.ComponentRegistryService) === null || _Digit5$ComponentRegi === void 0 ? void 0 : _Digit5$ComponentRegi.getComponent("WTMyApplications");
1232
1233
  const Inbox = Digit.ComponentRegistryService.getComponent("WTEmpInbox");
1233
- const WTCard = Digit.ComponentRegistryService.getComponent("WTCitizenCard");
1234
- const MTCard = Digit.ComponentRegistryService.getComponent("MTCitizenCard");
1235
1234
  const ApplicationDetails = (_Digit6 = Digit) === null || _Digit6 === void 0 ? void 0 : (_Digit6$ComponentRegi = _Digit6.ComponentRegistryService) === null || _Digit6$ComponentRegi === void 0 ? void 0 : _Digit6$ComponentRegi.getComponent("ApplicationDetails");
1236
1235
  const getDynamicBreadcrumbs = () => {
1237
1236
  const pathname = location.pathname;
@@ -1355,9 +1354,39 @@ const App = () => {
1355
1354
  })
1356
1355
  }), /*#__PURE__*/React.createElement(PrivateRoute, {
1357
1356
  path: `${path}/wt-Vendor`,
1358
- component: () => Digit.UserService.hasAccess(["WT_VENDOR"]) ? /*#__PURE__*/React.createElement(WTCard, {
1359
- parentRoute: path
1360
- }) : /*#__PURE__*/React.createElement(Redirect, {
1357
+ component: () => Digit.UserService.hasAccess(["WT_VENDOR"]) ? /*#__PURE__*/React.createElement("div", {
1358
+ style: {
1359
+ display: "flex",
1360
+ gap: "24px",
1361
+ flexWrap: "wrap",
1362
+ width: "100%",
1363
+ padding: "8px 0"
1364
+ }
1365
+ }, /*#__PURE__*/React.createElement(CitizenHomeCard, {
1366
+ header: t("WT_MODULE_NAME"),
1367
+ links: [{
1368
+ i18nKey: t("ES_COMMON_INBOX"),
1369
+ link: `${APPLICATION_PATH}/citizen/wt/inbox`
1370
+ }, {
1371
+ i18nKey: t("ES_COMMON_APPLICATION_SEARCH"),
1372
+ link: `${APPLICATION_PATH}/citizen/wt/my-bookings`
1373
+ }, {
1374
+ i18nKey: t("WT_REQUEST_TANKER"),
1375
+ link: `${APPLICATION_PATH}/citizen/wt/request-service`
1376
+ }],
1377
+ Icon: () => /*#__PURE__*/React.createElement(CHBIcon, {
1378
+ className: "fill-path-primary-main"
1379
+ })
1380
+ }), /*#__PURE__*/React.createElement(CitizenHomeCard, {
1381
+ header: t("TITLE_VENDOR_MANAGEMENT"),
1382
+ links: [{
1383
+ i18nKey: t("SEARCH_VENDOR"),
1384
+ link: `${APPLICATION_PATH}/citizen/vendor/search-vendor`
1385
+ }],
1386
+ Icon: () => /*#__PURE__*/React.createElement(PropertyHouse, {
1387
+ className: "fill-path-primary-main"
1388
+ })
1389
+ })) : /*#__PURE__*/React.createElement(Redirect, {
1361
1390
  to: {
1362
1391
  pathname: `${APPLICATION_PATH}/citizen/login`,
1363
1392
  state: {
@@ -1368,9 +1397,39 @@ const App = () => {
1368
1397
  })
1369
1398
  }), /*#__PURE__*/React.createElement(PrivateRoute, {
1370
1399
  path: `${path}/mt-Vendor`,
1371
- component: () => Digit.UserService.hasAccess(["MT_VENDOR"]) ? /*#__PURE__*/React.createElement(MTCard, {
1372
- parentRoute: path
1373
- }) : /*#__PURE__*/React.createElement(Redirect, {
1400
+ component: () => Digit.UserService.hasAccess(["MT_VENDOR"]) ? /*#__PURE__*/React.createElement("div", {
1401
+ style: {
1402
+ display: "flex",
1403
+ gap: "24px",
1404
+ flexWrap: "wrap",
1405
+ width: "100%",
1406
+ padding: "8px 0"
1407
+ }
1408
+ }, /*#__PURE__*/React.createElement(CitizenHomeCard, {
1409
+ header: t("ACTION_TEST_MT"),
1410
+ links: [{
1411
+ i18nKey: t("ES_COMMON_INBOX"),
1412
+ link: `${APPLICATION_PATH}/citizen/wt/mt/inbox`
1413
+ }, {
1414
+ i18nKey: t("ES_COMMON_APPLICATION_SEARCH"),
1415
+ link: `${APPLICATION_PATH}/citizen/wt/mt/my-bookings`
1416
+ }, {
1417
+ i18nKey: t("MT_REQUEST_TANKER"),
1418
+ link: `${APPLICATION_PATH}/citizen/wt/request-service`
1419
+ }],
1420
+ Icon: () => /*#__PURE__*/React.createElement(CHBIcon, {
1421
+ className: "fill-path-primary-main"
1422
+ })
1423
+ }), /*#__PURE__*/React.createElement(CitizenHomeCard, {
1424
+ header: t("TITLE_VENDOR_MANAGEMENT"),
1425
+ links: [{
1426
+ i18nKey: t("SEARCH_VENDOR"),
1427
+ link: `${APPLICATION_PATH}/citizen/vendor/search-vendor`
1428
+ }],
1429
+ Icon: () => /*#__PURE__*/React.createElement(PropertyHouse, {
1430
+ className: "fill-path-primary-main"
1431
+ })
1432
+ })) : /*#__PURE__*/React.createElement(Redirect, {
1374
1433
  to: {
1375
1434
  pathname: `${APPLICATION_PATH}/citizen/login`,
1376
1435
  state: {
@@ -7578,69 +7637,238 @@ const SearchFillingPointAddress = () => {
7578
7637
  }));
7579
7638
  };
7580
7639
 
7581
- const SelectServiceType = ({
7582
- config,
7640
+ const VendorMultiSelectDropdown = ({
7641
+ options,
7642
+ optionsKey,
7643
+ selected: _selected = [],
7583
7644
  onSelect,
7584
- t,
7585
- userType,
7586
- formData
7645
+ defaultLabel: _defaultLabel = "",
7646
+ defaultUnit: _defaultUnit = "",
7647
+ BlockNumber: _BlockNumber = 1,
7648
+ isOBPSMultiple: _isOBPSMultiple = false,
7649
+ props: _props = {},
7650
+ isPropsNeeded: _isPropsNeeded = false,
7651
+ ServerStyle: _ServerStyle = {},
7652
+ isSurvey: _isSurvey = false,
7653
+ disable: _disable = false
7587
7654
  }) => {
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([]);
7655
+ const [active, setActive] = useState(false);
7656
+ const [searchQuery, setSearchQuery] = useState();
7657
+ const [optionIndex, setOptionIndex] = useState(-1);
7658
+ const dropdownRef = useRef();
7592
7659
  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;
7660
+ t
7661
+ } = useTranslation();
7662
+ function reducer(state, action) {
7663
+ var _action$payload, _action$payload$;
7664
+ switch (action.type) {
7665
+ case "ADD_TO_SELECTED_EVENT_QUEUE":
7666
+ return [...state, {
7667
+ [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],
7668
+ propsData: action.payload
7669
+ }];
7670
+ case "REMOVE_FROM_SELECTED_EVENT_QUEUE":
7671
+ return state.filter(e => {
7672
+ var _action$payload2, _action$payload2$;
7673
+ 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]);
7674
+ });
7675
+ case "REPLACE_COMPLETE_STATE":
7676
+ return action.payload;
7677
+ default:
7678
+ return state;
7601
7679
  }
7602
- });
7680
+ }
7603
7681
  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
- }
7682
+ dispatch({
7683
+ type: "REPLACE_COMPLETE_STATE",
7684
+ payload: fnToSelectOptionThroughProvidedSelection(_selected)
7685
+ });
7686
+ }, [_selected === null || _selected === void 0 ? void 0 : _selected.map(e => e === null || e === void 0 ? void 0 : e[optionsKey]).join(",")]);
7687
+ function fnToSelectOptionThroughProvidedSelection(selected) {
7688
+ return selected === null || selected === void 0 ? void 0 : selected.map(e => ({
7689
+ [optionsKey]: e === null || e === void 0 ? void 0 : e[optionsKey],
7690
+ propsData: [null, e]
7691
+ }));
7692
+ }
7693
+ const [alreadyQueuedSelectedState, dispatch] = useReducer(reducer, _selected, fnToSelectOptionThroughProvidedSelection);
7694
+ function handleOutsideClickAndSubmitSimultaneously() {
7695
+ setActive(false);
7696
+ }
7697
+ Digit.Hooks.useClickOutside(dropdownRef, handleOutsideClickAndSubmitSimultaneously, active, {
7698
+ capture: true
7699
+ });
7700
+ 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;
7701
+ function onSearch(e) {
7702
+ setSearchQuery(e.target.value);
7703
+ }
7704
+ function onSelectToAddToQueue(...args) {
7705
+ const isChecked = args[0].target.checked;
7706
+ const option = args[1];
7707
+ if (isChecked) {
7708
+ dispatch({
7709
+ type: "ADD_TO_SELECTED_EVENT_QUEUE",
7710
+ payload: [...args]
7711
+ });
7712
+ const newSelected = [...alreadyQueuedSelectedState, {
7713
+ [optionsKey]: option[optionsKey],
7714
+ propsData: args
7715
+ }];
7716
+ onSelect(newSelected.map(e => e.propsData), _props);
7717
+ } else {
7718
+ dispatch({
7719
+ type: "REMOVE_FROM_SELECTED_EVENT_QUEUE",
7720
+ payload: [...args]
7721
+ });
7722
+ const newSelected = alreadyQueuedSelectedState.filter(e => (e === null || e === void 0 ? void 0 : e[optionsKey]) !== option[optionsKey]);
7723
+ onSelect(newSelected.map(e => e.propsData), _props);
7724
+ }
7725
+ }
7726
+ const keyChange = e => {
7727
+ if (e.key == "ArrowDown") {
7728
+ setOptionIndex(state => state + 1 == filtOptns.length ? 0 : state + 1);
7729
+ if (optionIndex + 1 == filtOptns.length) {
7730
+ var _e$target, _e$target$parentEleme, _e$target$parentEleme2, _e$target$parentEleme3, _e$target$parentEleme4, _e$target$parentEleme5;
7731
+ 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);
7732
+ } else {
7733
+ var _e$target2, _e$target2$parentElem, _e$target2$parentElem2, _e$target2$parentElem3, _e$target2$parentElem4, _e$target2$parentElem5;
7734
+ 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));
7735
+ }
7736
+ e.preventDefault();
7737
+ } else if (e.key == "ArrowUp") {
7738
+ setOptionIndex(state => state !== 0 ? state - 1 : filtOptns.length - 1);
7739
+ if (optionIndex === 0) {
7740
+ var _e$target3, _e$target3$parentElem, _e$target3$parentElem2, _e$target3$parentElem3, _e$target3$parentElem4, _e$target3$parentElem5;
7741
+ 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);
7742
+ } else {
7743
+ var _e$target4, _e$target4$parentElem, _e$target4$parentElem2, _e$target4$parentElem3, _e$target4$parentElem4, _e$target4$parentElem5;
7744
+ 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
7745
  }
7746
+ e.preventDefault();
7747
+ } else if (e.key == "Enter") {
7748
+ onSelectToAddToQueue(e, filtOptns[optionIndex]);
7749
+ }
7750
+ };
7751
+ const MenuItem = ({
7752
+ option,
7753
+ index
7754
+ }) => /*#__PURE__*/React.createElement("div", {
7755
+ key: index,
7756
+ style: _isOBPSMultiple ? index % 2 !== 0 ? {
7757
+ background: "#EEEEEE"
7758
+ } : {} : {}
7759
+ }, /*#__PURE__*/React.createElement("input", {
7760
+ type: "checkbox",
7761
+ value: option[optionsKey],
7762
+ checked: alreadyQueuedSelectedState.find(selectedOption => selectedOption[optionsKey] === option[optionsKey]) ? true : false,
7763
+ onChange: e => _isPropsNeeded ? onSelectToAddToQueue(e, option, _props) : _isOBPSMultiple ? onSelectToAddToQueue(e, option, _BlockNumber) : onSelectToAddToQueue(e, option),
7764
+ style: {
7765
+ minWidth: "24px",
7766
+ width: "100%"
7620
7767
  }
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);
7768
+ }), /*#__PURE__*/React.createElement("div", {
7769
+ className: "custom-checkbox"
7770
+ }, /*#__PURE__*/React.createElement(CheckSvg, {
7771
+ style: {
7772
+ innerWidth: "24px",
7773
+ width: "24px"
7626
7774
  }
7775
+ })), /*#__PURE__*/React.createElement("p", {
7776
+ className: "label",
7777
+ style: index === optionIndex ? {
7778
+ opacity: 1,
7779
+ backgroundColor: "rgba(238, 238, 238, var(--bg-opacity))"
7780
+ } : {}
7781
+ }, t(option[optionsKey] && typeof option[optionsKey] == "string" && option[optionsKey])));
7782
+ const Menu = () => {
7783
+ 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;
7784
+ 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])));
7785
+ const onSelectAll = e => {
7786
+ const isChecked = e.target.checked;
7787
+ if (isChecked) {
7788
+ const allOptions = filteredOptions.map(option => ({
7789
+ [optionsKey]: option[optionsKey],
7790
+ propsData: [null, option]
7791
+ }));
7792
+ dispatch({
7793
+ type: "REPLACE_COMPLETE_STATE",
7794
+ payload: allOptions
7795
+ });
7796
+ onSelect(allOptions.map(e => e.propsData));
7797
+ } else {
7798
+ dispatch({
7799
+ type: "REPLACE_COMPLETE_STATE",
7800
+ payload: []
7801
+ });
7802
+ onSelect([]);
7803
+ }
7804
+ };
7805
+ return /*#__PURE__*/React.createElement(React.Fragment, null, (filteredOptions === null || filteredOptions === void 0 ? void 0 : filteredOptions.length) > 0 && /*#__PURE__*/React.createElement("div", {
7806
+ key: "select-all",
7807
+ style: {
7808
+ borderBottom: "1px solid #eee",
7809
+ display: "flex",
7810
+ alignItems: "center"
7811
+ }
7812
+ }, /*#__PURE__*/React.createElement("input", {
7813
+ type: "checkbox",
7814
+ checked: isAllSelected,
7815
+ onChange: onSelectAll,
7816
+ style: {
7817
+ minWidth: "24px"
7818
+ }
7819
+ }), /*#__PURE__*/React.createElement("div", {
7820
+ className: "custom-checkbox"
7821
+ }, /*#__PURE__*/React.createElement(CheckSvg, {
7822
+ style: {
7823
+ innerWidth: "24px",
7824
+ width: "24px"
7825
+ }
7826
+ })), /*#__PURE__*/React.createElement("p", {
7827
+ className: "label",
7828
+ style: {
7829
+ fontWeight: "bold",
7830
+ marginLeft: "8px"
7831
+ }
7832
+ }, t("WT_SELECT_ALL"))), filteredOptions === null || filteredOptions === void 0 ? void 0 : filteredOptions.map((option, index) => /*#__PURE__*/React.createElement(MenuItem, {
7833
+ option: option,
7834
+ key: index,
7835
+ index: index
7836
+ })));
7627
7837
  };
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;
7838
+ return /*#__PURE__*/React.createElement("div", {
7839
+ className: `multi-select-dropdown-wrap ${_disable ? "disabled" : ""}`,
7840
+ ref: dropdownRef,
7841
+ style: _disable ? {
7842
+ pointerEvents: "none",
7843
+ opacity: 0.5
7844
+ } : {}
7845
+ }, /*#__PURE__*/React.createElement("div", {
7846
+ className: `master${active ? `-active` : ``}`
7847
+ }, /*#__PURE__*/React.createElement("input", {
7848
+ className: "cursorPointer",
7849
+ type: "text",
7850
+ onKeyDown: keyChange,
7851
+ onFocus: () => !_disable && setActive(true),
7852
+ value: searchQuery,
7853
+ onChange: onSearch,
7854
+ disabled: _disable
7855
+ }), /*#__PURE__*/React.createElement("div", {
7856
+ className: "label"
7857
+ }, /*#__PURE__*/React.createElement("p", {
7858
+ title: (_selected === null || _selected === void 0 ? void 0 : _selected.length) > 0 ? _selected.map(ob => t(ob[optionsKey])).join(', ') : _defaultLabel,
7859
+ style: {
7860
+ whiteSpace: "normal",
7861
+ wordBreak: "break-word"
7862
+ }
7863
+ }, (_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", {
7864
+ className: "server",
7865
+ id: "jk-dropdown-unique",
7866
+ style: {
7867
+ ..._ServerStyle,
7868
+ maxHeight: "300px",
7869
+ overflowY: "auto"
7870
+ }
7871
+ }, /*#__PURE__*/React.createElement(Menu, null)) : null);
7644
7872
  };
7645
7873
 
7646
7874
  const VendorAssign = ({
@@ -7672,9 +7900,22 @@ const VendorAssign = ({
7672
7900
  select: data => (data === null || data === void 0 ? void 0 : data.vendor) || []
7673
7901
  }
7674
7902
  });
7903
+ const [selectedFillingPoints, setSelectedFillingPoints] = useState([]);
7904
+ const {
7905
+ data: allFillingPointsData
7906
+ } = Digit.Hooks.wt.useFillPointSearch({
7907
+ tenantId,
7908
+ filters: {
7909
+ status: "ACTIVE"
7910
+ }
7911
+ });
7912
+ const allFillingPoints = (allFillingPointsData === null || allFillingPointsData === void 0 ? void 0 : allFillingPointsData.fillingPoints) || [];
7675
7913
  const {
7676
7914
  mutate: createWorkOrder
7677
7915
  } = Digit.Hooks.wt.useVendorWorkOrderCreate(tenantId);
7916
+ const {
7917
+ mutate: mapFixedFilling
7918
+ } = Digit.Hooks.wt.useVendorFillingMap(tenantId);
7678
7919
  useEffect(() => {
7679
7920
  (async () => {
7680
7921
  setError(null);
@@ -7698,9 +7939,6 @@ const VendorAssign = ({
7698
7939
  }
7699
7940
  })();
7700
7941
  }, [file]);
7701
- const onServiceTypeSelect = (key, value) => {
7702
- setSelectedServiceType(value);
7703
- };
7704
7942
  const handleSubmit = () => {
7705
7943
  const payload = {
7706
7944
  vendorWorkOrder: {
@@ -7712,24 +7950,49 @@ const VendorAssign = ({
7712
7950
  fileStoreId: uploadedFile
7713
7951
  }
7714
7952
  };
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
- });
7953
+ const doCreateWorkOrder = () => {
7954
+ createWorkOrder(payload, {
7955
+ onSuccess: result => {
7956
+ setShowToast({
7957
+ isError: false,
7958
+ label: t("ES_COMMON_SAVE_SUCCESS")
7959
+ });
7960
+ setTimeout(() => {
7961
+ history.push("/digit-ui/employee/vendor/search-vendor");
7962
+ }, 3000);
7963
+ },
7964
+ onError: err => {
7965
+ var _err$response, _err$response$data, _err$response$data$Er, _err$response$data$Er2;
7966
+ setShowToast({
7967
+ isError: true,
7968
+ 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")
7969
+ });
7970
+ }
7971
+ });
7972
+ };
7973
+ if (selectedFillingPoints && selectedFillingPoints.length > 0) {
7974
+ const mapPayload = {
7975
+ mappings: selectedFillingPoints.map(val => ({
7976
+ tenantId: tenantId,
7977
+ 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),
7978
+ vendorId: (vendor === null || vendor === void 0 ? void 0 : vendor.code) || (vendor === null || vendor === void 0 ? void 0 : vendor.id)
7979
+ }))
7980
+ };
7981
+ mapFixedFilling(mapPayload, {
7982
+ onSuccess: () => {
7983
+ doCreateWorkOrder();
7984
+ },
7985
+ onError: err => {
7986
+ var _err$response2, _err$response2$data, _err$response2$data$E, _err$response2$data$E2;
7987
+ setShowToast({
7988
+ isError: true,
7989
+ 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")
7990
+ });
7991
+ }
7992
+ });
7993
+ } else {
7994
+ doCreateWorkOrder();
7995
+ }
7733
7996
  };
7734
7997
  const isMobile = window.Digit.Utils.browser.isMobile();
7735
7998
  const userType = Digit.UserService.getUser().info.type;
@@ -7737,7 +8000,7 @@ const VendorAssign = ({
7737
8000
  setUploadedFile(null);
7738
8001
  setFile(e.target.files[0]);
7739
8002
  }
7740
- const isFormDisabled = !vendor || !validFrom || !validTo || !selectedServiceType;
8003
+ const isFormDisabled = !vendor || !validFrom || !validTo;
7741
8004
  return /*#__PURE__*/React.createElement("div", {
7742
8005
  className: "employee-form-section-wrapper"
7743
8006
  }, /*#__PURE__*/React.createElement(VerticalTimeline, {
@@ -7813,18 +8076,80 @@ const VendorAssign = ({
7813
8076
  },
7814
8077
  message: uploadedFile ? `1 ${t(`WT_ACTION_FILEUPLOADED`)}` : t(`WT_ACTION_NO_FILEUPLOADED`),
7815
8078
  error: error
7816
- })), /*#__PURE__*/React.createElement(SelectServiceType, {
7817
- t: t,
7818
- config: {
7819
- key: "serviceType",
7820
- label: t("WT_SELECT_SERVICE_TYPE")
8079
+ })), /*#__PURE__*/React.createElement("div", {
8080
+ style: {
8081
+ display: "flex",
8082
+ flexDirection: "column"
8083
+ }
8084
+ }, /*#__PURE__*/React.createElement(Label, null, `${t("WT_FILLING_POINT")}`), /*#__PURE__*/React.createElement(VendorMultiSelectDropdown, {
8085
+ options: allFillingPoints,
8086
+ optionsKey: "fillingPointName",
8087
+ selected: selectedFillingPoints,
8088
+ onSelect: values => {
8089
+ const extractedValues = (values === null || values === void 0 ? void 0 : values.map(v => Array.isArray(v) ? v[1] : v)) || [];
8090
+ setSelectedFillingPoints(extractedValues);
8091
+ },
8092
+ defaultLabel: t("SELECT_FILLING_POINT"),
8093
+ defaultUnit: t("SELECTED"),
8094
+ ServerStyle: {
8095
+ textAlign: "left",
8096
+ width: "100%",
8097
+ minWidth: "250px",
8098
+ backgroundColor: "#fff"
7821
8099
  },
7822
- onSelect: onServiceTypeSelect,
7823
- userType: userType,
7824
- formData: {
7825
- serviceType: selectedServiceType
8100
+ isPropsNeeded: false
8101
+ }), selectedFillingPoints && selectedFillingPoints.length > 0 && /*#__PURE__*/React.createElement("div", {
8102
+ style: {
8103
+ display: "flex",
8104
+ flexWrap: "wrap",
8105
+ gap: "8px",
8106
+ marginTop: "12px",
8107
+ maxHeight: "120px",
8108
+ overflowY: "auto",
8109
+ padding: "4px"
7826
8110
  }
7827
- }))), /*#__PURE__*/React.createElement("div", {
8111
+ }, selectedFillingPoints.map((fp, index) => /*#__PURE__*/React.createElement("div", {
8112
+ key: index,
8113
+ style: {
8114
+ display: "flex",
8115
+ alignItems: "center",
8116
+ backgroundColor: "#f4f4f4",
8117
+ border: "1px solid #ddd",
8118
+ borderRadius: "16px",
8119
+ padding: "4px 12px",
8120
+ fontSize: "14px",
8121
+ fontWeight: "500"
8122
+ }
8123
+ }, /*#__PURE__*/React.createElement("span", {
8124
+ style: {
8125
+ marginRight: "8px",
8126
+ color: "#333",
8127
+ maxWidth: "200px",
8128
+ whiteSpace: "nowrap",
8129
+ overflow: "hidden",
8130
+ textOverflow: "ellipsis"
8131
+ }
8132
+ }, t((fp === null || fp === void 0 ? void 0 : fp.fillingPointName) || (fp === null || fp === void 0 ? void 0 : fp.id))), /*#__PURE__*/React.createElement("button", {
8133
+ type: "button",
8134
+ onClick: e => {
8135
+ e.preventDefault();
8136
+ e.stopPropagation();
8137
+ const fpId = fp.id || fp.fillingPointId;
8138
+ setSelectedFillingPoints(prev => prev.filter(p => (p.id || p.fillingPointId) !== fpId));
8139
+ },
8140
+ style: {
8141
+ background: "transparent",
8142
+ border: "none",
8143
+ color: "#888",
8144
+ cursor: "pointer",
8145
+ fontSize: "16px",
8146
+ display: "flex",
8147
+ alignItems: "center",
8148
+ justifyContent: "center",
8149
+ marginLeft: "auto",
8150
+ padding: "0"
8151
+ }
8152
+ }, "\xD7"))))))), /*#__PURE__*/React.createElement("div", {
7828
8153
  style: {
7829
8154
  display: "flex",
7830
8155
  marginTop: "24px",