diff --git a/frontend/package.json b/frontend/package.json index 265ef83..d7d31a3 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -27,6 +27,7 @@ "qrcode.react": "^1.0.0", "react": "^17.0.2", "react-color": "^2.19.3", + "react-csv": "^2.2.2", "react-dom": "^17.0.2", "react-modal-image": "^2.5.0", "react-router-dom": "^5.2.0", diff --git a/frontend/src/components/Report/DatePicker/index.js b/frontend/src/components/Report/DatePicker/index.js index 5031bd9..becec0c 100644 --- a/frontend/src/components/Report/DatePicker/index.js +++ b/frontend/src/components/Report/DatePicker/index.js @@ -12,6 +12,8 @@ import { MuiPickersUtilsProvider, } from '@material-ui/pickers'; +import ptBrLocale from "date-fns/locale/pt-BR"; + function formatDateDatePicker(data){ return String(new Date(data).getFullYear())+'-'+ @@ -27,7 +29,7 @@ function ResponsiveDatePickers(props) { return ( - + { + + const [header, setHeader] = useState([]) + const [dataRow, setDataRow] = useState([]) + + const csvLink = useRef() + + let headerFormat = JSON.parse(JSON.stringify(props.columns).split('"field":').join('"key":')) + headerFormat = JSON.parse(JSON.stringify(headerFormat).split('"title":').join('"label":')) + + //const dataRows = props.data.map((row) => { return { ...row }}); + + // const dataRows = props.data.map((obj)=>{ + // return {'fromMe': obj.fromMe, 'body': obj.body.replace(/ /g,''), 'createdAt': obj.createdAt} + // }) + + //console.log('******************************* dataRows: ',dataRows) + + useEffect(()=>{ + setHeader(headerFormat) + setDataRow(props.data) + },[]) + + const getTransactionData = async () => { + + csvLink.current.link.click() + + } + + return ( +
+ + +
+ ); +} + +export default ExportCSV \ No newline at end of file diff --git a/frontend/src/components/Report/MTable/index.js b/frontend/src/components/Report/MTable/index.js index ed32cde..2e2ceb5 100644 --- a/frontend/src/components/Report/MTable/index.js +++ b/frontend/src/components/Report/MTable/index.js @@ -23,9 +23,11 @@ const MTable = (props) => { return (
{ @@ -34,8 +36,16 @@ const MTable = (props) => { console.log(selectedRow); console.log(selectedRow.messages); setSelectedRow(selectedRow.tableData.id) - - render() + + if(props.hasChild) { + render() + } + + console.log('props.hasChild: ', props.hasChild) //evt.stopPropagation() } @@ -46,6 +56,7 @@ const MTable = (props) => { selection: false, paging: false, padding: 'dense', + sorting: true ? props.hasChild: false, //loadingType: 'linear', searchFieldStyle: { width: 300, @@ -53,8 +64,7 @@ const MTable = (props) => { rowStyle: rowData => ({ fontSize: 12, - backgroundColor: - selectedRow === rowData.tableData.id ? '#ec5114' : '#FFF' + backgroundColor: selectedRow === rowData.tableData.id ? '#ec5114' : '#FFF' }) }} /> diff --git a/frontend/src/components/Report/Modal/index.js b/frontend/src/components/Report/Modal/index.js index 0099389..93ea492 100644 --- a/frontend/src/components/Report/Modal/index.js +++ b/frontend/src/components/Report/Modal/index.js @@ -3,19 +3,27 @@ import Button from '@mui/material/Button'; import Dialog from '@mui/material/Dialog'; import DialogActions from '@mui/material/DialogActions'; +import DialogContent from '@mui/material/DialogContent'; +import DialogContentText from '@mui/material/DialogContentText'; +import DialogTitle from '@mui/material/DialogTitle'; + import DataGridTable from '../Table'; import MTable from "../MTable"; +import ExportCSV from '../ExportCSV' +import { margin } from '@mui/system'; + let columns = [ { title: 'Atendente/Cliente', field: 'fromMe', + }, { title: 'Mensagem', field: 'body', - cellStyle: {whiteSpace: 'nowrap'}, + //cellStyle: {whiteSpace: 'nowrap'}, }, { title: 'Criado', field: 'createdAt' } @@ -61,7 +69,9 @@ const Modal = (props) => { }, [open]); return ( -
+ + +
{ scroll={scroll} aria-labelledby="scroll-dialog-title" aria-describedby="scroll-dialog-description" - > + > - + {props.modal_header} + + + + + + - - + + +
+ +
+
-
+
+ ); } diff --git a/frontend/src/components/Report/SelectField/index.js b/frontend/src/components/Report/SelectField/index.js index ce5bd3a..92c3a28 100644 --- a/frontend/src/components/Report/SelectField/index.js +++ b/frontend/src/components/Report/SelectField/index.js @@ -14,26 +14,34 @@ const SelectTextFields = (props) => { const handleChange = (event) => { setCurrency(event.target.value); }; + + return ( - - + {/* */} @@ -296,7 +296,12 @@ console.log('XXXXXXXXX: ', query) display: 'grid', }}> - + + +