Implementing Get api.

This commit is contained in:
Kartik Sharma 2025-11-19 18:47:30 +05:30
parent e7a68aeab7
commit 7e4dffff34

View File

@ -22,12 +22,11 @@ const ServiceBranch = () => {
const { data, isLoading, isError, error } = useBranches(
projectId,
debouncedSearch || null,
null,
true,
ITEMS_PER_PAGE,
currentPage,
ITEMS_PER_PAGE
debouncedSearch,
);
const paginate = (page) => {
if (page >= 1 && page <= (data?.totalPages ?? 1)) {
setCurrentPage(page);
@ -68,30 +67,38 @@ const ServiceBranch = () => {
<div className="mx-2">
{/* {Array.isArray(filteredData) && filteredData.length > 0 && ( */}
<table className="table border-top dataTable text-nowrap align-middle">
<table className="table border-top text-nowrap align-middle">
<thead>
<tr>
{ServiceBranch.map((col) => (
<th key={col.key} className={`sorting ${col.align}`}>
<th key={col.key} className={col.align}>
{col.label}
</th>
))}
<th className="text-center">Action</th>
</tr>
</thead>
{/* <tbody>
<tbody>
{isLoading ? (
<tr>
<td colSpan={ServiceBranch.length + 1} className="text-center py-5">
Loading...
</td>
</tr>
) : isError ? (
<tr>
<td colSpan={ServiceBranch.length + 1} className="text-center py-5">
{error?.message || "Error loading branches"}
</td>
</tr>
) : data?.data?.length > 0 ? (
data.data.map((branch) => (
<tr key={branch.id} className="align-middle">
<td className="text-start">{branch.branchName}</td>
<tr key={branch.id}>
{ServiceBranch.map((col) => (
<td key={col.key} className={col.align}>
{col.getValue(branch)}
</td>
))}
<td className="text-center">
<i
className="bx bx-edit text-primary cursor-pointer"
@ -101,7 +108,7 @@ const ServiceBranch = () => {
branchId: branch.id,
})
}
></i>
/>
</td>
</tr>
))
@ -112,9 +119,7 @@ const ServiceBranch = () => {
</td>
</tr>
)}
</tbody> */}
</tbody>
</table>
{/* )} */}
{/* {!filteredData ||