Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about just adding default value to count? like
const {
requests,
isLoading,
refetch,
count = 0,
} = ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, refactored

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const RequestProductCategoryList = () => {

const [currentFilter, setCurrentFilter] = useState<FilterState>("");

const { requests, isLoading, refetch, count } = useVendorRequests({
const { requests, isLoading, refetch, count = 0 } = useVendorRequests({
offset: currentPage * PAGE_SIZE,
limit: PAGE_SIZE,
type: "product_category",
Expand Down Expand Up @@ -104,16 +104,16 @@ export const RequestProductCategoryList = () => {
</Table.Body>
</Table>
<Table.Pagination
canNextPage={PAGE_SIZE * (currentPage + 1) < count!}
canNextPage={PAGE_SIZE * (currentPage + 1) < count}
canPreviousPage={currentPage > 0}
previousPage={() => {
setCurrentPage(currentPage - 1);
}}
nextPage={() => {
setCurrentPage(currentPage + 1);
}}
count={count!}
pageCount={Math.ceil(count! / PAGE_SIZE)}
count={count ?? 0}
pageCount={Math.ceil(count / PAGE_SIZE)}
pageIndex={currentPage}
pageSize={PAGE_SIZE}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const RequestProductCollectionList = () => {

const [currentFilter, setCurrentFilter] = useState<FilterState>("");

const { requests, isLoading, refetch, count } = useVendorRequests({
const { requests, isLoading, refetch, count = 0 } = useVendorRequests({
offset: currentPage * PAGE_SIZE,
limit: PAGE_SIZE,
type: "product_collection",
Expand Down Expand Up @@ -105,16 +105,16 @@ export const RequestProductCollectionList = () => {
</Table.Body>
</Table>
<Table.Pagination
canNextPage={PAGE_SIZE * (currentPage + 1) < count!}
canNextPage={PAGE_SIZE * (currentPage + 1) < count}
canPreviousPage={currentPage > 0}
previousPage={() => {
setCurrentPage(currentPage - 1);
}}
nextPage={() => {
setCurrentPage(currentPage + 1);
}}
count={count!}
pageCount={Math.ceil(count! / PAGE_SIZE)}
count={count ?? 0}
pageCount={Math.ceil(count / PAGE_SIZE)}
pageIndex={currentPage}
pageSize={PAGE_SIZE}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const RequestProductList = () => {
setDetailOpen(true);
};

const { requests, isLoading, count } = useVendorRequests({
const { requests, isLoading, count = 0 } = useVendorRequests({
limit: PAGE_SIZE,
offset: currentPage * PAGE_SIZE,
type: "product",
Expand Down Expand Up @@ -87,16 +87,16 @@ export const RequestProductList = () => {
</Table.Body>
</Table>
<Table.Pagination
canNextPage={PAGE_SIZE * (currentPage + 1) < count!}
canNextPage={PAGE_SIZE * (currentPage + 1) < count}
canPreviousPage={currentPage > 0}
previousPage={() => {
setCurrentPage(currentPage - 1);
}}
nextPage={() => {
setCurrentPage(currentPage + 1);
}}
count={count!}
pageCount={Math.ceil(count! / PAGE_SIZE)}
count={count ?? 0}
pageCount={Math.ceil(count / PAGE_SIZE)}
pageIndex={currentPage}
pageSize={PAGE_SIZE}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const RequestProductTagList = () => {

const [currentFilter, setCurrentFilter] = useState<FilterState>("");

const { requests, isLoading, refetch, count } = useVendorRequests({
const { requests, isLoading, refetch, count = 0 } = useVendorRequests({
offset: currentPage * PAGE_SIZE,
limit: PAGE_SIZE,
type: "product_tag",
Expand Down Expand Up @@ -102,16 +102,16 @@ export const RequestProductTagList = () => {
</Table.Body>
</Table>
<Table.Pagination
canNextPage={PAGE_SIZE * (currentPage + 1) < count!}
canNextPage={PAGE_SIZE * (currentPage + 1) < count}
canPreviousPage={currentPage > 0}
previousPage={() => {
setCurrentPage(currentPage - 1);
}}
nextPage={() => {
setCurrentPage(currentPage + 1);
}}
count={count!}
pageCount={Math.ceil(count! / PAGE_SIZE)}
count={count ?? 0}
pageCount={Math.ceil(count / PAGE_SIZE)}
pageIndex={currentPage}
pageSize={PAGE_SIZE}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const RequestProductTypeList = () => {

const [currentFilter, setCurrentFilter] = useState<FilterState>("");

const { requests, isLoading, refetch, count } = useVendorRequests({
const { requests, isLoading, refetch, count = 0 } = useVendorRequests({
offset: currentPage * PAGE_SIZE,
limit: PAGE_SIZE,
type: "product_type",
Expand Down Expand Up @@ -103,16 +103,16 @@ export const RequestProductTypeList = () => {
</Table.Body>
</Table>
<Table.Pagination
canNextPage={PAGE_SIZE * (currentPage + 1) < count!}
canNextPage={PAGE_SIZE * (currentPage + 1) < count}
canPreviousPage={currentPage > 0}
previousPage={() => {
setCurrentPage(currentPage - 1);
}}
nextPage={() => {
setCurrentPage(currentPage + 1);
}}
count={count!}
pageCount={Math.ceil(count! / PAGE_SIZE)}
count={count ?? 0}
pageCount={Math.ceil(count / PAGE_SIZE)}
pageIndex={currentPage}
pageSize={PAGE_SIZE}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const RequestProductUpdateList = () => {

const [currentFilter, setCurrentFilter] = useState<FilterState>("");

const { requests, isLoading, count } = useVendorRequests({
const { requests, isLoading, count = 0 } = useVendorRequests({
offset: currentPage * PAGE_SIZE,
limit: PAGE_SIZE,
type: "product_update",
Expand Down Expand Up @@ -92,16 +92,16 @@ export const RequestProductUpdateList = () => {
</Table.Body>
</Table>
<Table.Pagination
canNextPage={PAGE_SIZE * (currentPage + 1) < count!}
canNextPage={PAGE_SIZE * (currentPage + 1) < count}
canPreviousPage={currentPage > 0}
previousPage={() => {
setCurrentPage(currentPage - 1);
}}
nextPage={() => {
setCurrentPage(currentPage + 1);
}}
count={count!}
pageCount={Math.ceil(count! / PAGE_SIZE)}
count={count ?? 0}
pageCount={Math.ceil(count / PAGE_SIZE)}
pageIndex={currentPage}
pageSize={PAGE_SIZE}
/>
Expand Down
10 changes: 5 additions & 5 deletions src/routes/requests/request-return-list/request-return-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ export const OrderReturnRequestsPage = () => {
order_return_request: requests,
isLoading,
refetch,
count,
count = 0,
} = useReturnRequests({
offset: currentPage * PAGE_SIZE,
limit: PAGE_SIZE,
status: currentFilter !== "" ? currentFilter : undefined,
});

return (
<Container>
<div className="flex items-center justify-between px-6 py-4">
Expand Down Expand Up @@ -109,16 +109,16 @@ export const OrderReturnRequestsPage = () => {
</Table.Body>
</Table>
<Table.Pagination
canNextPage={PAGE_SIZE * (currentPage + 1) < count!}
canNextPage={PAGE_SIZE * (currentPage + 1) < count}
canPreviousPage={currentPage > 0}
previousPage={() => {
setCurrentPage(currentPage - 1);
}}
nextPage={() => {
setCurrentPage(currentPage + 1);
}}
count={count!}
pageCount={Math.ceil(count! / PAGE_SIZE)}
count={count ?? 0}
pageCount={Math.ceil(count / PAGE_SIZE)}
pageIndex={currentPage}
pageSize={PAGE_SIZE}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const RequestReviewRemoveList = () => {

const [currentFilter, setCurrentFilter] = useState<FilterState>("");

const { requests, isLoading, refetch, count } = useVendorRequests({
const { requests, isLoading, refetch, count = 0 } = useVendorRequests({
offset: currentPage * PAGE_SIZE,
limit: PAGE_SIZE,
type: "review_remove",
Expand Down Expand Up @@ -102,16 +102,16 @@ export const RequestReviewRemoveList = () => {
</Table.Body>
</Table>
<Table.Pagination
canNextPage={PAGE_SIZE * (currentPage + 1) < count!}
canNextPage={PAGE_SIZE * (currentPage + 1) < count}
canPreviousPage={currentPage > 0}
previousPage={() => {
setCurrentPage(currentPage - 1);
}}
nextPage={() => {
setCurrentPage(currentPage + 1);
}}
count={count!}
pageCount={Math.ceil(count! / PAGE_SIZE)}
count={count ?? 0}
pageCount={Math.ceil(count / PAGE_SIZE)}
pageIndex={currentPage}
pageSize={PAGE_SIZE}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const RequestSellerList = () => {

const [currentFilter, setCurrentFilter] = useState<FilterState>("");

const { requests, isLoading, refetch, count } = useVendorRequests({
const { requests, isLoading, refetch, count = 0 } = useVendorRequests({
offset: currentPage * PAGE_SIZE,
limit: PAGE_SIZE,
type: "seller",
Expand Down Expand Up @@ -110,16 +110,16 @@ export const RequestSellerList = () => {
</Table>
<Table.Pagination
className="w-full"
canNextPage={PAGE_SIZE * (currentPage + 1) < count!}
canNextPage={PAGE_SIZE * (currentPage + 1) < count}
canPreviousPage={currentPage > 0}
previousPage={() => {
setCurrentPage(currentPage - 1);
}}
nextPage={() => {
setCurrentPage(currentPage + 1);
}}
count={count!}
pageCount={Math.ceil(count! / PAGE_SIZE)}
count={count ?? 0}
pageCount={Math.ceil(count / PAGE_SIZE)}
pageIndex={currentPage}
pageSize={PAGE_SIZE}
/>
Expand Down