diff --git a/components/CallUs.tsx b/components/CallUs.tsx index a380618..52f2f75 100644 --- a/components/CallUs.tsx +++ b/components/CallUs.tsx @@ -14,16 +14,21 @@ import { useQuery } from "@tanstack/react-query"; export default function CallUs(props: any) { const { position, zoom } = props; - + const { data, isLoading, isError, refetch } = useQuery({ + queryKey: ["WebContents", "CallUs"], + queryFn: () => getSingleWebContents("CallUs"), + refetchOnWindowFocus: false, + }); + console.log(data); + const fetchedContent = data?.content || ""; return ( -
+
- {/*
*/} - {/* */} + {/* */} {/*
*/} - -
+
+ {/*
{callUsItems.map((item) => { return ( @@ -59,7 +64,7 @@ export default function CallUs(props: any) { ); })}
-
+
*/}
); diff --git a/components/ComplainsDetails.tsx b/components/ComplainsDetails.tsx index 6b8cef8..b41cf42 100644 --- a/components/ComplainsDetails.tsx +++ b/components/ComplainsDetails.tsx @@ -116,6 +116,8 @@ export default function ComplainsDetails({ mutationFn: postComplaintTracking, onSuccess: (res) => { setOpen(false); + localStorage.removeItem("trackingNumber2"); + localStorage.removeItem("password2"); }, onError: (err: any | string) => { toast(<>{err.response.data.detail}, { @@ -143,7 +145,7 @@ export default function ComplainsDetails({ getComplaintMutation.mutate({ Data: { trackingNumber: tk, password: pw }, }); - } + } }, []); data = getComplaintMutation?.data; diff --git a/components/FollowResult.tsx b/components/FollowResult.tsx index eb639c3..1f978da 100644 --- a/components/FollowResult.tsx +++ b/components/FollowResult.tsx @@ -78,7 +78,6 @@ export default function FollowResult() {
diff --git a/components/Navbar.tsx b/components/Navbar.tsx index 90719b2..9936c71 100644 --- a/components/Navbar.tsx +++ b/components/Navbar.tsx @@ -3,13 +3,13 @@ import React, { useEffect, useState } from "react"; import { Input } from "./ui/input"; import Image from "next/image"; -import { menuItems } from "@/constants"; +import { authorizedMenuItems, menuItems } from "@/constants"; import Link from "next/link"; import Login from "./Login"; import { Button } from "./ui/button"; import { usePathname } from "next/navigation"; import TopNav from "./TopNav"; -import { isAuthorized } from "@/lib/utils"; +import { cn, isAuthorized } from "@/lib/utils"; import useToken from "@/store/useToken"; import { DropdownMenu } from "@radix-ui/react-dropdown-menu"; import ProfileDropDown from "./ProfileDropDown"; @@ -30,7 +30,7 @@ export default function Navbar() { setAuth(false); } }, [isAuth, token]); - + console.log(pathname); return (
{/* */} @@ -53,36 +53,73 @@ export default function Navbar() { className="fixed z-[100] left-0 shadow-4xl right-0 top-[4rem] p-5 bg-white border-b-2 shadow-md" >
    - {menuItems.map((item, idx, array) => { - // const { Icon } = item; - const lastItem = array.length - 1; - return ( - - setOpen((prev) => !prev)} - className={`flex items-center justify-between w-full p-3 rounded-xl text-white + {auth ? ( + <> + {authorizedMenuItems.map((item, idx, array) => { + // const { Icon } = item; + const lastItem = array.length - 1; + return ( + + setOpen((prev) => !prev)} + className={`flex items-center justify-between w-full p-3 rounded-xl text-white ${lastItem === idx ? "bg-yellow" : "bg-blue"} `} - href={item.href} - > - - {item.name} - - {/* */} - - - ); - })} + href={item.href} + > + + {item.name} + + {/* */} + + + ); + })} + + ) : ( + <> + {menuItems.map((item, idx, array) => { + // const { Icon } = item; + const lastItem = array.length - 1; + return ( + + setOpen((prev) => !prev)} + className={`flex items-center justify-between w-full p-3 rounded-xl text-white + ${lastItem === idx ? "bg-yellow" : "bg-blue"} `} + href={item.href} + > + + {item.name} + + {/* */} + + + ); + })} + + )}
)} @@ -107,17 +144,45 @@ export default function Navbar() {
- {menuItems.map((item, index, array) => { - if (array.length - 1 !== index) { - return ( - -
{item.name}
- - ); - } else { - return <>; - } - })} + {auth ? ( + <> + {authorizedMenuItems.map((item, index, array) => { + return ( + +
{item.name}
+ + ); + })} + + ) : ( + <> + {menuItems.map((item, index, array) => { + if (array.length - 1 !== index) { + return ( + +
+ {item.name} +
+ + ); + } + })} + + )}
{auth ? ( diff --git a/components/News.tsx b/components/News.tsx index b8e491d..2def7b8 100644 --- a/components/News.tsx +++ b/components/News.tsx @@ -6,6 +6,7 @@ import { useQuery } from "@tanstack/react-query"; import Image from "next/image"; import Link from "next/link"; import { convertFullTime } from "@/lib/utils"; +import { useRouter } from "next/navigation"; interface News { id: string; image: { @@ -27,11 +28,11 @@ interface News { } export default function News() { + const router = useRouter(); const { data, isLoading, isError, refetch } = useQuery({ queryKey: ["News"], queryFn: () => getNews(), }); - return (
@@ -44,8 +45,9 @@ export default function News() { return (
router.push(`/News/${item.id}`)} className="w-full lg:w-[48%] border rounded-lg flex flex-row shadow-md hover:shadow-none transition-all - h-[20em] sm:h-[15em] max-sm:flex-col max-sm:gap-[3px]" + h-[20em] sm:h-[15em] max-sm:flex-col max-sm:gap-[3px] cursor-pointer" >
state.saveToken); return ( - - diff --git a/components/TableController.tsx b/components/TableController.tsx index f00f305..e652d26 100644 --- a/components/TableController.tsx +++ b/components/TableController.tsx @@ -21,7 +21,7 @@ import { } from "@/components/ui/dialog"; import { ControllerTableItems } from "@/constants"; import Link from "next/link"; -import { Decrypt, convertDate } from "@/lib/utils"; +import { Decrypt, convertDate, convertFullTime } from "@/lib/utils"; import useData from "@/store/useData"; import { Label } from "./ui/label"; import { Input } from "./ui/input"; @@ -76,8 +76,9 @@ export default function TableController({ data }: { data: Complaint[] }) { ردیف - تاریخ کد پیگیری + تاریخ ثبت + تاریخ آخرین تغییر موضوع وضعیت دستگاه مربوطه @@ -104,19 +105,22 @@ export default function TableController({ data }: { data: Complaint[] }) { {index + 1} + {item.trackingNumber} - {convertDate(item.registeredAt)} + {convertFullTime(item.registeredAt)} - {item.trackingNumber} + {convertFullTime(item.lastChanged)} + + {item?.title ? item.title : "-"} - + {item?.statusWithDescription ? item.statusWithDescription.description : "-"} - + {item?.complaintOrganization ? item?.complaintOrganization.title : "-"} diff --git a/constants/index.tsx b/constants/index.tsx index 95b5011..8fb2875 100644 --- a/constants/index.tsx +++ b/constants/index.tsx @@ -5,12 +5,20 @@ import bgimg from "../public/img/bg.png"; export const menuItems = [ { id: 1, name: "صفحه اصلی", href: "/" }, - { id: 2, name: "اخبار", href: "/News" }, - { id: 3, name: "تماس با ما", href: "/CallUs" }, - { id: 4, name: "پیگیری", href: "/FollowUp" }, + { id: 2, name: "پیگیری", href: "/FollowUp" }, + { id: 3, name: "اخبار", href: "/News" }, + { id: 4, name: "تماس با ما", href: "/CallUs" }, { id: 5, name: "ورود به پنل کاربری", href: "/Login" }, ]; +export const authorizedMenuItems = [ + { id: 1, name: "صفحه اصلی", href: "/" }, + { id: 2, name: "پیگیری", href: "/FollowUp" }, + { id: 3, name: "درخواست های من", href: "/Account/Complaints" }, + { id: 4, name: "اخبار", href: "/News" }, + { id: 5, name: "تماس با ما", href: "/CallUs" }, +]; + export const sliderItems = [ { id: 1, img: bgimg }, { id: 2, img: bgimg },