From 6df048c3b32b7bc995b86127c426a0996294651e Mon Sep 17 00:00:00 2001 From: mahdi andalib Date: Tue, 8 Mar 2022 19:14:23 +0330 Subject: [PATCH] update --- src/App.js | 2 +- src/components/ReactTable5/BasicTable.js | 70 +----------------------- src/components/ReactTable5/COLUMNS.js | 8 +-- src/components/ReactTable5/Checkbox.js | 33 ++++++----- 4 files changed, 23 insertions(+), 90 deletions(-) diff --git a/src/App.js b/src/App.js index def34a0..4f0ca6c 100644 --- a/src/App.js +++ b/src/App.js @@ -101,7 +101,7 @@ function App() { {/* */} {/* */} {/* */} - + {/* */} {/* */} {/* diff --git a/src/components/ReactTable5/BasicTable.js b/src/components/ReactTable5/BasicTable.js index 8fafa3d..6f51252 100644 --- a/src/components/ReactTable5/BasicTable.js +++ b/src/components/ReactTable5/BasicTable.js @@ -34,10 +34,6 @@ import { } from "react-table"; import ButtonNewDesign from "../ButtonNewDesign"; -export function CheckBox({}) { - return ; -} - export const SelectColumnFilter = ({ column: { filterValue, setFilter, preFilteredRows, id, render }, }) => { @@ -109,33 +105,6 @@ const BasicTable = ({ }) => { const data = useMemo(() => MOCK_DATA2, []); // console.log(data); - // console.log(MOCK_DATA2); - - const EditableCell = ({ - value: initialValue, - row: { index }, - column: { id }, - updateMyData, // This is a custom function that we supplied to our table instance - }) => { - // We need to keep and update the state of the cell normally - const [value, setValue] = React.useState(initialValue); - - const onChange = (e) => { - setValue(e.target.value); - }; - - // We'll only update the external data when the input is blurred - const onBlur = () => { - updateMyData(index, id, value); - }; - - // If the initialValue is changed external, sync it up with our state - React.useEffect(() => { - setValue(initialValue); - }, [initialValue]); - - return ; - }; const [filtering, setFiltering] = useState(false); @@ -187,23 +156,6 @@ const BasicTable = ({ useExpanded, usePagination, useRowSelect - // (hooks) => { - // hooks.visibleColumns.push((columns) => { - // return [ - // { - // id: "selection", - // className: "w-7", - // Header: ({ getToggleAllRowsSelectedProps }) => ( - // - // ), - // Cell: ({ row }) => ( - // - // ), - // }, - // ...columns, - // ]; - // }); - // } ); const { globalFilter, pageIndex, pageSize } = state; @@ -212,6 +164,7 @@ const BasicTable = ({ return (
+ {/* {filtering &&
TANNAZ
} */} {/*
{listView.map((list, i) => ( - {activeList === true && ( + {activeList === false && ( // table )} - {/* filter row */} - {filtering && ( - - {headerGroups.map((headerGroup, index) => ( - - {headerGroup.headers.map((column) => ( - - ))} - - ))} - - )} )} {/* GRID LIST */} - {activeList === false && ( + {activeList === true && (
[ { Header: "چک باکس", - accessor: CheckBox, + accessor: () => Checkbox({ setFiltering, filtering, addTab }), className: "w-7", }, { diff --git a/src/components/ReactTable5/Checkbox.js b/src/components/ReactTable5/Checkbox.js index 4915153..21f9884 100644 --- a/src/components/ReactTable5/Checkbox.js +++ b/src/components/ReactTable5/Checkbox.js @@ -1,21 +1,20 @@ -import React from "react"; +import React, { useState } from "react"; -export const Checkbox = React.forwardRef(({ indeterminate, ...rest }, ref) => { - const defaultRef = React.useRef(); - const resolvedRef = ref || defaultRef; - - React.useEffect(() => { - resolvedRef.current.indeterminate = indeterminate; - }, [resolvedRef, indeterminate]); +export function Checkbox({ setFiltering, filtering, addTab }) { + // const [selectedFilterRow, setSelectedFilterRow] = useState(filtering); return ( - <> - - + { + // console.log("mahdi"); + // setFiltering(!selectedFilterRow); + // setSelectedFilterRow(!selectedFilterRow); + // }} + type="checkbox" + // className={`cursor-pointer ${selectedFilterRow ? "p-72" : "p-5"}`} + className={`cursor-pointer`} + /> ); -}); +} + +Checkbox.defaultProps = {};
- {column.canFilter ? column.render("Filter") : null} -