Merge branch 'Kahdooei' of https://gitea.shetabdahi.ir/Hossein-Rahmani/Sootzani into Kahdooei
commit
b61278ea19
|
|
@ -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({
|
|||
<Navbar />
|
||||
{/* <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 />
|
||||
<SonnerToaster />
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<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]
|
||||
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 " />
|
||||
|
||||
<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>
|
||||
|
||||
<Form {...form}>
|
||||
<form
|
||||
onSubmit={form.handleSubmit(onSubmit)}
|
||||
className="w-full flex flex-col "
|
||||
className="flex flex-col w-full "
|
||||
>
|
||||
<FormField
|
||||
control={form.control}
|
||||
|
|
@ -127,13 +130,13 @@ export default function CitizenLogin() {
|
|||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<div className="flex gap-4 mt-4 items-center">
|
||||
<div className="flex items-center gap-4 mt-4">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="captcha"
|
||||
rules={{ required: true }}
|
||||
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> */}
|
||||
|
|
@ -145,7 +148,7 @@ export default function CitizenLogin() {
|
|||
)}
|
||||
/>
|
||||
{isLoading ? (
|
||||
<div className=" w-36 flex justify-center text-center">
|
||||
<div className="flex justify-center text-center w-36">
|
||||
<ThreeDots
|
||||
visible={true}
|
||||
height="50"
|
||||
|
|
@ -158,31 +161,31 @@ export default function CitizenLogin() {
|
|||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div className=" flex justify-center items-center text-center gap-2">
|
||||
<div className="flex items-center justify-center gap-2 text-center ">
|
||||
<Image
|
||||
alt="icon"
|
||||
src={srcForImage as string}
|
||||
className=" h-12 rounded-md shadow-md w-36"
|
||||
className="h-12 rounded-md shadow-md w-36"
|
||||
width={150}
|
||||
height={20}
|
||||
quality={100}
|
||||
/>
|
||||
<RefreshCcw
|
||||
className=" cursor-pointer"
|
||||
className="cursor-pointer "
|
||||
onClick={() => refetch()}
|
||||
color="#003778"
|
||||
/>
|
||||
</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
|
||||
disabled={loginMutation.isPending}
|
||||
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 ? (
|
||||
<div className="flex justify-center items-center gap-2">
|
||||
<div className="flex items-center justify-center gap-2">
|
||||
<Oval
|
||||
visible={true}
|
||||
height="20"
|
||||
|
|
|
|||
|
|
@ -117,8 +117,8 @@ export default function ComplainsDetails({
|
|||
onSuccess: (res) => {
|
||||
setOpen(false);
|
||||
},
|
||||
onError: (err) => {
|
||||
toast("رمز عبور شما صحیح نمیباشد.", {
|
||||
onError: (err: any | string) => {
|
||||
toast(<>{err.response.data.detail}</>, {
|
||||
className: "!bg-red-500 !text-white",
|
||||
});
|
||||
},
|
||||
|
|
@ -163,7 +163,7 @@ export default function ComplainsDetails({
|
|||
dir="rtl"
|
||||
id="picture"
|
||||
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>
|
||||
<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" && (
|
||||
<button
|
||||
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>
|
||||
<ArrowRight />
|
||||
|
|
@ -198,7 +198,7 @@ export default function ComplainsDetails({
|
|||
)}
|
||||
|
||||
{/* 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 */}
|
||||
<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>
|
||||
|
||||
{/* 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">
|
||||
{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>
|
||||
|
|
@ -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>
|
||||
|
|
@ -284,7 +284,7 @@ export default function ComplainsDetails({
|
|||
</span>
|
||||
</p>
|
||||
</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>
|
||||
|
|
@ -322,14 +322,14 @@ export default function ComplainsDetails({
|
|||
<div className="bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col max-h-[50vh] lg:max-h-[39.5vh] 2xl:max-h-[43.5vh] 3xl:max-h-[41vh] min-[1920px]:max-h-[48.5vh] overflow-auto
|
||||
scrollbar-thin scrollbar-thumb-gray-500 scrollbar-track-gray-100">
|
||||
<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) => {
|
||||
return (
|
||||
<div
|
||||
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="">
|
||||
<Badge>
|
||||
{item.sender == 0 ? "شهروند" : "بازرس"}
|
||||
|
|
@ -348,10 +348,10 @@ export default function ComplainsDetails({
|
|||
</span>
|
||||
</div>
|
||||
{/* {item.media.length !== 0 && (
|
||||
<Separator className=" mt-2 mb-1" />
|
||||
<Separator className="mt-2 mb-1 " />
|
||||
)} */}
|
||||
<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) => {
|
||||
return (
|
||||
<div
|
||||
|
|
@ -362,15 +362,15 @@ export default function ComplainsDetails({
|
|||
onClick={() =>
|
||||
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">
|
||||
{item.title}
|
||||
</p>
|
||||
</a>
|
||||
<ArrowDownToLine
|
||||
className=" cursor-pointer"
|
||||
className="cursor-pointer "
|
||||
onClick={() =>
|
||||
downloadFile(
|
||||
item.data,
|
||||
|
|
@ -408,7 +408,7 @@ export default function ComplainsDetails({
|
|||
) : (
|
||||
<>
|
||||
{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
|
||||
visible={true}
|
||||
height="100"
|
||||
|
|
|
|||
|
|
@ -64,9 +64,10 @@ export default function FollowResult() {
|
|||
onSuccess: (res) => {
|
||||
setComplaintData(res);
|
||||
},
|
||||
onError: (error) => {
|
||||
console.log(error);
|
||||
console.log(error?.message);
|
||||
onError: (err: any | string) => {
|
||||
toast(<>{err.response.data.detail}</>, {
|
||||
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">
|
||||
{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>
|
||||
<AlertDialogTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
type="submit"
|
||||
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>
|
||||
|
|
@ -109,14 +110,14 @@ export default function FollowResult() {
|
|||
گزارش شکایات
|
||||
</p>
|
||||
|
||||
<AlertDialogCancel className="p-0 border-0 h-auto">
|
||||
<AlertDialogCancel className="h-auto p-0 border-0">
|
||||
<IoMdClose />
|
||||
</AlertDialogCancel>
|
||||
</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 ? (
|
||||
<div className="felx justify-center items-center self-center h-full">
|
||||
<div className="items-center self-center justify-center h-full felx">
|
||||
<ThreeDots
|
||||
visible={true}
|
||||
height="80"
|
||||
|
|
@ -159,9 +160,9 @@ export default function FollowResult() {
|
|||
<br />
|
||||
<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 جهت پشتیبانی تماس
|
||||
حاصل کنید.
|
||||
|
|
@ -172,7 +173,7 @@ export default function FollowResult() {
|
|||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<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}
|
||||
>
|
||||
پرینت گزارش
|
||||
|
|
|
|||
|
|
@ -48,10 +48,10 @@ export default function FollowUp() {
|
|||
console.log(result);
|
||||
|
||||
// alert("Success");
|
||||
console.log("Success FollowUp");
|
||||
console.log("Success FollowUp");
|
||||
|
||||
// router.push("/FollowResult");
|
||||
router.push("/FollowResult", {data: JSON.stringify( result ) });
|
||||
router.push("/FollowResult", { data: JSON.stringify(result) });
|
||||
|
||||
// router.push(
|
||||
// "/FollowResult",
|
||||
|
|
@ -62,16 +62,17 @@ export default function FollowUp() {
|
|||
|
||||
// router.push({
|
||||
// pathname : '/FollowResult',
|
||||
// query : {
|
||||
// query : {
|
||||
// data: JSON.stringify( result ) ;
|
||||
// },
|
||||
// });
|
||||
|
||||
// return (res)
|
||||
},
|
||||
onError: (error) => {
|
||||
console.log(error);
|
||||
console.log(error?.message);
|
||||
onError: (err: any | string) => {
|
||||
toast(<>{err.response.data.detail}</>, {
|
||||
className: "!bg-red-500 !text-white",
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -103,9 +104,9 @@ export default function FollowUp() {
|
|||
});
|
||||
}
|
||||
return (
|
||||
<div className="w-full h-full sm:w-2/3 md:w-2/4 max-sm:p-8 pt-12">
|
||||
<div className="space-y-3 md:space-y-4 h-full flex flex-col justify-start ">
|
||||
<p className="text-sm md:text-base font-bold leading-tight tracking-tight text-blue dark:text-white">
|
||||
<div className="w-full h-full pt-12 sm:w-2/3 md:w-2/4 max-sm:p-8">
|
||||
<div className="flex flex-col justify-start h-full space-y-3 md:space-y-4 ">
|
||||
<p className="text-sm font-bold leading-tight tracking-tight md:text-base text-blue dark:text-white">
|
||||
لطفا جهت پیگیری درخواست و مشاهده وضعیت آن کد رهگیری و رمز عبور خود را
|
||||
وارد نمایید.
|
||||
</p>
|
||||
|
|
@ -113,7 +114,7 @@ export default function FollowUp() {
|
|||
<Form {...form}>
|
||||
<form
|
||||
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">
|
||||
<FormField
|
||||
|
|
@ -155,11 +156,11 @@ export default function FollowUp() {
|
|||
/>
|
||||
</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
|
||||
// href="/FollowResult"
|
||||
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>
|
||||
|
|
|
|||
|
|
@ -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<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">
|
||||
<Label htmlFor="picture">پیوست</Label>
|
||||
<Input multiple id="picture" type="file" className=" bg-white" />
|
||||
<Input multiple id="picture" type="file" className="bg-white " />
|
||||
</div> */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
|
|
@ -150,19 +154,19 @@ export default function InspectorOperations({
|
|||
console.log(e.target.files);
|
||||
}}
|
||||
multiple
|
||||
className=" bg-white"
|
||||
className="bg-white "
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<div className=" flex justify-between mt-3 gap-2">
|
||||
<div className="flex justify-between gap-2 mt-3 ">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="operation"
|
||||
render={({ field }) => (
|
||||
<FormItem className=" flex-1">
|
||||
<FormItem className="flex-1 ">
|
||||
{/* <FormLabel>Email</FormLabel> */}
|
||||
<Select
|
||||
onValueChange={field.onChange}
|
||||
|
|
@ -176,7 +180,7 @@ export default function InspectorOperations({
|
|||
disabled={possibleOperations.length == 0}
|
||||
>
|
||||
<SelectValue
|
||||
className=" text-xs"
|
||||
className="text-xs "
|
||||
placeholder="نوع عملیات را انتخاب نمایید."
|
||||
/>
|
||||
</SelectTrigger>
|
||||
|
|
@ -206,7 +210,7 @@ export default function InspectorOperations({
|
|||
/>
|
||||
<Button
|
||||
disabled={possibleOperations.length == 0}
|
||||
className=" bg-blue w-1/3"
|
||||
className="w-1/3 bg-blue"
|
||||
type="submit"
|
||||
>
|
||||
ثبت
|
||||
|
|
|
|||
|
|
@ -60,11 +60,10 @@ export default function Login() {
|
|||
const loginMutation = useMutation({
|
||||
mutationFn: loginStaff,
|
||||
onSuccess: (res) => {},
|
||||
onError: (err: any) => {
|
||||
if (err.response.status == 428) {
|
||||
console.log(useData);
|
||||
router.push("/Verify");
|
||||
}
|
||||
onError: (err: any | string) => {
|
||||
toast(<>{err.response.data.detail}</>, {
|
||||
className: "!bg-red-500 !text-white",
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -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]
|
||||
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 " />
|
||||
|
||||
<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>
|
||||
|
||||
<Form {...form}>
|
||||
<form
|
||||
onSubmit={form.handleSubmit(onSubmit)}
|
||||
className="w-full flex flex-col "
|
||||
className="flex flex-col w-full "
|
||||
>
|
||||
<FormField
|
||||
control={form.control}
|
||||
|
|
@ -153,13 +152,13 @@ export default function Login() {
|
|||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<div className="flex gap-4 mt-4 items-center">
|
||||
<div className="flex items-center gap-4 mt-4">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="captcha"
|
||||
rules={{ required: true }}
|
||||
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> */}
|
||||
|
|
@ -171,7 +170,7 @@ export default function Login() {
|
|||
)}
|
||||
/>
|
||||
{isLoading ? (
|
||||
<div className=" w-36 flex justify-center text-center">
|
||||
<div className="flex justify-center text-center w-36">
|
||||
<ThreeDots
|
||||
visible={true}
|
||||
height="50"
|
||||
|
|
@ -184,31 +183,31 @@ export default function Login() {
|
|||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div className=" flex justify-center text-center gap-2">
|
||||
<div className="flex justify-center gap-2 text-center ">
|
||||
<Image
|
||||
alt="icon"
|
||||
src={srcForImage as string}
|
||||
className=" h-12 rounded-md shadow-md w-36"
|
||||
className="h-12 rounded-md shadow-md w-36"
|
||||
width={150}
|
||||
height={20}
|
||||
quality={100}
|
||||
/>
|
||||
<RefreshCcw
|
||||
className=" cursor-pointer"
|
||||
className="cursor-pointer "
|
||||
onClick={() => refetch()}
|
||||
color="#003778"
|
||||
/>
|
||||
</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
|
||||
disabled={loginMutation.isPending}
|
||||
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 ? (
|
||||
<div className="flex justify-center items-center gap-2">
|
||||
<div className="flex items-center justify-center gap-2">
|
||||
<Oval
|
||||
visible={true}
|
||||
height="20"
|
||||
|
|
|
|||
|
|
@ -66,7 +66,11 @@ export default function Profile() {
|
|||
router.push("/RequestStep2");
|
||||
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>>({
|
||||
|
|
@ -98,13 +102,13 @@ export default function Profile() {
|
|||
}
|
||||
|
||||
return (
|
||||
<div className="w-full h-full sm:w-2/3 md:w-2/4 max-sm:p-8 pt-12">
|
||||
<div className="space-y-4 md:space-y-4 h-full flex flex-col justify-center">
|
||||
<div className="w-full h-full pt-12 sm:w-2/3 md:w-2/4 max-sm:p-8">
|
||||
<div className="flex flex-col justify-center h-full space-y-4 md:space-y-4">
|
||||
{profileData && (
|
||||
<Form {...form}>
|
||||
<form
|
||||
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">
|
||||
<FormField
|
||||
|
|
|
|||
|
|
@ -32,11 +32,11 @@ import {
|
|||
DropdownMenuSubTrigger,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import { getProfile } from "@/utils/authenticateApi";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { getProfile, revoke } from "@/utils/authenticateApi";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import Link from "next/link";
|
||||
import useToken from "@/store/useToken";
|
||||
import { deleteCookie } from "cookies-next";
|
||||
import { deleteCookie, getCookie } from "cookies-next";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
export default function ProfileDropDown() {
|
||||
|
|
@ -50,7 +50,22 @@ export default function ProfileDropDown() {
|
|||
queryFn: () => getProfile(),
|
||||
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);
|
||||
return (
|
||||
<DropdownMenu dir="rtl">
|
||||
|
|
@ -62,23 +77,17 @@ export default function ProfileDropDown() {
|
|||
<DropdownMenuContent className="w-56 sm:ml-10">
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem onClick={() => router.push("/Account/Profile")}>
|
||||
<User className="ml-2 h-4 w-4" />
|
||||
<User className="w-4 h-4 ml-2" />
|
||||
<span>مشاهده پروفایل</span>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => router.push("/Account/Complaints")}>
|
||||
<CreditCard className="ml-2 h-4 w-4" />
|
||||
<CreditCard className="w-4 h-4 ml-2" />
|
||||
<span>درخواست های من</span>
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuGroup>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem
|
||||
onClick={() => {
|
||||
saveToken(false);
|
||||
deleteCookie("Sootzani_Token");
|
||||
router.push("/");
|
||||
}}
|
||||
>
|
||||
<LogOut className="ml-2 h-4 w-4" />
|
||||
<DropdownMenuItem onClick={logout}>
|
||||
<LogOut className="w-4 h-4 ml-2" />
|
||||
<span>خروج</span>
|
||||
</DropdownMenuItem>
|
||||
</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");
|
||||
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>>({
|
||||
|
|
@ -100,16 +104,16 @@ export default function RequestStep1() {
|
|||
}
|
||||
|
||||
return (
|
||||
<div className="w-full h-full sm:w-2/3 md:w-2/4 max-sm:p-8 pt-12">
|
||||
<div className="space-y-4 md:space-y-4 h-full flex flex-col justify-center">
|
||||
<p className="text-sm md:text-base font-bold leading-tight tracking-tight text-blue dark:text-white">
|
||||
<div className="w-full h-full pt-12 sm:w-2/3 md:w-2/4 max-sm:p-8">
|
||||
<div className="flex flex-col justify-center h-full space-y-4 md:space-y-4">
|
||||
<p className="text-sm font-bold leading-tight tracking-tight md:text-base text-blue dark:text-white">
|
||||
لطفا جهت ارسال درخواست فرم زیر را تکمیل نمایید.
|
||||
</p>
|
||||
{profileData && (
|
||||
<Form {...form}>
|
||||
<form
|
||||
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">
|
||||
<FormField
|
||||
|
|
@ -169,10 +173,10 @@ export default function RequestStep1() {
|
|||
/>
|
||||
</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
|
||||
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>
|
||||
|
|
|
|||
|
|
@ -118,8 +118,8 @@ export default function RequestStep2() {
|
|||
localStorage.setItem("password", res.password);
|
||||
router.push("/RequestResult");
|
||||
},
|
||||
onError: (error) => {
|
||||
toast("مشکلی در ارسال درخواست به وجود آمد.", {
|
||||
onError: (err: any | string) => {
|
||||
toast(<>{err.response.data.detail}</>, {
|
||||
className: "!bg-red-500 !text-white",
|
||||
});
|
||||
},
|
||||
|
|
@ -135,8 +135,8 @@ export default function RequestStep2() {
|
|||
localStorage.removeItem("authorized");
|
||||
router.push("/RequestResult");
|
||||
},
|
||||
onError: (error) => {
|
||||
toast("مشکلی در ارسال درخواست به وجود آمد.", {
|
||||
onError: (err: any | string) => {
|
||||
toast(<>{err.response.data.detail}</>, {
|
||||
className: "!bg-red-500 !text-white",
|
||||
});
|
||||
},
|
||||
|
|
@ -216,16 +216,16 @@ export default function RequestStep2() {
|
|||
const { resetField } = useForm();
|
||||
|
||||
return (
|
||||
<div className="w-full h-full sm:w-2/3 md:w-2/4 max-sm:p-8 pt-12">
|
||||
<div className="space-y-3 md:space-y-4 h-full flex flex-col justify-center">
|
||||
<p className="text-sm md:text-base font-bold leading-tight tracking-tight text-blue dark:text-white">
|
||||
<div className="w-full h-full pt-12 sm:w-2/3 md:w-2/4 max-sm:p-8">
|
||||
<div className="flex flex-col justify-center h-full space-y-3 md:space-y-4">
|
||||
<p className="text-sm font-bold leading-tight tracking-tight md:text-base text-blue dark:text-white">
|
||||
لطفا جهت ارسال درخواست فرم زیر را تکمیل نمایید.
|
||||
</p>
|
||||
|
||||
<Form {...form}>
|
||||
<form
|
||||
onSubmit={form.handleSubmit(onSubmit)}
|
||||
className="w-full flex flex-col mt-6"
|
||||
className="flex flex-col w-full mt-6"
|
||||
>
|
||||
<FormField
|
||||
control={form.control}
|
||||
|
|
@ -282,7 +282,7 @@ export default function RequestStep2() {
|
|||
</SelectGroup>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<FormMessage className=" mt-2" />
|
||||
<FormMessage className="mt-2 " />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
|
@ -318,7 +318,7 @@ export default function RequestStep2() {
|
|||
<FormControl>
|
||||
<Textarea
|
||||
placeholder="متن توضیحات خود را بنویسید"
|
||||
className="resize-none mb-3"
|
||||
className="mb-3 resize-none"
|
||||
{...field}
|
||||
/>
|
||||
</FormControl>
|
||||
|
|
@ -355,7 +355,7 @@ export default function RequestStep2() {
|
|||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<FormMessage className=" mt-2" />
|
||||
<FormMessage className="mt-2 " />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
|
@ -465,13 +465,13 @@ export default function RequestStep2() {
|
|||
<Image
|
||||
alt="icon"
|
||||
src={srcForImage as string}
|
||||
className=" h-12 rounded-md shadow-md w-36"
|
||||
className="h-12 rounded-md shadow-md w-36"
|
||||
width={150}
|
||||
height={20}
|
||||
quality={100}
|
||||
/>
|
||||
<RefreshCcw
|
||||
className=" cursor-pointer"
|
||||
className="cursor-pointer "
|
||||
onClick={() => refetch()}
|
||||
color="#003778"
|
||||
/>
|
||||
|
|
@ -479,10 +479,10 @@ export default function RequestStep2() {
|
|||
)}
|
||||
</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
|
||||
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>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import { useRouter } from "next/navigation";
|
|||
import useData from "@/store/useData";
|
||||
import { JwtPayload, jwtDecode } from "jwt-decode";
|
||||
import { setCookie } from "cookies-next";
|
||||
import { Oval } from "react-loader-spinner";
|
||||
import { Oval, Triangle } from "react-loader-spinner";
|
||||
import useToken from "@/store/useToken";
|
||||
import { toast } from "sonner";
|
||||
|
||||
|
|
@ -21,32 +21,14 @@ export default function Verify() {
|
|||
const userData = useData((state) => state.data);
|
||||
const [VerifyRole, setVerifyRole] = useState<any>("");
|
||||
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({
|
||||
mutationFn: verifyCitizen,
|
||||
onSuccess: (res) => {
|
||||
saveToken(true);
|
||||
const decodedToken = jwtDecode<any>(res);
|
||||
setCookie("Sootzani_Token", res);
|
||||
const decodedToken = jwtDecode<any>(res.jwtToken);
|
||||
setCookie("Sootzani_Token", res.jwtToken);
|
||||
setCookie("Sootzani_Refresh_Token", res.refreshToken);
|
||||
const userRole =
|
||||
decodedToken[
|
||||
"http://schemas.microsoft.com/ws/2008/06/identity/claims/role"
|
||||
|
|
@ -60,16 +42,19 @@ export default function Verify() {
|
|||
router.push("/RequestStep1");
|
||||
}
|
||||
},
|
||||
onError: (err: any) => {
|
||||
toast("کد تایید شما صحیح نمیباشد.", {
|
||||
className: "!bg-red-500 !text-white",
|
||||
});
|
||||
onError: (err: any | string) => {
|
||||
toast(<>{err.response.data.detail}</>, {
|
||||
className: "!bg-red-500 !text-white",
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const handelVerify = () => {
|
||||
console.log(otp);
|
||||
const payload = { ...userData, verificationCode: otp };
|
||||
const payload = {
|
||||
otpToken: localStorage.getItem("verificationToken"),
|
||||
verificationCode: otp,
|
||||
};
|
||||
console.log(userData);
|
||||
CitizenVerifyMutation.mutate(payload);
|
||||
};
|
||||
|
|
@ -80,19 +65,34 @@ export default function Verify() {
|
|||
|
||||
useEffect(() => {
|
||||
if (otp.length == 6) {
|
||||
const payload = { ...userData, verificationCode: otp };
|
||||
console.log(userData);
|
||||
const payload = {
|
||||
otpToken: localStorage.getItem("verificationToken"),
|
||||
verificationCode: otp,
|
||||
};
|
||||
CitizenVerifyMutation.mutate(payload);
|
||||
}
|
||||
}, [otp]);
|
||||
return (
|
||||
<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]
|
||||
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 " />
|
||||
<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>
|
||||
<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"
|
||||
/>
|
||||
</div>
|
||||
<label className="label text-center">
|
||||
<span className="text-xs text-blue/70 label-text text-center">
|
||||
<label className="text-center label">
|
||||
<span className="text-xs text-center text-blue/70 label-text">
|
||||
کد دریافت شده توسط پیامک را وارد نمایید.
|
||||
</span>
|
||||
</label>
|
||||
{/* <div className="flex justify-end gap-2 w-full mt-14">
|
||||
{/* <div className="flex justify-end w-full gap-2 mt-14">
|
||||
<Button
|
||||
disabled={CitizenVerifyMutation.isPending}
|
||||
onClick={handelVerify}
|
||||
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 ? (
|
||||
<div className="flex justify-center items-center gap-2">
|
||||
<div className="flex items-center justify-center gap-2">
|
||||
<Oval
|
||||
visible={true}
|
||||
height="20"
|
||||
|
|
@ -140,7 +140,7 @@ export default function Verify() {
|
|||
{/* <Form {...form}>
|
||||
<form
|
||||
onSubmit={form.handleSubmit(onSubmit)}
|
||||
className="w-full flex flex-col "
|
||||
className="flex flex-col w-full "
|
||||
>
|
||||
<FormField
|
||||
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
|
||||
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>
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@
|
|||
"leaflet-geosearch": "^3.11.0",
|
||||
"lucide-react": "^0.292.0",
|
||||
"next": "14.0.3",
|
||||
"next-nprogress-bar": "^2.1.2",
|
||||
"next-themes": "^0.2.1",
|
||||
"npm": "^10.2.5",
|
||||
"react": "^18.2.0",
|
||||
|
|
@ -4824,6 +4825,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": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/next-themes/-/next-themes-0.2.1.tgz",
|
||||
|
|
@ -7588,6 +7597,11 @@
|
|||
"inBundle": true,
|
||||
"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": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@
|
|||
"leaflet-geosearch": "^3.11.0",
|
||||
"lucide-react": "^0.292.0",
|
||||
"next": "14.0.3",
|
||||
"next-nprogress-bar": "^2.1.2",
|
||||
"next-themes": "^0.2.1",
|
||||
"npm": "^10.2.5",
|
||||
"react": "^18.2.0",
|
||||
|
|
|
|||
|
|
@ -1,8 +1,37 @@
|
|||
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.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: {
|
||||
username: string;
|
||||
password: string;
|
||||
|
|
@ -36,7 +65,7 @@ export async function logisterCitizen(payload: {
|
|||
}
|
||||
|
||||
export async function verifyCitizen(payload: {
|
||||
phoneNumber: string;
|
||||
otpToken: string | null;
|
||||
verificationCode: string;
|
||||
}) {
|
||||
const data = await axios.post("api/Authenticate/VerifyCitizen", payload);
|
||||
|
|
@ -71,3 +100,25 @@ export async function editProfile(payload: {
|
|||
});
|
||||
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