master
mahdi andalib 3 years ago
parent 7745963b25
commit d37848f186
  1. 59
      src/components/ReactTable4/BasicTable.js
  2. 3
      src/components/ReactTable4/Settings.js
  3. 31
      src/components/ReactTable4/ShowMoreRows.js
  4. 2
      src/components/ReactTable4/ToggleColumns.js
  5. 16
      src/components/ReactTable4/columns.js

@ -12,6 +12,7 @@ import { ToggleColumns } from "./ToggleColumns";
import { COLUMNS } from "./COLUMNS"; import { COLUMNS } from "./COLUMNS";
import { Pagination } from "./Pagination"; import { Pagination } from "./Pagination";
import { GoToPage } from "./GoToPage"; import { GoToPage } from "./GoToPage";
import ShowMoreRows from "./ShowMoreRows";
import { Settings } from "./Settings"; import { Settings } from "./Settings";
import { Checkbox } from "./Checkbox"; import { Checkbox } from "./Checkbox";
@ -115,11 +116,6 @@ const BasicTable = ({
return ( return (
<> <>
{/* toggle columns */}
{/* <ToggleColumns
allColumns={allColumns}
getToggleHideAllColumnsProps={getToggleHideAllColumnsProps}
/> */}
<div className="flex flex-row items-center justify-between"> <div className="flex flex-row items-center justify-between">
{/* right box */} {/* right box */}
<div className="flex-1"> <div className="flex-1">
@ -179,7 +175,7 @@ const BasicTable = ({
<> <>
<table <table
{...getTableProps()} {...getTableProps()}
className="min-w-full divide-y divide-gray-200" className="min-w-full divide-y divide-gray-200 mb-5"
> >
<thead className="" style={{ backgroundColor: "#F3F8FF" }}> <thead className="" style={{ backgroundColor: "#F3F8FF" }}>
{headerGroups.map((headerGroup, index) => ( {headerGroups.map((headerGroup, index) => (
@ -288,50 +284,13 @@ const BasicTable = ({
))} ))}
</tfoot> </tfoot>
</table> </table>
<div className="mt-3 "> {/* bottom table */}
<span className="text-sm ml-4"> <GoToPage
صفحه{" "} pageIndex={pageIndex}
<strong className="text-indigo-500"> gotoPage={gotoPage}
<input pageOptions={pageOptions}
className="ml-1 text-xs p-1 rounded border-blue-400" />
type="number" <ShowMoreRows pageSize={pageSize} setPageSize={setPageSize} />
defaultValue={pageIndex + 1}
onChange={(e) => {
const pageNumber = e.target.value
? Number(e.target.value) - 1
: 0;
gotoPage(pageNumber);
}}
style={{ width: "50px" }}
/>{" "}
از {pageOptions.length}
</strong>
{""}
</span>
<select
className="text-white text-sm rounded cursor-pointer"
style={{
backgroundColor: "#65A9FF",
borderColor: "#65A9FF",
}}
value={pageSize}
onChange={(e) => setPageSize(Number(e.target.value))}
>
{[7, 10, 25, 50].map((pageSize) => (
<option
key={pageSize}
value={pageSize}
className=" text-sm"
style={{
direction: "ltr",
textAlign: "right",
}}
>
نمایش {pageSize}
</option>
))}
</select>
</div>
</> </>
) : ( ) : (
<EditRow <EditRow

@ -24,10 +24,9 @@ export const Settings = ({ allColumns, getToggleHideAllColumnsProps }) => {
onClick={() => setOpenModal(false)} onClick={() => setOpenModal(false)}
> >
<div <div
className="absolute bg-white w-8/12 p-4 rounded" className="absolute bg-white w-6/12 p-4 rounded"
style={{ top: "10%" }} style={{ top: "10%" }}
onClick={(e) => e.stopPropagation()} onClick={(e) => e.stopPropagation()}
onClick={() => setOpenModal(false)}
> >
<ToggleColumns <ToggleColumns
allColumns={allColumns} allColumns={allColumns}

@ -0,0 +1,31 @@
import React from "react";
const ShowMoreRows = ({ pageSize, setPageSize }) => {
return (
<select
className="text-white text-sm rounded cursor-pointer mr-2"
style={{
backgroundColor: "#65A9FF",
borderColor: "#65A9FF",
}}
value={pageSize}
onChange={(e) => setPageSize(Number(e.target.value))}
>
{[7, 10, 25, 50].map((pageSize) => (
<option
key={pageSize}
value={pageSize}
className=" text-xs"
style={{
direction: "ltr",
textAlign: "right",
}}
>
نمایش {pageSize}
</option>
))}
</select>
);
};
export default ShowMoreRows;

@ -25,7 +25,7 @@ export const ToggleColumns = ({ allColumns, getToggleHideAllColumnsProps }) => {
className="ml-2 " className="ml-2 "
{...column.getToggleHiddenProps()} {...column.getToggleHiddenProps()}
/> />
{column.Header} {column.Footer}
</label> </label>
</div> </div>
))} ))}

@ -11,13 +11,13 @@ import { SliderColumnFilter } from "./SliderColumnFilter.js";
export const COLUMNS = ({ setFiltering, filtering, addTab }) => [ export const COLUMNS = ({ setFiltering, filtering, addTab }) => [
{ {
Header: "نام و نام خانوادگی", Header: "نام و نام خانوادگی",
Footer: "نام و نام خانوادگی", Footer: "ستون نام و نام خانوادگی",
accessor: "name", accessor: "name",
disableSortBy: true, disableSortBy: true,
}, },
{ {
Header: "تاریخ سفارش", Header: "تاریخ سفارش",
Footer: "تاریخ سفارش", Footer: "ستون تاریخ سفارش",
accessor: "order_date", accessor: "order_date",
Filter: SliderColumnFilter, Filter: SliderColumnFilter,
Cell: ({ value }) => { Cell: ({ value }) => {
@ -26,37 +26,37 @@ export const COLUMNS = ({ setFiltering, filtering, addTab }) => [
}, },
{ {
Header: "مبلغ سفارش", Header: "مبلغ سفارش",
Footer: "مبلغ سفارش", Footer: "ستون مبلغ سفارش",
accessor: "order_price", accessor: "order_price",
Filter: SliderColumnFilter, Filter: SliderColumnFilter,
}, },
{ {
Header: "شماره سفارش", Header: "شماره سفارش",
Footer: "شماره سفارش", Footer: "ستون شماره سفارش",
accessor: "order_number", accessor: "order_number",
}, },
{ {
Header: "شغل کاربر", Header: "شغل کاربر",
Footer: "شغل کاربر", Footer: "ستون شغل کاربر",
accessor: "user_job", accessor: "user_job",
}, },
{ {
Header: "وضعیت سفارش", Header: "وضعیت سفارش",
Footer: "وضعیت سفارش", Footer: "ستون وضعیت سفارش",
accessor: "order_status", accessor: "order_status",
Cell: OrderStatus, Cell: OrderStatus,
Filter: SelectColumnFilter2, Filter: SelectColumnFilter2,
}, },
{ {
Header: "سطح اهمیت", Header: "سطح اهمیت",
Footer: "سطح اهمیت", Footer: تون سطح اهمیت",
accessor: "order_level", accessor: "order_level",
Cell: OrderLevel, Cell: OrderLevel,
Filter: SelectColumnFilter, Filter: SelectColumnFilter,
}, },
{ {
Header: () => EditButtons({ setFiltering, filtering, addTab }), Header: () => EditButtons({ setFiltering, filtering, addTab }),
Footer: "ویرایش", Footer: "ستون ویرایش",
accessor: "edit", accessor: "edit",
Cell: ({ row }) => Buttons({ row, addTab }), Cell: ({ row }) => Buttons({ row, addTab }),
disableSortBy: true, disableSortBy: true,

Loading…
Cancel
Save