Response Errors handled + Refresh Token added
parent
228eeff4b3
commit
e12d88c0de
|
|
@ -6,6 +6,7 @@ import Navbar from "@/components/Navbar";
|
||||||
import NavbarSm from "@/components/NavbarSm";
|
import NavbarSm from "@/components/NavbarSm";
|
||||||
import Provider from "../utils/Provider";
|
import Provider from "../utils/Provider";
|
||||||
import { Toaster as SonnerToaster } from "@/components/ui/sonner";
|
import { Toaster as SonnerToaster } from "@/components/ui/sonner";
|
||||||
|
import ProgressBarProviders from "@/components/ProgressBar";
|
||||||
const inter = Inter({ subsets: ["latin"] });
|
const inter = Inter({ subsets: ["latin"] });
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
|
|
@ -25,7 +26,9 @@ export default function RootLayout({
|
||||||
<Navbar />
|
<Navbar />
|
||||||
{/* <NavbarSm /> */}
|
{/* <NavbarSm /> */}
|
||||||
|
|
||||||
<div className="flex justify-center mt-20 sm:mt-14">{children}</div>
|
<div className="flex justify-center mt-20 sm:mt-14">
|
||||||
|
<ProgressBarProviders>{children}</ProgressBarProviders>
|
||||||
|
</div>
|
||||||
|
|
||||||
<Toaster />
|
<Toaster />
|
||||||
<SonnerToaster />
|
<SonnerToaster />
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ import {
|
||||||
} from "@/components/ui/form";
|
} from "@/components/ui/form";
|
||||||
|
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { toast } from "@/components/ui/use-toast";
|
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import LoginIcon from "../public/img/login-icon.svg";
|
import LoginIcon from "../public/img/login-icon.svg";
|
||||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||||
|
|
@ -28,6 +27,7 @@ import { Oval, ThreeDots } from "react-loader-spinner";
|
||||||
import useData from "@/store/useData";
|
import useData from "@/store/useData";
|
||||||
import { getCookie } from "cookies-next";
|
import { getCookie } from "cookies-next";
|
||||||
import { RefreshCcw } from "lucide-react";
|
import { RefreshCcw } from "lucide-react";
|
||||||
|
import { toast } from "sonner";
|
||||||
const FormSchema = z.object({
|
const FormSchema = z.object({
|
||||||
phoneNumber: z.string().min(1, {
|
phoneNumber: z.string().min(1, {
|
||||||
message: "لطفا شماره موبایل خود را وارد نمایید.",
|
message: "لطفا شماره موبایل خود را وارد نمایید.",
|
||||||
|
|
@ -53,13 +53,17 @@ export default function CitizenLogin() {
|
||||||
|
|
||||||
const loginMutation = useMutation({
|
const loginMutation = useMutation({
|
||||||
mutationFn: logisterCitizen,
|
mutationFn: logisterCitizen,
|
||||||
onSuccess: (res) => {},
|
onSuccess: (res: any | string) => {
|
||||||
onError: (err: any) => {
|
console.log(res);
|
||||||
if (err.response.status == 428) {
|
router.push("/Verify");
|
||||||
console.log(useData);
|
localStorage.setItem("VerifyRole", "citizen");
|
||||||
router.push("/Verify");
|
localStorage.setItem("verificationToken", res);
|
||||||
localStorage.setItem("VerifyRole", "citizen");
|
},
|
||||||
}
|
onError: (err: any | string) => {
|
||||||
|
console.log(err);
|
||||||
|
toast(<>{err.response.data.detail}</>, {
|
||||||
|
className: "!bg-red-500 !text-white",
|
||||||
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -75,8 +79,8 @@ export default function CitizenLogin() {
|
||||||
value: data.captcha,
|
value: data.captcha,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
refetch()
|
refetch();
|
||||||
loginMutation.mutate(payload);
|
loginMutation.mutateAsync(payload);
|
||||||
saveData({
|
saveData({
|
||||||
phoneNumber: data.phoneNumber,
|
phoneNumber: data.phoneNumber,
|
||||||
});
|
});
|
||||||
|
|
@ -86,23 +90,22 @@ export default function CitizenLogin() {
|
||||||
? URL.createObjectURL(CaptchaData.data)
|
? URL.createObjectURL(CaptchaData.data)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="w-full mt-14 sm:w-2/3 md:w-2/4 xl:w-1/3 bg-white rounded-lg dark:border xl:p-0 dark:bg-gray-800 dark:border-gray-700 shadow-[0px_0px_15px_0px_#00000040]
|
className="w-full mt-14 sm:w-2/3 md:w-2/4 xl:w-1/3 bg-white rounded-lg dark:border xl:p-0 dark:bg-gray-800 dark:border-gray-700 shadow-[0px_0px_15px_0px_#00000040]
|
||||||
h-full max-md:p-8 pt-12 mb-10"
|
h-full max-md:p-8 pt-12 mb-10"
|
||||||
>
|
>
|
||||||
<div className="space-y-3 md:space-y-4 flex flex-col md:py-10 md:px-12 lg:px-16 h-full justify-center">
|
<div className="flex flex-col justify-center h-full space-y-3 md:space-y-4 md:py-10 md:px-12 lg:px-16">
|
||||||
<Image alt="icon" src={LoginIcon} className="self-center w-1/3 " />
|
<Image alt="icon" src={LoginIcon} className="self-center w-1/3 " />
|
||||||
|
|
||||||
<p className="text-lg font-bold leading-tight tracking-tight text-blue dark:text-white">
|
<p className="text-lg font-bold leading-tight tracking-tight text-blue dark:text-white">
|
||||||
احراز هویت
|
احراز هویت
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<Form {...form}>
|
<Form {...form}>
|
||||||
<form
|
<form
|
||||||
onSubmit={form.handleSubmit(onSubmit)}
|
onSubmit={form.handleSubmit(onSubmit)}
|
||||||
className="w-full flex flex-col "
|
className="flex flex-col w-full "
|
||||||
>
|
>
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
|
|
@ -127,13 +130,13 @@ export default function CitizenLogin() {
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<div className="flex gap-4 mt-4 items-center">
|
<div className="flex items-center gap-4 mt-4">
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="captcha"
|
name="captcha"
|
||||||
rules={{ required: true }}
|
rules={{ required: true }}
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem className=" items-center h-10 flex-1">
|
<FormItem className="items-center flex-1 h-10 ">
|
||||||
{/* <FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
|
{/* <FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
|
||||||
رمز عبور
|
رمز عبور
|
||||||
</FormLabel> */}
|
</FormLabel> */}
|
||||||
|
|
@ -145,7 +148,7 @@ export default function CitizenLogin() {
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<div className=" w-36 flex justify-center text-center">
|
<div className="flex justify-center text-center w-36">
|
||||||
<ThreeDots
|
<ThreeDots
|
||||||
visible={true}
|
visible={true}
|
||||||
height="50"
|
height="50"
|
||||||
|
|
@ -158,31 +161,31 @@ export default function CitizenLogin() {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className=" flex justify-center items-center text-center gap-2">
|
<div className="flex items-center justify-center gap-2 text-center ">
|
||||||
<Image
|
<Image
|
||||||
alt="icon"
|
alt="icon"
|
||||||
src={srcForImage as string}
|
src={srcForImage as string}
|
||||||
className=" h-12 rounded-md shadow-md w-36"
|
className="h-12 rounded-md shadow-md w-36"
|
||||||
width={150}
|
width={150}
|
||||||
height={20}
|
height={20}
|
||||||
quality={100}
|
quality={100}
|
||||||
/>
|
/>
|
||||||
<RefreshCcw
|
<RefreshCcw
|
||||||
className=" cursor-pointer"
|
className="cursor-pointer "
|
||||||
onClick={() => refetch()}
|
onClick={() => refetch()}
|
||||||
color="#003778"
|
color="#003778"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex justify-end gap-2 w-full mt-14">
|
<div className="flex justify-end w-full gap-2 mt-14">
|
||||||
<Button
|
<Button
|
||||||
disabled={loginMutation.isPending}
|
disabled={loginMutation.isPending}
|
||||||
type="submit"
|
type="submit"
|
||||||
className="bg-blue hover:bg-blue/90 transition text-white w-1/2 md:w-1/3 p-2 rounded-xl"
|
className="w-1/2 p-2 text-white transition bg-blue hover:bg-blue/90 md:w-1/3 rounded-xl"
|
||||||
>
|
>
|
||||||
{loginMutation.isPending ? (
|
{loginMutation.isPending ? (
|
||||||
<div className="flex justify-center items-center gap-2">
|
<div className="flex items-center justify-center gap-2">
|
||||||
<Oval
|
<Oval
|
||||||
visible={true}
|
visible={true}
|
||||||
height="20"
|
height="20"
|
||||||
|
|
|
||||||
|
|
@ -117,8 +117,8 @@ export default function ComplainsDetails({
|
||||||
onSuccess: (res) => {
|
onSuccess: (res) => {
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
},
|
},
|
||||||
onError: (err) => {
|
onError: (err: any | string) => {
|
||||||
toast("رمز عبور شما صحیح نمیباشد.", {
|
toast(<>{err.response.data.detail}</>, {
|
||||||
className: "!bg-red-500 !text-white",
|
className: "!bg-red-500 !text-white",
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
@ -163,7 +163,7 @@ export default function ComplainsDetails({
|
||||||
dir="rtl"
|
dir="rtl"
|
||||||
id="picture"
|
id="picture"
|
||||||
onChange={(e) => setPassword(e.target.value)}
|
onChange={(e) => setPassword(e.target.value)}
|
||||||
className=" bg-white hover:bg-white focus:bg-white"
|
className="bg-white hover:bg-white focus:bg-white"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<AlertDialogFooter className=" gap-y-2 max-md:w-full max-md:flex max-md:flex-col">
|
<AlertDialogFooter className=" gap-y-2 max-md:w-full max-md:flex max-md:flex-col">
|
||||||
|
|
@ -188,7 +188,7 @@ export default function ComplainsDetails({
|
||||||
{state !== "FollowResult" && (
|
{state !== "FollowResult" && (
|
||||||
<button
|
<button
|
||||||
onClick={() => router.push("/Account/Complaints")}
|
onClick={() => router.push("/Account/Complaints")}
|
||||||
className=" my-2 flex gap-1 cursor-pointer text-blue "
|
className="flex gap-1 my-2 cursor-pointer text-blue"
|
||||||
>
|
>
|
||||||
<span>
|
<span>
|
||||||
<ArrowRight />
|
<ArrowRight />
|
||||||
|
|
@ -198,7 +198,7 @@ export default function ComplainsDetails({
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Editt */}
|
{/* Editt */}
|
||||||
<div className="w-full flex max-lg:flex-col items-start mt-2 gap-2">
|
<div className="flex items-start w-full gap-2 mt-2 max-lg:flex-col">
|
||||||
{/* 1 */}
|
{/* 1 */}
|
||||||
<div className="flex flex-col w-full lg:w-1/3 gap-3 lg:sticky top-28 lg:h-[78vh]">
|
<div className="flex flex-col w-full lg:w-1/3 gap-3 lg:sticky top-28 lg:h-[78vh]">
|
||||||
{/* ***** */}
|
{/* ***** */}
|
||||||
|
|
@ -215,11 +215,11 @@ export default function ComplainsDetails({
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* 2 */}
|
{/* 2 */}
|
||||||
<div className="w-full lg:w-2/3 self-stretch rounded-lg flex flex-col gap-2 ">
|
<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 lg:sticky top-28">
|
||||||
{data.user == null ? (
|
{data.user == null ? (
|
||||||
<>
|
<>
|
||||||
<div className="mt-2 flex flex-col gap-y-1 border rounded-md border-gray-400 w-full p-5 relative">
|
<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">
|
||||||
اطلاعات کلی
|
اطلاعات کلی
|
||||||
</p>
|
</p>
|
||||||
|
|
@ -253,7 +253,7 @@ export default function ComplainsDetails({
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<div className="mt-2 flex flex-col gap-y-1 border rounded-md border-gray-400 md:w-1/2 p-5 relative">
|
<div className="relative flex flex-col p-5 mt-2 border border-gray-400 rounded-md gap-y-1 md:w-1/2">
|
||||||
<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">
|
||||||
اطلاعات کلی
|
اطلاعات کلی
|
||||||
</p>
|
</p>
|
||||||
|
|
@ -284,7 +284,7 @@ export default function ComplainsDetails({
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-2 flex flex-col gap-y-1 border rounded-md border-gray-400 md:w-1/2 p-5 relative">
|
<div className="relative flex flex-col p-5 mt-2 border border-gray-400 rounded-md gap-y-1 md:w-1/2">
|
||||||
<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">
|
||||||
اطلاعات شاکی
|
اطلاعات شاکی
|
||||||
</p>
|
</p>
|
||||||
|
|
@ -321,14 +321,14 @@ export default function ComplainsDetails({
|
||||||
|
|
||||||
<div className="bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col">
|
<div className="bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col">
|
||||||
<p className="text-[#464646] text-base font-bold">روند شکایت</p>
|
<p className="text-[#464646] text-base font-bold">روند شکایت</p>
|
||||||
<div className=" flex flex-col gap-y-4 mt-4">
|
<div className="flex flex-col mt-4 gap-y-4">
|
||||||
{data.contents?.map((item: any) => {
|
{data.contents?.map((item: any) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={item.id}
|
key={item.id}
|
||||||
className=" bg-white p-4 rounded-lg shadow-md"
|
className="p-4 bg-white rounded-lg shadow-md "
|
||||||
>
|
>
|
||||||
<div className=" flex gap-4 items-center">
|
<div className="flex items-center gap-4 ">
|
||||||
<p className="">
|
<p className="">
|
||||||
<Badge>
|
<Badge>
|
||||||
{item.sender == 0 ? "شهروند" : "بازرس"}
|
{item.sender == 0 ? "شهروند" : "بازرس"}
|
||||||
|
|
@ -347,10 +347,10 @@ export default function ComplainsDetails({
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{/* {item.media.length !== 0 && (
|
{/* {item.media.length !== 0 && (
|
||||||
<Separator className=" mt-2 mb-1" />
|
<Separator className="mt-2 mb-1 " />
|
||||||
)} */}
|
)} */}
|
||||||
<div className=" text-[#464646] mt-2">
|
<div className=" text-[#464646] mt-2">
|
||||||
<div className=" flex flex-wrap max-md:flex-col w-full items-center gap-2 text-xs mt-2">
|
<div className="flex flex-wrap items-center w-full gap-2 mt-2 text-xs max-md:flex-col">
|
||||||
{item?.media.map((item: any, index: number) => {
|
{item?.media.map((item: any, index: number) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|
@ -361,15 +361,15 @@ export default function ComplainsDetails({
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
openFileInNewTab(item.data, item.mimeType)
|
openFileInNewTab(item.data, item.mimeType)
|
||||||
}
|
}
|
||||||
className=" cursor-pointer flex gap-2 truncate items-center"
|
className="flex items-center gap-2 truncate cursor-pointer "
|
||||||
>
|
>
|
||||||
<File className=" w-6 h-6" />
|
<File className="w-6 h-6 " />
|
||||||
<p className=" max-w-[5rem] truncate">
|
<p className=" max-w-[5rem] truncate">
|
||||||
{item.title}
|
{item.title}
|
||||||
</p>
|
</p>
|
||||||
</a>
|
</a>
|
||||||
<ArrowDownToLine
|
<ArrowDownToLine
|
||||||
className=" cursor-pointer"
|
className="cursor-pointer "
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
downloadFile(
|
downloadFile(
|
||||||
item.data,
|
item.data,
|
||||||
|
|
@ -407,7 +407,7 @@ export default function ComplainsDetails({
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
{getComplaintMutation.isPending && (
|
{getComplaintMutation.isPending && (
|
||||||
<div className="w-full h-full flex justify-center mt-20">
|
<div className="flex justify-center w-full h-full mt-20">
|
||||||
<Triangle
|
<Triangle
|
||||||
visible={true}
|
visible={true}
|
||||||
height="100"
|
height="100"
|
||||||
|
|
|
||||||
|
|
@ -64,9 +64,10 @@ export default function FollowResult() {
|
||||||
onSuccess: (res) => {
|
onSuccess: (res) => {
|
||||||
setComplaintData(res);
|
setComplaintData(res);
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (err: any | string) => {
|
||||||
console.log(error);
|
toast(<>{err.response.data.detail}</>, {
|
||||||
console.log(error?.message);
|
className: "!bg-red-500 !text-white",
|
||||||
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -89,14 +90,14 @@ export default function FollowResult() {
|
||||||
<div className="w-[90vw] sm:w-[90vw] lg:w-[85vw] xl:w-[75vw] 3xl:w-[70vw] max-sm:mt-16 pt-12 mx-auto mb-10">
|
<div className="w-[90vw] sm:w-[90vw] lg:w-[85vw] xl:w-[75vw] 3xl:w-[70vw] max-sm:mt-16 pt-12 mx-auto mb-10">
|
||||||
{complaintPrintMutation?.data ? (
|
{complaintPrintMutation?.data ? (
|
||||||
<>
|
<>
|
||||||
{/* <div className="flex justify-center sm:justify-end gap-2 mb-2">
|
{/* <div className="flex justify-center gap-2 mb-2 sm:justify-end">
|
||||||
<AlertDialog>
|
<AlertDialog>
|
||||||
<AlertDialogTrigger asChild>
|
<AlertDialogTrigger asChild>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
type="submit"
|
type="submit"
|
||||||
onClick={() => onSubmit()}
|
onClick={() => onSubmit()}
|
||||||
className="w-fit bg-blue text-white p-2 rounded-xl text-center"
|
className="p-2 text-center text-white w-fit bg-blue rounded-xl"
|
||||||
>
|
>
|
||||||
پرینت درخواست
|
پرینت درخواست
|
||||||
</Button>
|
</Button>
|
||||||
|
|
@ -109,14 +110,14 @@ export default function FollowResult() {
|
||||||
گزارش شکایات
|
گزارش شکایات
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<AlertDialogCancel className="p-0 border-0 h-auto">
|
<AlertDialogCancel className="h-auto p-0 border-0">
|
||||||
<IoMdClose />
|
<IoMdClose />
|
||||||
</AlertDialogCancel>
|
</AlertDialogCancel>
|
||||||
</AlertDialogTitle>
|
</AlertDialogTitle>
|
||||||
|
|
||||||
<AlertDialogDescription className="h-full px-0 py-0 sm:px-0 sm:pt-0 ">
|
<AlertDialogDescription className="h-full px-0 py-0 sm:px-0 sm:pt-0 ">
|
||||||
{complaintPrintMutation.isPending ? (
|
{complaintPrintMutation.isPending ? (
|
||||||
<div className="felx justify-center items-center self-center h-full">
|
<div className="items-center self-center justify-center h-full felx">
|
||||||
<ThreeDots
|
<ThreeDots
|
||||||
visible={true}
|
visible={true}
|
||||||
height="80"
|
height="80"
|
||||||
|
|
@ -159,9 +160,9 @@ export default function FollowResult() {
|
||||||
<br />
|
<br />
|
||||||
<p className="text-[#464646] text-sm font-medium">
|
<p className="text-[#464646] text-sm font-medium">
|
||||||
درخواست شما با کد رهگیری
|
درخواست شما با کد رهگیری
|
||||||
<span className="text-slate-500 mx-2">{`${trackingNumber}`}</span>
|
<span className="mx-2 text-slate-500">{`${trackingNumber}`}</span>
|
||||||
و رمز عبور
|
و رمز عبور
|
||||||
<span className="text-slate-500 mx-2">{`${password}`}</span>
|
<span className="mx-2 text-slate-500">{`${password}`}</span>
|
||||||
در دست بررسی و اقدام می باشد. در صورت تمایل می
|
در دست بررسی و اقدام می باشد. در صورت تمایل می
|
||||||
توانید با شماره تلفن 0353286545 جهت پشتیبانی تماس
|
توانید با شماره تلفن 0353286545 جهت پشتیبانی تماس
|
||||||
حاصل کنید.
|
حاصل کنید.
|
||||||
|
|
@ -172,7 +173,7 @@ export default function FollowResult() {
|
||||||
</AlertDialogHeader>
|
</AlertDialogHeader>
|
||||||
<AlertDialogFooter>
|
<AlertDialogFooter>
|
||||||
<Button
|
<Button
|
||||||
className="bg-blue text-white w-1/2 sm:w-1/6"
|
className="w-1/2 text-white bg-blue sm:w-1/6"
|
||||||
onClick={handlePrint}
|
onClick={handlePrint}
|
||||||
>
|
>
|
||||||
پرینت گزارش
|
پرینت گزارش
|
||||||
|
|
|
||||||
|
|
@ -48,10 +48,10 @@ export default function FollowUp() {
|
||||||
console.log(result);
|
console.log(result);
|
||||||
|
|
||||||
// alert("Success");
|
// alert("Success");
|
||||||
console.log("Success FollowUp");
|
console.log("Success FollowUp");
|
||||||
|
|
||||||
// router.push("/FollowResult");
|
// router.push("/FollowResult");
|
||||||
router.push("/FollowResult", {data: JSON.stringify( result ) });
|
router.push("/FollowResult", { data: JSON.stringify(result) });
|
||||||
|
|
||||||
// router.push(
|
// router.push(
|
||||||
// "/FollowResult",
|
// "/FollowResult",
|
||||||
|
|
@ -62,16 +62,17 @@ export default function FollowUp() {
|
||||||
|
|
||||||
// router.push({
|
// router.push({
|
||||||
// pathname : '/FollowResult',
|
// pathname : '/FollowResult',
|
||||||
// query : {
|
// query : {
|
||||||
// data: JSON.stringify( result ) ;
|
// data: JSON.stringify( result ) ;
|
||||||
// },
|
// },
|
||||||
// });
|
// });
|
||||||
|
|
||||||
// return (res)
|
// return (res)
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (err: any | string) => {
|
||||||
console.log(error);
|
toast(<>{err.response.data.detail}</>, {
|
||||||
console.log(error?.message);
|
className: "!bg-red-500 !text-white",
|
||||||
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -103,9 +104,9 @@ export default function FollowUp() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div className="w-full h-full sm:w-2/3 md:w-2/4 max-sm:p-8 pt-12">
|
<div className="w-full h-full pt-12 sm:w-2/3 md:w-2/4 max-sm:p-8">
|
||||||
<div className="space-y-3 md:space-y-4 h-full flex flex-col justify-start ">
|
<div className="flex flex-col justify-start h-full space-y-3 md:space-y-4 ">
|
||||||
<p className="text-sm md:text-base font-bold leading-tight tracking-tight text-blue dark:text-white">
|
<p className="text-sm font-bold leading-tight tracking-tight md:text-base text-blue dark:text-white">
|
||||||
لطفا جهت پیگیری درخواست و مشاهده وضعیت آن کد رهگیری و رمز عبور خود را
|
لطفا جهت پیگیری درخواست و مشاهده وضعیت آن کد رهگیری و رمز عبور خود را
|
||||||
وارد نمایید.
|
وارد نمایید.
|
||||||
</p>
|
</p>
|
||||||
|
|
@ -113,7 +114,7 @@ export default function FollowUp() {
|
||||||
<Form {...form}>
|
<Form {...form}>
|
||||||
<form
|
<form
|
||||||
onSubmit={form.handleSubmit(onSubmit)}
|
onSubmit={form.handleSubmit(onSubmit)}
|
||||||
className="w-full flex flex-col mt-6 "
|
className="flex flex-col w-full mt-6 "
|
||||||
>
|
>
|
||||||
<div className="flex flex-row flex-wrap justify-between">
|
<div className="flex flex-row flex-wrap justify-between">
|
||||||
<FormField
|
<FormField
|
||||||
|
|
@ -155,11 +156,11 @@ export default function FollowUp() {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex justify-center sm:justify-end gap-2 w-full mt-8">
|
<div className="flex justify-center w-full gap-2 mt-8 sm:justify-end">
|
||||||
<Button
|
<Button
|
||||||
// href="/FollowResult"
|
// href="/FollowResult"
|
||||||
type="submit"
|
type="submit"
|
||||||
className="bg-blue text-white min-w-max w-1/2 sm:w-1/3 lg:w-1/4 p-2 rounded-xl text-center"
|
className="w-1/2 p-2 text-center text-white bg-blue min-w-max sm:w-1/3 lg:w-1/4 rounded-xl"
|
||||||
>
|
>
|
||||||
پیگیری درخواست
|
پیگیری درخواست
|
||||||
</Button>
|
</Button>
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,11 @@ export default function InspectorOperations({
|
||||||
className: "!bg-green-500 !text-white",
|
className: "!bg-green-500 !text-white",
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onError: (err) => {},
|
onError: (err: any | string) => {
|
||||||
|
toast(<>{err.response.data.detail}</>, {
|
||||||
|
className: "!bg-red-500 !text-white",
|
||||||
|
});
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
function onSubmit(data: z.infer<typeof FormSchema>) {
|
function onSubmit(data: z.infer<typeof FormSchema>) {
|
||||||
|
|
@ -133,7 +137,7 @@ export default function InspectorOperations({
|
||||||
/>
|
/>
|
||||||
{/* <div className="grid w-full max-w-sm items-center gap-1.5 mt-1">
|
{/* <div className="grid w-full max-w-sm items-center gap-1.5 mt-1">
|
||||||
<Label htmlFor="picture">پیوست</Label>
|
<Label htmlFor="picture">پیوست</Label>
|
||||||
<Input multiple id="picture" type="file" className=" bg-white" />
|
<Input multiple id="picture" type="file" className="bg-white " />
|
||||||
</div> */}
|
</div> */}
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
|
|
@ -150,19 +154,19 @@ export default function InspectorOperations({
|
||||||
console.log(e.target.files);
|
console.log(e.target.files);
|
||||||
}}
|
}}
|
||||||
multiple
|
multiple
|
||||||
className=" bg-white"
|
className="bg-white "
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<div className=" flex justify-between mt-3 gap-2">
|
<div className="flex justify-between gap-2 mt-3 ">
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="operation"
|
name="operation"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem className=" flex-1">
|
<FormItem className="flex-1 ">
|
||||||
{/* <FormLabel>Email</FormLabel> */}
|
{/* <FormLabel>Email</FormLabel> */}
|
||||||
<Select
|
<Select
|
||||||
onValueChange={field.onChange}
|
onValueChange={field.onChange}
|
||||||
|
|
@ -176,7 +180,7 @@ export default function InspectorOperations({
|
||||||
disabled={possibleOperations.length == 0}
|
disabled={possibleOperations.length == 0}
|
||||||
>
|
>
|
||||||
<SelectValue
|
<SelectValue
|
||||||
className=" text-xs"
|
className="text-xs "
|
||||||
placeholder="نوع عملیات را انتخاب نمایید."
|
placeholder="نوع عملیات را انتخاب نمایید."
|
||||||
/>
|
/>
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
|
|
@ -206,7 +210,7 @@ export default function InspectorOperations({
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
disabled={possibleOperations.length == 0}
|
disabled={possibleOperations.length == 0}
|
||||||
className=" bg-blue w-1/3"
|
className="w-1/3 bg-blue"
|
||||||
type="submit"
|
type="submit"
|
||||||
>
|
>
|
||||||
ثبت
|
ثبت
|
||||||
|
|
|
||||||
|
|
@ -60,11 +60,10 @@ export default function Login() {
|
||||||
const loginMutation = useMutation({
|
const loginMutation = useMutation({
|
||||||
mutationFn: loginStaff,
|
mutationFn: loginStaff,
|
||||||
onSuccess: (res) => {},
|
onSuccess: (res) => {},
|
||||||
onError: (err: any) => {
|
onError: (err: any | string) => {
|
||||||
if (err.response.status == 428) {
|
toast(<>{err.response.data.detail}</>, {
|
||||||
console.log(useData);
|
className: "!bg-red-500 !text-white",
|
||||||
router.push("/Verify");
|
});
|
||||||
}
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -97,17 +96,17 @@ export default function Login() {
|
||||||
className="w-full mt-12 sm:w-2/3 md:w-2/4 xl:w-1/3 bg-white rounded-lg dark:border xl:p-0 dark:bg-gray-800 dark:border-gray-700 shadow-[0px_0px_15px_0px_#00000040]
|
className="w-full mt-12 sm:w-2/3 md:w-2/4 xl:w-1/3 bg-white rounded-lg dark:border xl:p-0 dark:bg-gray-800 dark:border-gray-700 shadow-[0px_0px_15px_0px_#00000040]
|
||||||
h-full max-md:p-8 pt-12 mb-10"
|
h-full max-md:p-8 pt-12 mb-10"
|
||||||
>
|
>
|
||||||
<div className="space-y-3 md:space-y-4 flex flex-col md:py-10 md:px-12 lg:px-16 h-full justify-center">
|
<div className="flex flex-col justify-center h-full space-y-3 md:space-y-4 md:py-10 md:px-12 lg:px-16">
|
||||||
<Image alt="icon" src={LoginIcon} className="self-center w-1/3 " />
|
<Image alt="icon" src={LoginIcon} className="self-center w-1/3 " />
|
||||||
|
|
||||||
<p className="text-lg font-bold leading-tight tracking-tight text-blue dark:text-white">
|
<p className="text-lg font-bold leading-tight tracking-tight text-blue dark:text-white">
|
||||||
ورود به پنل کاربری
|
ورود به پنل کاربری
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<Form {...form}>
|
<Form {...form}>
|
||||||
<form
|
<form
|
||||||
onSubmit={form.handleSubmit(onSubmit)}
|
onSubmit={form.handleSubmit(onSubmit)}
|
||||||
className="w-full flex flex-col "
|
className="flex flex-col w-full "
|
||||||
>
|
>
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
|
|
@ -153,13 +152,13 @@ export default function Login() {
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<div className="flex gap-4 mt-4 items-center">
|
<div className="flex items-center gap-4 mt-4">
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="captcha"
|
name="captcha"
|
||||||
rules={{ required: true }}
|
rules={{ required: true }}
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem className=" items-center h-10 flex-1">
|
<FormItem className="items-center flex-1 h-10 ">
|
||||||
{/* <FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
|
{/* <FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
|
||||||
رمز عبور
|
رمز عبور
|
||||||
</FormLabel> */}
|
</FormLabel> */}
|
||||||
|
|
@ -171,7 +170,7 @@ export default function Login() {
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<div className=" w-36 flex justify-center text-center">
|
<div className="flex justify-center text-center w-36">
|
||||||
<ThreeDots
|
<ThreeDots
|
||||||
visible={true}
|
visible={true}
|
||||||
height="50"
|
height="50"
|
||||||
|
|
@ -184,31 +183,31 @@ export default function Login() {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className=" flex justify-center text-center gap-2">
|
<div className="flex justify-center gap-2 text-center ">
|
||||||
<Image
|
<Image
|
||||||
alt="icon"
|
alt="icon"
|
||||||
src={srcForImage as string}
|
src={srcForImage as string}
|
||||||
className=" h-12 rounded-md shadow-md w-36"
|
className="h-12 rounded-md shadow-md w-36"
|
||||||
width={150}
|
width={150}
|
||||||
height={20}
|
height={20}
|
||||||
quality={100}
|
quality={100}
|
||||||
/>
|
/>
|
||||||
<RefreshCcw
|
<RefreshCcw
|
||||||
className=" cursor-pointer"
|
className="cursor-pointer "
|
||||||
onClick={() => refetch()}
|
onClick={() => refetch()}
|
||||||
color="#003778"
|
color="#003778"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex justify-end gap-2 w-full mt-14">
|
<div className="flex justify-end w-full gap-2 mt-14">
|
||||||
<Button
|
<Button
|
||||||
disabled={loginMutation.isPending}
|
disabled={loginMutation.isPending}
|
||||||
type="submit"
|
type="submit"
|
||||||
className="bg-blue hover:bg-blue/90 transition text-white w-1/2 md:w-1/3 p-2 rounded-xl"
|
className="w-1/2 p-2 text-white transition bg-blue hover:bg-blue/90 md:w-1/3 rounded-xl"
|
||||||
>
|
>
|
||||||
{loginMutation.isPending ? (
|
{loginMutation.isPending ? (
|
||||||
<div className="flex justify-center items-center gap-2">
|
<div className="flex items-center justify-center gap-2">
|
||||||
<Oval
|
<Oval
|
||||||
visible={true}
|
visible={true}
|
||||||
height="20"
|
height="20"
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,11 @@ export default function Profile() {
|
||||||
router.push("/RequestStep2");
|
router.push("/RequestStep2");
|
||||||
localStorage.setItem("authorized", "true");
|
localStorage.setItem("authorized", "true");
|
||||||
},
|
},
|
||||||
onError: (error) => {},
|
onError: (err: any | string) => {
|
||||||
|
toast(<>{err.response.data.detail}</>, {
|
||||||
|
className: "!bg-red-500 !text-white",
|
||||||
|
});
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const form = useForm<z.infer<typeof FormSchema>>({
|
const form = useForm<z.infer<typeof FormSchema>>({
|
||||||
|
|
@ -98,13 +102,13 @@ export default function Profile() {
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full h-full sm:w-2/3 md:w-2/4 max-sm:p-8 pt-12">
|
<div className="w-full h-full pt-12 sm:w-2/3 md:w-2/4 max-sm:p-8">
|
||||||
<div className="space-y-4 md:space-y-4 h-full flex flex-col justify-center">
|
<div className="flex flex-col justify-center h-full space-y-4 md:space-y-4">
|
||||||
{profileData && (
|
{profileData && (
|
||||||
<Form {...form}>
|
<Form {...form}>
|
||||||
<form
|
<form
|
||||||
onSubmit={form.handleSubmit(onSubmit)}
|
onSubmit={form.handleSubmit(onSubmit)}
|
||||||
className="w-full flex flex-col mt-6 "
|
className="flex flex-col w-full mt-6 "
|
||||||
>
|
>
|
||||||
<div className="flex flex-row flex-wrap justify-between">
|
<div className="flex flex-row flex-wrap justify-between">
|
||||||
<FormField
|
<FormField
|
||||||
|
|
|
||||||
|
|
@ -32,11 +32,11 @@ import {
|
||||||
DropdownMenuSubTrigger,
|
DropdownMenuSubTrigger,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/components/ui/dropdown-menu";
|
} from "@/components/ui/dropdown-menu";
|
||||||
import { getProfile } from "@/utils/authenticateApi";
|
import { getProfile, revoke } from "@/utils/authenticateApi";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import useToken from "@/store/useToken";
|
import useToken from "@/store/useToken";
|
||||||
import { deleteCookie } from "cookies-next";
|
import { deleteCookie, getCookie } from "cookies-next";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
|
|
||||||
export default function ProfileDropDown() {
|
export default function ProfileDropDown() {
|
||||||
|
|
@ -50,7 +50,22 @@ export default function ProfileDropDown() {
|
||||||
queryFn: () => getProfile(),
|
queryFn: () => getProfile(),
|
||||||
refetchOnWindowFocus: false,
|
refetchOnWindowFocus: false,
|
||||||
});
|
});
|
||||||
console.log(profileData);
|
|
||||||
|
const revokeMutation = useMutation({
|
||||||
|
mutationFn: revoke,
|
||||||
|
onSuccess: (res) => {},
|
||||||
|
onError: (err: any | string) => {},
|
||||||
|
});
|
||||||
|
|
||||||
|
const logout = () => {
|
||||||
|
revokeMutation.mutate({
|
||||||
|
refreshToken: getCookie("Sootzani_Refresh_Token"),
|
||||||
|
});
|
||||||
|
saveToken(false);
|
||||||
|
deleteCookie("Sootzani_Refresh_Token");
|
||||||
|
deleteCookie("Sootzani_Token");
|
||||||
|
router.push("/");
|
||||||
|
};
|
||||||
const saveToken = useToken((state) => state.saveToken);
|
const saveToken = useToken((state) => state.saveToken);
|
||||||
return (
|
return (
|
||||||
<DropdownMenu dir="rtl">
|
<DropdownMenu dir="rtl">
|
||||||
|
|
@ -62,23 +77,17 @@ export default function ProfileDropDown() {
|
||||||
<DropdownMenuContent className="w-56 sm:ml-10">
|
<DropdownMenuContent className="w-56 sm:ml-10">
|
||||||
<DropdownMenuGroup>
|
<DropdownMenuGroup>
|
||||||
<DropdownMenuItem onClick={() => router.push("/Account/Profile")}>
|
<DropdownMenuItem onClick={() => router.push("/Account/Profile")}>
|
||||||
<User className="ml-2 h-4 w-4" />
|
<User className="w-4 h-4 ml-2" />
|
||||||
<span>مشاهده پروفایل</span>
|
<span>مشاهده پروفایل</span>
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
<DropdownMenuItem onClick={() => router.push("/Account/Complaints")}>
|
<DropdownMenuItem onClick={() => router.push("/Account/Complaints")}>
|
||||||
<CreditCard className="ml-2 h-4 w-4" />
|
<CreditCard className="w-4 h-4 ml-2" />
|
||||||
<span>درخواست های من</span>
|
<span>درخواست های من</span>
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
</DropdownMenuGroup>
|
</DropdownMenuGroup>
|
||||||
<DropdownMenuSeparator />
|
<DropdownMenuSeparator />
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem onClick={logout}>
|
||||||
onClick={() => {
|
<LogOut className="w-4 h-4 ml-2" />
|
||||||
saveToken(false);
|
|
||||||
deleteCookie("Sootzani_Token");
|
|
||||||
router.push("/");
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<LogOut className="ml-2 h-4 w-4" />
|
|
||||||
<span>خروج</span>
|
<span>خروج</span>
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
|
import { AppProgressBar as ProgressBar } from "next-nprogress-bar";
|
||||||
|
|
||||||
|
const ProgressBarProviders = ({ children }: { children: React.ReactNode }) => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{children}
|
||||||
|
<ProgressBar
|
||||||
|
height="4px"
|
||||||
|
color="#29D"
|
||||||
|
options={{ showSpinner: false }}
|
||||||
|
shallowRouting
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ProgressBarProviders;
|
||||||
|
|
@ -66,7 +66,11 @@ export default function RequestStep1() {
|
||||||
router.push("/RequestStep2");
|
router.push("/RequestStep2");
|
||||||
localStorage.setItem("authorized", "true");
|
localStorage.setItem("authorized", "true");
|
||||||
},
|
},
|
||||||
onError: (error) => {},
|
onError: (err: any | string) => {
|
||||||
|
toast(<>{err.response.data.detail}</>, {
|
||||||
|
className: "!bg-red-500 !text-white",
|
||||||
|
});
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const form = useForm<z.infer<typeof FormSchema>>({
|
const form = useForm<z.infer<typeof FormSchema>>({
|
||||||
|
|
@ -100,16 +104,16 @@ export default function RequestStep1() {
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full h-full sm:w-2/3 md:w-2/4 max-sm:p-8 pt-12">
|
<div className="w-full h-full pt-12 sm:w-2/3 md:w-2/4 max-sm:p-8">
|
||||||
<div className="space-y-4 md:space-y-4 h-full flex flex-col justify-center">
|
<div className="flex flex-col justify-center h-full space-y-4 md:space-y-4">
|
||||||
<p className="text-sm md:text-base font-bold leading-tight tracking-tight text-blue dark:text-white">
|
<p className="text-sm font-bold leading-tight tracking-tight md:text-base text-blue dark:text-white">
|
||||||
لطفا جهت ارسال درخواست فرم زیر را تکمیل نمایید.
|
لطفا جهت ارسال درخواست فرم زیر را تکمیل نمایید.
|
||||||
</p>
|
</p>
|
||||||
{profileData && (
|
{profileData && (
|
||||||
<Form {...form}>
|
<Form {...form}>
|
||||||
<form
|
<form
|
||||||
onSubmit={form.handleSubmit(onSubmit)}
|
onSubmit={form.handleSubmit(onSubmit)}
|
||||||
className="w-full flex flex-col mt-6 "
|
className="flex flex-col w-full mt-6 "
|
||||||
>
|
>
|
||||||
<div className="flex flex-row flex-wrap justify-between">
|
<div className="flex flex-row flex-wrap justify-between">
|
||||||
<FormField
|
<FormField
|
||||||
|
|
@ -169,10 +173,10 @@ export default function RequestStep1() {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex justify-center sm:justify-end gap-2 w-full mt-8">
|
<div className="flex justify-center w-full gap-2 mt-8 sm:justify-end">
|
||||||
<Button
|
<Button
|
||||||
type="submit"
|
type="submit"
|
||||||
className="w-1/2 sm:w-1/3 lg:w-1/4 bg-blue text-white p-2 rounded-xl text-center"
|
className="w-1/2 p-2 text-center text-white sm:w-1/3 lg:w-1/4 bg-blue rounded-xl"
|
||||||
>
|
>
|
||||||
صفحه ی بعد
|
صفحه ی بعد
|
||||||
</Button>
|
</Button>
|
||||||
|
|
|
||||||
|
|
@ -118,8 +118,8 @@ export default function RequestStep2() {
|
||||||
localStorage.setItem("password", res.password);
|
localStorage.setItem("password", res.password);
|
||||||
router.push("/RequestResult");
|
router.push("/RequestResult");
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (err: any | string) => {
|
||||||
toast("مشکلی در ارسال درخواست به وجود آمد.", {
|
toast(<>{err.response.data.detail}</>, {
|
||||||
className: "!bg-red-500 !text-white",
|
className: "!bg-red-500 !text-white",
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
@ -135,8 +135,8 @@ export default function RequestStep2() {
|
||||||
localStorage.removeItem("authorized");
|
localStorage.removeItem("authorized");
|
||||||
router.push("/RequestResult");
|
router.push("/RequestResult");
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (err: any | string) => {
|
||||||
toast("مشکلی در ارسال درخواست به وجود آمد.", {
|
toast(<>{err.response.data.detail}</>, {
|
||||||
className: "!bg-red-500 !text-white",
|
className: "!bg-red-500 !text-white",
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
@ -216,16 +216,16 @@ export default function RequestStep2() {
|
||||||
const { resetField } = useForm();
|
const { resetField } = useForm();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full h-full sm:w-2/3 md:w-2/4 max-sm:p-8 pt-12">
|
<div className="w-full h-full pt-12 sm:w-2/3 md:w-2/4 max-sm:p-8">
|
||||||
<div className="space-y-3 md:space-y-4 h-full flex flex-col justify-center">
|
<div className="flex flex-col justify-center h-full space-y-3 md:space-y-4">
|
||||||
<p className="text-sm md:text-base font-bold leading-tight tracking-tight text-blue dark:text-white">
|
<p className="text-sm font-bold leading-tight tracking-tight md:text-base text-blue dark:text-white">
|
||||||
لطفا جهت ارسال درخواست فرم زیر را تکمیل نمایید.
|
لطفا جهت ارسال درخواست فرم زیر را تکمیل نمایید.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<Form {...form}>
|
<Form {...form}>
|
||||||
<form
|
<form
|
||||||
onSubmit={form.handleSubmit(onSubmit)}
|
onSubmit={form.handleSubmit(onSubmit)}
|
||||||
className="w-full flex flex-col mt-6"
|
className="flex flex-col w-full mt-6"
|
||||||
>
|
>
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
|
|
@ -282,7 +282,7 @@ export default function RequestStep2() {
|
||||||
</SelectGroup>
|
</SelectGroup>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
<FormMessage className=" mt-2" />
|
<FormMessage className="mt-2 " />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
@ -318,7 +318,7 @@ export default function RequestStep2() {
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Textarea
|
<Textarea
|
||||||
placeholder="متن توضیحات خود را بنویسید"
|
placeholder="متن توضیحات خود را بنویسید"
|
||||||
className="resize-none mb-3"
|
className="mb-3 resize-none"
|
||||||
{...field}
|
{...field}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|
@ -355,7 +355,7 @@ export default function RequestStep2() {
|
||||||
))}
|
))}
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
<FormMessage className=" mt-2" />
|
<FormMessage className="mt-2 " />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
@ -465,13 +465,13 @@ export default function RequestStep2() {
|
||||||
<Image
|
<Image
|
||||||
alt="icon"
|
alt="icon"
|
||||||
src={srcForImage as string}
|
src={srcForImage as string}
|
||||||
className=" h-12 rounded-md shadow-md w-36"
|
className="h-12 rounded-md shadow-md w-36"
|
||||||
width={150}
|
width={150}
|
||||||
height={20}
|
height={20}
|
||||||
quality={100}
|
quality={100}
|
||||||
/>
|
/>
|
||||||
<RefreshCcw
|
<RefreshCcw
|
||||||
className=" cursor-pointer"
|
className="cursor-pointer "
|
||||||
onClick={() => refetch()}
|
onClick={() => refetch()}
|
||||||
color="#003778"
|
color="#003778"
|
||||||
/>
|
/>
|
||||||
|
|
@ -479,10 +479,10 @@ export default function RequestStep2() {
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex justify-center sm:justify-end gap-2 w-full mt-4">
|
<div className="flex justify-center w-full gap-2 mt-4 sm:justify-end">
|
||||||
<Button
|
<Button
|
||||||
type="submit"
|
type="submit"
|
||||||
className="w-1/2 sm:w-1/3 lg:w-1/4 bg-blue text-white p-2 rounded-xl text-center mb-4"
|
className="w-1/2 p-2 mb-4 text-center text-white sm:w-1/3 lg:w-1/4 bg-blue rounded-xl"
|
||||||
>
|
>
|
||||||
ارسال درخواست
|
ارسال درخواست
|
||||||
</Button>
|
</Button>
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import { useRouter } from "next/navigation";
|
||||||
import useData from "@/store/useData";
|
import useData from "@/store/useData";
|
||||||
import { JwtPayload, jwtDecode } from "jwt-decode";
|
import { JwtPayload, jwtDecode } from "jwt-decode";
|
||||||
import { setCookie } from "cookies-next";
|
import { setCookie } from "cookies-next";
|
||||||
import { Oval } from "react-loader-spinner";
|
import { Oval, Triangle } from "react-loader-spinner";
|
||||||
import useToken from "@/store/useToken";
|
import useToken from "@/store/useToken";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
|
|
||||||
|
|
@ -21,32 +21,14 @@ export default function Verify() {
|
||||||
const userData = useData((state) => state.data);
|
const userData = useData((state) => state.data);
|
||||||
const [VerifyRole, setVerifyRole] = useState<any>("");
|
const [VerifyRole, setVerifyRole] = useState<any>("");
|
||||||
const saveToken = useToken((state) => state.saveToken);
|
const saveToken = useToken((state) => state.saveToken);
|
||||||
// const verifyMutation = useMutation({
|
|
||||||
// mutationFn: verifyStaff,
|
|
||||||
// onSuccess: (res) => {
|
|
||||||
// const decodedToken = jwtDecode<any>(res);
|
|
||||||
// setCookie("Sootzani_Token", res);
|
|
||||||
// const userRole =
|
|
||||||
// decodedToken[
|
|
||||||
// "http://schemas.microsoft.com/ws/2008/06/identity/claims/role"
|
|
||||||
// ];
|
|
||||||
// localStorage.setItem("Sootzani_Role", userRole);
|
|
||||||
// if (userRole == "Inspector") {
|
|
||||||
// router.push("/UserPanel/ControllerDashboard");
|
|
||||||
// } else if (userRole == "Admin") {
|
|
||||||
// router.push("/UserPanel/AdminDashboard");
|
|
||||||
// } else {
|
|
||||||
// router.push("/UserPanel/CitizenDashboard");
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// onError: (err: any) => {},
|
|
||||||
// });
|
|
||||||
const CitizenVerifyMutation = useMutation({
|
const CitizenVerifyMutation = useMutation({
|
||||||
mutationFn: verifyCitizen,
|
mutationFn: verifyCitizen,
|
||||||
onSuccess: (res) => {
|
onSuccess: (res) => {
|
||||||
saveToken(true);
|
saveToken(true);
|
||||||
const decodedToken = jwtDecode<any>(res);
|
const decodedToken = jwtDecode<any>(res.jwtToken);
|
||||||
setCookie("Sootzani_Token", res);
|
setCookie("Sootzani_Token", res.jwtToken);
|
||||||
|
setCookie("Sootzani_Refresh_Token", res.refreshToken);
|
||||||
const userRole =
|
const userRole =
|
||||||
decodedToken[
|
decodedToken[
|
||||||
"http://schemas.microsoft.com/ws/2008/06/identity/claims/role"
|
"http://schemas.microsoft.com/ws/2008/06/identity/claims/role"
|
||||||
|
|
@ -60,16 +42,19 @@ export default function Verify() {
|
||||||
router.push("/RequestStep1");
|
router.push("/RequestStep1");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onError: (err: any) => {
|
onError: (err: any | string) => {
|
||||||
toast("کد تایید شما صحیح نمیباشد.", {
|
toast(<>{err.response.data.detail}</>, {
|
||||||
className: "!bg-red-500 !text-white",
|
className: "!bg-red-500 !text-white",
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const handelVerify = () => {
|
const handelVerify = () => {
|
||||||
console.log(otp);
|
console.log(otp);
|
||||||
const payload = { ...userData, verificationCode: otp };
|
const payload = {
|
||||||
|
otpToken: localStorage.getItem("verificationToken"),
|
||||||
|
verificationCode: otp,
|
||||||
|
};
|
||||||
console.log(userData);
|
console.log(userData);
|
||||||
CitizenVerifyMutation.mutate(payload);
|
CitizenVerifyMutation.mutate(payload);
|
||||||
};
|
};
|
||||||
|
|
@ -80,19 +65,34 @@ export default function Verify() {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (otp.length == 6) {
|
if (otp.length == 6) {
|
||||||
const payload = { ...userData, verificationCode: otp };
|
const payload = {
|
||||||
console.log(userData);
|
otpToken: localStorage.getItem("verificationToken"),
|
||||||
|
verificationCode: otp,
|
||||||
|
};
|
||||||
CitizenVerifyMutation.mutate(payload);
|
CitizenVerifyMutation.mutate(payload);
|
||||||
}
|
}
|
||||||
}, [otp]);
|
}, [otp]);
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="w-full mt-28 sm:w-2/3 md:w-2/4 xl:w-1/3 bg-white rounded-lg dark:border xl:p-0 dark:bg-gray-800 dark:border-gray-700 shadow-[0px_0px_15px_0px_#00000040]
|
className="w-full mt-28 sm:w-2/3 md:w-2/4 xl:w-1/3 bg-white rounded-lg dark:border xl:p-0 dark:bg-gray-800 dark:border-gray-700 shadow-[0px_0px_15px_0px_#00000040]
|
||||||
h-full max-md:p-8 pt-12"
|
h-full max-md:p-8 pt-12 relative"
|
||||||
>
|
>
|
||||||
<div className="space-y-3 md:space-y-4 flex flex-col md:py-12 md:px-20 h-full justify-center">
|
{CitizenVerifyMutation.isPending && (
|
||||||
|
<div className="absolute top-3 left-5 ">
|
||||||
|
<Triangle
|
||||||
|
visible={true}
|
||||||
|
height="30"
|
||||||
|
width="30"
|
||||||
|
color="#003778"
|
||||||
|
ariaLabel="triangle-loading"
|
||||||
|
wrapperStyle={{}}
|
||||||
|
wrapperClass=""
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div className="flex flex-col justify-center h-full space-y-3 md:space-y-4 md:py-12 md:px-20">
|
||||||
<Image alt="icon" src={LoginIcon} className="self-center w-1/3 " />
|
<Image alt="icon" src={LoginIcon} className="self-center w-1/3 " />
|
||||||
<p className="text-lg font-bold leading-tight tracking-tight text-blue dark:text-white">
|
<p className="text-lg font-bold leading-tight tracking-tight text-blue dark:text-white">
|
||||||
تایید کد
|
تایید کد
|
||||||
</p>
|
</p>
|
||||||
<div className="w-full " dir="ltr">
|
<div className="w-full " dir="ltr">
|
||||||
|
|
@ -108,20 +108,20 @@ export default function Verify() {
|
||||||
inputStyle=" !w-10 rounded-md h-10 bg-[#F5F5F5] border border-blue/30 text-black"
|
inputStyle=" !w-10 rounded-md h-10 bg-[#F5F5F5] border border-blue/30 text-black"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<label className="label text-center">
|
<label className="text-center label">
|
||||||
<span className="text-xs text-blue/70 label-text text-center">
|
<span className="text-xs text-center text-blue/70 label-text">
|
||||||
کد دریافت شده توسط پیامک را وارد نمایید.
|
کد دریافت شده توسط پیامک را وارد نمایید.
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
{/* <div className="flex justify-end gap-2 w-full mt-14">
|
{/* <div className="flex justify-end w-full gap-2 mt-14">
|
||||||
<Button
|
<Button
|
||||||
disabled={CitizenVerifyMutation.isPending}
|
disabled={CitizenVerifyMutation.isPending}
|
||||||
onClick={handelVerify}
|
onClick={handelVerify}
|
||||||
type="submit"
|
type="submit"
|
||||||
className="bg-blue hover:bg-blue/90 text-white w-1/2 md:w-1/3 p-2 rounded-xl"
|
className="w-1/2 p-2 text-white bg-blue hover:bg-blue/90 md:w-1/3 rounded-xl"
|
||||||
>
|
>
|
||||||
{CitizenVerifyMutation.isPending ? (
|
{CitizenVerifyMutation.isPending ? (
|
||||||
<div className="flex justify-center items-center gap-2">
|
<div className="flex items-center justify-center gap-2">
|
||||||
<Oval
|
<Oval
|
||||||
visible={true}
|
visible={true}
|
||||||
height="20"
|
height="20"
|
||||||
|
|
@ -140,7 +140,7 @@ export default function Verify() {
|
||||||
{/* <Form {...form}>
|
{/* <Form {...form}>
|
||||||
<form
|
<form
|
||||||
onSubmit={form.handleSubmit(onSubmit)}
|
onSubmit={form.handleSubmit(onSubmit)}
|
||||||
className="w-full flex flex-col "
|
className="flex flex-col w-full "
|
||||||
>
|
>
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
|
|
@ -181,10 +181,10 @@ export default function Verify() {
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="flex justify-end gap-2 w-full mt-14">
|
<div className="flex justify-end w-full gap-2 mt-14">
|
||||||
<Button
|
<Button
|
||||||
type="submit"
|
type="submit"
|
||||||
className="bg-blue text-white w-1/2 md:w-1/3 p-2 rounded-xl"
|
className="w-1/2 p-2 text-white bg-blue md:w-1/3 rounded-xl"
|
||||||
>
|
>
|
||||||
ورود
|
ورود
|
||||||
</Button>
|
</Button>
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@
|
||||||
"leaflet-geosearch": "^3.11.0",
|
"leaflet-geosearch": "^3.11.0",
|
||||||
"lucide-react": "^0.292.0",
|
"lucide-react": "^0.292.0",
|
||||||
"next": "14.0.3",
|
"next": "14.0.3",
|
||||||
|
"next-nprogress-bar": "^2.1.2",
|
||||||
"next-themes": "^0.2.1",
|
"next-themes": "^0.2.1",
|
||||||
"npm": "^10.2.5",
|
"npm": "^10.2.5",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
|
|
@ -4823,6 +4824,14 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/next-nprogress-bar": {
|
||||||
|
"version": "2.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/next-nprogress-bar/-/next-nprogress-bar-2.1.2.tgz",
|
||||||
|
"integrity": "sha512-2Df5d7fr6uPx+BX8MkoWCfl+RjG+uWI5mA399e5sEe8mbT3q/GIUvCXLzBgJBIISpKuMmdLAOYEzqpjlsRVOWw==",
|
||||||
|
"dependencies": {
|
||||||
|
"nprogress": "^0.2.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/next-themes": {
|
"node_modules/next-themes": {
|
||||||
"version": "0.2.1",
|
"version": "0.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/next-themes/-/next-themes-0.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/next-themes/-/next-themes-0.2.1.tgz",
|
||||||
|
|
@ -7587,6 +7596,11 @@
|
||||||
"inBundle": true,
|
"inBundle": true,
|
||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
},
|
},
|
||||||
|
"node_modules/nprogress": {
|
||||||
|
"version": "0.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/nprogress/-/nprogress-0.2.0.tgz",
|
||||||
|
"integrity": "sha512-I19aIingLgR1fmhftnbWWO3dXc0hSxqHQHQb3H8m+K3TnEn/iSeTZZOyvKXWqQESMwuUVnatlCnZdLBZZt2VSA=="
|
||||||
|
},
|
||||||
"node_modules/object-assign": {
|
"node_modules/object-assign": {
|
||||||
"version": "4.1.1",
|
"version": "4.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@
|
||||||
"leaflet-geosearch": "^3.11.0",
|
"leaflet-geosearch": "^3.11.0",
|
||||||
"lucide-react": "^0.292.0",
|
"lucide-react": "^0.292.0",
|
||||||
"next": "14.0.3",
|
"next": "14.0.3",
|
||||||
|
"next-nprogress-bar": "^2.1.2",
|
||||||
"next-themes": "^0.2.1",
|
"next-themes": "^0.2.1",
|
||||||
"npm": "^10.2.5",
|
"npm": "^10.2.5",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,37 @@
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { CookieValueTypes, getCookie } from "cookies-next";
|
import {
|
||||||
|
CookieValueTypes,
|
||||||
|
deleteCookie,
|
||||||
|
getCookie,
|
||||||
|
setCookie,
|
||||||
|
} from "cookies-next";
|
||||||
|
|
||||||
axios.defaults.baseURL = process.env.NEXT_PUBLIC_BASE_URL_APP;
|
axios.defaults.baseURL = process.env.NEXT_PUBLIC_BASE_URL_APP;
|
||||||
|
|
||||||
|
axios.interceptors.response.use(
|
||||||
|
(response) => {
|
||||||
|
return response;
|
||||||
|
},
|
||||||
|
async function (error) {
|
||||||
|
const originalRequest = error.config;
|
||||||
|
if (error.response.status === 401) {
|
||||||
|
const accessToken = getCookie("Sootzani_Token");
|
||||||
|
const refreshToken = getCookie("Sootzani_Refresh_Token");
|
||||||
|
const data = await RefreshToken({
|
||||||
|
token: accessToken,
|
||||||
|
refreshToken: refreshToken,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// if (error.response.status === 403 && !originalRequest._retry) {
|
||||||
|
// originalRequest._retry = true;
|
||||||
|
// const access_token = await refreshAccessToken();
|
||||||
|
// axios.defaults.headers.common["Authorization"] = "Bearer " + access_token;
|
||||||
|
// return axiosApiInstance(originalRequest);
|
||||||
|
// }
|
||||||
|
return Promise.reject(error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
export async function loginStaff(payload: {
|
export async function loginStaff(payload: {
|
||||||
username: string;
|
username: string;
|
||||||
password: string;
|
password: string;
|
||||||
|
|
@ -36,7 +65,7 @@ export async function logisterCitizen(payload: {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function verifyCitizen(payload: {
|
export async function verifyCitizen(payload: {
|
||||||
phoneNumber: string;
|
otpToken: string | null;
|
||||||
verificationCode: string;
|
verificationCode: string;
|
||||||
}) {
|
}) {
|
||||||
const data = await axios.post("api/Authenticate/VerifyCitizen", payload);
|
const data = await axios.post("api/Authenticate/VerifyCitizen", payload);
|
||||||
|
|
@ -71,3 +100,25 @@ export async function editProfile(payload: {
|
||||||
});
|
});
|
||||||
return data.data;
|
return data.data;
|
||||||
}
|
}
|
||||||
|
export async function revoke(payload: {
|
||||||
|
refreshToken: string | CookieValueTypes;
|
||||||
|
}) {
|
||||||
|
const token = getCookie("Sootzani_Token");
|
||||||
|
const data = await axios.post("api/Authenticate/Revoke", payload, {
|
||||||
|
headers: { Authorization: `Bearer ${token}` },
|
||||||
|
});
|
||||||
|
return data.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function RefreshToken(payload: { token: any; refreshToken: any }) {
|
||||||
|
try {
|
||||||
|
const response = await axios.post("api/Authenticate/Refresh", payload);
|
||||||
|
setCookie("Sootzani_Token", response.data.jwtToken);
|
||||||
|
setCookie("Sootzani_Refresh_Token", response.data.refreshToken);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
deleteCookie("Sootzani_Token");
|
||||||
|
deleteCookie("Sootzani_Refresh_Token");
|
||||||
|
window.location.href = "/";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue