Compare commits
8 Commits
4763e8afbd
...
d7e8b21fad
| Author | SHA1 | Date |
|---|---|---|
|
|
d7e8b21fad | |
|
|
3e79297afc | |
|
|
4397e5141e | |
|
|
13fafbf9a8 | |
|
|
525cd00055 | |
|
|
8e66dada93 | |
|
|
e04ef37a75 | |
|
|
e71f4b92dc |
2
.env
2
.env
|
|
@ -1 +1 @@
|
||||||
NEXT_PUBLIC_BASE_URL_APP="https://sootzaniapi.shetabdahi.ir/"
|
NEXT_PUBLIC_BASE_URL_APP="https://oyoonapi.yazd.ir/"
|
||||||
|
|
@ -14,7 +14,7 @@ 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/navigation';
|
import "swiper/css/navigation";
|
||||||
// import required modules
|
// import required modules
|
||||||
import { Autoplay, Navigation } from "swiper/modules";
|
import { Autoplay, Navigation } from "swiper/modules";
|
||||||
import { sliderItems } from "@/constants";
|
import { sliderItems } from "@/constants";
|
||||||
|
|
@ -74,7 +74,7 @@ export default function Landing() {
|
||||||
pagination={{
|
pagination={{
|
||||||
clickable: true,
|
clickable: true,
|
||||||
}}
|
}}
|
||||||
modules={[Autoplay , Navigation]}
|
modules={[Autoplay, Navigation]}
|
||||||
className="mySwiper w-full h-full"
|
className="mySwiper w-full h-full"
|
||||||
>
|
>
|
||||||
{data?.length > 0 ? (
|
{data?.length > 0 ? (
|
||||||
|
|
@ -148,6 +148,9 @@ export default function Landing() {
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
localStorage.setItem("unknown", "true");
|
localStorage.setItem("unknown", "true");
|
||||||
}
|
}
|
||||||
|
if (item.id == 2) {
|
||||||
|
localStorage.removeItemItem("unknown");
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<p className="text-xs text-center font-medium text-gray hidden group-hover:flex group-hover:text-white">
|
<p className="text-xs text-center font-medium text-gray hidden group-hover:flex group-hover:text-white">
|
||||||
|
|
|
||||||
|
|
@ -14,16 +14,21 @@ import { useQuery } from "@tanstack/react-query";
|
||||||
|
|
||||||
export default function CallUs(props: any) {
|
export default function CallUs(props: any) {
|
||||||
const { position, zoom } = props;
|
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 (
|
return (
|
||||||
<div className="bg-white dark:bg-gray-900 w-screen">
|
<div className="bg-white dark:bg-gray-900 pt-8 3xl:w-[60%] w-[80%] ">
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
|
|
||||||
{/* <div className="w-full mt-6"> */}
|
{/* <div className="w-full mt-6"> */}
|
||||||
{/* <Map /> */}
|
{/* <Map /> */}
|
||||||
{/* </div> */}
|
{/* </div> */}
|
||||||
|
<div dangerouslySetInnerHTML={{ __html: fetchedContent }} />
|
||||||
<div className="container flex items-center h-[90vh]">
|
{/* <div className="container flex items-center h-[90vh]">
|
||||||
<div className="grid gap-8 md:gap-0 grid-cols-1 md:grid-cols-2 md:h-[40vh] h-full w-full lg:px-32 xl:px-52 md:py-8 py-12">
|
<div className="grid gap-8 md:gap-0 grid-cols-1 md:grid-cols-2 md:h-[40vh] h-full w-full lg:px-32 xl:px-52 md:py-8 py-12">
|
||||||
{callUsItems.map((item) => {
|
{callUsItems.map((item) => {
|
||||||
return (
|
return (
|
||||||
|
|
@ -59,7 +64,7 @@ export default function CallUs(props: any) {
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div> */}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ export default function CitizenLogin() {
|
||||||
localStorage.setItem("verificationToken", res);
|
localStorage.setItem("verificationToken", res);
|
||||||
},
|
},
|
||||||
onError: (err: any | string) => {
|
onError: (err: any | string) => {
|
||||||
|
refetch();
|
||||||
toast(<>{err.response.data.detail}</>, {
|
toast(<>{err.response.data.detail}</>, {
|
||||||
className: "!bg-red-500 !text-white",
|
className: "!bg-red-500 !text-white",
|
||||||
});
|
});
|
||||||
|
|
@ -77,7 +78,6 @@ export default function CitizenLogin() {
|
||||||
value: data.captcha,
|
value: data.captcha,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
refetch();
|
|
||||||
loginMutation.mutateAsync(payload);
|
loginMutation.mutateAsync(payload);
|
||||||
saveData({
|
saveData({
|
||||||
phoneNumber: data.phoneNumber,
|
phoneNumber: data.phoneNumber,
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ export default function ComplainsDetails({
|
||||||
const [open, setOpen] = useState<boolean>(
|
const [open, setOpen] = useState<boolean>(
|
||||||
state == "FollowResult" ? false : true
|
state == "FollowResult" ? false : true
|
||||||
);
|
);
|
||||||
const [password, setPassword] = useState<any>(true);
|
const [password, setPassword] = useState<any>(null);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const storeData = useData((state) => state.data);
|
const storeData = useData((state) => state.data);
|
||||||
let data;
|
let data;
|
||||||
|
|
@ -116,6 +116,8 @@ export default function ComplainsDetails({
|
||||||
mutationFn: postComplaintTracking,
|
mutationFn: postComplaintTracking,
|
||||||
onSuccess: (res) => {
|
onSuccess: (res) => {
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
|
localStorage.removeItem("trackingNumber2");
|
||||||
|
localStorage.removeItem("password2");
|
||||||
},
|
},
|
||||||
onError: (err: any | string) => {
|
onError: (err: any | string) => {
|
||||||
toast(<>{err.response.data.detail}</>, {
|
toast(<>{err.response.data.detail}</>, {
|
||||||
|
|
@ -136,11 +138,17 @@ export default function ComplainsDetails({
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
if (getComplaintMutation.isSuccess && !Data) {
|
useEffect(() => {
|
||||||
data = getComplaintMutation.data;
|
const tk = localStorage.getItem("trackingNumber2");
|
||||||
} else {
|
const pw = localStorage.getItem("password2");
|
||||||
data = Data;
|
if (tk && pw) {
|
||||||
}
|
getComplaintMutation.mutate({
|
||||||
|
Data: { trackingNumber: tk, password: pw },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
data = getComplaintMutation?.data;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
@ -178,9 +186,9 @@ export default function ComplainsDetails({
|
||||||
</AlertDialogFooter>
|
</AlertDialogFooter>
|
||||||
</AlertDialogContent>
|
</AlertDialogContent>
|
||||||
</AlertDialog>
|
</AlertDialog>
|
||||||
{data ? (
|
{getComplaintMutation.data && !getComplaintMutation.isPending ? (
|
||||||
<>
|
<>
|
||||||
{state !== "FollowResult" && (
|
{/* {state !== "FollowResult" && (
|
||||||
<button
|
<button
|
||||||
onClick={() => router.push("/Account/Complaints")}
|
onClick={() => router.push("/Account/Complaints")}
|
||||||
className="flex gap-1 my-2 cursor-pointer text-blue"
|
className="flex gap-1 my-2 cursor-pointer text-blue"
|
||||||
|
|
@ -190,7 +198,7 @@ export default function ComplainsDetails({
|
||||||
</span>
|
</span>
|
||||||
<p>بازگشت</p>
|
<p>بازگشت</p>
|
||||||
</button>
|
</button>
|
||||||
)}
|
)} */}
|
||||||
|
|
||||||
{/* Editt */}
|
{/* Editt */}
|
||||||
<div className="flex items-start w-full gap-2 mt-2 max-lg:flex-col">
|
<div className="flex items-start w-full gap-2 mt-2 max-lg:flex-col">
|
||||||
|
|
@ -202,17 +210,20 @@ export default function ComplainsDetails({
|
||||||
انجام عملیات
|
انجام عملیات
|
||||||
</p>
|
</p>
|
||||||
<InspectorOperations
|
<InspectorOperations
|
||||||
updateData={() => getComplaintMutation.mutate(storeData)}
|
updateData={(payload) =>
|
||||||
|
getComplaintMutation.mutate({ Data: payload })
|
||||||
|
}
|
||||||
role={role}
|
role={role}
|
||||||
complaintData={data}
|
complaintData={data}
|
||||||
|
password={password}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* 2 */}
|
{/* 2 */}
|
||||||
<div className="flex flex-col self-stretch w-full gap-2 rounded-lg lg:w-2/3 ">
|
<div className="flex flex-col self-stretch w-full gap-2 rounded-lg lg:w-2/3 ">
|
||||||
<div className=" bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col md:flex-row gap-2 items-center justify-center lg:sticky top-28">
|
<div className=" bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col md:flex-row gap-2 items-center justify-center">
|
||||||
{data.user == null ? (
|
{data?.user == null ? (
|
||||||
<>
|
<>
|
||||||
<div className="relative flex flex-col w-full p-5 mt-2 border border-gray-400 rounded-md gap-y-1">
|
<div className="relative flex flex-col w-full p-5 mt-2 border border-gray-400 rounded-md gap-y-1">
|
||||||
<p className=" absolute -top-3 right-2 bg-[#E9E9E9] px-2 text-sm text-gray-500">
|
<p className=" absolute -top-3 right-2 bg-[#E9E9E9] px-2 text-sm text-gray-500">
|
||||||
|
|
|
||||||
|
|
@ -61,31 +61,25 @@ export default function FollowResult() {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const printableContent = "This is the content to be printed.";
|
const printableContent = "This is the content to be printed.";
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="w-[90vw] sm:w-[90vw] lg:w-[85vw] xl:w-[75vw] 3xl:w-[70vw] pt-6 mx-auto">
|
<div className="w-[90vw] sm:w-[90vw] lg:w-[85vw] xl:w-[75vw] 3xl:w-[70vw] pt-6 mx-auto">
|
||||||
{complaintPrintMutation?.data ? (
|
<>
|
||||||
<>
|
{/* <button
|
||||||
<button
|
onClick={() => router.push("/FollowUp")}
|
||||||
onClick={() => router.push("/FollowUp")}
|
className="flex gap-1 cursor-pointer text-blue"
|
||||||
className="flex gap-1 cursor-pointer text-blue"
|
>
|
||||||
>
|
<span>
|
||||||
<span>
|
<ArrowRight />
|
||||||
<ArrowRight />
|
</span>
|
||||||
</span>
|
<p>بازگشت</p>
|
||||||
<p>بازگشت</p>
|
</button> */}
|
||||||
</button>
|
<ComplainsDetails
|
||||||
<ComplainsDetails
|
role="Citizen"
|
||||||
role="Citizen"
|
state="FollowResult"
|
||||||
state="FollowResult"
|
/>
|
||||||
Data={complaintPrintMutation?.data}
|
</>
|
||||||
/>
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
""
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -38,22 +38,17 @@ export default function InspectorOperations({
|
||||||
complaintData,
|
complaintData,
|
||||||
role,
|
role,
|
||||||
updateData,
|
updateData,
|
||||||
|
password,
|
||||||
}: {
|
}: {
|
||||||
complaintData: any;
|
complaintData: any;
|
||||||
role: string;
|
role: string;
|
||||||
updateData: () => any;
|
updateData: (data: any) => any;
|
||||||
|
password?: string;
|
||||||
}) {
|
}) {
|
||||||
const FormSchema = z.object({
|
const FormSchema = z.object({
|
||||||
text: z
|
text: z.string({ required_error: "لطفا متن خود را وارد نمایید." }),
|
||||||
.string({ required_error: "لطفا متن خود را وارد نمایید." })
|
|
||||||
.min(8, {
|
|
||||||
message: "Bio must be at least 8 characters.",
|
|
||||||
})
|
|
||||||
.max(260, {
|
|
||||||
message: "Bio must not be longer than 30 characters.",
|
|
||||||
}),
|
|
||||||
operation: z.string({
|
operation: z.string({
|
||||||
required_error: "Please select an email to display.",
|
required_error: "لطفا نوع عملیات را انتخاب نمایید.",
|
||||||
}),
|
}),
|
||||||
media: z
|
media: z
|
||||||
.custom<FileList>((val) => val instanceof FileList, "Required")
|
.custom<FileList>((val) => val instanceof FileList, "Required")
|
||||||
|
|
@ -61,12 +56,7 @@ export default function InspectorOperations({
|
||||||
.refine((files) => files.length <= 5, `Maximum of 5 File are allowed.`)
|
.refine((files) => files.length <= 5, `Maximum of 5 File are allowed.`)
|
||||||
.nullish(),
|
.nullish(),
|
||||||
});
|
});
|
||||||
const password = useData((state) => state.data.password);
|
|
||||||
const possibleOperations = complaintData?.possibleOperationsWithDescription;
|
const possibleOperations = complaintData?.possibleOperationsWithDescription;
|
||||||
const selectOptions = Operations.filter((item, index) =>
|
|
||||||
possibleOperations.includes(index)
|
|
||||||
);
|
|
||||||
|
|
||||||
const form = useForm<z.infer<typeof FormSchema>>({
|
const form = useForm<z.infer<typeof FormSchema>>({
|
||||||
resolver: zodResolver(FormSchema),
|
resolver: zodResolver(FormSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
|
|
@ -79,12 +69,19 @@ export default function InspectorOperations({
|
||||||
|
|
||||||
const OperationMutation = useMutation({
|
const OperationMutation = useMutation({
|
||||||
mutationKey: ["Operation"],
|
mutationKey: ["Operation"],
|
||||||
mutationFn:
|
mutationFn: postComplaintsDetails,
|
||||||
role == "Inspector" ? OperateByInspector : postComplaintsDetails,
|
|
||||||
onSuccess: (res) => {
|
onSuccess: (res) => {
|
||||||
toast("عملیات شما با موفقیت انجام شد. ", {
|
toast("عملیات شما با موفقیت انجام شد. ", {
|
||||||
className: "!bg-green-500 !text-white",
|
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) => {
|
onError: (err: any | string) => {
|
||||||
toast(<>{err.response.data.detail}</>, {
|
toast(<>{err.response.data.detail}</>, {
|
||||||
|
|
@ -98,7 +95,10 @@ export default function InspectorOperations({
|
||||||
formData.append("text", data.text);
|
formData.append("text", data.text);
|
||||||
formData.append("trackingNumber", complaintData.trackingNumber);
|
formData.append("trackingNumber", complaintData.trackingNumber);
|
||||||
formData.append("Operation", data.operation);
|
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) {
|
if (data?.media && data?.media?.length > 0) {
|
||||||
for (let i = 0; i < data.media.length; i++) {
|
for (let i = 0; i < data.media.length; i++) {
|
||||||
formData.append("Medias", data.media[i]);
|
formData.append("Medias", data.media[i]);
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,13 @@
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { Input } from "./ui/input";
|
import { Input } from "./ui/input";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import { menuItems } from "@/constants";
|
import { authorizedMenuItems, menuItems } from "@/constants";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import Login from "./Login";
|
import Login from "./Login";
|
||||||
import { Button } from "./ui/button";
|
import { Button } from "./ui/button";
|
||||||
import { usePathname } from "next/navigation";
|
import { usePathname } from "next/navigation";
|
||||||
import TopNav from "./TopNav";
|
import TopNav from "./TopNav";
|
||||||
import { isAuthorized } from "@/lib/utils";
|
import { cn, isAuthorized } from "@/lib/utils";
|
||||||
import useToken from "@/store/useToken";
|
import useToken from "@/store/useToken";
|
||||||
import { DropdownMenu } from "@radix-ui/react-dropdown-menu";
|
import { DropdownMenu } from "@radix-ui/react-dropdown-menu";
|
||||||
import ProfileDropDown from "./ProfileDropDown";
|
import ProfileDropDown from "./ProfileDropDown";
|
||||||
|
|
@ -30,7 +30,7 @@ export default function Navbar() {
|
||||||
setAuth(false);
|
setAuth(false);
|
||||||
}
|
}
|
||||||
}, [isAuth, token]);
|
}, [isAuth, token]);
|
||||||
|
console.log(pathname);
|
||||||
return (
|
return (
|
||||||
<div className={` left-0 right-0 top-0 z-20 fixed`}>
|
<div className={` left-0 right-0 top-0 z-20 fixed`}>
|
||||||
{/* <TopNav /> */}
|
{/* <TopNav /> */}
|
||||||
|
|
@ -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"
|
className="fixed z-[100] left-0 shadow-4xl right-0 top-[4rem] p-5 bg-white border-b-2 shadow-md"
|
||||||
>
|
>
|
||||||
<ul className="grid gap-2 ">
|
<ul className="grid gap-2 ">
|
||||||
{menuItems.map((item, idx, array) => {
|
{auth ? (
|
||||||
// const { Icon } = item;
|
<>
|
||||||
const lastItem = array.length - 1;
|
{authorizedMenuItems.map((item, idx, array) => {
|
||||||
return (
|
// const { Icon } = item;
|
||||||
<motion.li
|
const lastItem = array.length - 1;
|
||||||
initial={{ scale: 0, opacity: 0 }}
|
return (
|
||||||
animate={{ scale: 1, opacity: 1 }}
|
<motion.li
|
||||||
transition={{
|
initial={{ scale: 0, opacity: 0 }}
|
||||||
type: "spring",
|
animate={{ scale: 1, opacity: 1 }}
|
||||||
stiffness: 260,
|
transition={{
|
||||||
damping: 20,
|
type: "spring",
|
||||||
delay: 0.1 + idx / 10,
|
stiffness: 260,
|
||||||
}}
|
damping: 20,
|
||||||
key={item.name}
|
delay: 0.1 + idx / 10,
|
||||||
className=" w-full p-[0.08rem] rounded-xl bg-gradient-to-tr from-neutral-800 via-white to-neutral-700"
|
}}
|
||||||
>
|
key={item.name}
|
||||||
<Link
|
className=" w-full p-[0.08rem] rounded-xl bg-gradient-to-tr from-neutral-800 via-white to-neutral-700"
|
||||||
onClick={() => setOpen((prev) => !prev)}
|
>
|
||||||
className={`flex items-center justify-between w-full p-3 rounded-xl text-white
|
<Link
|
||||||
|
onClick={() => setOpen((prev) => !prev)}
|
||||||
|
className={`flex items-center justify-between w-full p-3 rounded-xl text-white
|
||||||
${lastItem === idx ? "bg-yellow" : "bg-blue"} `}
|
${lastItem === idx ? "bg-yellow" : "bg-blue"} `}
|
||||||
href={item.href}
|
href={item.href}
|
||||||
>
|
>
|
||||||
<span className="flex gap-1 text-sm">
|
<span className="flex gap-1 text-sm">
|
||||||
{item.name}
|
{item.name}
|
||||||
</span>
|
</span>
|
||||||
{/* <Icon className="text-xl" /> */}
|
{/* <Icon className="text-xl" /> */}
|
||||||
</Link>
|
</Link>
|
||||||
</motion.li>
|
</motion.li>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
{menuItems.map((item, idx, array) => {
|
||||||
|
// const { Icon } = item;
|
||||||
|
const lastItem = array.length - 1;
|
||||||
|
return (
|
||||||
|
<motion.li
|
||||||
|
initial={{ scale: 0, opacity: 0 }}
|
||||||
|
animate={{ scale: 1, opacity: 1 }}
|
||||||
|
transition={{
|
||||||
|
type: "spring",
|
||||||
|
stiffness: 260,
|
||||||
|
damping: 20,
|
||||||
|
delay: 0.1 + idx / 10,
|
||||||
|
}}
|
||||||
|
key={item.name}
|
||||||
|
className=" w-full p-[0.08rem] rounded-xl bg-gradient-to-tr from-neutral-800 via-white to-neutral-700"
|
||||||
|
>
|
||||||
|
<Link
|
||||||
|
onClick={() => 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}
|
||||||
|
>
|
||||||
|
<span className="flex gap-1 text-sm">
|
||||||
|
{item.name}
|
||||||
|
</span>
|
||||||
|
{/* <Icon className="text-xl" /> */}
|
||||||
|
</Link>
|
||||||
|
</motion.li>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</ul>
|
</ul>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
)}
|
)}
|
||||||
|
|
@ -107,17 +144,45 @@ export default function Navbar() {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className=" flex gap-5 items-center mr-8 max-md:hidden">
|
<div className=" flex gap-5 items-center mr-8 max-md:hidden">
|
||||||
{menuItems.map((item, index, array) => {
|
{auth ? (
|
||||||
if (array.length - 1 !== index) {
|
<>
|
||||||
return (
|
{authorizedMenuItems.map((item, index, array) => {
|
||||||
<Link key={item.id} href={item.href}>
|
return (
|
||||||
<div className=" text-sm font-bold">{item.name}</div>
|
<Link
|
||||||
</Link>
|
className={cn(
|
||||||
);
|
" p-2 rounded-md",
|
||||||
} else {
|
pathname == item.href && "bg-gray-200"
|
||||||
return <></>;
|
)}
|
||||||
}
|
key={item.id}
|
||||||
})}
|
href={item.href}
|
||||||
|
>
|
||||||
|
<div className=" text-sm font-bold">{item.name}</div>
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
{menuItems.map((item, index, array) => {
|
||||||
|
if (array.length - 1 !== index) {
|
||||||
|
return (
|
||||||
|
<Link
|
||||||
|
className={cn(
|
||||||
|
" p-1 rounded-md",
|
||||||
|
pathname == item.href && "bg-gray-200"
|
||||||
|
)}
|
||||||
|
key={item.id}
|
||||||
|
href={item.href}
|
||||||
|
>
|
||||||
|
<div className=" text-sm font-bold p-2">
|
||||||
|
{item.name}
|
||||||
|
</div>
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
})}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{auth ? (
|
{auth ? (
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import { useQuery } from "@tanstack/react-query";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { convertFullTime } from "@/lib/utils";
|
import { convertFullTime } from "@/lib/utils";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
interface News {
|
interface News {
|
||||||
id: string;
|
id: string;
|
||||||
image: {
|
image: {
|
||||||
|
|
@ -27,12 +28,12 @@ interface News {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function News() {
|
export default function News() {
|
||||||
|
const router = useRouter();
|
||||||
const { data, isLoading, isError, refetch } = useQuery({
|
const { data, isLoading, isError, refetch } = useQuery({
|
||||||
queryKey: ["News"],
|
queryKey: ["News"],
|
||||||
queryFn: () => getNews(),
|
queryFn: () => getNews(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
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%] ">
|
||||||
<h2 className=" w-full font-bold mb-2">اخبار</h2>
|
<h2 className=" w-full font-bold mb-2">اخبار</h2>
|
||||||
|
|
@ -44,8 +45,9 @@ export default function News() {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={item.id}
|
key={item.id}
|
||||||
|
onClick={() => router.push(`/News/${item.id}`)}
|
||||||
className="w-full lg:w-[48%] border rounded-lg flex flex-row shadow-md hover:shadow-none transition-all
|
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"
|
||||||
>
|
>
|
||||||
<div className="w-1/2 h-full rounded-r-lg max-sm:h-1/2 max-md:w-1/3 max-sm:w-full">
|
<div className="w-1/2 h-full rounded-r-lg max-sm:h-1/2 max-md:w-1/3 max-sm:w-full">
|
||||||
<Image
|
<Image
|
||||||
|
|
|
||||||
|
|
@ -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];
|
const items = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14];
|
||||||
|
|
||||||
export default function Pagination({
|
export default function Pagination({
|
||||||
itemsPerPage,
|
TotalPages,
|
||||||
|
currentPage,
|
||||||
|
PageSize,
|
||||||
Page,
|
Page,
|
||||||
countPage,
|
countPage,
|
||||||
length,
|
length,
|
||||||
}: {
|
}: {
|
||||||
itemsPerPage?: any;
|
TotalPages?: any;
|
||||||
|
currentPage?: any;
|
||||||
|
PageSize?: number;
|
||||||
Page?: any;
|
Page?: any;
|
||||||
countPage?: any;
|
countPage?: any;
|
||||||
length?: 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 handlePageClick = (event: any) => {
|
||||||
const newOffset = (event.selected * itemsPerPage) % items.length;
|
|
||||||
setItemOffset(newOffset);
|
|
||||||
Page(event.selected);
|
Page(event.selected);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* <Items currentItems={currentItems} /> */}
|
|
||||||
<ReactPaginate
|
<ReactPaginate
|
||||||
breakLabel="..."
|
breakLabel="..."
|
||||||
onPageActive={(e) => console.log(e)}
|
onPageActive={(e) => console.log(e)}
|
||||||
nextLabel={<MdKeyboardArrowLeft className="w-5 h-5 " />}
|
nextLabel={<MdKeyboardArrowLeft className="w-5 h-5 " />}
|
||||||
onPageChange={handlePageClick}
|
onPageChange={handlePageClick}
|
||||||
pageRangeDisplayed={3}
|
pageRangeDisplayed={3}
|
||||||
pageCount={Math.ceil(countPage / 5)}
|
forcePage={currentPage}
|
||||||
|
pageCount={TotalPages}
|
||||||
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 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"
|
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"
|
||||||
|
|
|
||||||
|
|
@ -63,15 +63,25 @@ export default function ProfileDropDown() {
|
||||||
saveToken(false);
|
saveToken(false);
|
||||||
deleteCookie("Sootzani_Refresh_Token");
|
deleteCookie("Sootzani_Refresh_Token");
|
||||||
deleteCookie("Sootzani_Token");
|
deleteCookie("Sootzani_Token");
|
||||||
|
localStorage.removeItem("password2");
|
||||||
|
localStorage.removeItem("trackingNumber2");
|
||||||
router.push("/");
|
router.push("/");
|
||||||
};
|
};
|
||||||
const saveToken = useToken((state) => state.saveToken);
|
const saveToken = useToken((state) => state.saveToken);
|
||||||
return (
|
return (
|
||||||
<DropdownMenu dir="rtl">
|
<DropdownMenu dir="rtl">
|
||||||
<DropdownMenuTrigger className=" max-sm:-mr-8 max-sm:text-xs" asChild>
|
<DropdownMenuTrigger
|
||||||
<Button variant="outline">
|
className=" max-sm:-mr-8 max-sm:text-xs w-12"
|
||||||
|
asChild
|
||||||
|
>
|
||||||
|
<Button variant="outline" className=" truncate w-32 grid place-content-center">
|
||||||
{/* {profileData?.title ? profileData?.title : profileData?.userName} */}
|
{/* {profileData?.title ? profileData?.title : profileData?.userName} */}
|
||||||
{profileData?.firstName || profileData?.lastName ? profileData?.firstName +" "+ profileData?.lastName : profileData?.userName}
|
<p className=" truncate w-full">
|
||||||
|
{" "}
|
||||||
|
{profileData?.firstName || profileData?.lastName
|
||||||
|
? profileData?.firstName + " " + profileData?.lastName
|
||||||
|
: profileData?.userName}
|
||||||
|
</p>
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
<DropdownMenuContent className="w-56 sm:ml-10">
|
<DropdownMenuContent className="w-56 sm:ml-10">
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ export default function Result() {
|
||||||
onClick={handlePrint}
|
onClick={handlePrint}
|
||||||
className="w-full sm:w-fit bg-blue text-white p-2 rounded-xl text-center "
|
className="w-full sm:w-fit bg-blue text-white p-2 rounded-xl text-center "
|
||||||
>
|
>
|
||||||
پرینت درخواست
|
پرینت
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{/* <Image
|
{/* <Image
|
||||||
|
|
|
||||||
|
|
@ -116,9 +116,11 @@ export default function RequestStep2() {
|
||||||
onSuccess: (res) => {
|
onSuccess: (res) => {
|
||||||
localStorage.setItem("trackingNumber", res.trackingNumber);
|
localStorage.setItem("trackingNumber", res.trackingNumber);
|
||||||
localStorage.setItem("password", res.password);
|
localStorage.setItem("password", res.password);
|
||||||
|
localStorage.removeItem("unknown");
|
||||||
router.push("/RequestResult");
|
router.push("/RequestResult");
|
||||||
},
|
},
|
||||||
onError: (err: any | string) => {
|
onError: (err: any | string) => {
|
||||||
|
refetch();
|
||||||
toast(<>{err.response.data.detail}</>, {
|
toast(<>{err.response.data.detail}</>, {
|
||||||
className: "!bg-red-500 !text-white",
|
className: "!bg-red-500 !text-white",
|
||||||
});
|
});
|
||||||
|
|
@ -133,9 +135,11 @@ export default function RequestStep2() {
|
||||||
localStorage.setItem("password", res.password);
|
localStorage.setItem("password", res.password);
|
||||||
localStorage.setItem("registeredAt", res.registeredAt);
|
localStorage.setItem("registeredAt", res.registeredAt);
|
||||||
localStorage.removeItem("authorized");
|
localStorage.removeItem("authorized");
|
||||||
|
localStorage.removeItem("unknown");
|
||||||
router.push("/RequestResult");
|
router.push("/RequestResult");
|
||||||
},
|
},
|
||||||
onError: (err: any | string) => {
|
onError: (err: any | string) => {
|
||||||
|
refetch();
|
||||||
toast(<>{err.response.data.detail}</>, {
|
toast(<>{err.response.data.detail}</>, {
|
||||||
className: "!bg-red-500 !text-white",
|
className: "!bg-red-500 !text-white",
|
||||||
});
|
});
|
||||||
|
|
@ -204,7 +208,6 @@ export default function RequestStep2() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
refetch();
|
|
||||||
resetField("Title");
|
resetField("Title");
|
||||||
resetField("Text");
|
resetField("Text");
|
||||||
resetField("Medias");
|
resetField("Medias");
|
||||||
|
|
@ -373,7 +376,6 @@ export default function RequestStep2() {
|
||||||
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@ export default function TabController() {
|
||||||
const [selectedFile, setSelectedFile] = useState<any>(null);
|
const [selectedFile, setSelectedFile] = useState<any>(null);
|
||||||
const [page, setPage] = useState<any>(1);
|
const [page, setPage] = useState<any>(1);
|
||||||
const [totalCount, setTotalCount] = useState<any>(0);
|
const [totalCount, setTotalCount] = useState<any>(0);
|
||||||
|
const [currentPage, setCurrentPage] = useState<any>(0);
|
||||||
|
const [pageSize, setPageSize] = useState<any>(0);
|
||||||
|
const [totalPages, setTotalPages] = useState<any>(0);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [search, setSearch] = useState<any>(null);
|
const [search, setSearch] = useState<any>(null);
|
||||||
|
|
||||||
|
|
@ -46,6 +49,9 @@ export default function TabController() {
|
||||||
if (data) {
|
if (data) {
|
||||||
const headersData = JSON.parse(data.headers["x-pagination"]);
|
const headersData = JSON.parse(data.headers["x-pagination"]);
|
||||||
setTotalCount(headersData.TotalCount);
|
setTotalCount(headersData.TotalCount);
|
||||||
|
setTotalPages(headersData.TotalPages);
|
||||||
|
setCurrentPage(headersData.CurrentPage);
|
||||||
|
setPageSize(headersData.PageSize);
|
||||||
}
|
}
|
||||||
}, [data]);
|
}, [data]);
|
||||||
|
|
||||||
|
|
@ -55,11 +61,15 @@ 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
|
||||||
<Button className=" bg-blue hover:bg-blue/90 rounded-lg max-sm:text-xs">
|
onClick={() => {
|
||||||
ثبت درخواست
|
router.push("/RequestStep2");
|
||||||
</Button>
|
localStorage.removeItemItem("unknown");
|
||||||
</Link>
|
}}
|
||||||
|
className=" bg-blue hover:bg-blue/90 rounded-lg max-sm:text-xs"
|
||||||
|
>
|
||||||
|
ثبت درخواست
|
||||||
|
</Button>
|
||||||
|
|
||||||
<Search
|
<Search
|
||||||
value={search}
|
value={search}
|
||||||
|
|
@ -69,6 +79,8 @@ export default function TabController() {
|
||||||
/>
|
/>
|
||||||
<TableController data={data?.data} />
|
<TableController data={data?.data} />
|
||||||
<Pagination
|
<Pagination
|
||||||
|
TotalPages={totalPages}
|
||||||
|
currentPage={currentPage - 1}
|
||||||
countPage={totalCount}
|
countPage={totalCount}
|
||||||
Page={(num: number) => setPage(num + 1)}
|
Page={(num: number) => setPage(num + 1)}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ import {
|
||||||
} from "@/components/ui/dialog";
|
} from "@/components/ui/dialog";
|
||||||
import { ControllerTableItems } from "@/constants";
|
import { ControllerTableItems } from "@/constants";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { Decrypt, convertDate } from "@/lib/utils";
|
import { Decrypt, convertDate, convertFullTime } from "@/lib/utils";
|
||||||
import useData from "@/store/useData";
|
import useData from "@/store/useData";
|
||||||
import { Label } from "./ui/label";
|
import { Label } from "./ui/label";
|
||||||
import { Input } from "./ui/input";
|
import { Input } from "./ui/input";
|
||||||
|
|
@ -71,13 +71,14 @@ export default function TableController({ data }: { data: Complaint[] }) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Table className="border-[1px] border-solid border-muted rounded-md ">
|
<Table className="border-[1px] border-solid border-muted rounded-md mb-20">
|
||||||
{/* <TableCaption>A list of your recent invoices.</TableCaption> */}
|
{/* <TableCaption>A list of your recent invoices.</TableCaption> */}
|
||||||
<TableHeader>
|
<TableHeader>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableHead>ردیف</TableHead>
|
<TableHead>ردیف</TableHead>
|
||||||
<TableHead>تاریخ</TableHead>
|
|
||||||
<TableHead>کد پیگیری</TableHead>
|
<TableHead>کد پیگیری</TableHead>
|
||||||
|
<TableHead>تاریخ ثبت</TableHead>
|
||||||
|
<TableHead>تاریخ آخرین تغییر</TableHead>
|
||||||
<TableHead>موضوع</TableHead>
|
<TableHead>موضوع</TableHead>
|
||||||
<TableHead>وضعیت</TableHead>
|
<TableHead>وضعیت</TableHead>
|
||||||
<TableHead>دستگاه مربوطه</TableHead>
|
<TableHead>دستگاه مربوطه</TableHead>
|
||||||
|
|
@ -104,25 +105,27 @@ export default function TableController({ data }: { data: Complaint[] }) {
|
||||||
<TableCell className="w-1/12 font-medium ">
|
<TableCell className="w-1/12 font-medium ">
|
||||||
{index + 1}
|
{index + 1}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
<TableCell className="w-1/12">{item.trackingNumber}</TableCell>
|
||||||
<TableCell className="w-2/12">
|
<TableCell className="w-2/12">
|
||||||
{convertDate(item.registeredAt)}
|
{convertFullTime(item.registeredAt)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className="w-2/12">{item.trackingNumber}</TableCell>
|
|
||||||
<TableCell className="w-2/12">
|
<TableCell className="w-2/12">
|
||||||
|
{convertFullTime(item.lastChanged)}
|
||||||
|
</TableCell>
|
||||||
|
<TableCell className="w-1/12">
|
||||||
{item?.title ? item.title : "-"}
|
{item?.title ? item.title : "-"}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className="w-2/12">
|
<TableCell className="w-3/12">
|
||||||
{item?.statusWithDescription
|
{item?.statusWithDescription
|
||||||
? item.statusWithDescription.description
|
? item.statusWithDescription.description
|
||||||
: "-"}
|
: "-"}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className="w-3/12">
|
<TableCell className="w-4/12">
|
||||||
{item?.complaintOrganization
|
{item?.complaintOrganization
|
||||||
? item?.complaintOrganization.title
|
? item?.complaintOrganization.title
|
||||||
: "-"}
|
: "-"}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
{/* </Link> */}
|
{/* </Link> */}
|
||||||
|
|
||||||
</TableRow>
|
</TableRow>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,20 @@ import bgimg from "../public/img/bg.png";
|
||||||
|
|
||||||
export const menuItems = [
|
export const menuItems = [
|
||||||
{ id: 1, name: "صفحه اصلی", href: "/" },
|
{ id: 1, name: "صفحه اصلی", href: "/" },
|
||||||
{ id: 2, name: "اخبار", href: "/News" },
|
{ id: 2, name: "پیگیری", href: "/FollowUp" },
|
||||||
{ id: 3, name: "تماس با ما", href: "/CallUs" },
|
{ id: 3, name: "اخبار", href: "/News" },
|
||||||
{ id: 4, name: "پیگیری", href: "/FollowUp" },
|
{ id: 4, name: "تماس با ما", href: "/CallUs" },
|
||||||
{ id: 5, name: "ورود به پنل کاربری", href: "/Login" },
|
{ 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 = [
|
export const sliderItems = [
|
||||||
{ id: 1, img: bgimg },
|
{ id: 1, img: bgimg },
|
||||||
{ id: 2, img: bgimg },
|
{ id: 2, img: bgimg },
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
output: "standalone",
|
output: "standalone",
|
||||||
images: {
|
images: {
|
||||||
domains: ["sootzaniapi.shetabdahi.ir"],
|
domains: ["sootzaniapi.shetabdahi.ir", "oyoonapi.yazd.ir"],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "sootzani",
|
"name": "sootzani",
|
||||||
"version": "0.1.8",
|
"version": "0.1.13",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "sootzani",
|
"name": "sootzani",
|
||||||
"version": "0.1.8",
|
"version": "0.1.13",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@hookform/resolvers": "^3.3.2",
|
"@hookform/resolvers": "^3.3.2",
|
||||||
"@radix-ui/react-alert-dialog": "^1.0.5",
|
"@radix-ui/react-alert-dialog": "^1.0.5",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "sootzani",
|
"name": "sootzani",
|
||||||
"version": "0.1.8",
|
"version": "0.1.13",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
|
|
|
||||||
|
|
@ -7,27 +7,46 @@ import {
|
||||||
} from "cookies-next";
|
} from "cookies-next";
|
||||||
|
|
||||||
axios.defaults.baseURL = process.env.NEXT_PUBLIC_BASE_URL_APP;
|
axios.defaults.baseURL = process.env.NEXT_PUBLIC_BASE_URL_APP;
|
||||||
|
let isRefreshing = false;
|
||||||
|
|
||||||
axios.interceptors.response.use(
|
axios.interceptors.response.use(
|
||||||
(response) => {
|
(response) => {
|
||||||
return response;
|
return response;
|
||||||
},
|
},
|
||||||
async function (error) {
|
async function (error) {
|
||||||
|
console.log(error);
|
||||||
const originalRequest = error.config;
|
const originalRequest = error.config;
|
||||||
|
|
||||||
if (error.response.status === 401) {
|
if (error.response.status === 401) {
|
||||||
const accessToken = getCookie("Sootzani_Token");
|
if (!originalRequest._retry) {
|
||||||
const refreshToken = getCookie("Sootzani_Refresh_Token");
|
originalRequest._retry = true;
|
||||||
const data = await RefreshToken({
|
const accessToken = getCookie("Sootzani_Token");
|
||||||
token: accessToken,
|
const refreshToken = getCookie("Sootzani_Refresh_Token");
|
||||||
refreshToken: refreshToken,
|
|
||||||
});
|
if (accessToken && refreshToken && !isRefreshing) {
|
||||||
|
isRefreshing = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Perform token refresh
|
||||||
|
const data = await RefreshToken({
|
||||||
|
token: accessToken,
|
||||||
|
refreshToken: refreshToken,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Retry the original request
|
||||||
|
return axios(originalRequest);
|
||||||
|
} catch (refreshError) {
|
||||||
|
console.error("Token refresh failed", refreshError);
|
||||||
|
// Handle refresh error, e.g., redirect to login page
|
||||||
|
return Promise.reject(refreshError);
|
||||||
|
} finally {
|
||||||
|
isRefreshing = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// if (error.response.status === 403 && !originalRequest._retry) {
|
|
||||||
// originalRequest._retry = true;
|
// For other errors or if refresh token logic is not applicable
|
||||||
// const access_token = await refreshAccessToken();
|
|
||||||
// axios.defaults.headers.common["Authorization"] = "Bearer " + access_token;
|
|
||||||
// return axiosApiInstance(originalRequest);
|
|
||||||
// }
|
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ export async function getComplaints({
|
||||||
states = 0,
|
states = 0,
|
||||||
TrackingNumber,
|
TrackingNumber,
|
||||||
PageNumber = 1,
|
PageNumber = 1,
|
||||||
PageSize = 5,
|
PageSize = 10,
|
||||||
}: {
|
}: {
|
||||||
states?: number;
|
states?: number;
|
||||||
TrackingNumber?: string;
|
TrackingNumber?: string;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue