Bugs Fixed + Cleaned Code

Kahdooei
yasaman 2024-01-28 15:19:22 +03:30
parent b11a60dd1b
commit 4763e8afbd
21 changed files with 79 additions and 81 deletions

View File

@ -14,9 +14,9 @@ import Footer from "@/components/Footer";
import { Swiper, SwiperSlide } from "swiper/react"; import { Swiper, SwiperSlide } from "swiper/react";
// Import Swiper styles // Import Swiper styles
import "swiper/css"; import "swiper/css";
import "swiper/css/pagination"; import 'swiper/css/navigation';
// import required modules // import required modules
import { Autoplay, Pagination, Navigation } from "swiper/modules"; import { Autoplay, Navigation } from "swiper/modules";
import { sliderItems } from "@/constants"; import { sliderItems } from "@/constants";
import { useQuery } from "@tanstack/react-query"; import { useQuery } from "@tanstack/react-query";
import { getSliders, getNews } from "@/utils/commonApi"; import { getSliders, getNews } from "@/utils/commonApi";
@ -47,7 +47,6 @@ export default function Landing() {
queryFn: () => getSliders(), queryFn: () => getSliders(),
refetchOnWindowFocus: false, refetchOnWindowFocus: false,
}); });
console.log(data);
const { const {
data: NewsData, data: NewsData,
@ -66,6 +65,7 @@ export default function Landing() {
<Swiper <Swiper
slidesPerView={1} slidesPerView={1}
spaceBetween={0} spaceBetween={0}
navigation={true}
autoplay={{ autoplay={{
delay: 2500, delay: 2500,
disableOnInteraction: false, disableOnInteraction: false,
@ -74,13 +74,12 @@ export default function Landing() {
pagination={{ pagination={{
clickable: true, clickable: true,
}} }}
modules={[Autoplay]} modules={[Autoplay , Navigation]}
className="mySwiper w-full h-full" className="mySwiper w-full h-full"
> >
{data?.length > 0 ? ( {data?.length > 0 ? (
<> <>
{data.map((item: any, index: number) => { {data.map((item: any, index: number) => {
console.log(item);
return ( return (
<SwiperSlide key={item.id}> <SwiperSlide key={item.id}>
<Image <Image

View File

@ -70,6 +70,7 @@
* { * {
@apply border-border; @apply border-border;
} }
body { body {
@apply bg-background text-foreground; @apply bg-background text-foreground;
} }
@ -91,7 +92,7 @@
} }
.printPage{ .printPage {
background-color: antiquewhite; background-color: antiquewhite;
color: black; color: black;
direction: rtl; direction: rtl;
@ -101,6 +102,34 @@
border: 2px solid black; border: 2px solid black;
} }
.footer span{ .footer span {
color: white !important; color: white !important;
} }
.swiper-button-prev,
.swiper-button-next {
width: 2em !important;
height: 2em !important;
background-color: rgba(255, 255, 255, 0.886);
color: blue !important;
/*font-size: 10px;
*/border-radius: 8px;
}
/* Optional: Adjust the position of the navigation buttons */
.swiper-button-prev {
right: 1em !important;
left: auto !important;
/* Set your desired left position */
}
.swiper-button-next {
left: 2em !important;
right: auto !important;
/* Set your desired right position */
}
.swiper-button-prev::after ,
.swiper-button-next::after {
font-size: 1em !important;
font-weight: 700;
}

View File

@ -12,7 +12,6 @@ export default function AboutUs() {
queryFn: () => getSingleWebContents(title), queryFn: () => getSingleWebContents(title),
refetchOnWindowFocus: false, refetchOnWindowFocus: false,
}); });
console.log(data);
useEffect(() => { useEffect(() => {
refetch(); refetch();

View File

@ -54,13 +54,11 @@ export default function CitizenLogin() {
const loginMutation = useMutation({ const loginMutation = useMutation({
mutationFn: logisterCitizen, mutationFn: logisterCitizen,
onSuccess: (res: any | string) => { onSuccess: (res: any | string) => {
console.log(res);
router.push("/Verify"); router.push("/Verify");
localStorage.setItem("VerifyRole", "citizen"); localStorage.setItem("VerifyRole", "citizen");
localStorage.setItem("verificationToken", res); localStorage.setItem("verificationToken", res);
}, },
onError: (err: any | string) => { onError: (err: any | string) => {
console.log(err);
toast(<>{err.response.data.detail}</>, { toast(<>{err.response.data.detail}</>, {
className: "!bg-red-500 !text-white", className: "!bg-red-500 !text-white",
}); });

View File

@ -128,7 +128,7 @@ export default function ComplainsDetails({
const payload = { ...storeData, password: password }; const payload = { ...storeData, password: password };
getComplaintMutation.mutate({ Data: payload }); getComplaintMutation.mutate({ Data: payload });
}; };
console.log(storeData);
useEffect(() => { useEffect(() => {
useData.persist.rehydrate(); useData.persist.rehydrate();
if (state == "FollowResult") { if (state == "FollowResult") {

View File

@ -45,11 +45,6 @@ export default function FollowUp() {
onSuccess: (res) => { onSuccess: (res) => {
const result = res; const result = res;
console.log(res);
console.log(result);
// alert("Success");
console.log("Success FollowUp");
// router.push("/FollowResult"); // router.push("/FollowResult");
router.push("/FollowResult", { data: JSON.stringify(result) }); router.push("/FollowResult", { data: JSON.stringify(result) });
@ -79,8 +74,6 @@ export default function FollowUp() {
// ), // ),
// }); // });
console.log(data);
localStorage.setItem("trackingNumber2", data.trackingNumber); localStorage.setItem("trackingNumber2", data.trackingNumber);
localStorage.setItem("password2", data.password); localStorage.setItem("password2", data.password);

View File

@ -15,7 +15,7 @@ export default function Footer() {
refetchOnWindowFocus: false, refetchOnWindowFocus: false,
}); });
const fetchedContent = data?.content || ""; const fetchedContent = data?.content || "";
console.log(data);
return ( return (
// <div classNameName="flex justify-center items-center w-full bg-blue "> // <div classNameName="flex justify-center items-center w-full bg-blue ">

View File

@ -94,7 +94,6 @@ export default function InspectorOperations({
}); });
function onSubmit(data: z.infer<typeof FormSchema>) { function onSubmit(data: z.infer<typeof FormSchema>) {
console.log(data);
const formData = new FormData(); const formData = new FormData();
formData.append("text", data.text); formData.append("text", data.text);
formData.append("trackingNumber", complaintData.trackingNumber); formData.append("trackingNumber", complaintData.trackingNumber);
@ -122,6 +121,8 @@ export default function InspectorOperations({
placeholder="متن خود را وارد نمایید" placeholder="متن خود را وارد نمایید"
className="resize-none bg-white lg:min-h-[20em]" className="resize-none bg-white lg:min-h-[20em]"
{...field} {...field}
// disabled={possibleOperations.length == 0}
readOnly={possibleOperations.length == 0}
/> />
</FormControl> </FormControl>
{/* <FormDescription> {/* <FormDescription>
@ -147,10 +148,10 @@ export default function InspectorOperations({
type="file" type="file"
onChange={(e) => { onChange={(e) => {
field.onChange(e.target.files ? e.target.files : null); field.onChange(e.target.files ? e.target.files : null);
console.log(e.target.files);
}} }}
multiple multiple
className="bg-white " className="bg-white "
disabled={possibleOperations.length == 0}
/> />
</FormControl> </FormControl>
<FormMessage /> <FormMessage />

View File

@ -62,7 +62,6 @@ export default function Login() {
onSuccess: (res) => {}, onSuccess: (res) => {},
onError: (err: any) => { onError: (err: any) => {
if (err.response.status == 428) { if (err.response.status == 428) {
console.log(useData);
router.push("/Verify"); router.push("/Verify");
} }
}, },

View File

@ -12,7 +12,6 @@ export default function NavbarPanel() {
setRole(userRole); setRole(userRole);
}, []); }, []);
console.log(role);
const menus = { const menus = {
Admin: AdminMenuItems, Admin: AdminMenuItems,
Inspector: ControllerMenuItems, Inspector: ControllerMenuItems,

View File

@ -31,7 +31,7 @@ export default function News() {
queryKey: ["News"], queryKey: ["News"],
queryFn: () => getNews(), queryFn: () => getNews(),
}); });
console.log(data);
return ( return (
<div className="bg-white dark:bg-gray-900 pt-8 3xl:w-[60%] w-[80%] "> <div className="bg-white dark:bg-gray-900 pt-8 3xl:w-[60%] w-[80%] ">

View File

@ -25,23 +25,17 @@ export default function Pagination({
// (This could be items from props; or items loaded in a local state // (This could be items from props; or items loaded in a local state
// from an API endpoint with useEffect and useState) // from an API endpoint with useEffect and useState)
const endOffset = itemOffset + itemsPerPage; const endOffset = itemOffset + itemsPerPage;
// console.log(`Loading items from ${itemOffset} to ${endOffset}`);
const currentItems = items.slice(itemOffset, endOffset); const currentItems = items.slice(itemOffset, endOffset);
const pageCount = Math.ceil(items.length / itemsPerPage); const pageCount = Math.ceil(items.length / itemsPerPage);
// Invoke when user click to request another page. // Invoke when user click to request another page.
const handlePageClick = (event: any) => { const handlePageClick = (event: any) => {
const newOffset = (event.selected * itemsPerPage) % items.length; const newOffset = (event.selected * itemsPerPage) % items.length;
console.log(
`User requested page number ${event.selected}, which is offset ${newOffset}`
);
setItemOffset(newOffset); setItemOffset(newOffset);
// console.log(event.selected);
console.log(event);
Page(event.selected); Page(event.selected);
}; };
console.log(countPage);
// console.log(pageCount, "1111");
return ( return (
<> <>
{/* <Items currentItems={currentItems} /> */} {/* <Items currentItems={currentItems} /> */}
@ -55,7 +49,7 @@ export default function Pagination({
previousLabel={<MdKeyboardArrowRight className="w-5 h-5 " />} previousLabel={<MdKeyboardArrowRight className="w-5 h-5 " />}
pageClassName=" w-10 h-10 grid place-content-center rounded-lg !text-blue shadow-md" pageClassName=" w-10 h-10 grid place-content-center rounded-lg !text-blue shadow-md"
className={twMerge( className={twMerge(
" flex flex-wrap gap-3 text-sm md:text-base w-full bottom-0 rounded-md p-1 bg-white/30 backdrop-blur-lg justify-center text-blue mt-5" " 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"
)} )}
activeClassName=" bg-blue text-blue shadow-md shadow-main" activeClassName=" bg-blue text-blue shadow-md shadow-main"
activeLinkClassName=" text-white w-full p-1 h-full" activeLinkClassName=" text-white w-full p-1 h-full"

View File

@ -68,6 +68,7 @@ export default function Profile() {
toast("پروفایل شما با موفقیت ویرایش شد.", { toast("پروفایل شما با موفقیت ویرایش شد.", {
className: "!bg-green-500 !text-white", className: "!bg-green-500 !text-white",
}); });
router.push("/")
}, },
onError: (err: any | string) => { onError: (err: any | string) => {
toast(<>{err.response.data.detail}</>, { toast(<>{err.response.data.detail}</>, {
@ -88,13 +89,9 @@ export default function Profile() {
} }
}, [profileData]); }, [profileData]);
console.log(form.getValues());
function onSubmit(data: z.infer<typeof FormSchema>) { function onSubmit(data: z.infer<typeof FormSchema>) {
console.log(data);
const strNationalId = String(data.nationalId); const strNationalId = String(data.nationalId);
const payload = { ...data, nationalId: strNationalId }; const payload = { ...data, nationalId: strNationalId };
console.log(data);
editProfileMutation.mutate(payload); editProfileMutation.mutate(payload);
} }

View File

@ -70,7 +70,8 @@ export default function ProfileDropDown() {
<DropdownMenu dir="rtl"> <DropdownMenu dir="rtl">
<DropdownMenuTrigger className=" max-sm:-mr-8 max-sm:text-xs" asChild> <DropdownMenuTrigger className=" max-sm:-mr-8 max-sm:text-xs" asChild>
<Button variant="outline"> <Button variant="outline">
{profileData?.title ? profileData?.title : profileData?.userName} {/* {profileData?.title ? profileData?.title : profileData?.userName} */}
{profileData?.firstName || profileData?.lastName ? profileData?.firstName +" "+ profileData?.lastName : profileData?.userName}
</Button> </Button>
</DropdownMenuTrigger> </DropdownMenuTrigger>
<DropdownMenuContent className="w-56 sm:ml-10"> <DropdownMenuContent className="w-56 sm:ml-10">

View File

@ -44,7 +44,6 @@ export default function Result() {
queryFn: () => getSingleWebContents(title), queryFn: () => getSingleWebContents(title),
refetchOnWindowFocus: false, refetchOnWindowFocus: false,
}); });
console.log(data);
useEffect(() => { useEffect(() => {
refetch(); refetch();

View File

@ -77,7 +77,6 @@ export default function RequestStep1() {
resolver: zodResolver(FormSchema), resolver: zodResolver(FormSchema),
}); });
if (profileData?.firstName) { if (profileData?.firstName) {
console.log(111);
} }
useEffect(() => { useEffect(() => {
if (profileData) { if (profileData) {
@ -87,7 +86,6 @@ export default function RequestStep1() {
} }
}, [profileData]); }, [profileData]);
console.log(form.getValues());
function onSubmit(data: z.infer<typeof FormSchema>) { function onSubmit(data: z.infer<typeof FormSchema>) {
// toast({ // toast({
// title: "You submitted the following values:", // title: "You submitted the following values:",
@ -99,7 +97,6 @@ export default function RequestStep1() {
// }); // });
const strNationalId = String(data.nationalId); const strNationalId = String(data.nationalId);
const payload = { ...data, nationalId: strNationalId }; const payload = { ...data, nationalId: strNationalId };
console.log(data);
editProfileMutation.mutate(payload); editProfileMutation.mutate(payload);
} }

View File

@ -162,7 +162,6 @@ export default function RequestStep2() {
queryKey: ["Captcha"], queryKey: ["Captcha"],
queryFn: () => getCaptcha(), queryFn: () => getCaptcha(),
}); });
// console.log(captchaData);
const srcForImage = CaptchaData const srcForImage = CaptchaData
? URL.createObjectURL(CaptchaData.data) ? URL.createObjectURL(CaptchaData.data)
@ -367,18 +366,14 @@ export default function RequestStep2() {
render={({ field: { onChange }, ...field }) => { render={({ field: { onChange }, ...field }) => {
// Get current uploadFile value (always watched updated) // Get current uploadFile value (always watched updated)
const uploadFile = form.watch("uploadFile"); const uploadFile = form.watch("uploadFile");
{
console.log(uploadFile);
}
var filenames: string[] | undefined = undefined; var filenames: string[] | undefined = undefined;
if (uploadFile) { if (uploadFile) {
// 1. covert to File[] using Array.from // 1. covert to File[] using Array.from
const files: File[] = Array.from(uploadFile); const files: File[] = Array.from(uploadFile);
// 2. now you can use array methods on files; // 2. now you can use array methods on files;
filenames = files.map((file) => file?.name); filenames = files.map((file) => file?.name);
{
console.log(filenames);
}
} }
return ( return (

View File

@ -23,6 +23,7 @@ import useData from "@/store/useData";
import { toast } from "sonner"; import { toast } from "sonner";
import { getComplaints } from "@/utils/citizenApi"; import { getComplaints } from "@/utils/citizenApi";
import Pagination from "./Pagination"; import Pagination from "./Pagination";
import Link from "next/link";
export default function TabController() { export default function TabController() {
const saveData = useData((state) => state.saveData); const saveData = useData((state) => state.saveData);
const [selectedFile, setSelectedFile] = useState<any>(null); const [selectedFile, setSelectedFile] = useState<any>(null);
@ -41,7 +42,6 @@ export default function TabController() {
refetchOnWindowFocus: false, refetchOnWindowFocus: false,
}); });
console.log(data);
useEffect(() => { useEffect(() => {
if (data) { if (data) {
const headersData = JSON.parse(data.headers["x-pagination"]); const headersData = JSON.parse(data.headers["x-pagination"]);
@ -55,6 +55,12 @@ export default function TabController() {
return ( return (
<div className="w-[95vw] lg:w-[82vw] xl:w-[70vw] 3xl:w-[65vw] mt-16 pt-9"> <div className="w-[95vw] lg:w-[82vw] xl:w-[70vw] 3xl:w-[65vw] mt-16 pt-9">
<Link href="/RequestStep2">
<Button className=" bg-blue hover:bg-blue/90 rounded-lg max-sm:text-xs">
ثبت درخواست
</Button>
</Link>
<Search <Search
value={search} value={search}
changeValue={(data: any) => setSearch(data)} changeValue={(data: any) => setSearch(data)}

View File

@ -52,7 +52,7 @@ interface Complaint {
cipherKeyInspector: string; cipherKeyInspector: string;
} }
export default function TableController({ data }: { data: Complaint[] }) { export default function TableController({ data }: { data: Complaint[] }) {
console.log(data);
const saveData = useData((state) => state.saveData); const saveData = useData((state) => state.saveData);
const [selectedFile, setSelectedFile] = useState<any>(null); const [selectedFile, setSelectedFile] = useState<any>(null);
const [open, setOpen] = useState<boolean>(false); const [open, setOpen] = useState<boolean>(false);
@ -64,7 +64,6 @@ export default function TableController({ data }: { data: Complaint[] }) {
const contents = e?.target?.result; const contents = e?.target?.result;
// Process the contents of the file here // Process the contents of the file here
setSelectedFile(contents); setSelectedFile(contents);
console.log(contents);
}; };
reader.readAsText(file); reader.readAsText(file);

View File

@ -36,7 +36,7 @@ export default function Verify() {
localStorage.setItem("Sootzani_Role", userRole); localStorage.setItem("Sootzani_Role", userRole);
const justLogin = localStorage.getItem("Sootzani_Login_State"); const justLogin = localStorage.getItem("Sootzani_Login_State");
if (justLogin) { if (justLogin) {
router.push("/"); router.push("/Account/Complaints");
localStorage.removeItem("Sootzani_Login_State"); localStorage.removeItem("Sootzani_Login_State");
} else { } else {
router.push("/RequestStep1"); router.push("/RequestStep1");
@ -50,12 +50,10 @@ export default function Verify() {
}); });
const handelVerify = () => { const handelVerify = () => {
console.log(otp);
const payload = { const payload = {
otpToken: localStorage.getItem("verificationToken"), otpToken: localStorage.getItem("verificationToken"),
verificationCode: otp, verificationCode: otp,
}; };
console.log(userData);
CitizenVerifyMutation.mutate(payload); CitizenVerifyMutation.mutate(payload);
}; };

View File

@ -29,16 +29,11 @@ dEqG/38xFdYTFEekexcHnT/Vt1MW4/j76vBJHYWuAJU=
try { try {
const decryptor = new JSEncrypt(); const decryptor = new JSEncrypt();
decryptor.setPrivateKey(privateKey); decryptor.setPrivateKey(privateKey);
console.log(decryptor);
console.log(privateKey);
console.log(encryptedData);
const decrypted = decryptor.decrypt( const decrypted = decryptor.decrypt(
"FLjMFDdOUjeJDhBdTXjqkKDx81H6gWwXxvx0sQHTgDFiUoggMwCoJbn+eruMdjnppksh8zhm3rUPCIKeWe6SEuw1PX1MaKpDvZd7wNphKgWb6pLafTQTxsB0eLmTurYHkvtOyJkMHhdRravaEeoGSKmMeC9G2ahYpVYgobicBAU=" "FLjMFDdOUjeJDhBdTXjqkKDx81H6gWwXxvx0sQHTgDFiUoggMwCoJbn+eruMdjnppksh8zhm3rUPCIKeWe6SEuw1PX1MaKpDvZd7wNphKgWb6pLafTQTxsB0eLmTurYHkvtOyJkMHhdRravaEeoGSKmMeC9G2ahYpVYgobicBAU="
); );
console.log(decrypted);
setDecryptedData(decrypted); setDecryptedData(decrypted);
} catch (error) { } catch (error) {
console.log(error);
setError(error); setError(error);
} }
}, [encryptedData]); }, [encryptedData]);