diff --git a/app/layout.tsx b/app/layout.tsx index ab41acb..f7a8fb1 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -6,6 +6,7 @@ import Navbar from "@/components/Navbar"; import NavbarSm from "@/components/NavbarSm"; import Provider from "../utils/Provider"; import { Toaster as SonnerToaster } from "@/components/ui/sonner"; +import ProgressBarProviders from "@/components/ProgressBar"; const inter = Inter({ subsets: ["latin"] }); export const metadata: Metadata = { @@ -25,7 +26,9 @@ export default function RootLayout({ {/* */} -
{children}
+
+ {children} +
diff --git a/components/CitizenLogin.tsx b/components/CitizenLogin.tsx index 4aa48e9..39b06d2 100644 --- a/components/CitizenLogin.tsx +++ b/components/CitizenLogin.tsx @@ -17,7 +17,6 @@ import { } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; -import { toast } from "@/components/ui/use-toast"; import Image from "next/image"; import LoginIcon from "../public/img/login-icon.svg"; import { useMutation, useQuery } from "@tanstack/react-query"; @@ -28,6 +27,7 @@ import { Oval, ThreeDots } from "react-loader-spinner"; import useData from "@/store/useData"; import { getCookie } from "cookies-next"; import { RefreshCcw } from "lucide-react"; +import { toast } from "sonner"; const FormSchema = z.object({ phoneNumber: z.string().min(1, { message: "لطفا شماره موبایل خود را وارد نمایید.", @@ -53,13 +53,17 @@ export default function CitizenLogin() { const loginMutation = useMutation({ mutationFn: logisterCitizen, - onSuccess: (res) => {}, - onError: (err: any) => { - if (err.response.status == 428) { - console.log(useData); - router.push("/Verify"); - localStorage.setItem("VerifyRole", "citizen"); - } + onSuccess: (res: any | string) => { + console.log(res); + router.push("/Verify"); + localStorage.setItem("VerifyRole", "citizen"); + localStorage.setItem("verificationToken", res); + }, + 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, }, }; - refetch() - loginMutation.mutate(payload); + refetch(); + loginMutation.mutateAsync(payload); saveData({ phoneNumber: data.phoneNumber, }); @@ -86,23 +90,22 @@ export default function CitizenLogin() { ? URL.createObjectURL(CaptchaData.data) : null; - return (
-
+
icon -

+

احراز هویت

)} /> -
+
( - + {/* رمز عبور */} @@ -145,7 +148,7 @@ export default function CitizenLogin() { )} /> {isLoading ? ( -
+
) : ( -
+
icon refetch()} color="#003778" />
)}
-
+
@@ -109,14 +110,14 @@ export default function FollowResult() { گزارش شکایات

- + - + {complaintPrintMutation.isPending ? ( -
+

درخواست شما با کد رهگیری - {`${trackingNumber}`} + {`${trackingNumber}`} و رمز عبور - {`${password}`} + {`${password}`} در دست بررسی و اقدام می باشد. در صورت تمایل می توانید با شماره تلفن 0353286545 جهت پشتیبانی تماس حاصل کنید. @@ -172,7 +173,7 @@ export default function FollowResult() { diff --git a/components/InspectorOperations.tsx b/components/InspectorOperations.tsx index 62b89ef..73d1a2e 100644 --- a/components/InspectorOperations.tsx +++ b/components/InspectorOperations.tsx @@ -86,7 +86,11 @@ export default function InspectorOperations({ 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) { @@ -133,7 +137,7 @@ export default function InspectorOperations({ /> {/*

- +
*/} )} /> -
+
( - + {/* Email */} - + )} /> @@ -318,7 +318,7 @@ export default function RequestStep2() {