@djb25/digit-ui-module-ekyc 1.0.9 → 1.0.10

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,7 +1,7 @@
1
1
  import React, { useRef, useEffect, useMemo, useState, createContext, isValidElement, cloneElement, createElement, useContext, useCallback, useReducer, Fragment } from 'react';
2
2
  import { useTranslation } from 'react-i18next';
3
3
  import { useHistory, Link, useLocation, useRouteMatch, Switch, Route, Redirect } from 'react-router-dom';
4
- import { PersonIcon, EmployeeModuleCard, Loader, Card, InboxLinks, Table, HomeIcon, TextInput, Header, SubmitBar, DetailsCard, FilterForm, FilterFormField, Dropdown, Label, Tooltip, CardLabelError, InboxComposer, Toast, Modal, RadioButtons, CardHeader, CardSubHeader, StatusTable, Row, GenericFileIcon, CheckBox, ActionBar, LinkButton, EditIcon as EditIcon$1, FormStep, CardLabel, UploadFile, VerticalTimeline, AppContainer, ModuleHeader, ArrowLeft, PrivateRoute, CitizenHomeCard, DocumentIcon } from '@djb25/digit-ui-react-components';
4
+ import { PersonIcon, EmployeeModuleCard, Loader, Card, InboxLinks, Table, HomeIcon, TextInput, Header, SubmitBar, DetailsCard, FilterForm, FilterFormField, Dropdown, Label, Tooltip, CardLabelError, InboxComposer, Toast, Modal, RadioButtons, CardHeader, CardSubHeader, StatusTable, Row, GenericFileIcon, CheckBox, ActionBar, LinkButton, EditIcon as EditIcon$1, FormStep, CardLabel, UploadFile, VerticalTimeline, AppContainer, ModuleHeader, ArrowLeft, PrivateRoute, ModuleLinksView, CitizenHomeCard, DocumentIcon } from '@djb25/digit-ui-react-components';
5
5
  import * as Chartjs from 'chart.js/auto';
6
6
  import Chartjs__default, { Chart } from 'chart.js/auto';
7
7
  import 'react-dom';
@@ -197,13 +197,7 @@ const StatusCards = ({
197
197
  }, "0.04%")))))));
198
198
  };
199
199
 
200
- const Dashboard = ({
201
- parentRoute,
202
- businessService: _businessService = "EKYC",
203
- initialStates: _initialStates = {},
204
- filterComponent,
205
- isInbox
206
- }) => {
200
+ const Dashboard = () => {
207
201
  const tenantId = Digit.ULBService.getCurrentTenantId();
208
202
  const {
209
203
  isLoading,
@@ -225,7 +219,9 @@ const Dashboard = ({
225
219
  active: info.active || 0
226
220
  };
227
221
  }, [dashboardData]);
228
- return isLoading ? /*#__PURE__*/React.createElement(Loader, null) : /*#__PURE__*/React.createElement(Card, null, /*#__PURE__*/React.createElement(StatusCards, {
222
+ return isLoading ? /*#__PURE__*/React.createElement(Loader, null) : /*#__PURE__*/React.createElement(Card, {
223
+ className: "min-width-full"
224
+ }, /*#__PURE__*/React.createElement(StatusCards, {
229
225
  countData: countData
230
226
  }));
231
227
  };
@@ -4153,6 +4149,290 @@ const MeterDetails = ({
4153
4149
  })));
4154
4150
  };
4155
4151
 
4152
+ const Home = () => {
4153
+ const {
4154
+ t
4155
+ } = useTranslation();
4156
+ const propsForModuleCard = {
4157
+ moduleName: t("ACTION_TEST_EKYC"),
4158
+ kpis: [{
4159
+ count: "-",
4160
+ label: t("TOTAL_EKYC"),
4161
+ link: `/digit-ui/citizen/ekyc/dashboard`
4162
+ }],
4163
+ links: [{
4164
+ label: t("EKYC_DASHBOARD"),
4165
+ link: `/digit-ui/citizen/ekyc/dashboard`
4166
+ }, {
4167
+ label: t("EKYC_INBOX"),
4168
+ link: `/digit-ui/citizen/ekyc/inbox`
4169
+ }, {
4170
+ label: t("EKYC_MAPPING"),
4171
+ link: `/digit-ui/citizen/ekyc/mapping`
4172
+ }]
4173
+ };
4174
+ return /*#__PURE__*/React.createElement(ModuleLinksView, {
4175
+ links: propsForModuleCard.links
4176
+ });
4177
+ };
4178
+
4179
+ const Inbox$1 = ({
4180
+ parentRoute
4181
+ }) => {
4182
+ var _formState$tableForm3, _formState$tableForm4, _formState$searchForm3, _formState$searchForm4, _dashboardData$dashbo2;
4183
+ const tenantId = Digit.ULBService.getCurrentTenantId();
4184
+ const location = useLocation();
4185
+ const formInitValue = {
4186
+ filterForm: {},
4187
+ searchForm: {},
4188
+ tableForm: {
4189
+ limit: 10,
4190
+ offset: 0,
4191
+ sortBy: "createdTime",
4192
+ sortOrder: "DESC"
4193
+ }
4194
+ };
4195
+ const [formState, dispatch] = useReducer(formReducer, formInitValue);
4196
+ const queryParams = useMemo(() => {
4197
+ var _formState$tableForm, _formState$tableForm2;
4198
+ return {
4199
+ tenantId,
4200
+ offset: (formState === null || formState === void 0 ? void 0 : (_formState$tableForm = formState.tableForm) === null || _formState$tableForm === void 0 ? void 0 : _formState$tableForm.offset) || 0,
4201
+ limit: (formState === null || formState === void 0 ? void 0 : (_formState$tableForm2 = formState.tableForm) === null || _formState$tableForm2 === void 0 ? void 0 : _formState$tableForm2.limit) || 10,
4202
+ search: (formState === null || formState === void 0 ? void 0 : formState.searchForm) || {}
4203
+ };
4204
+ }, [tenantId, formState === null || formState === void 0 ? void 0 : (_formState$tableForm3 = formState.tableForm) === null || _formState$tableForm3 === void 0 ? void 0 : _formState$tableForm3.offset, formState === null || formState === void 0 ? void 0 : (_formState$tableForm4 = formState.tableForm) === null || _formState$tableForm4 === void 0 ? void 0 : _formState$tableForm4.limit, formState === null || formState === void 0 ? void 0 : formState.searchForm]);
4205
+ const {
4206
+ isLoading,
4207
+ data: dashboardData = {}
4208
+ } = Digit.Hooks.ekyc.useEkycSurveyorDashboard({}, queryParams, {
4209
+ enabled: !!tenantId,
4210
+ keepPreviousData: true
4211
+ });
4212
+ const searchDetails = useMemo(() => {
4213
+ var _formState$searchForm, _formState$searchForm2;
4214
+ return {
4215
+ kno: (formState === null || formState === void 0 ? void 0 : (_formState$searchForm = formState.searchForm) === null || _formState$searchForm === void 0 ? void 0 : _formState$searchForm.kNumber) || "",
4216
+ name: (formState === null || formState === void 0 ? void 0 : (_formState$searchForm2 = formState.searchForm) === null || _formState$searchForm2 === void 0 ? void 0 : _formState$searchForm2.kName) || ""
4217
+ };
4218
+ }, [formState === null || formState === void 0 ? void 0 : (_formState$searchForm3 = formState.searchForm) === null || _formState$searchForm3 === void 0 ? void 0 : _formState$searchForm3.kNumber, formState === null || formState === void 0 ? void 0 : (_formState$searchForm4 = formState.searchForm) === null || _formState$searchForm4 === void 0 ? void 0 : _formState$searchForm4.kName]);
4219
+ const isSearchActive = !!(searchDetails.kno || searchDetails.name);
4220
+ const {
4221
+ isLoading: isSearchLoading,
4222
+ data: searchData
4223
+ } = Digit.Hooks.ekyc.useSearchConnection({
4224
+ tenantId,
4225
+ details: searchDetails
4226
+ }, {
4227
+ enabled: !!tenantId && !!searchDetails.kno,
4228
+ keepPreviousData: true
4229
+ });
4230
+ const sourceData = useMemo(() => {
4231
+ var _dashboardData$dashbo;
4232
+ if (isSearchActive) {
4233
+ if (!searchData) return [];
4234
+ return [searchData];
4235
+ }
4236
+ return (dashboardData === null || dashboardData === void 0 ? void 0 : (_dashboardData$dashbo = dashboardData.dashboardInfo) === null || _dashboardData$dashbo === void 0 ? void 0 : _dashboardData$dashbo.consumerList) || [];
4237
+ }, [isSearchActive, searchData, dashboardData]);
4238
+ const filteredData = useMemo(() => {
4239
+ return (sourceData || []).map(item => {
4240
+ const isSearchItem = !!item.connectionDetails;
4241
+ if (isSearchItem) {
4242
+ var _item$propertyInfo, _item$propertyInfo2, _item$connectionDetai, _item$propertyInfo3, _item$connectionDetai2, _item$connectionDetai3;
4243
+ return {
4244
+ applicationNo: ((_item$propertyInfo = item.propertyInfo) === null || _item$propertyInfo === void 0 ? void 0 : _item$propertyInfo.kno) || "",
4245
+ connectionNo: ((_item$propertyInfo2 = item.propertyInfo) === null || _item$propertyInfo2 === void 0 ? void 0 : _item$propertyInfo2.kno) || "",
4246
+ owner: ((_item$connectionDetai = item.connectionDetails) === null || _item$connectionDetai === void 0 ? void 0 : _item$connectionDetai.consumerName) || "",
4247
+ applicationNumber: ((_item$propertyInfo3 = item.propertyInfo) === null || _item$propertyInfo3 === void 0 ? void 0 : _item$propertyInfo3.kno) || "",
4248
+ citizenName: ((_item$connectionDetai2 = item.connectionDetails) === null || _item$connectionDetai2 === void 0 ? void 0 : _item$connectionDetai2.consumerName) || "",
4249
+ status: ((_item$connectionDetai3 = item.connectionDetails) === null || _item$connectionDetai3 === void 0 ? void 0 : _item$connectionDetai3.statusflag) || "",
4250
+ sla: 0
4251
+ };
4252
+ }
4253
+ return {
4254
+ ...item,
4255
+ applicationNo: item.kno || item.applicationNumber || "",
4256
+ connectionNo: item.connectionNo || "",
4257
+ owner: item.consumerName || item.citizenName || "",
4258
+ applicationNumber: item.kno || item.applicationNumber || "",
4259
+ citizenName: item.consumerName || item.citizenName || "",
4260
+ status: item.status || "",
4261
+ sla: item.sla ?? 0
4262
+ };
4263
+ });
4264
+ }, [sourceData]);
4265
+ const totalRecords = (dashboardData === null || dashboardData === void 0 ? void 0 : (_dashboardData$dashbo2 = dashboardData.dashboardInfo) === null || _dashboardData$dashbo2 === void 0 ? void 0 : _dashboardData$dashbo2.totalRecords) || (dashboardData === null || dashboardData === void 0 ? void 0 : dashboardData.totalCount) || 0;
4266
+ const checkPathName = location.pathname.includes("ekyc/inbox");
4267
+ const PropsForInboxLinks = {
4268
+ headerText: checkPathName ? "MODULE_WATER" : "MODULE_SW"
4269
+ };
4270
+ const SearchFormFields = useCallback(({
4271
+ registerRef,
4272
+ searchFormState,
4273
+ controlSearchForm
4274
+ }) => /*#__PURE__*/React.createElement(SearchFormFieldsComponents, Object.assign({}, {
4275
+ registerRef,
4276
+ searchFormState,
4277
+ controlSearchForm
4278
+ }, {
4279
+ className: "search"
4280
+ })), []);
4281
+ const tableOrderFormDefaultValues = {
4282
+ sortBy: "createdTime",
4283
+ limit: window.Digit.Utils.browser.isMobile() ? 50 : 10,
4284
+ offset: 0,
4285
+ sortOrder: "DESC"
4286
+ };
4287
+ const onSearchFormSubmit = data => {
4288
+ data.hasOwnProperty("") && (data === null || data === void 0 ? true : delete data[""]);
4289
+ dispatch({
4290
+ action: "mutateTableForm",
4291
+ data: {
4292
+ ...tableOrderFormDefaultValues
4293
+ },
4294
+ checkPathName
4295
+ });
4296
+ dispatch({
4297
+ action: "mutateSearchForm",
4298
+ data,
4299
+ checkPathName
4300
+ });
4301
+ };
4302
+ const searchFormDefaultValues = {
4303
+ mobileNumber: "",
4304
+ applicationNumber: "",
4305
+ consumerNo: ""
4306
+ };
4307
+ const onSearchFormReset = setSearchFormValue => {
4308
+ setSearchFormValue("mobileNumber", null);
4309
+ setSearchFormValue("applicationNumber", null);
4310
+ setSearchFormValue("consumerNo", null);
4311
+ dispatch({
4312
+ action: "mutateSearchForm",
4313
+ data: searchFormDefaultValues
4314
+ });
4315
+ };
4316
+ const propsForSearchForm = {
4317
+ SearchFormFields,
4318
+ onSearchFormSubmit,
4319
+ searchFormDefaultValues: formState === null || formState === void 0 ? void 0 : formState.searchForm,
4320
+ resetSearchFormDefaultValues: searchFormDefaultValues,
4321
+ onSearchFormReset,
4322
+ className: "search-form-wns-inbox"
4323
+ };
4324
+ const FilterFormFields = useCallback(({
4325
+ registerRef,
4326
+ controlFilterForm,
4327
+ setFilterFormValue,
4328
+ getFilterFormValue
4329
+ }) => /*#__PURE__*/React.createElement(React.Fragment, null), []);
4330
+ const propsForFilterForm = {
4331
+ FilterFormFields,
4332
+ onFilterFormSubmit: () => {},
4333
+ filterFormDefaultValues: "",
4334
+ resetFilterFormDefaultValues: "",
4335
+ onFilterFormReset: () => {}
4336
+ };
4337
+ function formReducer(state, payload) {
4338
+ const storageKey = payload.checkPathName ? "EKYC.INBOX" : "EKYC.SW.INBOX";
4339
+ switch (payload.action) {
4340
+ case "mutateSearchForm":
4341
+ Digit.SessionStorage.set(storageKey, {
4342
+ ...state,
4343
+ searchForm: payload.data
4344
+ });
4345
+ return {
4346
+ ...state,
4347
+ searchForm: payload.data
4348
+ };
4349
+ case "mutateFilterForm":
4350
+ Digit.SessionStorage.set(storageKey, {
4351
+ ...state,
4352
+ filterForm: payload.data
4353
+ });
4354
+ return {
4355
+ ...state,
4356
+ filterForm: payload.data
4357
+ };
4358
+ case "mutateTableForm":
4359
+ Digit.SessionStorage.set(storageKey, {
4360
+ ...state,
4361
+ tableForm: payload.data
4362
+ });
4363
+ return {
4364
+ ...state,
4365
+ tableForm: payload.data
4366
+ };
4367
+ default:
4368
+ return state;
4369
+ }
4370
+ }
4371
+ const onPageSizeChange = e => {
4372
+ const newLimit = Number(e.target.value);
4373
+ dispatch({
4374
+ action: "mutateTableForm",
4375
+ data: {
4376
+ ...formState.tableForm,
4377
+ limit: newLimit,
4378
+ offset: 0
4379
+ },
4380
+ checkPathName
4381
+ });
4382
+ };
4383
+ const onSortingByData = e => {
4384
+ if (e.length > 0) {
4385
+ const [{
4386
+ id,
4387
+ desc
4388
+ }] = e;
4389
+ const sortOrder = desc ? "DESC" : "ASC";
4390
+ const sortBy = id;
4391
+ if (!(formState.tableForm.sortBy === sortBy && formState.tableForm.sortOrder === sortOrder)) {
4392
+ dispatch({
4393
+ action: "mutateTableForm",
4394
+ data: {
4395
+ ...formState.tableForm,
4396
+ sortBy: id,
4397
+ sortOrder: desc ? "DESC" : "ASC"
4398
+ },
4399
+ checkPathName
4400
+ });
4401
+ }
4402
+ }
4403
+ };
4404
+ const propsForInboxTable = useInboxTableConfig({
4405
+ ...{
4406
+ parentRoute,
4407
+ onPageSizeChange,
4408
+ formState,
4409
+ totalCount: totalRecords,
4410
+ table: filteredData,
4411
+ dispatch,
4412
+ onSortingByData,
4413
+ tenantId,
4414
+ checkPathName,
4415
+ inboxStyles: {
4416
+ overflowX: "scroll",
4417
+ overflowY: "hidden"
4418
+ },
4419
+ tableStyle: {
4420
+ width: "70%"
4421
+ }
4422
+ }
4423
+ });
4424
+ const isInboxLoading = isLoading || isSearchLoading;
4425
+ return /*#__PURE__*/React.createElement("div", {
4426
+ className: "app-container"
4427
+ }, /*#__PURE__*/React.createElement(InboxComposer, _extends({
4428
+ isInboxLoading,
4429
+ PropsForInboxLinks
4430
+ }, propsForSearchForm, propsForFilterForm, {
4431
+ propsForInboxTable,
4432
+ formState
4433
+ })));
4434
+ };
4435
+
4156
4436
  const CitizenApp = () => {
4157
4437
  const {
4158
4438
  t
@@ -4187,8 +4467,15 @@ const CitizenApp = () => {
4187
4467
  onLeftClick: () => window.history.back(),
4188
4468
  breadcrumbs: breadcrumbs
4189
4469
  }), /*#__PURE__*/React.createElement(Switch, null, /*#__PURE__*/React.createElement(PrivateRoute, {
4190
- path: `${path}/create-kyc`,
4191
- component: () => /*#__PURE__*/React.createElement(Create, null)
4470
+ exact: true,
4471
+ path: `${path}`,
4472
+ component: () => /*#__PURE__*/React.createElement(Home, null)
4473
+ }), /*#__PURE__*/React.createElement(PrivateRoute, {
4474
+ path: `${path}/dashboard`,
4475
+ component: () => /*#__PURE__*/React.createElement(Dashboard, null)
4476
+ }), /*#__PURE__*/React.createElement(PrivateRoute, {
4477
+ path: `${path}/inbox`,
4478
+ component: () => /*#__PURE__*/React.createElement(Inbox$1, null)
4192
4479
  }), /*#__PURE__*/React.createElement(PrivateRoute, {
4193
4480
  path: `${path}/aadhaar-verification`,
4194
4481
  component: () => /*#__PURE__*/React.createElement(AadhaarVerification, null)
@@ -4204,14 +4491,10 @@ const CitizenApp = () => {
4204
4491
  }), /*#__PURE__*/React.createElement(PrivateRoute, {
4205
4492
  path: `${path}/review`,
4206
4493
  component: () => /*#__PURE__*/React.createElement(Review, null)
4207
- }), /*#__PURE__*/React.createElement(PrivateRoute, {
4208
- path: `${path}/`,
4209
- component: () => /*#__PURE__*/React.createElement(Create, null)
4210
4494
  }))));
4211
4495
  };
4212
4496
 
4213
4497
  const EkycModule = ({
4214
- stateCode,
4215
4498
  userType,
4216
4499
  tenants
4217
4500
  }) => {
@@ -4219,20 +4502,7 @@ const EkycModule = ({
4219
4502
  path,
4220
4503
  url
4221
4504
  } = useRouteMatch();
4222
- const moduleCode = "EKYC";
4223
- const language = Digit.StoreData.getCurrentLanguage();
4224
- const {
4225
- isLoading,
4226
- data: store
4227
- } = Digit.Services.useStore({
4228
- stateCode,
4229
- moduleCode,
4230
- language
4231
- });
4232
4505
  Digit.SessionStorage.set("EKYC_TENANTS", tenants);
4233
- if (isLoading) {
4234
- return null;
4235
- }
4236
4506
  if (userType === "employee") {
4237
4507
  return /*#__PURE__*/React.createElement(EmployeeApp, {
4238
4508
  path: path,