@mseva/digit-ui-module-core 1.0.17 → 1.0.18

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.
@@ -3,7 +3,7 @@ import { useQueryClient, QueryClient, QueryClientProvider } from 'react-query';
3
3
  import { Provider } from 'react-redux';
4
4
  import { Link, useLocation, useRouteMatch, useHistory, Switch, Route, Redirect, BrowserRouter } from 'react-router-dom';
5
5
  import { useTranslation, getI18n } from 'react-i18next';
6
- import { PTIcon, BillsIcon, WSICon, TLIcon, PGRIcon, OBPSIcon, MCollectIcon, FSMIcon, Loader, BackButton, CitizenHomeCard, CitizenInfoLabel, PTRIcon, FormStep, CheckBox, CitizenConsentForm, OTPInput, CardText as CardText$1, CardLabelError as CardLabelError$1, AppContainer, Toast, Dropdown, FormComposer as FormComposer$1, CardSubHeader as CardSubHeader$1, Card as Card$1, CustomButton, SubmitBar as SubmitBar$1, TopBar as TopBar$1, Hamburger, Modal, CloseSvg, PropertyHouse, CaseIcon, CollectionIcon, BirthIcon, DeathIcon, FirenocIcon, HomeIcon, EditPencilIcon, LogoutIcon, Phone, LoginIcon, NavBar, ArrowVectorDown, ArrowForward, ComplaintIcon, BPAHomeIcon, ReceiptIcon, PersonIcon, DocumentIconSolid, DropIcon, CollectionsBookmarIcons, FinanceChartIcon, SearchIcon, GalleryIcon, RemoveIcon, BreadCrumb, CameraIcon, LabelFieldPair as LabelFieldPair$1, CardLabel as CardLabel$1, TextInput as TextInput$1, DatePicker, MobileNumber as MobileNumber$1, PrivateRoute, Calender, DocumentIcon, CardBasedOptions, WhatsNewCard, PageBasedInput, CardHeader, RadioButtons, SearchOnRadioButtons, Header as Header$1, PDFSvg, DownloadImgIcon, HelpLineIcon, ServiceCenterIcon, ValidityTimeIcon, TimerIcon, RupeeSymbol, Banner, Rating, TextArea as TextArea$1, SearchField, SearchAction, PopUp, DetailsCard, DownloadBtnCommon, SearchForm, Table, StatusTable, Row, LinkButton as LinkButton$1, Body } from '@mseva/digit-ui-react-components';
6
+ import { PTIcon, BillsIcon, WSICon, TLIcon, PGRIcon, OBPSIcon, MCollectIcon, FSMIcon, Loader, BackButton, CitizenHomeCard, CitizenInfoLabel, PTRIcon, FormStep, CheckBox, CitizenConsentForm, OTPInput, CardText as CardText$1, CardLabelError as CardLabelError$1, AppContainer, Toast, Dropdown, FormComposer as FormComposer$1, CardSubHeader as CardSubHeader$1, Card as Card$1, CustomButton, SubmitBar as SubmitBar$1, TopBar as TopBar$1, Hamburger, Modal, CloseSvg, PropertyHouse, CaseIcon, CollectionIcon, BirthIcon, DeathIcon, FirenocIcon, HomeIcon, EditPencilIcon, LogoutIcon, Phone, LoginIcon, NavBar, ArrowVectorDown, ArrowForward, ComplaintIcon, BPAHomeIcon, ReceiptIcon, PersonIcon, DocumentIconSolid, DropIcon, CollectionsBookmarIcons, FinanceChartIcon, SearchIcon, GalleryIcon, RemoveIcon, BreadCrumb, CameraIcon, LabelFieldPair as LabelFieldPair$1, CardLabel as CardLabel$1, TextInput as TextInput$1, DatePicker, MobileNumber as MobileNumber$1, PrivateRoute, Calender, DocumentIcon, CardBasedOptions, WhatsNewCard, PageBasedInput, CardHeader, RadioButtons, Header as Header$1, PDFSvg, DownloadImgIcon, HelpLineIcon, ServiceCenterIcon, ValidityTimeIcon, TimerIcon, RupeeSymbol, Banner, Rating, TextArea as TextArea$1, SearchField, SearchAction, PopUp, DetailsCard, DownloadBtnCommon, SearchForm, Table, StatusTable, Row, LinkButton as LinkButton$1, Body } from '@mseva/digit-ui-react-components';
7
7
  import ReactTooltip from 'react-tooltip';
8
8
  import { compose, applyMiddleware, createStore, combineReducers } from 'redux';
9
9
  import thunk from 'redux-thunk';
@@ -12476,6 +12476,26 @@ const AppModules = ({
12476
12476
  path
12477
12477
  } = useRouteMatch();
12478
12478
  const location = useLocation();
12479
+ const parseValue = value => {
12480
+ try {
12481
+ return JSON.parse(value);
12482
+ } catch (e) {
12483
+ return value;
12484
+ }
12485
+ };
12486
+ const getFromStorage = key => {
12487
+ const value = window.localStorage.getItem(key);
12488
+ return value && value !== "undefined" ? parseValue(value) : null;
12489
+ };
12490
+ const employeeToken = getFromStorage("Employee.token");
12491
+ const employeeInfo = getFromStorage("Employee.user-info");
12492
+ const getUserDetails = (access_token, info) => ({
12493
+ token: access_token,
12494
+ access_token,
12495
+ info
12496
+ });
12497
+ const userDetails = getUserDetails(employeeToken, employeeInfo);
12498
+ window.Digit.SessionStorage.set("User", userDetails);
12479
12499
  const user = Digit.UserService.getUser();
12480
12500
  if (!user || !(user !== null && user !== void 0 && user.access_token) || !(user !== null && user !== void 0 && user.info)) {
12481
12501
  return /*#__PURE__*/React.createElement(Redirect, {
@@ -15609,12 +15629,36 @@ const Home = () => {
15609
15629
  } = Digit.Hooks.useStore.getInitData();
15610
15630
  let isMobile = window.Digit.Utils.browser.isMobile();
15611
15631
  if (window.Digit.SessionStorage.get("TL_CREATE_TRADE")) window.Digit.SessionStorage.set("TL_CREATE_TRADE", {});
15632
+ const parseValue = value => {
15633
+ try {
15634
+ return JSON.parse(value);
15635
+ } catch (e) {
15636
+ return value;
15637
+ }
15638
+ };
15612
15639
  const conditionsToDisableNotificationCountTrigger = () => {
15613
15640
  var _Digit$UserService2, _Digit$UserService2$g, _Digit$UserService2$g2, _Digit$UserService3, _Digit$UserService3$g;
15614
15641
  if (((_Digit$UserService2 = Digit.UserService) === null || _Digit$UserService2 === void 0 ? void 0 : (_Digit$UserService2$g = _Digit$UserService2.getUser()) === null || _Digit$UserService2$g === void 0 ? void 0 : (_Digit$UserService2$g2 = _Digit$UserService2$g.info) === null || _Digit$UserService2$g2 === void 0 ? void 0 : _Digit$UserService2$g2.type) === "EMPLOYEE") return false;
15615
15642
  if (!((_Digit$UserService3 = Digit.UserService) !== null && _Digit$UserService3 !== void 0 && (_Digit$UserService3$g = _Digit$UserService3.getUser()) !== null && _Digit$UserService3$g !== void 0 && _Digit$UserService3$g.access_token)) return false;
15616
15643
  return true;
15617
15644
  };
15645
+ const getFromStorage = key => {
15646
+ const value = window.localStorage.getItem(key);
15647
+ return value && value !== "undefined" ? parseValue(value) : null;
15648
+ };
15649
+ const token = getFromStorage("token");
15650
+ const citizenToken = getFromStorage("Citizen.token");
15651
+ const userType = token === citizenToken ? "citizen" : "employee";
15652
+ const citizenInfoMain = getFromStorage("Citizen.user-info");
15653
+ const employeeToken = getFromStorage("Employee.token");
15654
+ const employeeInfo = getFromStorage("Employee.user-info");
15655
+ const getUserDetails = (access_token, info) => ({
15656
+ token: access_token,
15657
+ access_token,
15658
+ info
15659
+ });
15660
+ const userDetails = userType === "citizen" ? getUserDetails(citizenToken, citizenInfoMain) : getUserDetails(employeeToken, employeeInfo);
15661
+ window.Digit.SessionStorage.set("User", userDetails);
15618
15662
  console.log("citizenInfo", citizenInfo);
15619
15663
  console.log("localCheck", localCheck, tIDCheck);
15620
15664
  const {
@@ -15852,10 +15896,8 @@ const LocationSelection = () => {
15852
15896
  }), [t]);
15853
15897
  function selectCity(city) {
15854
15898
  setSelectedCity(city);
15855
- console.log("selected city", city);
15856
15899
  setShowError(false);
15857
15900
  }
15858
- console.log("selected city", selectCity);
15859
15901
  const RadioButtonProps = useMemo(() => {
15860
15902
  return {
15861
15903
  options: cities,
@@ -15878,15 +15920,24 @@ const LocationSelection = () => {
15878
15920
  setShowError(true);
15879
15921
  }
15880
15922
  }
15923
+ const cityOptions = cities === null || cities === void 0 ? void 0 : cities.map(city => ({
15924
+ ...city,
15925
+ displayName: t(city.i18nKey)
15926
+ }));
15881
15927
  return isLoading ? /*#__PURE__*/React.createElement("loader", null) : /*#__PURE__*/React.createElement("div", {
15882
15928
  className: "selection-card-wrapper"
15883
15929
  }, /*#__PURE__*/React.createElement(BackButton, null), /*#__PURE__*/React.createElement(PageBasedInput, {
15884
15930
  texts: texts,
15885
15931
  onSubmit: onSubmit,
15886
15932
  className: "location-selection-container"
15887
- }, /*#__PURE__*/React.createElement(CardHeader, null, t("CS_COMMON_CHOOSE_LOCATION")), /*#__PURE__*/React.createElement(SearchOnRadioButtons, Object.assign({}, RadioButtonProps, {
15933
+ }, /*#__PURE__*/React.createElement(CardHeader, null, t("CS_COMMON_CHOOSE_LOCATION")), /*#__PURE__*/React.createElement(Dropdown, {
15934
+ option: cityOptions,
15935
+ optionKey: "displayName",
15936
+ id: "city",
15937
+ selected: selectedCity,
15938
+ select: selectCity,
15888
15939
  placeholder: t("COMMON_TABLE_SEARCH")
15889
- })), showError ? /*#__PURE__*/React.createElement(CardLabelError$1, null, t("CS_COMMON_LOCATION_SELECTION_ERROR")) : null));
15940
+ }), showError ? /*#__PURE__*/React.createElement(CardLabelError$1, null, t("CS_COMMON_LOCATION_SELECTION_ERROR")) : null));
15890
15941
  };
15891
15942
 
15892
15943
  const FaqComponent = props => {