impact-chatbot 2.3.31 → 2.3.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.
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) => {
@@ -5107,6 +5119,13 @@ const sseevent = (message, messageToStoreRef) => {
5107
5119
  ? parsedData.additional_args
5108
5120
  : {};
5109
5121
  }
5122
+ if (parsedData?.status === "notification") {
5123
+ messageToStoreRef.current.notificationData = {
5124
+ message: parsedData?.message || "",
5125
+ chat_id: parsedData?.chat_id || "",
5126
+ session_id: parsedData?.session_id || "",
5127
+ };
5128
+ }
5110
5129
  if (parsedData?.status === "completed" ||
5111
5130
  parsedData?.status === "follow-up") {
5112
5131
  messageToStoreRef.current.initValue = true;
@@ -5406,7 +5425,7 @@ const TableContent = ({ bodyText }) => {
5406
5425
  if (lodash.isEmpty(bodyText)) {
5407
5426
  return null;
5408
5427
  }
5409
- const { table_config, row_data, display_name = "", unique_id, select_all_component, table_name, hide_table_setting = false, } = bodyText;
5428
+ 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
5429
  const [columns, setColumns] = React.useState([]);
5411
5430
  const [rowData, setRowData] = React.useState([]);
5412
5431
  const [isModalOpen, setIsModalOpen] = React.useState(false);
@@ -5420,10 +5439,27 @@ const TableContent = ({ bodyText }) => {
5420
5439
  }
5421
5440
  }, [table_config]);
5422
5441
  React.useEffect(() => {
5423
- if (lodash.isEmpty(rowData)) {
5442
+ if (!is_server_side && lodash.isEmpty(rowData)) {
5424
5443
  setRowData(row_data);
5425
5444
  }
5426
5445
  }, [row_data]);
5446
+ const serverSideManualCallBack = async (manualbody, pageIndex, params) => {
5447
+ try {
5448
+ const baseUrl = localStorage.getItem("stepForm_baseUrl") || "";
5449
+ const response = await getTableRecords(baseUrl, table_name, pageIndex + 1, page_size);
5450
+ return {
5451
+ data: response?.data?.data || [],
5452
+ totalCount: response?.data?.total_count || 0,
5453
+ };
5454
+ }
5455
+ catch (error) {
5456
+ console.error("Error in serverSideManualCallBack", error);
5457
+ return {
5458
+ data: [],
5459
+ totalCount: 0,
5460
+ };
5461
+ }
5462
+ };
5427
5463
  const onSelectionChanged = (event) => {
5428
5464
  try {
5429
5465
  const selectedList = event.api.getSelectedRows();
@@ -5442,7 +5478,17 @@ const TableContent = ({ bodyText }) => {
5442
5478
  const handleModalClose = () => {
5443
5479
  setIsModalOpen(false);
5444
5480
  };
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 }) })] }));
5481
+ 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 && {
5482
+ manualCallBack: serverSideManualCallBack,
5483
+ rowModelType: "serverSide",
5484
+ serverSideStoreType: "partial",
5485
+ cacheBlockSize: page_size,
5486
+ }) }) }) }), 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 && {
5487
+ manualCallBack: serverSideManualCallBack,
5488
+ rowModelType: "serverSide",
5489
+ serverSideStoreType: "partial",
5490
+ cacheBlockSize: page_size,
5491
+ }) }) })] }));
5446
5492
  };
5447
5493
 
5448
5494
  const GraphContent = ({ bodyText }) => {
@@ -5752,7 +5798,7 @@ const SelectContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
5752
5798
 
5753
5799
  const DatePickerContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
5754
5800
  const formKey = `${messageIndex}_${bodyText?.paramName}`;
5755
- const { displayFormat, label, isRequired, labelOrientation, placeholder, minDate, maxDate, isDisabled, } = bodyText;
5801
+ const { displayFormat, label, isRequired, labelOrientation, placeholder, minDate, maxDate, isDisabled, minStartDate, } = bodyText;
5756
5802
  const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
5757
5803
  const persistedFormValues = reactRedux.useSelector((state) => state.smartBotReducer.persistedFormValues);
5758
5804
  const dispatch = reactRedux.useDispatch();
@@ -5774,7 +5820,11 @@ const DatePickerContent = ({ bodyText, isFormDisabled = false, messageIndex }) =
5774
5820
  console.error("Error in datepicker handleChange", error);
5775
5821
  }
5776
5822
  };
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,
5823
+ 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) => {
5824
+ // Disable dates before minStartDate
5825
+ const minimumStartDate = moment(minStartDate, displayFormat);
5826
+ return day <= minimumStartDate;
5827
+ },
5778
5828
  // minDate={minDate}
5779
5829
  // maxDate={maxDate}
5780
5830
  isDisabled: isDisabled || isFormDisabled, setSelectedDate: (date) => handleDateChange(date),
@@ -5785,7 +5835,7 @@ const DatePickerContent = ({ bodyText, isFormDisabled = false, messageIndex }) =
5785
5835
 
5786
5836
  const DateRangePickerContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
5787
5837
  const formKey = `${messageIndex}_${bodyText?.paramName}`;
5788
- const { displayFormat, label, isRequired, labelOrientation, minDate, maxDate, isDisabled, showMonthYearSelect, } = bodyText;
5838
+ const { displayFormat, label, isRequired, labelOrientation, minDate, maxDate, isDisabled, showMonthYearSelect, minStartDate, } = bodyText;
5789
5839
  const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
5790
5840
  const persistedFormValues = reactRedux.useSelector((state) => state.smartBotReducer.persistedFormValues);
5791
5841
  const dispatch = reactRedux.useDispatch();
@@ -5812,7 +5862,14 @@ const DateRangePickerContent = ({ bodyText, isFormDisabled = false, messageIndex
5812
5862
  console.error("Error in dateRangePicker handleDatesChange", error);
5813
5863
  }
5814
5864
  };
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: () => {
5865
+ 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) => {
5866
+ // Disable dates before minStartDate
5867
+ const minimumStartDate = moment(minStartDate, displayFormat);
5868
+ return day <= minimumStartDate;
5869
+ },
5870
+ // minDate={minDate}
5871
+ // maxDate={maxDate}
5872
+ isDisabled: isDisabled || isFormDisabled, startDate: startDate, setStartDate: setStartDate, endDate: endDate, setEndDate: setEndDate, showMonthYearSelect: showMonthYearSelect, handleDatesChange: handleDatesChange, onPrimaryButtonClick: () => handleDatesChange(startDate, endDate), onSecondaryButtonClick: () => {
5816
5873
  setStartDate(null);
5817
5874
  setEndDate(null);
5818
5875
  }, onResetClick: () => {
@@ -6624,6 +6681,15 @@ const StreamedContent = ({ botData }) => {
6624
6681
  thinkingStartTimeRef.current = Date.now();
6625
6682
  }
6626
6683
  const data = JSON.parse(event.data);
6684
+ if (data?.status === "notification") {
6685
+ window.dispatchEvent(new CustomEvent("agent-notification", {
6686
+ detail: {
6687
+ message: data?.message || "",
6688
+ chat_id: data?.chat_id || "",
6689
+ session_id: data?.session_id || "",
6690
+ },
6691
+ }));
6692
+ }
6627
6693
  if (data?.message || data?.status === "step" || data?.status === "step_form" || data?.status === "thinking" || data?.status === "questions") {
6628
6694
  if (data.status === "questions") {
6629
6695
  const incomingQuestions = data.widget_data?.[0]?.questions || [];