impact-chatbot 2.3.31 → 2.3.32

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.
package/dist/index.cjs.js CHANGED
@@ -232,6 +232,18 @@ const getFilterOptions = (postBody) => async () => {
232
232
  data: postBody,
233
233
  });
234
234
  };
235
+ const getTableRecords = async (baseUrl, tableName, page, pageSize) => {
236
+ try {
237
+ return axiosInstance({
238
+ url: `${baseUrl}/chatbot/agent/tabular-data/${tableName}?page=${page}&page_size=${pageSize}`,
239
+ method: 'GET',
240
+ });
241
+ }
242
+ catch (error) {
243
+ console.error('getTableRecords error:', error);
244
+ return null;
245
+ }
246
+ };
235
247
 
236
248
  const useBotConfiguration = (setRefreshLoader, setEnableRefreshAction, dispatch) => {
237
249
  const displaySnackMessages = React.useCallback((message, variant) => {
@@ -5406,7 +5418,7 @@ const TableContent = ({ bodyText }) => {
5406
5418
  if (lodash.isEmpty(bodyText)) {
5407
5419
  return null;
5408
5420
  }
5409
- const { table_config, row_data, display_name = "", unique_id, select_all_component, table_name, hide_table_setting = false, } = bodyText;
5421
+ const { table_config, row_data, display_name = "", unique_id, select_all_component, table_name, hide_table_setting = false, is_server_side = false, page_size = 10, } = bodyText;
5410
5422
  const [columns, setColumns] = React.useState([]);
5411
5423
  const [rowData, setRowData] = React.useState([]);
5412
5424
  const [isModalOpen, setIsModalOpen] = React.useState(false);
@@ -5420,10 +5432,27 @@ const TableContent = ({ bodyText }) => {
5420
5432
  }
5421
5433
  }, [table_config]);
5422
5434
  React.useEffect(() => {
5423
- if (lodash.isEmpty(rowData)) {
5435
+ if (!is_server_side && lodash.isEmpty(rowData)) {
5424
5436
  setRowData(row_data);
5425
5437
  }
5426
5438
  }, [row_data]);
5439
+ const serverSideManualCallBack = async (manualbody, pageIndex, params) => {
5440
+ try {
5441
+ const baseUrl = localStorage.getItem("stepForm_baseUrl") || "";
5442
+ const response = await getTableRecords(baseUrl, table_name, pageIndex + 1, page_size);
5443
+ return {
5444
+ data: response?.data?.data || [],
5445
+ totalCount: response?.data?.total_count || 0,
5446
+ };
5447
+ }
5448
+ catch (error) {
5449
+ console.error("Error in serverSideManualCallBack", error);
5450
+ return {
5451
+ data: [],
5452
+ totalCount: 0,
5453
+ };
5454
+ }
5455
+ };
5427
5456
  const onSelectionChanged = (event) => {
5428
5457
  try {
5429
5458
  const selectedList = event.api.getSelectedRows();
@@ -5442,7 +5471,17 @@ const TableContent = ({ bodyText }) => {
5442
5471
  const handleModalClose = () => {
5443
5472
  setIsModalOpen(false);
5444
5473
  };
5445
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(impactUiV3.Modal, { className: "test-modal", onClose: handleModalClose, onPrimaryButtonClick: () => { }, onSecondaryButtonClick: handleModalClose, open: isModalOpen, size: "large", title: "", children: jsxRuntime.jsx("div", { style: { width: '100%', height: '70vh' }, children: jsxRuntime.jsx(AgGridComponent, { columns: columns, rowdata: rowData, pagination: true, paginationPageSize: 20, suppressFieldDotNotation: true, domLayout: "normal", sizeColumnsToFitFlag: true, showSaveTableConfig: false, showSearchModalBtn: false, hideFormatSideBar: true, uniqueRowId: unique_id, selectAllHeaderComponent: select_all_component, onSelectionChanged: onSelectionChanged, hideTableSetting: hide_table_setting, downloadAsExcel: true, tableHeader: display_name }) }) }), jsxRuntime.jsx("div", { style: { width: '100%', marginTop: '10px' }, children: jsxRuntime.jsx(AgGridComponent, { columns: columns, rowdata: rowData, pagination: true, paginationPageSize: 10, suppressFieldDotNotation: true, domLayout: "autoHeight", customClass: "bot_table_auto_height", sizeColumnsToFitFlag: true, showSaveTableConfig: false, showSearchModalBtn: false, hideFormatSideBar: true, uniqueRowId: unique_id, selectAllHeaderComponent: select_all_component, onSelectionChanged: onSelectionChanged, hideTableSetting: hide_table_setting, customSystemButton: getTopRightOptions(), customSystemButtonWithDownload: true, topRightOptions: null, downloadAsExcel: true, tableHeader: display_name }) })] }));
5474
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(impactUiV3.Modal, { className: "test-modal", onClose: handleModalClose, onPrimaryButtonClick: () => { }, onSecondaryButtonClick: handleModalClose, open: isModalOpen, size: "large", title: "", children: jsxRuntime.jsx("div", { style: { width: '100%', height: '70vh' }, children: jsxRuntime.jsx(AgGridComponent, { columns: columns, rowdata: is_server_side ? undefined : rowData, pagination: true, paginationPageSize: is_server_side ? page_size : 20, suppressFieldDotNotation: true, domLayout: "normal", sizeColumnsToFitFlag: true, showSaveTableConfig: false, showSearchModalBtn: false, hideFormatSideBar: true, uniqueRowId: unique_id, selectAllHeaderComponent: select_all_component, onSelectionChanged: onSelectionChanged, hideTableSetting: hide_table_setting, downloadAsExcel: true, tableHeader: display_name, ...(is_server_side && {
5475
+ manualCallBack: serverSideManualCallBack,
5476
+ rowModelType: "serverSide",
5477
+ serverSideStoreType: "partial",
5478
+ cacheBlockSize: page_size,
5479
+ }) }) }) }), jsxRuntime.jsx("div", { style: { width: '100%', marginTop: '10px' }, children: jsxRuntime.jsx(AgGridComponent, { columns: columns, rowdata: is_server_side ? undefined : rowData, pagination: true, paginationPageSize: is_server_side ? page_size : 10, suppressFieldDotNotation: true, domLayout: "autoHeight", customClass: "bot_table_auto_height", sizeColumnsToFitFlag: true, showSaveTableConfig: false, showSearchModalBtn: false, hideFormatSideBar: true, uniqueRowId: unique_id, selectAllHeaderComponent: select_all_component, onSelectionChanged: onSelectionChanged, hideTableSetting: hide_table_setting, customSystemButton: getTopRightOptions(), customSystemButtonWithDownload: true, topRightOptions: null, downloadAsExcel: true, tableHeader: display_name, ...(is_server_side && {
5480
+ manualCallBack: serverSideManualCallBack,
5481
+ rowModelType: "serverSide",
5482
+ serverSideStoreType: "partial",
5483
+ cacheBlockSize: page_size,
5484
+ }) }) })] }));
5446
5485
  };
5447
5486
 
5448
5487
  const GraphContent = ({ bodyText }) => {
@@ -5752,7 +5791,7 @@ const SelectContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
5752
5791
 
5753
5792
  const DatePickerContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
5754
5793
  const formKey = `${messageIndex}_${bodyText?.paramName}`;
5755
- const { displayFormat, label, isRequired, labelOrientation, placeholder, minDate, maxDate, isDisabled, } = bodyText;
5794
+ const { displayFormat, label, isRequired, labelOrientation, placeholder, minDate, maxDate, isDisabled, minStartDate, } = bodyText;
5756
5795
  const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
5757
5796
  const persistedFormValues = reactRedux.useSelector((state) => state.smartBotReducer.persistedFormValues);
5758
5797
  const dispatch = reactRedux.useDispatch();
@@ -5774,7 +5813,11 @@ const DatePickerContent = ({ bodyText, isFormDisabled = false, messageIndex }) =
5774
5813
  console.error("Error in datepicker handleChange", error);
5775
5814
  }
5776
5815
  };
5777
- return (jsxRuntime.jsx("div", { style: { width: "100%", marginTop: "10px" }, children: jsxRuntime.jsx(impactUiV3.DatePicker, { displayFormat: displayFormat, label: label, required: isRequired, labelOrientation: labelOrientation, placeholder: placeholder,
5816
+ return (jsxRuntime.jsx("div", { style: { width: "100%", marginTop: "10px" }, children: jsxRuntime.jsx(impactUiV3.DatePicker, { displayFormat: displayFormat, label: label, required: isRequired, labelOrientation: labelOrientation, placeholder: placeholder, isOutsideRange: (day) => {
5817
+ // Disable dates before minStartDate
5818
+ const minimumStartDate = moment(minStartDate, displayFormat);
5819
+ return day <= minimumStartDate;
5820
+ },
5778
5821
  // minDate={minDate}
5779
5822
  // maxDate={maxDate}
5780
5823
  isDisabled: isDisabled || isFormDisabled, setSelectedDate: (date) => handleDateChange(date),
@@ -5785,7 +5828,7 @@ const DatePickerContent = ({ bodyText, isFormDisabled = false, messageIndex }) =
5785
5828
 
5786
5829
  const DateRangePickerContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
5787
5830
  const formKey = `${messageIndex}_${bodyText?.paramName}`;
5788
- const { displayFormat, label, isRequired, labelOrientation, minDate, maxDate, isDisabled, showMonthYearSelect, } = bodyText;
5831
+ const { displayFormat, label, isRequired, labelOrientation, minDate, maxDate, isDisabled, showMonthYearSelect, minStartDate, } = bodyText;
5789
5832
  const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
5790
5833
  const persistedFormValues = reactRedux.useSelector((state) => state.smartBotReducer.persistedFormValues);
5791
5834
  const dispatch = reactRedux.useDispatch();
@@ -5812,7 +5855,14 @@ const DateRangePickerContent = ({ bodyText, isFormDisabled = false, messageIndex
5812
5855
  console.error("Error in dateRangePicker handleDatesChange", error);
5813
5856
  }
5814
5857
  };
5815
- return (jsxRuntime.jsx("div", { style: { width: "100%", marginTop: "10px" }, children: jsxRuntime.jsx(impactUiV3.DateRangePicker, { displayFormat: displayFormat, label: label, isRequired: isRequired, labelOrientation: labelOrientation || "top", minDate: minDate, maxDate: maxDate, isDisabled: isDisabled || isFormDisabled, startDate: startDate, setStartDate: setStartDate, endDate: endDate, setEndDate: setEndDate, showMonthYearSelect: showMonthYearSelect, handleDatesChange: handleDatesChange, onPrimaryButtonClick: () => handleDatesChange(startDate, endDate), onSecondaryButtonClick: () => {
5858
+ return (jsxRuntime.jsx("div", { style: { width: "100%", marginTop: "10px" }, children: jsxRuntime.jsx(impactUiV3.DateRangePicker, { displayFormat: displayFormat, label: label, isRequired: isRequired, labelOrientation: labelOrientation || "top", isOutsideRange: (day) => {
5859
+ // Disable dates before minStartDate
5860
+ const minimumStartDate = moment(minStartDate, displayFormat);
5861
+ return day <= minimumStartDate;
5862
+ },
5863
+ // minDate={minDate}
5864
+ // maxDate={maxDate}
5865
+ isDisabled: isDisabled || isFormDisabled, startDate: startDate, setStartDate: setStartDate, endDate: endDate, setEndDate: setEndDate, showMonthYearSelect: showMonthYearSelect, handleDatesChange: handleDatesChange, onPrimaryButtonClick: () => handleDatesChange(startDate, endDate), onSecondaryButtonClick: () => {
5816
5866
  setStartDate(null);
5817
5867
  setEndDate(null);
5818
5868
  }, onResetClick: () => {