|
|
|
@ -1,11 +1,21 @@ |
|
|
|
|
import React from "react"; |
|
|
|
|
import React, { useState } from "react"; |
|
|
|
|
|
|
|
|
|
import arrowDown from "./arrow-down.svg"; |
|
|
|
|
import arrowUp from "./arrow-up.svg"; |
|
|
|
|
|
|
|
|
|
const TableDesign1 = ({ tableItems, tableSubItems }) => { |
|
|
|
|
const [sortedField, setSortedField] = useState(null); |
|
|
|
|
|
|
|
|
|
if (sortedField !== null) { |
|
|
|
|
tableSubItems.sort((a, b) => { |
|
|
|
|
if (a.payedPrice > b.payedPrice) { |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<section className="w-10/12 mx-auto my-10"> |
|
|
|
|
<section className="w-8/12 mx-auto my-10"> |
|
|
|
|
<div className="flex flex-col"> |
|
|
|
|
<div className="-my-2 overflow-x-auto sm:-mx-6 lg:-mx-8"> |
|
|
|
|
<div className="py-2 align-middle inline-block min-w-full sm:px-6 lg:px-8"> |
|
|
|
@ -13,7 +23,7 @@ const TableDesign1 = ({ tableItems, tableSubItems }) => { |
|
|
|
|
<table className="min-w-full divide-y divide-gray-200"> |
|
|
|
|
<thead className="bg-gray-50"> |
|
|
|
|
{tableItems.map((tableItem, index) => ( |
|
|
|
|
<tr className=""> |
|
|
|
|
<tr className="" key={index}> |
|
|
|
|
<th |
|
|
|
|
scope="col" |
|
|
|
|
className="text-blue-400 font-light text-right text-sm p-4" |
|
|
|
@ -33,9 +43,9 @@ const TableDesign1 = ({ tableItems, tableSubItems }) => { |
|
|
|
|
className="w-4 cursor-pointer" |
|
|
|
|
/> |
|
|
|
|
<img |
|
|
|
|
src={arrowDown} |
|
|
|
|
src={arrowUp} |
|
|
|
|
alt="" |
|
|
|
|
className="w-4 cursor-pointer" |
|
|
|
|
className="w-4 cursor-pointer rotate-180" |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
@ -51,11 +61,12 @@ const TableDesign1 = ({ tableItems, tableSubItems }) => { |
|
|
|
|
src={arrowUp} |
|
|
|
|
alt="" |
|
|
|
|
className="w-4 cursor-pointer" |
|
|
|
|
// onClick={() => setSortedField}
|
|
|
|
|
/> |
|
|
|
|
<img |
|
|
|
|
src={arrowDown} |
|
|
|
|
src={arrowUp} |
|
|
|
|
alt="" |
|
|
|
|
className="w-4 cursor-pointer" |
|
|
|
|
className="w-4 cursor-pointer rotate-180" |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
@ -71,11 +82,13 @@ const TableDesign1 = ({ tableItems, tableSubItems }) => { |
|
|
|
|
src={arrowUp} |
|
|
|
|
alt="" |
|
|
|
|
className="w-4 cursor-pointer" |
|
|
|
|
onClick={() => setSortedField()} |
|
|
|
|
/> |
|
|
|
|
<img |
|
|
|
|
src={arrowDown} |
|
|
|
|
src={arrowUp} |
|
|
|
|
alt="" |
|
|
|
|
className="w-4 cursor-pointer" |
|
|
|
|
className="w-4 cursor-pointer rotate-180" |
|
|
|
|
// onClick={() => setSortedField()}
|
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
@ -85,7 +98,7 @@ const TableDesign1 = ({ tableItems, tableSubItems }) => { |
|
|
|
|
</thead> |
|
|
|
|
<tbody className="bg-white divide-y divide-gray-200"> |
|
|
|
|
{tableSubItems.map((tableSubItem, i) => ( |
|
|
|
|
<tr> |
|
|
|
|
<tr key={i}> |
|
|
|
|
<td className="p-4 whitespace-nowrap text-base font-light"> |
|
|
|
|
{tableSubItem.title} |
|
|
|
|
</td> |
|
|
|
@ -133,13 +146,25 @@ TableDesign1.defaultProps = { |
|
|
|
|
title: "مایکروویر سامسونگ مدل", |
|
|
|
|
status: true, |
|
|
|
|
date: "1400/09/21", |
|
|
|
|
payedPrice: 2400000, |
|
|
|
|
payedPrice: 73, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
title: "آزمون آنلاین درس علوم تجربی", |
|
|
|
|
status: false, |
|
|
|
|
date: "1400/09/21", |
|
|
|
|
payedPrice: 75, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
title: "مایکروویر سامسونگ مدل", |
|
|
|
|
status: true, |
|
|
|
|
date: "1400/09/21", |
|
|
|
|
payedPrice: 25, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
title: "آزمون آنلاین درس علوم تجربی", |
|
|
|
|
status: false, |
|
|
|
|
date: "1400/09/21", |
|
|
|
|
payedPrice: 2400000, |
|
|
|
|
payedPrice: 27, |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
}; |
|
|
|
|