@ -0,0 +1,31 @@ |
||||
import arrowIcon from "./arrow-icon.svg"; |
||||
import more from "./more2.svg"; |
||||
import edit from "./edit.svg"; |
||||
|
||||
import { useState } from "react"; |
||||
|
||||
export function Buttons({ row }) { |
||||
const [activeDetails, setActiveDetails] = useState(null); |
||||
return ( |
||||
<div className="flex flex-row items-center justify-end"> |
||||
<button |
||||
className="flex flex-row items-center justify-around p-2 rounded border border-gray-300 mx-1" |
||||
onClick={() => setActiveDetails(!activeDetails)} |
||||
{...row.getToggleRowExpandedProps()} |
||||
> |
||||
جزیات |
||||
<img |
||||
src={arrowIcon} |
||||
alt="" |
||||
className={`w-3 cursor-pointer mr-2 ${ |
||||
activeDetails ? "rotate-60" : "rotate-90" |
||||
}`}
|
||||
/> |
||||
</button> |
||||
<div className="p-2 rounded border border-gray-300 cursor-pointer mx-1"> |
||||
<img src={edit} alt="" className="w-4" /> |
||||
</div> |
||||
<img src={more} alt="" className="w-5 cursor-pointer mx-1" /> |
||||
</div> |
||||
); |
||||
} |
@ -0,0 +1,16 @@ |
||||
import React 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]); |
||||
|
||||
return ( |
||||
<> |
||||
<input type="checkbox" ref={resolvedRef} {...rest} /> |
||||
</> |
||||
); |
||||
}); |
@ -0,0 +1,19 @@ |
||||
import React from 'react'; |
||||
|
||||
export const ColumnFilter = ({ column }) => { |
||||
|
||||
const { filterValue, setFilter } = column
|
||||
|
||||
return ( |
||||
|
||||
<span> |
||||
|
||||
Search: {''} |
||||
|
||||
<input value={filterValue || '' } |
||||
onChange={(e) => setFilter(e.target.value)} /> |
||||
|
||||
</span> |
||||
|
||||
); |
||||
}; |
@ -0,0 +1,126 @@ |
||||
import React, { useState } from "react"; |
||||
|
||||
import filter from "./filter.svg"; |
||||
import plus from "./plus.svg"; |
||||
import more from "./more2.svg"; |
||||
|
||||
export function EditButtons({ buttons }) { |
||||
const [selectedButton, setSelectedButton] = useState(null); |
||||
return ( |
||||
<div className="flex flex-row items-center justify-end"> |
||||
{buttons.map((button, index) => ( |
||||
<div> |
||||
<button |
||||
id="dropdownButton" |
||||
data-dropdown-toggle="dropdown" |
||||
type="button" |
||||
className={`flex flex-row items-center justify-around p-1 rounded-md bg-opacity-30 mx-1 ${ |
||||
button.border |
||||
} ${button.borderColor} ${ |
||||
selectedButton === button ? "border" : "border-0" |
||||
}`}
|
||||
key={index} |
||||
style={{ |
||||
backgroundColor: button.backgroundColor, |
||||
padding: button.padding, |
||||
}} |
||||
onClick={() => |
||||
setSelectedButton(selectedButton === button ? null : button) |
||||
} |
||||
> |
||||
<p className={` text-white`}>{button.title}</p> |
||||
<img |
||||
src={button.logo} |
||||
alt="" |
||||
className={`cursor-pointer ${button.width} ${button.height} ${ |
||||
button.title === null ? "mr-0" : "mx-2" |
||||
}`}
|
||||
/> |
||||
</button> |
||||
<div |
||||
id="dropdown" |
||||
className="hidden z-10 w-44 text-base list-none bg-red-600 rounded divide-y divide-gray-100 shadow dark:bg-gray-700" |
||||
> |
||||
{button.buttonSubItems === !null && |
||||
button.buttonSubItems.map((buttonSubItem, i) => ( |
||||
<p>{buttonSubItem.title}</p> |
||||
))} |
||||
|
||||
{/* <ul className="py-1" aria-labelledby="dropdownButton"> |
||||
{button.buttonSubItems === !null && |
||||
button.buttonSubItems.map((buttonSubItem, i) => ( |
||||
<li className="bg-red-400">{buttonSubItem.title}</li> |
||||
))} |
||||
</ul> */} |
||||
</div> |
||||
</div> |
||||
))} |
||||
</div> |
||||
); |
||||
} |
||||
|
||||
EditButtons.defaultProps = { |
||||
buttons: [ |
||||
{ |
||||
logo: plus, |
||||
width: "w-3", |
||||
height: "h-3", |
||||
title: "ثبت جدید", |
||||
backgroundColor: "#65A9FF", |
||||
border: "border-b-4", |
||||
borderColor: "#3686EC", |
||||
padding: "4px 7px", |
||||
components: "d", |
||||
buttonSubItems: [], |
||||
}, |
||||
{ |
||||
logo: filter, |
||||
width: "w-5", |
||||
height: "h-5", |
||||
title: null, |
||||
backgroundColor: "#F3F8FF", |
||||
border: null, |
||||
borderColor: null, |
||||
components: "a", |
||||
buttonSubItems: [], |
||||
}, |
||||
{ |
||||
logo: more, |
||||
width: "w-5", |
||||
height: "h-5", |
||||
title: null, |
||||
textColor: null, |
||||
backgroundColor: "#F3F8FF", |
||||
border: null, |
||||
borderColor: null, |
||||
components: "a", |
||||
buttonSubItems: [ |
||||
{ |
||||
title: "دراپ داون 1", |
||||
}, |
||||
{ |
||||
title: "دراپ داون 2", |
||||
}, |
||||
{ |
||||
title: "دراپ داون 3", |
||||
}, |
||||
{ |
||||
title: "دراپ داون 4", |
||||
}, |
||||
{ |
||||
title: "دراپ داون 5", |
||||
}, |
||||
], |
||||
}, |
||||
], |
||||
}; |
||||
|
||||
// {
|
||||
// logo: settings,
|
||||
// width: "w-5",
|
||||
// height: "h-5",
|
||||
// title: null,
|
||||
// textColor: null,
|
||||
// backgroundColor: "#F3F8FF",
|
||||
// components: "b",
|
||||
// },
|
@ -0,0 +1,27 @@ |
||||
import React, { useState } from "react"; |
||||
import { useAsyncDebounce } from "react-table"; |
||||
|
||||
import search from "./search-normal.svg"; |
||||
|
||||
export const GlobalFilter = ({ filter, setFilter }) => { |
||||
const [openModal, setOpenModal] = useState(true); |
||||
|
||||
const [value, setValue] = useState(filter); |
||||
|
||||
const onChange = useAsyncDebounce((value) => { |
||||
setFilter(value || undefined); |
||||
}, 400); |
||||
|
||||
return ( |
||||
<input |
||||
value={value || ""} |
||||
onChange={(e) => { |
||||
setValue(e.target.value); |
||||
onChange(e.target.value); |
||||
}} |
||||
type="text" |
||||
placeholder="نام کالا را جستجو کنید..." |
||||
className="text-xs rounded-sm pr-4 pl-10 py-2 w-full border border-gray-400 font-light text-lightGrayTextColor placeholder-gray-400 focus:outline-none" |
||||
/> |
||||
); |
||||
}; |
@ -0,0 +1,182 @@ |
||||
[ |
||||
{ |
||||
"name": "مایکروویر سامسونگ مدل 1", |
||||
"order-date": "1399/09/27", |
||||
"order-price": 27, |
||||
"order-number": "09120023100", |
||||
"user-job": "مهندس ساختمان", |
||||
"order-status": 1, |
||||
"order-level": 1 |
||||
}, |
||||
{ |
||||
"name": "مایکروویر سامسونگ مدل 2", |
||||
"order-date": "1399/09/25", |
||||
"order-price": 26, |
||||
"order-number": "09120023100", |
||||
"user-job": "مهندس ساختمان", |
||||
"order-status": 2, |
||||
"order-level": 2 |
||||
}, |
||||
{ |
||||
"name": "مایکروویر سامسونگ مدل 3", |
||||
"order-date": "1399/09/22", |
||||
"order-price": 44, |
||||
"order-number": "09120023100", |
||||
"user-job": "مهندس ساختمان", |
||||
"order-status": 3, |
||||
"order-level": 3 |
||||
}, |
||||
{ |
||||
"name": "لپ تاپ مک بوک اپل", |
||||
"order-date": "1410/09/27", |
||||
"order-price": 73, |
||||
"order-number": "09120023100", |
||||
"user-job": "مهندس ساختمان", |
||||
"order-status": 4, |
||||
"order-level": 4 |
||||
}, |
||||
{ |
||||
"name": "تبلت اپل", |
||||
"order-date": "1375/09/25", |
||||
"order-price": 96, |
||||
"order-number": "09120023100", |
||||
"user-job": "مهندس ساختمان", |
||||
"order-status": 5, |
||||
"order-level": 5 |
||||
}, |
||||
{ |
||||
"name": "مایکروویر سامسونگ مدل 1", |
||||
"order-date": "1399/09/27", |
||||
"order-price": 27, |
||||
"order-number": "09120023100", |
||||
"user-job": "مهندس ساختمان", |
||||
"order-status": 1, |
||||
"order-level": 1 |
||||
}, |
||||
{ |
||||
"name": "مایکروویر سامسونگ مدل 2", |
||||
"order-date": "1399/09/25", |
||||
"order-price": 26, |
||||
"order-number": "09120023100", |
||||
"user-job": "مهندس ساختمان", |
||||
"order-status": 2, |
||||
"order-level": 2 |
||||
}, |
||||
{ |
||||
"name": "مایکروویر سامسونگ مدل 3", |
||||
"order-date": "1399/09/22", |
||||
"order-price": 44, |
||||
"order-number": "09120023100", |
||||
"user-job": "مهندس ساختمان", |
||||
"order-status": 3, |
||||
"order-level": 3 |
||||
}, |
||||
{ |
||||
"name": "لپ تاپ مک بوک اپل", |
||||
"order-date": "1410/09/27", |
||||
"order-price": 73, |
||||
"order-number": "09120023100", |
||||
"user-job": "مهندس ساختمان", |
||||
"order-status": 4, |
||||
"order-level": 4 |
||||
}, |
||||
{ |
||||
"name": "تبلت اپل", |
||||
"order-date": "1375/09/25", |
||||
"order-price": 96, |
||||
"order-number": "09120023100", |
||||
"user-job": "مهندس ساختمان", |
||||
"order-status": 5, |
||||
"order-level": 5 |
||||
}, |
||||
{ |
||||
"name": "مایکروویر سامسونگ مدل 1", |
||||
"order-date": "1399/09/27", |
||||
"order-price": 27, |
||||
"order-number": "09120023100", |
||||
"user-job": "مهندس ساختمان", |
||||
"order-status": 1, |
||||
"order-level": 1 |
||||
}, |
||||
{ |
||||
"name": "مایکروویر سامسونگ مدل 2", |
||||
"order-date": "1399/09/25", |
||||
"order-price": 26, |
||||
"order-number": "09120023100", |
||||
"user-job": "مهندس ساختمان", |
||||
"order-status": 2, |
||||
"order-level": 2 |
||||
}, |
||||
{ |
||||
"name": "مایکروویر سامسونگ مدل 3", |
||||
"order-date": "1399/09/22", |
||||
"order-price": 44, |
||||
"order-number": "09120023100", |
||||
"user-job": "مهندس ساختمان", |
||||
"order-status": 3, |
||||
"order-level": 3 |
||||
}, |
||||
{ |
||||
"name": "لپ تاپ مک بوک اپل", |
||||
"order-date": "1410/09/27", |
||||
"order-price": 73, |
||||
"order-number": "09120023100", |
||||
"user-job": "مهندس ساختمان", |
||||
"order-status": 4, |
||||
"order-level": 4 |
||||
}, |
||||
{ |
||||
"name": "تبلت اپل", |
||||
"order-date": "1375/09/25", |
||||
"order-price": 96, |
||||
"order-number": "09120023100", |
||||
"user-job": "مهندس ساختمان", |
||||
"order-status": 5, |
||||
"order-level": 5 |
||||
}, |
||||
{ |
||||
"name": "مایکروویر سامسونگ مدل 1", |
||||
"order-date": "1399/09/27", |
||||
"order-price": 27, |
||||
"order-number": "09120023100", |
||||
"user-job": "مهندس ساختمان", |
||||
"order-status": 1, |
||||
"order-level": 1 |
||||
}, |
||||
{ |
||||
"name": "مایکروویر سامسونگ مدل 2", |
||||
"order-date": "1399/09/25", |
||||
"order-price": 26, |
||||
"order-number": "09120023100", |
||||
"user-job": "مهندس ساختمان", |
||||
"order-status": 2, |
||||
"order-level": 2 |
||||
}, |
||||
{ |
||||
"name": "مایکروویر سامسونگ مدل 3", |
||||
"order-date": "1399/09/22", |
||||
"order-price": 44, |
||||
"order-number": "09120023100", |
||||
"user-job": "مهندس ساختمان", |
||||
"order-status": 3, |
||||
"order-level": 3 |
||||
}, |
||||
{ |
||||
"name": "لپ تاپ مک بوک اپل", |
||||
"order-date": "1410/09/27", |
||||
"order-price": 73, |
||||
"order-number": "09120023100", |
||||
"user-job": "مهندس ساختمان", |
||||
"order-status": 4, |
||||
"order-level": 4 |
||||
}, |
||||
{ |
||||
"name": "تبلت اپل", |
||||
"order-date": "1375/09/25", |
||||
"order-price": 96, |
||||
"order-number": "09120023100", |
||||
"user-job": "مهندس ساختمان", |
||||
"order-status": 5, |
||||
"order-level": 5 |
||||
} |
||||
] |
@ -0,0 +1,302 @@ |
||||
import React, { useMemo } from "react"; |
||||
|
||||
import { |
||||
useTable, |
||||
useSortBy, |
||||
useGlobalFilter, |
||||
useFilters, |
||||
usePagination, |
||||
useRowSelect, |
||||
useColumnOrder, |
||||
} from "react-table"; |
||||
|
||||
import { COLUMNS } from "./columns"; |
||||
|
||||
import { GlobalFilter } from "./GlobalFilter"; |
||||
|
||||
import { Checkbox } from "./Checkbox"; |
||||
|
||||
import MOCK_DATA from "./MOCK_DATA.json"; |
||||
|
||||
const BasicTable = () => { |
||||
const columns = React.useMemo(() => COLUMNS, []); |
||||
const data = useMemo(() => MOCK_DATA, []); |
||||
|
||||
const { |
||||
getTableProps, |
||||
getTableBodyProps, |
||||
headerGroups, |
||||
footerGroups, |
||||
rows, |
||||
page, |
||||
nextPage, |
||||
previousPage, |
||||
canNextPage, |
||||
canPreviousPage, |
||||
pageOptions, |
||||
gotoPage, |
||||
pageCount, |
||||
setPageSize, |
||||
prepareRow, |
||||
allColumns, |
||||
getToggleHideAllColumnsProps, |
||||
setColumnOrder, |
||||
selectedFlatRows, |
||||
state, |
||||
setGlobalFilter, |
||||
} = useTable( |
||||
{ |
||||
columns, |
||||
data, |
||||
// initialState: { pageIndex: 2 }
|
||||
}, |
||||
useColumnOrder, |
||||
useFilters, |
||||
useGlobalFilter, |
||||
useSortBy, |
||||
usePagination, |
||||
useRowSelect, |
||||
(hooks) => { |
||||
hooks.visibleColumns.push((columns) => { |
||||
return [ |
||||
{ |
||||
id: "selection", |
||||
Header: ({ getToggleAllRowsSelectedProps }) => ( |
||||
<Checkbox {...getToggleAllRowsSelectedProps()} /> |
||||
), |
||||
Cell: ({ row }) => ( |
||||
<Checkbox {...row.getToggleRowSelectedProps()} /> |
||||
), |
||||
}, |
||||
...columns, |
||||
]; |
||||
}); |
||||
} |
||||
); |
||||
|
||||
const changeOrder = () => { |
||||
setColumnOrder([ |
||||
"name", |
||||
"order-number", |
||||
"user-job", |
||||
"order-level", |
||||
"order-status", |
||||
"order-price", |
||||
]); |
||||
}; |
||||
|
||||
const { globalFilter, pageIndex, pageSize } = state; |
||||
// const firstPageRows = rows.slice(0, 10);
|
||||
|
||||
return ( |
||||
<> |
||||
<div className="bg-yellow-500"> |
||||
{/* search box */} |
||||
<GlobalFilter filter={globalFilter} setFilter={setGlobalFilter} /> |
||||
{/* pagination */} |
||||
</div> |
||||
{/* toggle columns */} |
||||
{/* <div> |
||||
<div> |
||||
<Checkbox {...getToggleHideAllColumnsProps()} /> Toggle All |
||||
</div> |
||||
{allColumns.map((column) => ( |
||||
<div key={column.id}> |
||||
<label> |
||||
<input type="checkbox" {...column.getToggleHiddenProps()} /> |
||||
{column.Header} |
||||
</label> |
||||
</div> |
||||
))} |
||||
</div> */} |
||||
|
||||
{/* Change Column Order */} |
||||
{/* <button onClick={changeOrder}> Change Column Order </button> */} |
||||
|
||||
<table |
||||
{...getTableProps()} |
||||
className="min-w-full divide-y divide-gray-200" |
||||
> |
||||
<thead className="bg-gray-300"> |
||||
{headerGroups.map((headerGroup) => ( |
||||
<tr {...headerGroup.getHeaderGroupProps()}> |
||||
{headerGroup.headers.map((column) => ( |
||||
<th |
||||
{...column.getHeaderProps(column.getSortByToggleProps())} |
||||
scope="col" |
||||
className="cursor-pointer px-4 py-2 text-right text-xs" |
||||
style={{ color: "#3287B9" }} |
||||
> |
||||
{column.render("Header")} |
||||
<span> |
||||
{column.isSorted |
||||
? column.isSortedDesc |
||||
? " 🔽" |
||||
: " 🔼" |
||||
: ""} |
||||
</span> |
||||
{/* not using */} |
||||
{/* <div> |
||||
{column.canFilter ? column.render('Filter') : null } |
||||
</div> */} |
||||
</th> |
||||
))} |
||||
</tr> |
||||
))} |
||||
</thead> |
||||
|
||||
<tbody |
||||
{...getTableBodyProps()} |
||||
className="bg-white divide-y divide-gray-200" |
||||
> |
||||
{/* not using */} |
||||
{/* {rows.map((row) => { |
||||
prepareRow(row) |
||||
return( |
||||
<tr {...row.getRowProps()}> |
||||
{row.cells.map((cell) => { |
||||
return <td {...cell.getCellProps()} className="px-4 py-4 whitespace-nowrap text-sm" role="cell" style={{color:'#00253A'}}> |
||||
{cell.render('Cell')} |
||||
</td> |
||||
})} |
||||
</tr> |
||||
) |
||||
})} */} |
||||
{page.map((row) => { |
||||
prepareRow(row); |
||||
return ( |
||||
<tr {...row.getRowProps()}> |
||||
{row.cells.map((cell) => { |
||||
return ( |
||||
<td |
||||
{...cell.getCellProps()} |
||||
className="px-4 py-4 whitespace-nowrap text-sm" |
||||
role="cell" |
||||
style={{ color: "#00253A" }} |
||||
> |
||||
{cell.render("Cell")} |
||||
</td> |
||||
); |
||||
})} |
||||
</tr> |
||||
); |
||||
})} |
||||
|
||||
{/* not using */} |
||||
{/* {firstPageRows.map((row) => { |
||||
prepareRow(row); |
||||
return ( |
||||
<tr {...row.getRowProps()}> |
||||
{row.cells.map((cell) => { |
||||
return ( |
||||
<td |
||||
{...cell.getCellProps()} |
||||
className="px-4 py-4 whitespace-nowrap text-sm" |
||||
role="cell" |
||||
style={{ color: "#00253A" }} |
||||
> |
||||
{cell.render("Cell")} |
||||
</td> |
||||
); |
||||
})} |
||||
</tr> |
||||
); |
||||
})} */} |
||||
</tbody> |
||||
|
||||
<tfoot |
||||
className={`bg-gray-300 ${rows.length > 10 ? "w-full" : "hidden"}`} |
||||
> |
||||
{footerGroups.map((footerGroup) => ( |
||||
<tr {...footerGroup.getFooterGroupProps()}> |
||||
{footerGroup.headers.map((column) => ( |
||||
<td |
||||
{...column.getFooterProps} |
||||
className="px-4 py-2 text-right text-xs" |
||||
style={{ color: "#3287B9" }} |
||||
> |
||||
{column.render("Footer")} |
||||
</td> |
||||
))} |
||||
</tr> |
||||
))} |
||||
</tfoot> |
||||
</table> |
||||
|
||||
<pre> |
||||
<code> |
||||
{JSON.stringify( |
||||
{ |
||||
selectedFlatRows: selectedFlatRows.map((row) => row.original), |
||||
}, |
||||
null, |
||||
2 |
||||
)} |
||||
</code> |
||||
</pre> |
||||
|
||||
<div> |
||||
<span> |
||||
Page{" "} |
||||
<strong> |
||||
{pageIndex + 1} of {pageOptions.length} |
||||
</strong> |
||||
{""} |
||||
</span> |
||||
|
||||
<span> |
||||
| Go to Page:{" "} |
||||
<input |
||||
type="number" |
||||
defaultValue={pageIndex + 1} |
||||
onChange={(e) => { |
||||
const pageNumber = e.target.value |
||||
? Number(e.target.value) - 1 |
||||
: 0; |
||||
gotoPage(pageNumber); |
||||
}} |
||||
style={{ width: "50px" }} |
||||
/> |
||||
</span> |
||||
|
||||
<select |
||||
value={pageSize} |
||||
onChange={(e) => setPageSize(Number(e.target.value))} |
||||
> |
||||
{[7, 10, 25, 50].map((pageSize) => ( |
||||
<option key={pageSize} value={pageSize}> |
||||
Show {pageSize} |
||||
</option> |
||||
))} |
||||
</select> |
||||
|
||||
<button onClick={() => gotoPage(0)} disabled={!canPreviousPage}> |
||||
{" "} |
||||
{"<<"}{" "} |
||||
</button> |
||||
|
||||
<button |
||||
className="bg-blue-400 m-2 rounded text-white p-2" |
||||
onClick={() => previousPage()} |
||||
disabled={!canPreviousPage} |
||||
> |
||||
Previous |
||||
</button> |
||||
<button |
||||
className="bg-blue-400 m-2 rounded text-white p-2" |
||||
onClick={() => nextPage()} |
||||
disabled={!canNextPage} |
||||
> |
||||
Next |
||||
</button> |
||||
|
||||
<button onClick={() => gotoPage(pageCount - 1)} disabled={!canNextPage}> |
||||
{" "} |
||||
{">>"}{" "} |
||||
</button> |
||||
</div> |
||||
</> |
||||
); |
||||
}; |
||||
|
||||
export default BasicTable; |
@ -0,0 +1,35 @@ |
||||
export function OrderLevel({ value }) { |
||||
return ( |
||||
<div className="p-2 rounded-3xl border border-gray-300 w-fit"> |
||||
{(() => { |
||||
switch(value) { |
||||
case 1: |
||||
return <div className="flex flex-row items-center justify-center "> |
||||
<span className="w-2 h-2 rounded-full ml-2" style={{ backgroundColor: "#65FFAD" }}></span> |
||||
<span style={{ color: "#00253A" }} className="">وضعیت عادی</span> |
||||
</div>; |
||||
case 2: |
||||
return <div className="flex flex-row items-center justify-center "> |
||||
<span className="w-2 h-2 rounded-full ml-2" style={{ backgroundColor: "#FF6565" }}></span> |
||||
<span style={{ color: "#00253A" }} className="">اعلان سطح هشدار</span> |
||||
</div>; |
||||
case 3: |
||||
return <div className="flex flex-row items-center justify-center "> |
||||
<span className="w-2 h-2 rounded-full ml-2" style={{ backgroundColor: "#65DAFF" }}></span> |
||||
<span style={{ color: "#00253A" }} className="">بررسی و پیگیری</span> |
||||
</div>; |
||||
case 4: |
||||
return <div className="flex flex-row items-center justify-center "> |
||||
<span className="w-2 h-2 rounded-full ml-2" style={{ backgroundColor: "#FFEA65" }}></span> |
||||
<span style={{ color: "#00253A" }} className="">وضعیت بحرانی</span> |
||||
</div>; |
||||
default: |
||||
return <div className="flex flex-row items-center justify-center "> |
||||
<span className="w-2 h-2 rounded-full ml-2" style={{ backgroundColor: "#CCFF65" }}></span> |
||||
<span style={{ color: "#00253A" }} className="">وضعیت پایدار</span> |
||||
</div>; |
||||
} |
||||
})()} |
||||
</div> |
||||
); |
||||
} |
@ -0,0 +1,55 @@ |
||||
export function OrderStatus({ value }) { |
||||
return ( |
||||
<div className=""> |
||||
{(() => { |
||||
if (value === 1) { |
||||
return ( |
||||
<span |
||||
style={{ backgroundColor: "#E2FFE377", color: "#00613D" }} |
||||
className="p-2 rounded" |
||||
> |
||||
ارسال شده |
||||
</span> |
||||
); |
||||
} else if (value === 2) { |
||||
return ( |
||||
<span |
||||
style={{ backgroundColor: "#FFF78733", color: "#ECF150" }} |
||||
className="p-2 rounded" |
||||
> |
||||
رسیدگی |
||||
</span> |
||||
); |
||||
} else if (value === 3) { |
||||
return ( |
||||
<span |
||||
style={{ backgroundColor: "#FFD8CC33", color: "#611100" }} |
||||
className="p-2 rounded" |
||||
> |
||||
لغو شده |
||||
</span> |
||||
); |
||||
} else if (value === 4) { |
||||
return ( |
||||
<span |
||||
style={{ backgroundColor: "#E2FFFD33", color: "#00614A" }} |
||||
className="p-2 rounded" |
||||
> |
||||
پیگیری |
||||
</span> |
||||
); |
||||
} else { |
||||
return ( |
||||
<span |
||||
style={{ backgroundColor: "#DBCCFF33", color: "#440061" }} |
||||
className="p-2 rounded" |
||||
> |
||||
خطری |
||||
</span> |
||||
); |
||||
} |
||||
})()}{" "} |
||||
</div> |
||||
); |
||||
} |
||||
|
After Width: | Height: | Size: 489 B |
After Width: | Height: | Size: 472 B |
@ -0,0 +1,64 @@ |
||||
import { format } from "date-fns"; |
||||
|
||||
import Table, { SelectColumnFilter } from "./BasicTable"; // new
|
||||
|
||||
import { ColumnFilter } from "./ColumnFilter"; |
||||
|
||||
import { OrderStatus } from "./OrderStatus"; |
||||
import { OrderLevel } from "./OrderLevel"; |
||||
import { Buttons } from "./Buttons"; |
||||
import { EditButtons } from "./EditButtons"; |
||||
|
||||
export const COLUMNS = [ |
||||
{ |
||||
Header: "نام و نام خانوادگی", |
||||
Footer: "نام و نام خانوادگی", |
||||
accessor: "name", |
||||
disableSortBy: true, |
||||
}, |
||||
{ |
||||
Header: "تاریخ سفارش", |
||||
Footer: "تاریخ سفارش", |
||||
accessor: "order-date", |
||||
Cell: ({ value }) => { |
||||
return format(new Date(value), "dd/MM/yyyy"); |
||||
}, |
||||
}, |
||||
{ |
||||
Header: "مبلغ سفارش", |
||||
Footer: "مبلغ سفارش", |
||||
accessor: "order-price", |
||||
Filter: ColumnFilter, |
||||
}, |
||||
{ |
||||
Header: "شماره سفارش", |
||||
Footer: "شماره سفارش", |
||||
accessor: "order-number", |
||||
}, |
||||
{ |
||||
Header: "شغل کاربر", |
||||
Footer: "شغل کاربر", |
||||
accessor: "user-job", |
||||
}, |
||||
{ |
||||
Header: "وضعیت سفارش", |
||||
Footer: "وضعیت سفارش", |
||||
accessor: "order-status", |
||||
Cell: OrderStatus, |
||||
}, |
||||
{ |
||||
Header: "سطح اهمیت", |
||||
Footer: "سطح اهمیت", |
||||
accessor: "order-level", |
||||
Cell: OrderLevel, |
||||
// Filter: SelectColumnFilter,
|
||||
// new
|
||||
}, |
||||
{ |
||||
Header: EditButtons, |
||||
Footer: "ویرایش", |
||||
accessor: "edit", |
||||
Cell: Buttons, |
||||
disableSortBy: true, |
||||
}, |
||||
]; |
After Width: | Height: | Size: 725 B |
After Width: | Height: | Size: 570 B |
@ -0,0 +1,158 @@ |
||||
import React, { useRef } from "react"; |
||||
import BasicTable from "./BasicTable"; |
||||
// import useDraggableScroll from "use-draggable-scroll";
|
||||
|
||||
const ReactTable3 = ({ breadCrumbs, subTitle, title }) => { |
||||
return ( |
||||
<div className="my-10 w-11/12 mx-auto"> |
||||
{/* breadCrumb */} |
||||
|
||||
<div className="flex flex-row items-center"> |
||||
{breadCrumbs.map((breadCrumb, index) => ( |
||||
<div className="flex flex-row items-center"> |
||||
<span |
||||
className={`cursor-pointer text-xs hover:text-blue-900 ${ |
||||
breadCrumb.active ? "text-blue-900" : "text-blue-400" |
||||
}`}
|
||||
> |
||||
{breadCrumb.name} |
||||
</span> |
||||
{Number(index) !== breadCrumbs.length - 1 && ( |
||||
<div |
||||
className={`mx-2 ${ |
||||
breadCrumb.active ? "text-blue-900" : "text-blue-400" |
||||
}`}
|
||||
> |
||||
{" > "} |
||||
</div> |
||||
)} |
||||
</div> |
||||
))} |
||||
</div> |
||||
|
||||
<div className="my-7"> |
||||
{/* page Title */} |
||||
<div className="flex flex-row items-center"> |
||||
<div className="w-1 h-5 bg-blue-500 rounded ml-1"></div> |
||||
<h2 className="text-base text-blue-900">{title}</h2> |
||||
</div> |
||||
{/* page Title */} |
||||
<div className="flex flex-row items-center mt-4"> |
||||
<div className="w-1 h-5 bg-gray-400 rounded ml-1"></div> |
||||
<h2 className="text-sm">{subTitle}</h2> |
||||
</div> |
||||
</div> |
||||
<Tabbar /> |
||||
<BasicTable /> |
||||
</div> |
||||
); |
||||
}; |
||||
window.isDown = false; |
||||
export default ReactTable3; |
||||
function Tabbar({}) { |
||||
const ref = useRef(null); |
||||
|
||||
// const { onMouseDown } = useDraggableScroll(ref);
|
||||
const tabs = [ |
||||
"تست۱", |
||||
"تست۱", |
||||
"تست۱", |
||||
"تست۱", |
||||
"تست۱", |
||||
"تست۱", |
||||
"تست۱", |
||||
"تست۱", |
||||
"تست۱", |
||||
"تست۱", |
||||
"تست۱", |
||||
"تست۱", |
||||
"تست۱", |
||||
"تست۱", |
||||
"تست۱", |
||||
"تست۱", |
||||
"تست۱", |
||||
"تست۱", |
||||
"تست۱", |
||||
"تست۱", |
||||
"تست۱", |
||||
"تست۱", |
||||
"تست۱", |
||||
"تست۱", |
||||
"تست۱", |
||||
"تست۱", |
||||
"تست۱", |
||||
"تست۱", |
||||
"تست۱", |
||||
"تست۱", |
||||
"تست۱", |
||||
"تست۱", |
||||
"تست۱", |
||||
"تست۱", |
||||
]; |
||||
return ( |
||||
<ul |
||||
className="tabbar flex no-scrollbar border-b border-gray-200 dark:border-gray-700 overflow-x-scroll scrolling-touch" |
||||
onMouseDown={(e) => { |
||||
const slider = window.document.querySelector(".tabbar"); |
||||
window.isDown = true; |
||||
window.startX = e.pageX - slider.offsetLeft; |
||||
window.scrollLeft = slider.scrollLeft; |
||||
}} |
||||
onMouseLeave={(e) => { |
||||
window.isDown = false; |
||||
}} |
||||
onMouseUp={(e) => { |
||||
window.isDown = false; |
||||
}} |
||||
onMouseMove={(e) => { |
||||
const slider = window.document.querySelector(".tabbar"); |
||||
if (!window.isDown) return; |
||||
e.preventDefault(); |
||||
const x = e.pageX - slider.offsetLeft; |
||||
const walk = (x - window.startX) * 1; |
||||
slider.scrollLeft = window.scrollLeft - walk; |
||||
}} |
||||
> |
||||
{tabs.map((el) => ( |
||||
<li className="mr-2 "> |
||||
<span |
||||
onClick={(e) => { |
||||
if (window.isDown) return e.preventDefault(); |
||||
///do here
|
||||
}} |
||||
aria-current="page" |
||||
className="inline-block py-4 px-4 text-sm font-medium text-center text-blue-600 bg-gray-100 rounded-t-lg active dark:bg-gray-800 dark:text-blue-500" |
||||
> |
||||
<span className="p-2"> |
||||
{el} <span className="p-2">x</span> |
||||
</span> |
||||
</span> |
||||
</li> |
||||
))} |
||||
</ul> |
||||
); |
||||
} |
||||
|
||||
ReactTable3.defaultProps = { |
||||
breadCrumbs: [ |
||||
{ |
||||
name: "صفحه اصلی", |
||||
active: false, |
||||
}, |
||||
{ |
||||
name: "آمار و گزارشات", |
||||
active: false, |
||||
}, |
||||
{ |
||||
name: "فروش محصولات", |
||||
active: false, |
||||
}, |
||||
{ |
||||
name: "سال 1400", |
||||
active: true, |
||||
}, |
||||
], |
||||
|
||||
title: "میزان فروش محصولات", |
||||
subTitle: "اطلاعات جداول مشخصاتی کارکنان مجموعه ایران تایر", |
||||
}; |
@ -0,0 +1,16 @@ |
||||
.customeClass1 .customeClass2 input { |
||||
display: none !important; |
||||
} |
||||
.customeClass1 .customeClass2 span { |
||||
display: none !important; |
||||
} |
||||
.no-scrollbar { |
||||
-ms-overflow-style: none; /* IE and Edge */ |
||||
scrollbar-width: none; /* Firefox */ |
||||
} |
||||
.tabbar{ |
||||
cursor: pointer; |
||||
} |
||||
.active2 ,.active2 li a{ |
||||
cursor: move !important; |
||||
} |
After Width: | Height: | Size: 749 B |
After Width: | Height: | Size: 543 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 7.7 KiB |