made pagination not to display no item in array
This commit is contained in:
@@ -42,45 +42,49 @@ export default function MyActiveJobTable({MyJobList, className }) {
|
|||||||
MyJobList.result_list.length > 0 &&
|
MyJobList.result_list.length > 0 &&
|
||||||
currentActiveJobList.map((value, index) => (
|
currentActiveJobList.map((value, index) => (
|
||||||
<tr key={index} className="bg-white dark:bg-dark-white border-b dark:border-[#5356fb29] hover:bg-gray-50">
|
<tr key={index} className="bg-white dark:bg-dark-white border-b dark:border-[#5356fb29] hover:bg-gray-50">
|
||||||
<td className=" py-4">
|
<td className=" py-4">
|
||||||
<div className="flex space-x-2 items-center">
|
<div className="flex space-x-2 items-center">
|
||||||
<div className="w-[60px] h-[60px] rounded-full overflow-hidden flex justify-center items-center">
|
<div className="w-[60px] h-[60px] rounded-full overflow-hidden flex justify-center items-center">
|
||||||
<img
|
<img
|
||||||
src={dataImage2}
|
src={dataImage2}
|
||||||
alt="data"
|
alt="data"
|
||||||
className="w-full h-full"
|
className="w-full h-full"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
<h1 className="font-bold text-xl text-dark-gray dark:text-white whitespace-nowrap">
|
<h1 className="font-bold text-xl text-dark-gray dark:text-white whitespace-nowrap">
|
||||||
{value.title}
|
{value.title}
|
||||||
</h1>
|
</h1>
|
||||||
<div>
|
<div>
|
||||||
{value.description}
|
{value.description}
|
||||||
|
</div>
|
||||||
|
<span className="text-sm text-thin-light-gray">
|
||||||
|
Price: <span className="text-purple">{value.price*0.01}</span>
|
||||||
|
</span>
|
||||||
|
<span className="text-sm text-thin-light-gray">
|
||||||
|
Duration: <span className="text-purple"> {value.timeline_days} day(s)</span>
|
||||||
|
</span>
|
||||||
|
<span className="text-sm text-thin-light-gray">
|
||||||
|
Expire: <span className="text-purple"> {value.expire}</span>
|
||||||
|
</span>
|
||||||
|
<span className="text-sm text-thin-light-gray">
|
||||||
|
Send to: <span className="text-purple"> {value.job_to}</span>
|
||||||
|
</span>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<span className="text-sm text-thin-light-gray">
|
|
||||||
Price: <span className="text-purple">{value.price*0.01}</span>
|
|
||||||
</span>
|
|
||||||
<span className="text-sm text-thin-light-gray">
|
|
||||||
Duration: <span className="text-purple"> {value.timeline_days} day(s)</span>
|
|
||||||
</span>
|
|
||||||
<span className="text-sm text-thin-light-gray">
|
|
||||||
Expire: <span className="text-purple"> {value.expire}</span>
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</td>
|
||||||
</td>
|
|
||||||
|
|
||||||
|
|
||||||
<td className="text-right py-4 px-2">
|
<td className="text-right py-4 px-2">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="w-20 h-11 flex justify-center items-center btn-gradient text-base rounded-full text-white"
|
className="w-20 h-11 flex justify-center items-center btn-gradient text-base rounded-full text-white"
|
||||||
>
|
>
|
||||||
View
|
View
|
||||||
</button>
|
</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,49 +3,53 @@ import { createRoutesFromChildren } from 'react-router-dom';
|
|||||||
|
|
||||||
const PaginatedList = ({ onClick, prev, next, data, start, stop }) => {
|
const PaginatedList = ({ onClick, prev, next, data, start, stop }) => {
|
||||||
|
|
||||||
return (
|
if(data.length){
|
||||||
<div className='p-3 flex justify-center items-center space-x-2'>
|
return (
|
||||||
{/* Render pagination buttons */}
|
<div className='p-3 flex justify-center items-center space-x-2'>
|
||||||
{!prev &&
|
{/* Render pagination buttons */}
|
||||||
<button
|
{!prev &&
|
||||||
className={`p-2 ${prev ? 'border' : null}`}
|
<button
|
||||||
name='prev'
|
className={`p-2 ${prev ? 'border' : null}`}
|
||||||
onClick={onClick}
|
name='prev'
|
||||||
>
|
onClick={onClick}
|
||||||
<><</>
|
>
|
||||||
</button>
|
<><</>
|
||||||
}
|
</button>
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
data.map((item, index)=>{
|
data.map((item, index)=>{
|
||||||
if(index%process.env.REACT_APP_ITEM_PER_PAGE == 0 && index >= start && index <= stop){
|
if(index%process.env.REACT_APP_ITEM_PER_PAGE == 0 && index >= start && index <= stop){
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
key={index}
|
key={index}
|
||||||
value={index}
|
value={index}
|
||||||
className={`p-2 ${index==start ? 'border' : null}`}
|
className={`p-2 ${index==start ? 'border' : null}`}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
name='page_num'
|
name='page_num'
|
||||||
disabled={index == start}
|
disabled={index == start}
|
||||||
>
|
>
|
||||||
{index <= 0 ? index+1 : (index/process.env.REACT_APP_ITEM_PER_PAGE)+1}
|
{index <= 0 ? index+1 : (index/process.env.REACT_APP_ITEM_PER_PAGE)+1}
|
||||||
</button>
|
</button>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
{!next &&
|
{!next &&
|
||||||
<button
|
<button
|
||||||
className={`p-2 ${next ? 'border' : null}`}
|
className={`p-2 ${next ? 'border' : null}`}
|
||||||
name='next'
|
name='next'
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
>
|
>
|
||||||
<>></>
|
<>></>
|
||||||
</button>
|
</button>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
);
|
)
|
||||||
|
}else{
|
||||||
|
return null
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default PaginatedList;
|
export default PaginatedList;
|
||||||
|
|||||||
Reference in New Issue
Block a user