diff --git a/components/Pagination.tsx b/components/Pagination.tsx index 51a8d13..0ff6064 100644 --- a/components/Pagination.tsx +++ b/components/Pagination.tsx @@ -5,12 +5,14 @@ import { MdKeyboardArrowRight, MdKeyboardArrowLeft } from "react-icons/md"; import { twMerge } from "tailwind-merge"; export default function Pagination({ + TotalPages, currentPage, PageSize, Page, countPage, length, }: { + TotalPages?: any; currentPage?: any; PageSize?: number; Page?: any; @@ -30,11 +32,15 @@ export default function Pagination({ onPageChange={handlePageClick} pageRangeDisplayed={3} forcePage={currentPage} - pageCount={Math.ceil(countPage / (PageSize ? PageSize : 5))} + pageCount={ + TotalPages + ? TotalPages + : Math.ceil(countPage / (PageSize ? PageSize : 5)) + } previousLabel={} pageClassName=" w-10 h-10 grid place-content-center rounded-lg !text-blue shadow-md" className={twMerge( - " flex flex-wrap gap-3 text-sm md:text-base w-full rounded-md p-1 bg-white/30 backdrop-blur-lg justify-center text-blue mt-5 absolute left-0 right-0 bottom-6" + " flex flex-wrap gap-3 text-sm md:text-base w-full rounded-md p-2 pb-3 bg-white/30 backdrop-blur-lg justify-center fixed text-blue mt-5 left-0 right-0 bottom-0" )} activeClassName=" bg-blue text-blue shadow-md shadow-main" activeLinkClassName=" text-white w-full p-1 h-full" diff --git a/components/Search.tsx b/components/Search.tsx index 81782c1..19c52ac 100644 --- a/components/Search.tsx +++ b/components/Search.tsx @@ -1,26 +1,50 @@ "use client"; -import React, { useState, useEffect } from "react"; +import React, { useState, useEffect, useRef } from "react"; import { Input } from "./ui/input"; import { Label } from "./ui/label"; import { Button } from "./ui/button"; import { CiSearch } from "react-icons/ci"; +import { XCircle } from "lucide-react"; export default function Search({ mode, value, action, + Cancel, changeValue, }: { mode?: string; value?: any; action?: (any: any) => any; - changeValue?: (any: any) => any ; + Cancel: (any: any) => any; + changeValue?: (any: any) => any; }) { + const inputRef = useRef(null); + const [cancel, setCancel] = useState(false); + const handleSubmit = (e: any) => { + console.log(222); + e.preventDefault(); + setCancel(true); + }; + + const cancelSearch = (e: any) => { + e.preventDefault(); + setCancel(false); + if (changeValue !== undefined) { + console.log(444); + changeValue(""); + } + Cancel(true); + }; return ( - + { if (changeValue) { + setCancel(false); changeValue(e.target.value); } }} placeholder="جستجو..." - required /> - + {cancel ? ( + + + + ) : ( + + + + )} + {/* - - + */} + ); } diff --git a/components/TabController.tsx b/components/TabController.tsx index b09d026..6a8f210 100644 --- a/components/TabController.tsx +++ b/components/TabController.tsx @@ -31,7 +31,9 @@ export default function TabController() { const [totalCount, setTotalCount] = useState(0); const [currentPage, setCurrentPage] = useState(0); const [pageSize, setPageSize] = useState(0); - + const [totalPages, setTotalPages] = useState(0); + const [cancel, setCancel] = useState(false); + const router = useRouter(); const [psblState, setPsblState] = useState(0); @@ -61,13 +63,20 @@ export default function TabController() { const handelSearch = (event: any) => { refetch(); }; + useEffect(() => { + if (cancel) { + refetch(); + } + }, [cancel]); useEffect(() => { if (data) { const headersData = JSON.parse(data.headers["x-pagination"]); setTotalCount(headersData.TotalCount); + setTotalPages(headersData.TotalPages); setCurrentPage(headersData.CurrentPage); setPageSize(headersData.PageSize); + setCancel(false); } }, [data]); useEffect(() => { @@ -85,11 +94,7 @@ export default function TabController() { لیست شکایت ها - + {/* Tab Title */} @@ -108,7 +113,6 @@ export default function TabController() { setPsblState(item.value); setSelectedTab(String(item.value)); localStorage.setItem("ActiveTab", String(item.value)); - refetch(); setPage(0); }} @@ -127,6 +131,7 @@ export default function TabController() { changeValue={(data: any) => setSearch(data)} mode="controller" action={handelSearch} + Cancel={() => setCancel(true)} /> @@ -136,8 +141,8 @@ export default function TabController() { {data ? ( ) : ( @@ -150,6 +155,7 @@ export default function TabController() { {!isZero ? ( setPage(num + 1)} /> diff --git a/components/TableController.tsx b/components/TableController.tsx index df5a7a8..ef5a4f0 100644 --- a/components/TableController.tsx +++ b/components/TableController.tsx @@ -64,7 +64,7 @@ export default function TableController({ return ( - + {/* A list of your recent invoices. */} @@ -110,7 +110,7 @@ export default function TableController({ ); })} - {data.length != 0 && + {/* {data.length != 0 && [...Array(5 - data.length)].map(() => { return ( ); - })} + })} */} diff --git a/components/ui/input.tsx b/components/ui/input.tsx index 5b1aeeb..72ba761 100644 --- a/components/ui/input.tsx +++ b/components/ui/input.tsx @@ -13,7 +13,7 @@ const Input = React.forwardRef( className={cn( `flex w-full rounded-md border border-input px-3 py-2 ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50 text-black text-opacity-50 text-xs font-normal bg-slate-200 mb-3 - 3xl:h-9 h-10 transition-all + h-10 transition-all hover:bg-slate-300 hover:cursor-pointer focus:cursor-auto focus:outline-4 focus:outline-slate-300 focus:bg-slate-200 diff --git a/package-lock.json b/package-lock.json index 87aa24e..e34a286 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "sootzani", - "version": "0.2.7", + "version": "0.2.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "sootzani", - "version": "0.2.7", + "version": "0.2.8", "dependencies": { "@hookform/resolvers": "^3.3.2", "@radix-ui/react-alert-dialog": "^1.0.5", diff --git a/package.json b/package.json index 6642c94..c3ea196 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sootzani", - "version": "0.2.7", + "version": "0.2.8", "private": true, "scripts": { "dev": "next dev", diff --git a/utils/inspectorApi.ts b/utils/inspectorApi.ts index 5de3078..5e1bf29 100644 --- a/utils/inspectorApi.ts +++ b/utils/inspectorApi.ts @@ -21,7 +21,7 @@ export async function getComplaintsList({ states = 0, TrackingNumber, PageNumber = 1, - PageSize = 5, + PageSize = 10, }: { states: number; TrackingNumber?: string;
لیست شکایت ها