Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/config/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"IS_LOCAL": false,
"IS_LOCAL": true,
"IS_PROD": false,
"IS_CANARY": false,
"BUILD_VERSION": "4.16.22"
Expand Down
36 changes: 36 additions & 0 deletions app/containers/MassEnergizeSuperAdmin/ME Tools/table /METable.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { connect } from "react-redux";
import { bindActionCreators } from "redux";
import { reduxLoadTableFilters } from "../../../../redux/redux-actions/adminActions";
import { parseJSON } from "../../../../utils/common";
import { Button } from "@mui/material";
import { CloudDownload, Comment } from "@mui/icons-material";

export const FILTER_OBJ_KEY = "MAIN_FILTER_OBJECT";
export const FILTERS = "_FILTERS";
Expand Down Expand Up @@ -240,6 +242,37 @@ function METable(props) {
savePageProperties(pageTableProperties.current); // then save these new changes to localStorage
};

const customToolbar = () => {
return (
<CloudDownload onClick={() => onDownload()} style={{ cursor: "pointer" , color:"grey"}} />

);
};

const onDownload = () => {
/**
PLAN
- get active columns
- check if there are filters applied
- check for search text.
- send all these to the backend.
- generate a csv file and download it.
*/
const path = window.location.pathname;
console.log("path", path);
const searchText = pageTableProperties.current.search;
const activeFilters = filterObject.current;

const map = Object.values(activeFilters).map((value) => ({ name: value.name.toLowerCase(), list: value.list }))
const payload = {
filters: map,
search: searchText,
}

console.log("payload", payload);

};

var { search, rowsPerPage } = getProperties();
const options = {
onFilterChange,
Expand All @@ -251,6 +284,9 @@ function METable(props) {
onChangeRowsPerPage: whenRowsPerPageChanges,
rowsPerPage: rowsPerPage || tableProps.options.rowsPerPage,
onColumnSortChange: whenAdminSortsAColumn,
onDownload: onDownload,
download: false,
customToolbar: customToolbar,
};

return (
Expand Down