master
mahdi andalib 3 years ago
parent 2d8ee5994b
commit 5abafc2bfd
  1. 61
      src/components/ReactTable5/BasicTable.js
  2. 7
      src/components/ReactTable5/COLUMNS.js

@ -33,6 +33,10 @@ import {
useExpanded, useExpanded,
} from "react-table"; } from "react-table";
export function CheckBox({}) {
return <input type="checkbox" />;
}
const BasicTable = ({ const BasicTable = ({
settingsIcon, settingsIcon,
thead, thead,
@ -129,24 +133,24 @@ const BasicTable = ({
useSortBy, useSortBy,
useExpanded, useExpanded,
usePagination, usePagination,
useRowSelect, useRowSelect
(hooks) => { // (hooks) => {
hooks.visibleColumns.push((columns) => { // hooks.visibleColumns.push((columns) => {
return [ // return [
{ // {
id: "selection", // id: "selection",
className: "w-7", // className: "w-7",
Header: ({ getToggleAllRowsSelectedProps }) => ( // Header: ({ getToggleAllRowsSelectedProps }) => (
<Checkbox {...getToggleAllRowsSelectedProps()} /> // <Checkbox {...getToggleAllRowsSelectedProps()} />
), // ),
Cell: ({ row }) => ( // Cell: ({ row }) => (
<Checkbox {...row.getToggleRowSelectedProps()} /> // <Checkbox {...row.getToggleRowSelectedProps()} />
), // ),
}, // },
...columns, // ...columns,
]; // ];
}); // });
} // }
); );
const { globalFilter, pageIndex, pageSize } = state; const { globalFilter, pageIndex, pageSize } = state;
@ -154,7 +158,7 @@ const BasicTable = ({
const [activeList, setActiveList] = useState(false); const [activeList, setActiveList] = useState(false);
return ( return (
<> <div className="bg-white p-4 rounded">
{/* <div className="flex flex-row items-center"> {/* <div className="flex flex-row items-center">
{listView.map((list, i) => ( {listView.map((list, i) => (
<img <img
@ -165,16 +169,21 @@ const BasicTable = ({
/> />
))} ))}
</div>{" "} */} </div>{" "} */}
<div>
{/* select View list */}
<div className="flex flex-row items-center gap-x-2">
<img <img
src={list} src={list}
className="cursor-pointer my-5" className="cursor-pointer"
onClick={() => setActiveList(false)} onClick={() => setActiveList(false)}
/> />
<img <img
src={grid} src={grid}
className="cursor-pointer my-5" className="cursor-pointer"
onClick={() => setActiveList(true)} onClick={() => setActiveList(true)}
/> />
</div>
</div>
<div className="flex flex-row items-center justify-between"> <div className="flex flex-row items-center justify-between">
{/* right box */} {/* right box */}
<di className="bg-red-400"> <di className="bg-red-400">
@ -244,6 +253,7 @@ const BasicTable = ({
{activeTab == 0 ? ( {activeTab == 0 ? (
<> <>
{activeList === false && ( {activeList === false && (
// table
<table <table
{...getTableProps()} {...getTableProps()}
className="min-w-full divide-y divide-gray-200 mb-5" className="min-w-full divide-y divide-gray-200 mb-5"
@ -364,7 +374,7 @@ const BasicTable = ({
<div <div
className="flex flex-col px-4 py-5 rounded-md" className="flex flex-col px-4 py-5 rounded-md"
key={index} key={index}
style={{ backgroundColor: "#fff" }} style={{ backgroundColor: "#F3F3F3" }}
> >
<img src={image1} className="w-52" /> <img src={image1} className="w-52" />
<p className="text-sm my-3">{item.fileName}</p> <p className="text-sm my-3">{item.fileName}</p>
@ -396,7 +406,7 @@ const BasicTable = ({
columns={defaultColumn} columns={defaultColumn}
/> />
)} )}
</> </div>
); );
}; };
@ -408,4 +418,9 @@ BasicTable.defaultProps = {
thead: false, thead: false,
goToPage: false, goToPage: false,
showMore: false, showMore: false,
// listView: [
// { icon: grid, click: () => setActiveList(false) },
// { icon: list, click: () => setActiveList(true) },
// ],
}; };

@ -1,5 +1,7 @@
import { format } from "date-fns"; import { format } from "date-fns";
import BasicTable, { CheckBox } from "../ReactTable5/BasicTable";
import { OrderStatus } from "./OrderStatus"; import { OrderStatus } from "./OrderStatus";
import { OrderLevel } from "./OrderLevel"; import { OrderLevel } from "./OrderLevel";
import { Buttons } from "./Buttons"; import { Buttons } from "./Buttons";
@ -9,6 +11,11 @@ import { SelectColumnFilter2 } from "./SelectColumnFilter2.js";
import { SliderColumnFilter } from "./SliderColumnFilter.js"; import { SliderColumnFilter } from "./SliderColumnFilter.js";
export const COLUMNS = ({ setFiltering, filtering, addTab }) => [ export const COLUMNS = ({ setFiltering, filtering, addTab }) => [
{
Header: "چک باکس",
accessor: CheckBox,
className: "bg-red-100 w-7",
},
{ {
Header: "ایکن فایل", Header: "ایکن فایل",
accessor: "filePic", accessor: "filePic",

Loading…
Cancel
Save