Add transaction section to admin dashboard
This commit is contained in:
@@ -36,7 +36,7 @@ export default function CategoryDashboard() {
|
||||
|
||||
const handleRemove = (id) => {
|
||||
removeCategory(id)
|
||||
.then((res) => {
|
||||
.then(() => {
|
||||
fetchCategory(currentPage);
|
||||
})
|
||||
.catch((err) => {
|
||||
@@ -48,7 +48,7 @@ export default function CategoryDashboard() {
|
||||
useEffect(fetchCategory, []);
|
||||
|
||||
return (
|
||||
<div className="pt-10 p-20">
|
||||
<div className="pt-10 p-20 w-full">
|
||||
<h1 className="text-4xl pb-3 font-bold text-green-800 underline">
|
||||
CATEGORIES
|
||||
</h1>
|
||||
@@ -60,35 +60,46 @@ export default function CategoryDashboard() {
|
||||
<IoAddCircleSharp />
|
||||
</button>
|
||||
<CategoryForm onAddCategory={notiChange} visible={visible} />
|
||||
<table className="table-fixed w-full text-center border border-green-600">
|
||||
<thead className="bg-green-600 h-10">
|
||||
<tr>
|
||||
<th>CategoryID</th>
|
||||
<th>Name</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{categories.map((category) => (
|
||||
<tr key={category.UserID} className="border border-green-600 h-10">
|
||||
<td>{category.CategoryID}</td>
|
||||
<td>{category.Name}</td>
|
||||
<td className="flex justify-center pt-2">
|
||||
<MdDelete
|
||||
onClick={() => {
|
||||
handleRemove(category.CategoryID);
|
||||
}}
|
||||
className="hover:text-red-600 cursor-pointer transition-all text-xl"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
<Pagination
|
||||
pageNum={Math.ceil(total / pageLimit)}
|
||||
onChange={onChangePage}
|
||||
/>
|
||||
{categories.length > 0 ? (
|
||||
<>
|
||||
<table className="table-fixed w-full text-center border border-green-600">
|
||||
<thead className="bg-green-600 h-10">
|
||||
<tr>
|
||||
<th>CategoryID</th>
|
||||
<th>Name</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{categories.map((category) => (
|
||||
<tr
|
||||
key={category.UserID}
|
||||
className="border border-green-600 h-10"
|
||||
>
|
||||
<td>{category.CategoryID}</td>
|
||||
<td>{category.Name}</td>
|
||||
<td className="flex justify-center pt-2">
|
||||
<MdDelete
|
||||
onClick={() => {
|
||||
handleRemove(category.CategoryID);
|
||||
}}
|
||||
className="hover:text-red-600 cursor-pointer transition-all text-xl"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
<Pagination
|
||||
pageNum={Math.ceil(total / pageLimit)}
|
||||
onChange={onChangePage}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<p className="text-red-700 text-xl bg-red-200 px-3 rounded-md py-1 w-fit">
|
||||
No category exists!
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user