All files / src index.js

100% Statements 2/2
96.43% Branches 27/28
100% Functions 1/1
100% Lines 2/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75                                              4x   4x                                                                                                  
import React, { Component, Fragment } from "react";
import { Provider } from "react-redux";
import store from "./redux/store/store";
import DatatableInitializer from "./components/DatatableInitializer";
import "./app.css";
import { cloneDeep } from "lodash";
import { SnackbarProvider } from "notistack";
 
class Datatable extends Component {
  render() {
    const {
      options = {},
      dtKey = "",
      forceRerender = false,
      actions = null,
      refreshRows = null,
      stripped = false,
      customProps = null,
      CustomTableBodyCell = null,
      CustomTableBodyRow = null,
      CustomTableHeaderCell = null,
      CustomTableHeaderRow = null,
      customDataTypes = []
    } = this.props;
    
    return (
      <Fragment>
        {options.data &&
          options.data.columns &&
          options.data.columns.length > 0 &&
          options.keyColumn && (
            <Provider store={store}>
              <SnackbarProvider>
                <DatatableInitializer
                  optionsInit={cloneDeep(options)}
                  dtKey={dtKey}
                  forceRerender={forceRerender}
                  actions={actions}
                  refreshRows={refreshRows}
                  stripped={stripped}
                  customProps={customProps}
                  CustomTableBodyCell={CustomTableBodyCell}
                  CustomTableBodyRow={CustomTableBodyRow}
                  CustomTableHeaderCell={CustomTableHeaderCell}
                  CustomTableHeaderRow={CustomTableHeaderRow}
                  customDataTypes={customDataTypes}
                />
              </SnackbarProvider>
            </Provider>
          )}
        {options.data && !options.keyColumn && (
          <div id="no-keyColumn">
            @o2xp/react-datatable : You forgot to give keyColumn..
          </div>
        )}
        {(!options.data ||
          !options.data.columns ||
          options.data.columns.length === 0) &&
          options.keyColumn && (
            <div id="no-data">
              @o2xp/react-datatable : You forgot to give data..
            </div>
          )}
        {!options.data && !options.keyColumn && (
          <div id="no-data-and-no-keyColumn">
            @o2xp/react-datatable : You forgot to give data and keyColumn..
          </div>
        )}
      </Fragment>
    );
  }
}
 
export { Datatable };