added and updated

master
mahdi andalib 3 years ago
parent a2a7ffb1ed
commit f2516b9fb8
  1. 2
      src/components/ReactTable4/BasicTable.js
  2. 27
      src/components/ReactTable4/ColumnFilter.js
  3. 74
      src/components/ReactTable4/MOCK_DATA.json
  4. 13
      src/components/ReactTable4/columns.js

@ -11,7 +11,6 @@ import {
useRowSelect, useRowSelect,
useColumnOrder, useColumnOrder,
useExpanded, useExpanded,
useResizeColumns,
} from "react-table"; } from "react-table";
import { COLUMNS } from "./columns"; import { COLUMNS } from "./columns";
@ -239,6 +238,7 @@ const BasicTable = ({ settingsIcon }) => {
: " 🔼" : " 🔼"
: ""} : ""}
</span> </span>
{/* <div>{column.canFilter ? column.render("Filter") : null}</div> */}
</th> </th>
))} ))}
</tr> </tr>

@ -1,19 +1,14 @@
import React from 'react'; import React from "react";
export const ColumnFilter = ({ column }) => { export const ColumnFilter = ({ column }) => {
const { filterValue, setFilter } = column;
const { filterValue, setFilter } = column
return (
return ( <span>
<input
<span> value={filterValue || ""}
onChange={(e) => setFilter(e.target.value)}
Search: {''} />
</span>
<input value={filterValue || '' } );
onChange={(e) => setFilter(e.target.value)} />
</span>
);
}; };

@ -1,6 +1,6 @@
[ [
{ {
"name": "mahdi", "name": "سامسونگ موبایل مدل 1",
"order-date": "1399/09/27", "order-date": "1399/09/27",
"order-price": 25, "order-price": 25,
"order-number": "09120023100", "order-number": "09120023100",
@ -10,73 +10,43 @@
"history": "مهدی" "history": "مهدی"
}, },
{ {
"name": "مهدی", "name": "ایفون جدید 13",
"order-date": "1399/09/27", "order-date": "1305/09/27",
"order-price": 27, "order-price": 22,
"order-number": "09120023100",
"user-job": "مهندس ساختمان",
"order-status": 1,
"order-level": 1,
"history": "mahdimahdi"
},
{
"name": "mahdi",
"order-date": "1399/09/27",
"order-price": 25,
"order-number": "09120023100", "order-number": "09120023100",
"user-job": "مهندس ساختمان", "user-job": "مهندس ساختمان",
"order-status": 1, "order-status": 2,
"order-level": 1, "order-level": 2,
"history": "مهدی" "history": "مهدی"
}, },
{ {
"name": هدی", "name": "مک بوک پرو",
"order-date": "1399/09/27", "order-date": "1399/09/27",
"order-price": 27, "order-price": 75,
"order-number": "09120023100",
"user-job": "مهندس ساختمان",
"order-status": 1,
"order-level": 1,
"history": "mahdimahdi"
},
{
"name": "mahdi",
"order-date": "1399/09/27",
"order-price": 25,
"order-number": "09120023100", "order-number": "09120023100",
"user-job": "مهندس ساختمان", "user-job": "مهندس ساختمان",
"order-status": 1, "order-status": 3,
"order-level": 1, "order-level": 3,
"history": "مهدی" "history": "مهدی"
}, },
{ {
"name": "مهدی", "name": "تبلت",
"order-date": "1399/09/27", "order-date": "1305/09/27",
"order-price": 27, "order-price": 44,
"order-number": "09120023100",
"user-job": "مهندس ساختمان",
"order-status": 1,
"order-level": 1,
"history": "mahdimahdi"
},
{
"name": "mahdi",
"order-date": "1399/09/27",
"order-price": 25,
"order-number": "09120023100", "order-number": "09120023100",
"user-job": "مهندس ساختمان", "user-job": "مهندس ساختمان",
"order-status": 1, "order-status": 4,
"order-level": 1, "order-level": 4,
"history": "مهدی" "history": "مهدی"
}, },
{ {
"name": "مهدی", "name": "کتاب جدید",
"order-date": "1399/09/27", "order-date": "1305/09/27",
"order-price": 27, "order-price": 13,
"order-number": "09120023100", "order-number": "09120023100",
"user-job": "مهندس ساختمان", "user-job": "طناز",
"order-status": 1, "order-status": 5,
"order-level": 1, "order-level": 5,
"history": "mahdimahdi" "history": "مهدی"
} }
] ]

@ -2,7 +2,7 @@ import { format } from "date-fns";
import Table, { SelectColumnFilter } from "./BasicTable"; // new import Table, { SelectColumnFilter } from "./BasicTable"; // new
import { ColumnFilter } from "./ColumnFilter"; import { ColumnFilter } from "./ColumnFilter.js";
import { OrderStatus } from "./OrderStatus"; import { OrderStatus } from "./OrderStatus";
import { OrderLevel } from "./OrderLevel"; import { OrderLevel } from "./OrderLevel";
@ -15,11 +15,13 @@ export const COLUMNS = [
Footer: "نام و نام خانوادگی", Footer: "نام و نام خانوادگی",
accessor: "name", accessor: "name",
disableSortBy: true, disableSortBy: true,
Filter: false,
}, },
{ {
Header: "تاریخ سفارش", Header: "تاریخ سفارش",
Footer: "تاریخ سفارش", Footer: "تاریخ سفارش",
accessor: "order-date", accessor: "order-date",
Filter: false,
Cell: ({ value }) => { Cell: ({ value }) => {
return format(new Date(value), "dd/MM/yyyy"); return format(new Date(value), "dd/MM/yyyy");
}, },
@ -28,22 +30,25 @@ export const COLUMNS = [
Header: "مبلغ سفارش", Header: "مبلغ سفارش",
Footer: "مبلغ سفارش", Footer: "مبلغ سفارش",
accessor: "order-price", accessor: "order-price",
Filter: ColumnFilter, Filter: false,
}, },
{ {
Header: "شماره سفارش", Header: "شماره سفارش",
Footer: "شماره سفارش", Footer: "شماره سفارش",
accessor: "order-number", accessor: "order-number",
Filter: false,
}, },
{ {
Header: "شغل کاربر", Header: "شغل کاربر",
Footer: "شغل کاربر", Footer: "شغل کاربر",
accessor: "user-job", accessor: "user-job",
Filter: false,
}, },
{ {
Header: "وضعیت سفارش", Header: "وضعیت سفارش",
Footer: "وضعیت سفارش", Footer: "وضعیت سفارش",
accessor: "order-status", accessor: "order-status",
Filter: false,
Cell: OrderStatus, Cell: OrderStatus,
}, },
{ {
@ -51,13 +56,13 @@ export const COLUMNS = [
Footer: "سطح اهمیت", Footer: "سطح اهمیت",
accessor: "order-level", accessor: "order-level",
Cell: OrderLevel, Cell: OrderLevel,
// Filter: SelectColumnFilter, Filter: SelectColumnFilter,
// new
}, },
{ {
Header: EditButtons, Header: EditButtons,
Footer: "ویرایش", Footer: "ویرایش",
accessor: "edit", accessor: "edit",
Filter: false,
Cell: Buttons, Cell: Buttons,
disableSortBy: true, disableSortBy: true,
}, },

Loading…
Cancel
Save