diff --git a/app/components/Landing.tsx b/app/components/Landing.tsx
index 5cccf6c..5b914a1 100644
--- a/app/components/Landing.tsx
+++ b/app/components/Landing.tsx
@@ -14,7 +14,7 @@ import Footer from "@/components/Footer";
import { Swiper, SwiperSlide } from "swiper/react";
// Import Swiper styles
import "swiper/css";
-import 'swiper/css/navigation';
+import "swiper/css/navigation";
// import required modules
import { Autoplay, Navigation } from "swiper/modules";
import { sliderItems } from "@/constants";
@@ -74,7 +74,7 @@ export default function Landing() {
pagination={{
clickable: true,
}}
- modules={[Autoplay , Navigation]}
+ modules={[Autoplay, Navigation]}
className="mySwiper w-full h-full"
>
{data?.length > 0 ? (
@@ -148,6 +148,9 @@ export default function Landing() {
if (index == 0) {
localStorage.setItem("unknown", "true");
}
+ if (item.id == 2) {
+ localStorage.removeItemItem("unknown");
+ }
}}
>
diff --git a/components/CitizenLogin.tsx b/components/CitizenLogin.tsx
index 199f3a3..835d7f0 100644
--- a/components/CitizenLogin.tsx
+++ b/components/CitizenLogin.tsx
@@ -59,6 +59,7 @@ export default function CitizenLogin() {
localStorage.setItem("verificationToken", res);
},
onError: (err: any | string) => {
+ refetch();
toast(<>{err.response.data.detail}>, {
className: "!bg-red-500 !text-white",
});
@@ -77,7 +78,6 @@ export default function CitizenLogin() {
value: data.captcha,
},
};
- refetch();
loginMutation.mutateAsync(payload);
saveData({
phoneNumber: data.phoneNumber,
diff --git a/components/ComplainsDetails.tsx b/components/ComplainsDetails.tsx
index a23865e..6b8cef8 100644
--- a/components/ComplainsDetails.tsx
+++ b/components/ComplainsDetails.tsx
@@ -42,7 +42,7 @@ export default function ComplainsDetails({
const [open, setOpen] = useState(
state == "FollowResult" ? false : true
);
- const [password, setPassword] = useState(true);
+ const [password, setPassword] = useState(null);
const router = useRouter();
const storeData = useData((state) => state.data);
let data;
@@ -128,7 +128,7 @@ export default function ComplainsDetails({
const payload = { ...storeData, password: password };
getComplaintMutation.mutate({ Data: payload });
};
-
+
useEffect(() => {
useData.persist.rehydrate();
if (state == "FollowResult") {
@@ -136,11 +136,17 @@ export default function ComplainsDetails({
}
}, []);
- if (getComplaintMutation.isSuccess && !Data) {
- data = getComplaintMutation.data;
- } else {
- data = Data;
- }
+ useEffect(() => {
+ const tk = localStorage.getItem("trackingNumber2");
+ const pw = localStorage.getItem("password2");
+ if (tk && pw) {
+ getComplaintMutation.mutate({
+ Data: { trackingNumber: tk, password: pw },
+ });
+ }
+ }, []);
+
+ data = getComplaintMutation?.data;
return (
<>
@@ -178,9 +184,9 @@ export default function ComplainsDetails({
- {data ? (
+ {getComplaintMutation.data && !getComplaintMutation.isPending ? (
<>
- {state !== "FollowResult" && (
+ {/* {state !== "FollowResult" && (
- )}
+ )} */}
{/* Editt */}
@@ -202,17 +208,20 @@ export default function ComplainsDetails({
انجام عملیات
getComplaintMutation.mutate(storeData)}
+ updateData={(payload) =>
+ getComplaintMutation.mutate({ Data: payload })
+ }
role={role}
complaintData={data}
+ password={password}
/>
{/* 2 */}
-
- {data.user == null ? (
+
+ {data?.user == null ? (
<>
diff --git a/components/FollowResult.tsx b/components/FollowResult.tsx
index 0d8ea6d..eb639c3 100644
--- a/components/FollowResult.tsx
+++ b/components/FollowResult.tsx
@@ -61,31 +61,26 @@ export default function FollowResult() {
},
});
-
const printableContent = "This is the content to be printed.";
return (
<>
- {complaintPrintMutation?.data ? (
- <>
-
-
- >
- ) : (
- ""
- )}
+ <>
+ {/*
*/}
+
+ >
>
);
diff --git a/components/InspectorOperations.tsx b/components/InspectorOperations.tsx
index 000b69c..8337b33 100644
--- a/components/InspectorOperations.tsx
+++ b/components/InspectorOperations.tsx
@@ -38,22 +38,17 @@ export default function InspectorOperations({
complaintData,
role,
updateData,
+ password,
}: {
complaintData: any;
role: string;
- updateData: () => any;
+ updateData: (data: any) => any;
+ password?: string;
}) {
const FormSchema = z.object({
- text: z
- .string({ required_error: "لطفا متن خود را وارد نمایید." })
- .min(8, {
- message: "Bio must be at least 8 characters.",
- })
- .max(260, {
- message: "Bio must not be longer than 30 characters.",
- }),
+ text: z.string({ required_error: "لطفا متن خود را وارد نمایید." }),
operation: z.string({
- required_error: "Please select an email to display.",
+ required_error: "لطفا نوع عملیات را انتخاب نمایید.",
}),
media: z
.custom
((val) => val instanceof FileList, "Required")
@@ -61,12 +56,7 @@ export default function InspectorOperations({
.refine((files) => files.length <= 5, `Maximum of 5 File are allowed.`)
.nullish(),
});
- const password = useData((state) => state.data.password);
const possibleOperations = complaintData?.possibleOperationsWithDescription;
- const selectOptions = Operations.filter((item, index) =>
- possibleOperations.includes(index)
- );
-
const form = useForm>({
resolver: zodResolver(FormSchema),
defaultValues: {
@@ -79,12 +69,19 @@ export default function InspectorOperations({
const OperationMutation = useMutation({
mutationKey: ["Operation"],
- mutationFn:
- role == "Inspector" ? OperateByInspector : postComplaintsDetails,
+ mutationFn: postComplaintsDetails,
onSuccess: (res) => {
toast("عملیات شما با موفقیت انجام شد. ", {
className: "!bg-green-500 !text-white",
});
+ console.log(complaintData.trackingNumber);
+ console.log(localStorage.getItem("password2") as string);
+ updateData({
+ trackingNumber: complaintData.trackingNumber,
+ password: password
+ ? password
+ : (localStorage.getItem("password2") as string),
+ });
},
onError: (err: any | string) => {
toast(<>{err.response.data.detail}>, {
@@ -98,7 +95,10 @@ export default function InspectorOperations({
formData.append("text", data.text);
formData.append("trackingNumber", complaintData.trackingNumber);
formData.append("Operation", data.operation);
- formData.append("password", localStorage.getItem("password2") as string);
+ formData.append(
+ "password",
+ password ? password : (localStorage.getItem("password2") as string)
+ );
if (data?.media && data?.media?.length > 0) {
for (let i = 0; i < data.media.length; i++) {
formData.append("Medias", data.media[i]);
diff --git a/components/Pagination.tsx b/components/Pagination.tsx
index 5703e4e..7d865db 100644
--- a/components/Pagination.tsx
+++ b/components/Pagination.tsx
@@ -7,49 +7,38 @@ import { twMerge } from "tailwind-merge";
const items = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14];
export default function Pagination({
- itemsPerPage,
+ TotalPages,
+ currentPage,
+ PageSize,
Page,
countPage,
length,
}: {
- itemsPerPage?: any;
+ TotalPages?: any;
+ currentPage?: any;
+ PageSize?: number;
Page?: any;
countPage?: any;
length?: any;
}) {
- // Here we use item offsets; we could also use page offsets
- // following the API or data you're working with.
- const [itemOffset, setItemOffset] = useState(0);
-
- // Simulate fetching items from another resources.
- // (This could be items from props; or items loaded in a local state
- // from an API endpoint with useEffect and useState)
- const endOffset = itemOffset + itemsPerPage;
-
- const currentItems = items.slice(itemOffset, endOffset);
- const pageCount = Math.ceil(items.length / itemsPerPage);
-
- // Invoke when user click to request another page.
const handlePageClick = (event: any) => {
- const newOffset = (event.selected * itemsPerPage) % items.length;
- setItemOffset(newOffset);
Page(event.selected);
};
-
+
return (
<>
- {/* */}
console.log(e)}
nextLabel={}
onPageChange={handlePageClick}
pageRangeDisplayed={3}
- pageCount={Math.ceil(countPage / 5)}
+ forcePage={currentPage}
+ pageCount={TotalPages}
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 text-blue mt-5 fixed 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/ProfileDropDown.tsx b/components/ProfileDropDown.tsx
index 499b464..3f36143 100644
--- a/components/ProfileDropDown.tsx
+++ b/components/ProfileDropDown.tsx
@@ -63,6 +63,8 @@ export default function ProfileDropDown() {
saveToken(false);
deleteCookie("Sootzani_Refresh_Token");
deleteCookie("Sootzani_Token");
+ localStorage.removeItem("password2");
+ localStorage.removeItem("trackingNumber2");
router.push("/");
};
const saveToken = useToken((state) => state.saveToken);
@@ -71,7 +73,9 @@ export default function ProfileDropDown() {
diff --git a/components/RequestStep2.tsx b/components/RequestStep2.tsx
index c9355e1..ce6f321 100644
--- a/components/RequestStep2.tsx
+++ b/components/RequestStep2.tsx
@@ -116,9 +116,11 @@ export default function RequestStep2() {
onSuccess: (res) => {
localStorage.setItem("trackingNumber", res.trackingNumber);
localStorage.setItem("password", res.password);
+ localStorage.removeItem("unknown");
router.push("/RequestResult");
},
onError: (err: any | string) => {
+ refetch();
toast(<>{err.response.data.detail}>, {
className: "!bg-red-500 !text-white",
});
@@ -133,9 +135,11 @@ export default function RequestStep2() {
localStorage.setItem("password", res.password);
localStorage.setItem("registeredAt", res.registeredAt);
localStorage.removeItem("authorized");
+ localStorage.removeItem("unknown");
router.push("/RequestResult");
},
onError: (err: any | string) => {
+ refetch();
toast(<>{err.response.data.detail}>, {
className: "!bg-red-500 !text-white",
});
@@ -204,7 +208,6 @@ export default function RequestStep2() {
});
}
- refetch();
resetField("Title");
resetField("Text");
resetField("Medias");
@@ -373,7 +376,6 @@ export default function RequestStep2() {
const files: File[] = Array.from(uploadFile);
// 2. now you can use array methods on files;
filenames = files.map((file) => file?.name);
-
}
return (
diff --git a/components/TabController.tsx b/components/TabController.tsx
index 881e1df..4140c6b 100644
--- a/components/TabController.tsx
+++ b/components/TabController.tsx
@@ -29,6 +29,9 @@ export default function TabController() {
const [selectedFile, setSelectedFile] = useState(null);
const [page, setPage] = useState(1);
const [totalCount, setTotalCount] = useState(0);
+ const [currentPage, setCurrentPage] = useState(0);
+ const [pageSize, setPageSize] = useState(0);
+ const [totalPages, setTotalPages] = useState(0);
const router = useRouter();
const [search, setSearch] = useState(null);
@@ -46,6 +49,9 @@ export default function TabController() {
if (data) {
const headersData = JSON.parse(data.headers["x-pagination"]);
setTotalCount(headersData.TotalCount);
+ setTotalPages(headersData.TotalPages);
+ setCurrentPage(headersData.CurrentPage);
+ setPageSize(headersData.PageSize);
}
}, [data]);
@@ -55,11 +61,15 @@ export default function TabController() {
return (
-
-
-
+
setPage(num + 1)}
/>
diff --git a/components/TableController.tsx b/components/TableController.tsx
index ab54f11..f00f305 100644
--- a/components/TableController.tsx
+++ b/components/TableController.tsx
@@ -71,7 +71,7 @@ export default function TableController({ data }: { data: Complaint[] }) {
return (
-
+
{/* A list of your recent invoices. */}
@@ -122,7 +122,6 @@ export default function TableController({ data }: { data: Complaint[] }) {
: "-"}
{/* */}
-
);
})}
diff --git a/package-lock.json b/package-lock.json
index 67e8a21..b08ba19 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "sootzani",
- "version": "0.1.9",
+ "version": "0.1.10",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sootzani",
- "version": "0.1.9",
+ "version": "0.1.10",
"dependencies": {
"@hookform/resolvers": "^3.3.2",
"@radix-ui/react-alert-dialog": "^1.0.5",
diff --git a/package.json b/package.json
index 439a5d7..9fa7219 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "sootzani",
- "version": "0.1.9",
+ "version": "0.1.10",
"private": true,
"scripts": {
"dev": "next dev",
diff --git a/utils/citizenApi.ts b/utils/citizenApi.ts
index 2786237..1465766 100644
--- a/utils/citizenApi.ts
+++ b/utils/citizenApi.ts
@@ -48,7 +48,7 @@ export async function getComplaints({
states = 0,
TrackingNumber,
PageNumber = 1,
- PageSize = 5,
+ PageSize = 10,
}: {
states?: number;
TrackingNumber?: string;