Compare commits

..

No commits in common. "19f1031c37526b8ffb331aa5b81e2e6f8dc2f825" and "90d7a8377b60d67037645e0f58ceeeb4c497acdf" have entirely different histories.

20 changed files with 414 additions and 443 deletions

View File

@ -15,7 +15,7 @@ export default function RootLayout({
return ( return (
<> <>
<NavbarPanel /> <NavbarPanel />
<div className="px-2 mx-auto mt-10">{children}</div> <div className="mt-10 mx-auto px-2">{children}</div>
</> </>
); );
} }

View File

@ -8,7 +8,6 @@ import Provider from "../utils/Provider";
import { Toaster as SonnerToaster } from "@/components/ui/sonner"; import { Toaster as SonnerToaster } from "@/components/ui/sonner";
const inter = Inter({ subsets: ["latin"] }); const inter = Inter({ subsets: ["latin"] });
import { Suspense } from "react"; import { Suspense } from "react";
import ProgressBarProviders from "@/components/PrograssBar";
export const metadata: Metadata = { export const metadata: Metadata = {
title: "عیون", title: "عیون",
@ -25,7 +24,7 @@ export default function RootLayout({
<body className="font-[yekan] bg-white"> <body className="font-[yekan] bg-white">
<Provider> <Provider>
{/* <Suspense fallback={<Loading />}>{children}</Suspense> */} {/* <Suspense fallback={<Loading />}>{children}</Suspense> */}
<ProgressBarProviders>{children}</ProgressBarProviders> {children}
<Toaster /> <Toaster />
<SonnerToaster /> <SonnerToaster />
</Provider> </Provider>

View File

@ -149,9 +149,14 @@ export default function AdminCategories() {
className: "!bg-green-500 !text-white", className: "!bg-green-500 !text-white",
}); });
}, },
onError: (err: any | string) => { onError: (error) => {
toast(<>{err.response.data.detail}</>, { console.log(error);
className: "!bg-red-500 !text-white", console.log(error?.message);
setOpenEdit(false);
toast(error?.message, {
className: "!bg-red-500 !text-black",
}); });
}, },
}); });
@ -169,9 +174,12 @@ export default function AdminCategories() {
className: "!bg-green-500 !text-white", className: "!bg-green-500 !text-white",
}); });
}, },
onError: (err: any | string) => { onError: (error) => {
toast(<>{err.response.data.detail}</>, { console.log(error);
className: "!bg-red-500 !text-white", console.log(error?.message);
toast(error?.message, {
className: "!bg-red-500 !text-black",
}); });
}, },
}); });
@ -192,9 +200,14 @@ export default function AdminCategories() {
className: "!bg-green-500 !text-white", className: "!bg-green-500 !text-white",
}); });
}, },
onError: (err: any | string) => { onError: (error) => {
toast(<>{err.response.data.detail}</>, { console.log(error);
className: "!bg-red-500 !text-white", console.log(error?.message);
setOpenAdd(false);
toast(error?.message, {
className: "!bg-red-500 !text-black",
}); });
}, },
}); });
@ -217,9 +230,9 @@ export default function AdminCategories() {
return ( return (
<div className="w-full min-h-[85vh] flex justify-center"> <div className="w-full min-h-[85vh] flex justify-center">
<div className="w-[95vw] lg:w-[85vw] 3xl:w-[70vw] mt-8 max-sm:mt-16 pt-9 "> <div className="w-[95vw] lg:w-[85vw] 3xl:w-[70vw] mt-8 max-sm:mt-16 pt-9 ">
<div className="flex flex-row justify-between w-full "> <div className="flex w-full justify-between flex-row ">
{/* 1 */} {/* 1 */}
<div className="w-full my-4 text-lg font-bold text-right text-neutral-600"> <div className="w-full text-right text-neutral-600 text-lg font-bold my-4">
لیست دسته بندی ها لیست دسته بندی ها
</div> </div>
{/* 2 */} {/* 2 */}
@ -230,7 +243,7 @@ export default function AdminCategories() {
<Button <Button
variant="outline" variant="outline"
// onClick={handleClickAddCat} // onClick={handleClickAddCat}
className="text-white bg-orange-500" className="bg-orange-500 text-white"
// disabled={isNewKeyLoading} // disabled={isNewKeyLoading}
> >
افزودن دسته بندی افزودن دسته بندی
@ -242,21 +255,21 @@ export default function AdminCategories() {
<p className="text-[#464646] text-base font-bold"> <p className="text-[#464646] text-base font-bold">
افزودن دسته بندی افزودن دسته بندی
</p> </p>
<AlertDialogCancel className="h-auto p-0 border-0"> <AlertDialogCancel className="p-0 border-0 h-auto">
<IoMdClose /> <IoMdClose />
</AlertDialogCancel> </AlertDialogCancel>
</AlertDialogTitle> </AlertDialogTitle>
<AlertDialogDescription> <AlertDialogDescription>
<div className="w-full "> <div className="w-full ">
<div className="w-full mb-2 text-lg font-bold text-right text-neutral-600"> <div className="w-full text-right text-neutral-600 text-lg font-bold mb-2">
افزودن دسته بندی افزودن دسته بندی
</div> </div>
<Form {...formAdd}> <Form {...formAdd}>
<form <form
onSubmit={formAdd.handleSubmit(onSubmitAdd)} onSubmit={formAdd.handleSubmit(onSubmitAdd)}
className="flex flex-col w-full mt-6 " className="w-full flex flex-col mt-6 "
> >
<div className="flex flex-col flex-wrap justify-between"> <div className="flex flex-col flex-wrap justify-between">
<FormField <FormField
@ -300,14 +313,14 @@ export default function AdminCategories() {
/> />
</div> </div>
<div className="flex justify-center w-full gap-2 mt-8 sm:justify-end"> <div className="flex justify-center sm:justify-end gap-2 w-full mt-8">
<Button <Button
type="submit" type="submit"
className="text-center text-white bg-blue min-w-max rounded-xl hover:bg-white hover:text-slate-800" className="bg-blue text-white min-w-max rounded-xl text-center hover:bg-white hover:text-slate-800"
> >
افزودن افزودن
</Button> </Button>
<AlertDialogCancel className="mt-0 text-white bg-blue rounded-xl"> <AlertDialogCancel className="bg-blue text-white rounded-xl mt-0">
بستن بستن
</AlertDialogCancel> </AlertDialogCancel>
</div> </div>
@ -322,7 +335,7 @@ export default function AdminCategories() {
</AlertDialogContent> </AlertDialogContent>
</AlertDialog> </AlertDialog>
</div> </div>
<div className="flex flex-row flex-wrap justify-between w-full gap-8 md:gap-4 "> <div className="w-full flex flex-row flex-wrap justify-between gap-8 md:gap-4 ">
<AlertDialog open={openEdit} onOpenChange={setOpenEdit}> <AlertDialog open={openEdit} onOpenChange={setOpenEdit}>
<AlertDialogContent className=" w-full max-w-3xl h-full lg:max-h-[25em] max-h-[23em]"> <AlertDialogContent className=" w-full max-w-3xl h-full lg:max-h-[25em] max-h-[23em]">
<AlertDialogHeader> <AlertDialogHeader>
@ -330,7 +343,7 @@ export default function AdminCategories() {
<p className="text-[#464646] text-base font-bold"> <p className="text-[#464646] text-base font-bold">
تغییر دسته بندی تغییر دسته بندی
</p> </p>
<AlertDialogCancel className="h-auto p-0 border-0"> <AlertDialogCancel className="p-0 border-0 h-auto">
<IoMdClose /> <IoMdClose />
</AlertDialogCancel> </AlertDialogCancel>
</AlertDialogTitle> </AlertDialogTitle>
@ -339,7 +352,7 @@ export default function AdminCategories() {
<Form {...formEdit}> <Form {...formEdit}>
<form <form
onSubmit={formEdit.handleSubmit(onSubmitEdit)} onSubmit={formEdit.handleSubmit(onSubmitEdit)}
className="flex flex-col w-full" className="w-full flex flex-col"
> >
<div className="flex flex-col flex-wrap justify-between"> <div className="flex flex-col flex-wrap justify-between">
<FormField <FormField
@ -369,7 +382,7 @@ export default function AdminCategories() {
<FormControl> <FormControl>
<Textarea <Textarea
placeholder="توضیحات" placeholder="توضیحات"
className="bg-white resize-none" className="resize-none bg-white"
{...field} {...field}
/> />
</FormControl> </FormControl>
@ -379,15 +392,15 @@ export default function AdminCategories() {
/> />
</div> </div>
<div className="flex justify-center w-full gap-2 mt-8 sm:justify-end"> <div className="flex justify-center sm:justify-end gap-2 w-full mt-8">
<Button <Button
type="submit" type="submit"
className="p-2 text-center text-white bg-blue min-w-max rounded-xl hover:bg-white hover:text-slate-800" className="bg-blue text-white min-w-max p-2 rounded-xl text-center hover:bg-white hover:text-slate-800"
> >
تغییر دسته بندی تغییر دسته بندی
</Button> </Button>
<AlertDialogCancel className="mt-0 text-white bg-blue rounded-xl"> <AlertDialogCancel className="bg-blue text-white rounded-xl mt-0">
بستن بستن
</AlertDialogCancel> </AlertDialogCancel>
</div> </div>
@ -404,17 +417,18 @@ export default function AdminCategories() {
className={`flex flex-col justify-center gap-2 w-full lg:w-[49%] h-28 px-5 rounded-md shadow-md items-start bg-[#F5F5F5] className={`flex flex-col justify-center gap-2 w-full lg:w-[49%] h-28 px-5 rounded-md shadow-md items-start bg-[#F5F5F5]
`} `}
> >
<p className="text-sm font-normal leading-normal text-slate-500"> <p className=" text-slate-500 text-sm font-normal leading-normal">
عنوان :<span className=" text-slate-800">{item.title}</span> عنوان :
<span className=" text-slate-800">{item.title}</span>
</p> </p>
<p className="text-sm font-normal leading-normal text-slate-500"> <p className=" text-slate-500 text-sm font-normal leading-normal">
توضیحات: توضیحات:
<span className="self-end text-slate-800"> <span className=" text-slate-800 self-end">
{item.description} {item.description}
</span> </span>
</p> </p>
<div className="flex items-end justify-end w-full gap-2"> <div className="w-full flex justify-end items-end gap-2">
<Switch <Switch
dir="ltr" dir="ltr"
checked={!item.isDeleted} checked={!item.isDeleted}
@ -433,7 +447,7 @@ export default function AdminCategories() {
{/* <Button variant="outline">Show Dialog</Button> */} {/* <Button variant="outline">Show Dialog</Button> */}
<FaRegEdit <FaRegEdit
aria-hidden="true" aria-hidden="true"
className="self-end w-6 h-6 text-slate-600 hover:cursor-pointer" className="w-6 h-6 text-slate-600 hover:cursor-pointer self-end"
// onClick={() => setKeyId(item?.id)} // onClick={() => setKeyId(item?.id)}
onClick={() => onClick={() =>
handleClickEdit( handleClickEdit(

View File

@ -118,9 +118,14 @@ export default function AdminKeysManagement() {
// router.refresh() // router.refresh()
}, },
onError: (err: any | string) => { onError: (error) => {
toast(<>{err.response.data.detail}</>, { console.log(error);
className: "!bg-red-500 !text-white", console.log(error?.message);
setOpenEdit(false);
toast(error?.message, {
className: "!bg-red-500 !text-black",
}); });
}, },
}); });
@ -166,9 +171,13 @@ export default function AdminKeysManagement() {
// inputPubRef.current.clear(); // inputPubRef.current.clear();
// router.refresh() // router.refresh()
}, },
onError: (err: any | string) => { onError: (error) => {
toast(<>{err.response.data.detail}</>, { console.log(error);
className: "!bg-red-500 !text-white", console.log(error?.message);
setOpenAdd(false);
toast(error?.message, {
className: "!bg-red-500 !text-black",
}); });
}, },
}); });
@ -264,14 +273,14 @@ export default function AdminKeysManagement() {
<p className="text-[#464646] text-base font-bold"> <p className="text-[#464646] text-base font-bold">
افزودن کلید جدید افزودن کلید جدید
</p> </p>
<AlertDialogCancel className="h-auto p-0 border-0"> <AlertDialogCancel className="p-0 border-0 h-auto">
<IoMdClose /> <IoMdClose />
</AlertDialogCancel> </AlertDialogCancel>
</AlertDialogTitle> </AlertDialogTitle>
<AlertDialogDescription> <AlertDialogDescription>
<div className="flex justify-between w-full "> <div className=" w-full flex justify-between">
<div className="w-full mt-4 mb-2 text-lg font-bold text-right text-neutral-600"> <div className="w-full text-right text-neutral-600 text-lg font-bold mt-4 mb-2">
افزودن کلید جدید افزودن کلید جدید
</div> </div>
@ -288,7 +297,7 @@ export default function AdminKeysManagement() {
<Form {...formAdd}> <Form {...formAdd}>
<form <form
onSubmit={formAdd.handleSubmit(onSubmitAdd)} onSubmit={formAdd.handleSubmit(onSubmitAdd)}
className="flex flex-col w-full mt-6 " className="w-full flex flex-col mt-6 "
> >
<div className="flex flex-col flex-wrap justify-between"> <div className="flex flex-col flex-wrap justify-between">
<FormField <FormField
@ -333,10 +342,10 @@ export default function AdminKeysManagement() {
/> />
</div> </div>
<div className="flex justify-center w-full gap-2 mt-8 sm:justify-end"> <div className="flex justify-center sm:justify-end gap-2 w-full mt-8">
<Button <Button
type="submit" type="submit"
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" 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"
> >
افزودن کلید افزودن کلید
</Button> </Button>
@ -352,21 +361,21 @@ export default function AdminKeysManagement() {
</AlertDialogContent> </AlertDialogContent>
{/* 2 */} {/* 2 */}
<div className="flex items-center justify-between w-full mt-1 "> <div className=" w-full flex justify-between items-center mt-1">
<div className="w-full my-4 text-lg font-bold text-right text-neutral-600"> <div className="w-full text-right text-neutral-600 text-lg font-bold my-4">
لیست کلیدها لیست کلیدها
</div> </div>
<AlertDialogTrigger asChild> <AlertDialogTrigger asChild>
<Button <Button
variant="outline" variant="outline"
className="text-white bg-orange-500 hover:bg-orange-500/80 hover:text-white" className="bg-orange-500 hover:bg-orange-500/80 text-white hover:text-white"
// disabled={isNewKeyLoading} // disabled={isNewKeyLoading}
> >
افزودن کلید جدید افزودن کلید جدید
</Button> </Button>
</AlertDialogTrigger> </AlertDialogTrigger>
</div> </div>
<div className="flex flex-row flex-wrap justify-between w-full gap-8 md:gap-4 "> <div className="w-full flex flex-row flex-wrap justify-between gap-8 md:gap-4 ">
{data1?.map((item: any) => { {data1?.map((item: any) => {
return ( return (
<div <div
@ -374,13 +383,13 @@ export default function AdminKeysManagement() {
className={`flex flex-col justify-center gap-2 w-full lg:w-[49%] h-28 px-5 rounded-md shadow-md items-start bg-[#F5F5F5] className={`flex flex-col justify-center gap-2 w-full lg:w-[49%] h-28 px-5 rounded-md shadow-md items-start bg-[#F5F5F5]
`} `}
> >
<p className="text-sm font-normal leading-normal text-slate-500"> <p className=" text-slate-500 text-sm font-normal leading-normal">
عنوان کلید:{" "} عنوان کلید:{" "}
<span className=" text-slate-800">{item.title}</span> <span className=" text-slate-800">{item.title}</span>
</p> </p>
<p className="text-sm font-normal leading-normal text-slate-500"> <p className=" text-slate-500 text-sm font-normal leading-normal">
آیدی بازرس:{" "} آیدی بازرس:{" "}
<span className="self-end text-slate-800"> <span className=" text-slate-800 self-end">
{item.inspectorId} {item.inspectorId}
</span> </span>
</p> </p>
@ -390,7 +399,7 @@ export default function AdminKeysManagement() {
{/* <Button variant="outline">Show Dialog</Button> */} {/* <Button variant="outline">Show Dialog</Button> */}
<FaRegEdit <FaRegEdit
aria-hidden="true" aria-hidden="true"
className="self-end w-6 h-6 text-slate-600 hover:cursor-pointer" className="w-6 h-6 text-slate-600 hover:cursor-pointer self-end"
onClick={() => setKeyId(item?.id)} onClick={() => setKeyId(item?.id)}
/> />
</AlertDialogTrigger> </AlertDialogTrigger>
@ -401,7 +410,7 @@ export default function AdminKeysManagement() {
<Form {...formEdit}> <Form {...formEdit}>
<form <form
onSubmit={formEdit.handleSubmit(onSubmitEdit)} onSubmit={formEdit.handleSubmit(onSubmitEdit)}
className="flex flex-col w-full mt-6 " className="w-full flex flex-col mt-6 "
> >
<div className="flex flex-row flex-wrap justify-between"> <div className="flex flex-row flex-wrap justify-between">
<FormField <FormField
@ -417,7 +426,7 @@ export default function AdminKeysManagement() {
required={true} required={true}
type="file" type="file"
accept=".txt" accept=".txt"
className="mt-2 bg-slate-300" className="bg-slate-300 mt-2"
// {...field} // {...field}
onChange={handleFileChange} onChange={handleFileChange}
/> />
@ -437,7 +446,7 @@ export default function AdminKeysManagement() {
</FormLabel> </FormLabel>
<FormControl> <FormControl>
<Input <Input
className="mt-2 bg-slate-300" className="bg-slate-300 mt-2"
value={item?.id} value={item?.id}
readOnly={true} readOnly={true}
// {...field} // {...field}
@ -449,23 +458,23 @@ export default function AdminKeysManagement() {
/> */} /> */}
</div> </div>
<div className="flex justify-center w-full gap-2 mt-8 sm:justify-end"> <div className="flex justify-center sm:justify-end gap-2 w-full mt-8">
<Button <Button
// href="/FollowResult" // href="/FollowResult"
type="submit" type="submit"
className="p-2 text-center text-white bg-blue min-w-max rounded-xl hover:bg-white hover:text-slate-800" className="bg-blue text-white min-w-max p-2 rounded-xl text-center hover:bg-white hover:text-slate-800"
> >
تغییر کلید تغییر کلید
</Button> </Button>
{/* <AlertDialogAction {/* <AlertDialogAction
type="submit" type="submit"
className="p-2 text-center text-white bg-blue min-w-max rounded-xl hover:bg-white hover:text-slate-800" className="bg-blue text-white min-w-max p-2 rounded-xl text-center hover:bg-white hover:text-slate-800"
> >
تغییر کلید تغییر کلید
</AlertDialogAction> */} </AlertDialogAction> */}
<AlertDialogCancel className="mt-0 text-white bg-blue rounded-xl"> <AlertDialogCancel className="bg-blue text-white rounded-xl mt-0">
بستن بستن
</AlertDialogCancel> </AlertDialogCancel>
</div> </div>

View File

@ -220,9 +220,14 @@ export default function AdminNews() {
className: "!bg-green-500 !text-white", className: "!bg-green-500 !text-white",
}); });
}, },
onError: (err: any | string) => { onError: (error) => {
toast(<>{err.response.data.detail}</>, { console.log(error);
className: "!bg-red-500 !text-white", console.log(error?.message);
setOpenEdit(false);
toast(error?.message, {
className: "!bg-red-500 !text-black",
}); });
}, },
}); });
@ -240,9 +245,12 @@ export default function AdminNews() {
className: "!bg-green-500 !text-white", className: "!bg-green-500 !text-white",
}); });
}, },
onError: (err: any | string) => { onError: (error) => {
toast(<>{err.response.data.detail}</>, { console.log(error);
className: "!bg-red-500 !text-white", console.log(error?.message);
toast(error?.message, {
className: "!bg-red-500 !text-black",
}); });
}, },
}); });
@ -263,9 +271,14 @@ export default function AdminNews() {
className: "!bg-green-500 !text-white", className: "!bg-green-500 !text-white",
}); });
}, },
onError: (err: any | string) => { onError: (error) => {
toast(<>{err.response.data.detail}</>, { console.log(error);
className: "!bg-red-500 !text-white", console.log(error?.message);
setOpenAdd(false);
toast(error?.message, {
className: "!bg-red-500 !text-black",
}); });
}, },
}); });
@ -317,9 +330,9 @@ export default function AdminNews() {
return ( return (
<div className="w-full min-h-[85vh] flex justify-center"> <div className="w-full min-h-[85vh] flex justify-center">
<div className="w-[95vw] lg:w-[85vw] 3xl:w-[70vw] mt-8 max-sm:mt-16 pt-9 "> <div className="w-[95vw] lg:w-[85vw] 3xl:w-[70vw] mt-8 max-sm:mt-16 pt-9 ">
<div className="flex flex-row justify-between w-full "> <div className="flex w-full justify-between flex-row ">
{/* 1 */} {/* 1 */}
<div className="w-full my-4 text-lg font-bold text-right text-neutral-600"> <div className="w-full text-right text-neutral-600 text-lg font-bold my-4">
لیست خبر ها لیست خبر ها
</div> </div>
{/* 2 */} {/* 2 */}
@ -330,7 +343,7 @@ export default function AdminNews() {
<Button <Button
variant="outline" variant="outline"
// onClick={handleClickAddCat} // onClick={handleClickAddCat}
className="text-white bg-orange-500" className="bg-orange-500 text-white"
// disabled={isNewKeyLoading} // disabled={isNewKeyLoading}
> >
افزودن خبر افزودن خبر
@ -342,7 +355,7 @@ export default function AdminNews() {
<p className="text-[#464646] text-base font-bold"> <p className="text-[#464646] text-base font-bold">
افزودن خبر افزودن خبر
</p> </p>
<AlertDialogCancel className="h-auto p-0 border-0"> <AlertDialogCancel className="p-0 border-0 h-auto">
<IoMdClose /> <IoMdClose />
</AlertDialogCancel> </AlertDialogCancel>
</AlertDialogTitle> </AlertDialogTitle>
@ -352,7 +365,7 @@ export default function AdminNews() {
<Form {...formAdd}> <Form {...formAdd}>
<form <form
onSubmit={formAdd.handleSubmit(onSubmitAdd)} onSubmit={formAdd.handleSubmit(onSubmitAdd)}
className="flex flex-col w-full " className="w-full flex flex-col "
> >
<div className="flex flex-row flex-wrap justify-between"> <div className="flex flex-row flex-wrap justify-between">
<FormField <FormField
@ -488,14 +501,14 @@ export default function AdminNews() {
/> />
</div> </div>
<div className="flex justify-center w-full gap-2 mt-8 sm:justify-end"> <div className="flex justify-center sm:justify-end gap-2 w-full mt-8">
<Button <Button
type="submit" type="submit"
className="text-center text-white bg-blue min-w-max rounded-xl hover:bg-white hover:text-slate-800" className="bg-blue text-white min-w-max rounded-xl text-center hover:bg-white hover:text-slate-800"
> >
افزودن افزودن
</Button> </Button>
<AlertDialogCancel className="mt-0 text-white bg-blue rounded-xl"> <AlertDialogCancel className="bg-blue text-white rounded-xl mt-0">
بستن بستن
</AlertDialogCancel> </AlertDialogCancel>
</div> </div>
@ -510,7 +523,7 @@ export default function AdminNews() {
</AlertDialogContent> </AlertDialogContent>
</AlertDialog> </AlertDialog>
</div> </div>
<div className="flex flex-row flex-wrap justify-between w-full gap-8 md:gap-4 "> <div className="w-full flex flex-row flex-wrap justify-between gap-8 md:gap-4 ">
<AlertDialog open={openEdit} onOpenChange={setOpenEdit}> <AlertDialog open={openEdit} onOpenChange={setOpenEdit}>
<AlertDialogContent className=" w-full max-w-3xl h-full lg:max-h-[28em] max-h-screen sm:max-h-[27em]"> <AlertDialogContent className=" w-full max-w-3xl h-full lg:max-h-[28em] max-h-screen sm:max-h-[27em]">
<AlertDialogHeader> <AlertDialogHeader>
@ -518,7 +531,7 @@ export default function AdminNews() {
<p className="text-[#464646] text-base font-bold"> <p className="text-[#464646] text-base font-bold">
تغییر خبر تغییر خبر
</p> </p>
<AlertDialogCancel className="h-auto p-0 border-0"> <AlertDialogCancel className="p-0 border-0 h-auto">
<IoMdClose /> <IoMdClose />
</AlertDialogCancel> </AlertDialogCancel>
</AlertDialogTitle> </AlertDialogTitle>
@ -526,7 +539,7 @@ export default function AdminNews() {
<Form {...formEdit}> <Form {...formEdit}>
<form <form
onSubmit={formEdit.handleSubmit(onSubmitEdit)} onSubmit={formEdit.handleSubmit(onSubmitEdit)}
className="flex flex-col w-full" className="w-full flex flex-col"
> >
<div className="flex flex-row flex-wrap justify-between"> <div className="flex flex-row flex-wrap justify-between">
<FormField <FormField
@ -662,15 +675,15 @@ export default function AdminNews() {
/> />
</div> </div>
<div className="flex justify-center w-full gap-2 mt-8 sm:justify-end"> <div className="flex justify-center sm:justify-end gap-2 w-full mt-8">
<Button <Button
type="submit" type="submit"
className="p-2 text-center text-white bg-blue min-w-max rounded-xl hover:bg-white hover:text-slate-800" className="bg-blue text-white min-w-max p-2 rounded-xl text-center hover:bg-white hover:text-slate-800"
> >
تغییر خبر تغییر خبر
</Button> </Button>
<AlertDialogCancel className="mt-0 text-white bg-blue rounded-xl"> <AlertDialogCancel className="bg-blue text-white rounded-xl mt-0">
بستن بستن
</AlertDialogCancel> </AlertDialogCancel>
</div> </div>
@ -688,19 +701,19 @@ export default function AdminNews() {
className={`flex flex-col justify-center gap-2 w-full lg:w-[49%] h-56 px-5 rounded-md shadow-md items-start bg-[#F5F5F5] className={`flex flex-col justify-center gap-2 w-full lg:w-[49%] h-56 px-5 rounded-md shadow-md items-start bg-[#F5F5F5]
`} `}
> >
<p className="text-sm font-normal leading-normal text-slate-500"> <p className=" text-slate-500 text-sm font-normal leading-normal">
عنوان : عنوان :
<span className=" text-slate-800">{item.title}</span> <span className=" text-slate-800">{item.title}</span>
</p> </p>
<p className="text-sm font-normal leading-normal text-slate-500"> <p className=" text-slate-500 text-sm font-normal leading-normal">
توضیحات: توضیحات:
<span className="self-end text-slate-800"> <span className=" text-slate-800 self-end">
{item.description} {item.description}
</span> </span>
</p> </p>
<p className="text-sm font-normal leading-normal text-slate-500"> <p className=" text-slate-500 text-sm font-normal leading-normal">
محتوا: محتوا:
<span className="self-end text-slate-800"> <span className=" text-slate-800 self-end">
{item.content} {item.content}
</span> </span>
</p> </p>
@ -710,10 +723,10 @@ export default function AdminNews() {
width={100} width={100}
height={100} height={100}
quality={100} quality={100}
className="object-contain object-right w-full h-20 " className=" w-full h-20 object-contain object-right"
/> />
<div className="flex items-end justify-end w-full gap-2"> <div className="w-full flex justify-end items-end gap-2">
<Switch <Switch
dir="ltr" dir="ltr"
checked={!item.isDeleted} checked={!item.isDeleted}
@ -727,7 +740,7 @@ export default function AdminNews() {
{/* <Button variant="outline">Show Dialog</Button> */} {/* <Button variant="outline">Show Dialog</Button> */}
<FaRegEdit <FaRegEdit
aria-hidden="true" aria-hidden="true"
className="self-end w-6 h-6 text-slate-600 hover:cursor-pointer" className="w-6 h-6 text-slate-600 hover:cursor-pointer self-end"
// onClick={() => setKeyId(item?.id)} // onClick={() => setKeyId(item?.id)}
onClick={() => onClick={() =>
handleClickEdit( handleClickEdit(

View File

@ -152,9 +152,14 @@ export default function AdminOrganizations() {
className: "!bg-green-500 !text-white", className: "!bg-green-500 !text-white",
}); });
}, },
onError: (err: any | string) => { onError: (error) => {
toast(<>{err.response.data.detail}</>, { console.log(error);
className: "!bg-red-500 !text-white", console.log(error?.message);
setOpenEdit(false);
toast(error?.message, {
className: "!bg-red-500 !text-black",
}); });
}, },
}); });
@ -172,9 +177,12 @@ export default function AdminOrganizations() {
className: "!bg-green-500 !text-white", className: "!bg-green-500 !text-white",
}); });
}, },
onError: (err: any | string) => { onError: (error) => {
toast(<>{err.response.data.detail}</>, { console.log(error);
className: "!bg-red-500 !text-white", console.log(error?.message);
toast(error?.message, {
className: "!bg-red-500 !text-black",
}); });
}, },
}); });
@ -195,9 +203,14 @@ export default function AdminOrganizations() {
className: "!bg-green-500 !text-white", className: "!bg-green-500 !text-white",
}); });
}, },
onError: (err: any | string) => { onError: (error) => {
toast(<>{err.response.data.detail}</>, { console.log(error);
className: "!bg-red-500 !text-white", console.log(error?.message);
setOpenAdd(false);
toast(error?.message, {
className: "!bg-red-500 !text-black",
}); });
}, },
}); });
@ -220,9 +233,9 @@ export default function AdminOrganizations() {
return ( return (
<div className="w-full min-h-[85vh] flex justify-center"> <div className="w-full min-h-[85vh] flex justify-center">
<div className="w-[95vw] lg:w-[85vw] 3xl:w-[70vw] mt-8 max-sm:mt-16 pt-9 "> <div className="w-[95vw] lg:w-[85vw] 3xl:w-[70vw] mt-8 max-sm:mt-16 pt-9 ">
<div className="flex flex-row justify-between w-full "> <div className="flex w-full justify-between flex-row ">
{/* 1 */} {/* 1 */}
<div className="w-full my-4 text-lg font-bold text-right text-neutral-600"> <div className="w-full text-right text-neutral-600 text-lg font-bold my-4">
لیست سازمان ها لیست سازمان ها
</div> </div>
{/* 2 */} {/* 2 */}
@ -233,7 +246,7 @@ export default function AdminOrganizations() {
<Button <Button
variant="outline" variant="outline"
// onClick={handleClickAddCat} // onClick={handleClickAddCat}
className="text-white bg-orange-500" className="bg-orange-500 text-white"
// disabled={isNewKeyLoading} // disabled={isNewKeyLoading}
> >
افزودن سازمان افزودن سازمان
@ -245,21 +258,21 @@ export default function AdminOrganizations() {
<p className="text-[#464646] text-base font-bold"> <p className="text-[#464646] text-base font-bold">
افزودن سازمان افزودن سازمان
</p> </p>
<AlertDialogCancel className="h-auto p-0 border-0"> <AlertDialogCancel className="p-0 border-0 h-auto">
<IoMdClose /> <IoMdClose />
</AlertDialogCancel> </AlertDialogCancel>
</AlertDialogTitle> </AlertDialogTitle>
<AlertDialogDescription> <AlertDialogDescription>
<div className="w-full "> <div className="w-full ">
<div className="w-full mb-2 text-lg font-bold text-right text-neutral-600"> <div className="w-full text-right text-neutral-600 text-lg font-bold mb-2">
سازمان ها سازمان ها
</div> </div>
<Form {...formAdd}> <Form {...formAdd}>
<form <form
onSubmit={formAdd.handleSubmit(onSubmitAdd)} onSubmit={formAdd.handleSubmit(onSubmitAdd)}
className="flex flex-col w-full mt-6 " className="w-full flex flex-col mt-6 "
> >
<div className="flex flex-col flex-wrap justify-between"> <div className="flex flex-col flex-wrap justify-between">
<FormField <FormField
@ -303,14 +316,14 @@ export default function AdminOrganizations() {
/> />
</div> </div>
<div className="flex justify-center w-full gap-2 mt-8 sm:justify-end"> <div className="flex justify-center sm:justify-end gap-2 w-full mt-8">
<Button <Button
type="submit" type="submit"
className="text-center text-white bg-blue min-w-max rounded-xl hover:bg-white hover:text-slate-800" className="bg-blue text-white min-w-max rounded-xl text-center hover:bg-white hover:text-slate-800"
> >
افزودن افزودن
</Button> </Button>
<AlertDialogCancel className="mt-0 text-white bg-blue rounded-xl"> <AlertDialogCancel className="bg-blue text-white rounded-xl mt-0">
بستن بستن
</AlertDialogCancel> </AlertDialogCancel>
</div> </div>
@ -325,7 +338,7 @@ export default function AdminOrganizations() {
</AlertDialogContent> </AlertDialogContent>
</AlertDialog> </AlertDialog>
</div> </div>
<div className="flex flex-row flex-wrap justify-between w-full gap-8 md:gap-4 "> <div className="w-full flex flex-row flex-wrap justify-between gap-8 md:gap-4 ">
<AlertDialog open={openEdit} onOpenChange={setOpenEdit}> <AlertDialog open={openEdit} onOpenChange={setOpenEdit}>
<AlertDialogContent className=" w-full max-w-3xl h-full lg:max-h-[25em] max-h-[23em]"> <AlertDialogContent className=" w-full max-w-3xl h-full lg:max-h-[25em] max-h-[23em]">
<AlertDialogHeader> <AlertDialogHeader>
@ -333,7 +346,7 @@ export default function AdminOrganizations() {
<p className="text-[#464646] text-base font-bold"> <p className="text-[#464646] text-base font-bold">
تغییر سازمان تغییر سازمان
</p> </p>
<AlertDialogCancel className="h-auto p-0 border-0"> <AlertDialogCancel className="p-0 border-0 h-auto">
<IoMdClose /> <IoMdClose />
</AlertDialogCancel> </AlertDialogCancel>
</AlertDialogTitle> </AlertDialogTitle>
@ -341,7 +354,7 @@ export default function AdminOrganizations() {
<Form {...formEdit}> <Form {...formEdit}>
<form <form
onSubmit={formEdit.handleSubmit(onSubmitEdit)} onSubmit={formEdit.handleSubmit(onSubmitEdit)}
className="flex flex-col w-full" className="w-full flex flex-col"
> >
<div className="flex flex-col flex-wrap justify-between"> <div className="flex flex-col flex-wrap justify-between">
<FormField <FormField
@ -371,7 +384,7 @@ export default function AdminOrganizations() {
<FormControl> <FormControl>
<Textarea <Textarea
placeholder="توضیحات" placeholder="توضیحات"
className="bg-white resize-none" className="resize-none bg-white"
{...field} {...field}
/> />
</FormControl> </FormControl>
@ -381,15 +394,15 @@ export default function AdminOrganizations() {
/> />
</div> </div>
<div className="flex justify-center w-full gap-2 mt-8 sm:justify-end"> <div className="flex justify-center sm:justify-end gap-2 w-full mt-8">
<Button <Button
type="submit" type="submit"
className="p-2 text-center text-white bg-blue min-w-max rounded-xl hover:bg-white hover:text-slate-800" className="bg-blue text-white min-w-max p-2 rounded-xl text-center hover:bg-white hover:text-slate-800"
> >
تغییر سازمان تغییر سازمان
</Button> </Button>
<AlertDialogCancel className="mt-0 text-white bg-blue rounded-xl"> <AlertDialogCancel className="bg-blue text-white rounded-xl mt-0">
بستن بستن
</AlertDialogCancel> </AlertDialogCancel>
</div> </div>
@ -408,18 +421,18 @@ export default function AdminOrganizations() {
className={`flex flex-col justify-center gap-2 w-full lg:w-[49%] h-28 px-5 rounded-md shadow-md items-start bg-[#F5F5F5] className={`flex flex-col justify-center gap-2 w-full lg:w-[49%] h-28 px-5 rounded-md shadow-md items-start bg-[#F5F5F5]
`} `}
> >
<p className="text-sm font-normal leading-normal text-slate-500"> <p className=" text-slate-500 text-sm font-normal leading-normal">
عنوان : عنوان :
<span className=" text-slate-800">{item.title}</span> <span className=" text-slate-800">{item.title}</span>
</p> </p>
<p className="text-sm font-normal leading-normal text-slate-500"> <p className=" text-slate-500 text-sm font-normal leading-normal">
توضیحات: توضیحات:
<span className="self-end text-slate-800"> <span className=" text-slate-800 self-end">
{item.description} {item.description}
</span> </span>
</p> </p>
<div className="flex items-end justify-end w-full gap-2"> <div className="w-full flex justify-end items-end gap-2">
<Switch <Switch
dir="ltr" dir="ltr"
checked={!item.isDeleted} checked={!item.isDeleted}
@ -436,7 +449,7 @@ export default function AdminOrganizations() {
{/* <Button variant="outline">Show Dialog</Button> */} {/* <Button variant="outline">Show Dialog</Button> */}
<FaRegEdit <FaRegEdit
aria-hidden="true" aria-hidden="true"
className="self-end w-6 h-6 text-slate-600 hover:cursor-pointer" className="w-6 h-6 text-slate-600 hover:cursor-pointer self-end"
// onClick={() => setKeyId(item?.id)} // onClick={() => setKeyId(item?.id)}
onClick={() => onClick={() =>
handleClickEdit( handleClickEdit(

View File

@ -212,9 +212,14 @@ const ChangeSliderMutation = useMutation({
className: "!bg-green-500 !text-white", className: "!bg-green-500 !text-white",
}); });
}, },
onError: (err: any | string) => { onError: (error) => {
toast(<>{err.response.data.detail}</>, { console.log(error);
className: "!bg-red-500 !text-white", console.log(error?.message);
setOpenEdit(false);
toast(error?.message, {
className: "!bg-red-500 !text-black",
}); });
}, },
}); });
@ -232,9 +237,12 @@ const DeleteSliderMutation = useMutation({
className: "!bg-green-500 !text-white", className: "!bg-green-500 !text-white",
}); });
}, },
onError: (err: any | string) => { onError: (error) => {
toast(<>{err.response.data.detail}</>, { console.log(error);
className: "!bg-red-500 !text-white", console.log(error?.message);
toast(error?.message, {
className: "!bg-red-500 !text-black",
}); });
}, },
}); });
@ -255,9 +263,14 @@ const AddSliderMutation = useMutation({
className: "!bg-green-500 !text-white", className: "!bg-green-500 !text-white",
}); });
}, },
onError: (err: any | string) => { onError: (error) => {
toast(<>{err.response.data.detail}</>, { console.log(error);
className: "!bg-red-500 !text-white", console.log(error?.message);
setOpenAdd(false);
toast(error?.message, {
className: "!bg-red-500 !text-black",
}); });
}, },
}); });
@ -304,9 +317,9 @@ function onSubmitAdd(data: AddSliderFormValues) {
return ( return (
<div className="w-full min-h-[85vh] flex justify-center"> <div className="w-full min-h-[85vh] flex justify-center">
<div className="w-[95vw] lg:w-[85vw] 3xl:w-[70vw] mt-8 max-sm:mt-16 pt-9 "> <div className="w-[95vw] lg:w-[85vw] 3xl:w-[70vw] mt-8 max-sm:mt-16 pt-9 ">
<div className="flex flex-row justify-between w-full "> <div className="flex w-full justify-between flex-row ">
{/* 1 */} {/* 1 */}
<div className="w-full my-4 text-lg font-bold text-right text-neutral-600"> <div className="w-full text-right text-neutral-600 text-lg font-bold my-4">
لیست اسلایدرها لیست اسلایدرها
</div> </div>
{/* 2 */} {/* 2 */}
@ -317,7 +330,7 @@ function onSubmitAdd(data: AddSliderFormValues) {
<Button <Button
variant="outline" variant="outline"
// onClick={handleClickAddCat} // onClick={handleClickAddCat}
className="text-white bg-orange-500" className="bg-orange-500 text-white"
// disabled={isNewKeyLoading} // disabled={isNewKeyLoading}
> >
افزودن اسلایدر افزودن اسلایدر
@ -329,7 +342,7 @@ function onSubmitAdd(data: AddSliderFormValues) {
<p className="text-[#464646] text-base font-bold"> <p className="text-[#464646] text-base font-bold">
افزودن اسلایدر افزودن اسلایدر
</p> </p>
<AlertDialogCancel className="h-auto p-0 border-0"> <AlertDialogCancel className="p-0 border-0 h-auto">
<IoMdClose /> <IoMdClose />
</AlertDialogCancel> </AlertDialogCancel>
</AlertDialogTitle> </AlertDialogTitle>
@ -339,7 +352,7 @@ function onSubmitAdd(data: AddSliderFormValues) {
<Form {...formAdd}> <Form {...formAdd}>
<form <form
onSubmit={formAdd.handleSubmit(onSubmitAdd)} onSubmit={formAdd.handleSubmit(onSubmitAdd)}
className="flex flex-col w-full " className="w-full flex flex-col "
> >
<div className="flex flex-row flex-wrap justify-between"> <div className="flex flex-row flex-wrap justify-between">
<FormField <FormField
@ -459,14 +472,14 @@ function onSubmitAdd(data: AddSliderFormValues) {
</div> </div>
<div className="flex justify-center w-full gap-2 mt-8 sm:justify-end"> <div className="flex justify-center sm:justify-end gap-2 w-full mt-8">
<Button <Button
type="submit" type="submit"
className="text-center text-white bg-blue min-w-max rounded-xl hover:bg-white hover:text-slate-800" className="bg-blue text-white min-w-max rounded-xl text-center hover:bg-white hover:text-slate-800"
> >
افزودن افزودن
</Button> </Button>
<AlertDialogCancel className="mt-0 text-white bg-blue rounded-xl"> <AlertDialogCancel className="bg-blue text-white rounded-xl mt-0">
بستن بستن
</AlertDialogCancel> </AlertDialogCancel>
</div> </div>
@ -481,7 +494,7 @@ function onSubmitAdd(data: AddSliderFormValues) {
</AlertDialogContent> </AlertDialogContent>
</AlertDialog> </AlertDialog>
</div> </div>
<div className="flex flex-row flex-wrap justify-between w-full gap-8 md:gap-4 "> <div className="w-full flex flex-row flex-wrap justify-between gap-8 md:gap-4 ">
<AlertDialog open={openEdit} onOpenChange={setOpenEdit}> <AlertDialog open={openEdit} onOpenChange={setOpenEdit}>
<AlertDialogContent className=" w-full max-w-3xl h-full lg:max-h-[28em] max-h-screen sm:max-h-[27em]"> <AlertDialogContent className=" w-full max-w-3xl h-full lg:max-h-[28em] max-h-screen sm:max-h-[27em]">
<AlertDialogHeader> <AlertDialogHeader>
@ -489,7 +502,7 @@ function onSubmitAdd(data: AddSliderFormValues) {
<p className="text-[#464646] text-base font-bold"> <p className="text-[#464646] text-base font-bold">
تغییر اسلایدر تغییر اسلایدر
</p> </p>
<AlertDialogCancel className="h-auto p-0 border-0"> <AlertDialogCancel className="p-0 border-0 h-auto">
<IoMdClose /> <IoMdClose />
</AlertDialogCancel> </AlertDialogCancel>
</AlertDialogTitle> </AlertDialogTitle>
@ -497,7 +510,7 @@ function onSubmitAdd(data: AddSliderFormValues) {
<Form {...formEdit}> <Form {...formEdit}>
<form <form
onSubmit={formEdit.handleSubmit(onSubmitEdit)} onSubmit={formEdit.handleSubmit(onSubmitEdit)}
className="flex flex-col w-full" className="w-full flex flex-col"
> >
<div className="flex flex-row flex-wrap justify-between"> <div className="flex flex-row flex-wrap justify-between">
<FormField <FormField
@ -617,15 +630,15 @@ function onSubmitAdd(data: AddSliderFormValues) {
</div> </div>
<div className="flex justify-center w-full gap-2 mt-8 sm:justify-end"> <div className="flex justify-center sm:justify-end gap-2 w-full mt-8">
<Button <Button
type="submit" type="submit"
className="p-2 text-center text-white bg-blue min-w-max rounded-xl hover:bg-white hover:text-slate-800" className="bg-blue text-white min-w-max p-2 rounded-xl text-center hover:bg-white hover:text-slate-800"
> >
تغییر اسلایدر تغییر اسلایدر
</Button> </Button>
<AlertDialogCancel className="mt-0 text-white bg-blue rounded-xl"> <AlertDialogCancel className="bg-blue text-white rounded-xl mt-0">
بستن بستن
</AlertDialogCancel> </AlertDialogCancel>
</div> </div>
@ -643,13 +656,13 @@ function onSubmitAdd(data: AddSliderFormValues) {
className={`flex flex-col justify-around gap-2 w-full lg:w-[49%] h-52 px-5 rounded-md shadow-md items-start bg-[#F5F5F5] className={`flex flex-col justify-around gap-2 w-full lg:w-[49%] h-52 px-5 rounded-md shadow-md items-start bg-[#F5F5F5]
`} `}
> >
<p className="text-sm font-normal leading-normal text-slate-500"> <p className=" text-slate-500 text-sm font-normal leading-normal">
عنوان : عنوان :
<span className=" text-slate-800">{item.title}</span> <span className=" text-slate-800">{item.title}</span>
</p> </p>
<p className="text-sm font-normal leading-normal text-slate-500"> <p className=" text-slate-500 text-sm font-normal leading-normal">
توضیحات: توضیحات:
<span className="self-end text-slate-800"> <span className=" text-slate-800 self-end">
{item.description} {item.description}
</span> </span>
</p> </p>
@ -659,17 +672,17 @@ function onSubmitAdd(data: AddSliderFormValues) {
width={100} width={100}
height={100} height={100}
quality={100} quality={100}
className="object-contain object-right w-full h-20 " className=" w-full h-20 object-contain object-right"
/> />
{/* <p className="text-sm font-normal leading-normal text-slate-500"> {/* <p className=" text-slate-500 text-sm font-normal leading-normal">
محتوا: محتوا:
<span className="self-end text-slate-800"> <span className=" text-slate-800 self-end">
{item.content} {item.content}
</span> </span>
</p> */} </p> */}
<div className="flex items-end justify-end w-full gap-2"> <div className="w-full flex justify-end items-end gap-2">
<Switch <Switch
dir="ltr" dir="ltr"
checked={!item.isDeleted} checked={!item.isDeleted}
@ -685,7 +698,7 @@ function onSubmitAdd(data: AddSliderFormValues) {
{/* <Button variant="outline">Show Dialog</Button> */} {/* <Button variant="outline">Show Dialog</Button> */}
<FaRegEdit <FaRegEdit
aria-hidden="true" aria-hidden="true"
className="self-end w-6 h-6 text-slate-600 hover:cursor-pointer" className="w-6 h-6 text-slate-600 hover:cursor-pointer self-end"
// onClick={() => setKeyId(item?.id)} // onClick={() => setKeyId(item?.id)}
onClick={() => onClick={() =>
handleClickEdit( handleClickEdit(

View File

@ -129,9 +129,12 @@ export default function AdminWebContents() {
}); });
refetch1(); refetch1();
}, },
onError: (err: any | string) => { onError: (error) => {
toast(<>{err.response.data.detail}</>, { console.log(error);
className: "!bg-red-500 !text-white", console.log(error?.message);
toast(error?.message, {
className: "!bg-red-500 !text-black",
}); });
}, },
}); });
@ -144,14 +147,17 @@ export default function AdminWebContents() {
console.log(res); console.log(res);
console.log("Success Change UpdateWebContents"); console.log("Success Change UpdateWebContents");
toast("عملیات ویرایش شما با موفقیت انجام شد . ", { toast("عملیات ویرایش شما با موفقیت انجام شد . ", {
className: "!bg-green-500 !text-white", className: "!bg-green-500 !text-white",
}); });
refetch1(); refetch1();
}, },
onError: (err: any | string) => { onError: (error) => {
toast(<>{err.response.data.detail}</>, { console.log(error?.message);
className: "!bg-red-500 !text-white",
toast(error?.message, {
className: "!bg-red-500 !text-black",
}); });
}, },
}); });
@ -233,8 +239,8 @@ export default function AdminWebContents() {
<div className="w-full min-h-[85vh] flex justify-center"> <div className="w-full min-h-[85vh] flex justify-center">
<div className="w-[95vw] lg:w-[85vw] 3xl:w-[70vw] mt-8 max-sm:mt-16 pt-9 "> <div className="w-[95vw] lg:w-[85vw] 3xl:w-[70vw] mt-8 max-sm:mt-16 pt-9 ">
{/* Cull Us */} {/* Cull Us */}
<div className="flex flex-col w-full"> <div className="w-full flex flex-col">
<div className="my-4 text-base font-bold text-right text-neutral-600"> <div className=" text-right text-neutral-600 text-base font-bold my-4">
محتوای تماس با ما محتوای تماس با ما
</div> </div>
@ -256,15 +262,15 @@ export default function AdminWebContents() {
// setContentTitle("Test"); // setContentTitle("Test");
// setContentDesc("Test...."); // setContentDesc("Test....");
}} }}
className="self-end w-1/6 my-2" className="w-1/6 self-end my-2"
> >
ثبت ثبت
</Button> </Button>
</div> </div>
{/* About Us */} {/* About Us */}
<div className="flex flex-col w-full"> <div className="w-full flex flex-col">
<div className="my-4 text-base font-bold text-right text-neutral-600"> <div className=" text-right text-neutral-600 text-base font-bold my-4">
محتوای درباره ما محتوای درباره ما
</div> </div>
@ -284,15 +290,15 @@ export default function AdminWebContents() {
onEditAboutUs(); onEditAboutUs();
} }
}} }}
className="self-end w-1/6 my-2" className="w-1/6 self-end my-2"
> >
ثبت ثبت
</Button> </Button>
</div> </div>
{/* AfterRegistration */} {/* AfterRegistration */}
<div className="flex flex-col w-full"> <div className="w-full flex flex-col">
<div className="my-4 text-base font-bold text-right text-neutral-600"> <div className=" text-right text-neutral-600 text-base font-bold my-4">
محتوای بعد از ثبت گزارش محتوای بعد از ثبت گزارش
</div> </div>
@ -312,15 +318,15 @@ export default function AdminWebContents() {
onEditAfterText(); onEditAfterText();
} }
}} }}
className="self-end w-1/6 my-2" className="w-1/6 self-end my-2"
> >
ثبت ثبت
</Button> </Button>
</div> </div>
{/* BeforeRegistration*/} {/* BeforeRegistration*/}
<div className="flex flex-col w-full"> <div className="w-full flex flex-col">
<div className="my-4 text-base font-bold text-right text-neutral-600"> <div className=" text-right text-neutral-600 text-base font-bold my-4">
محتوای قبل از ثبت گزارش محتوای قبل از ثبت گزارش
</div> </div>
@ -340,7 +346,7 @@ export default function AdminWebContents() {
onEditBeforeText(); onEditBeforeText();
} }
}} }}
className="self-end w-1/6 my-2" className="w-1/6 self-end my-2"
> >
ثبت ثبت
</Button> </Button>

View File

@ -57,11 +57,7 @@ export default function ComplainsDetails({
onSuccess: (res) => { onSuccess: (res) => {
localStorage.setItem("trackingNumber", res.trackingNumber); localStorage.setItem("trackingNumber", res.trackingNumber);
}, },
onError: (err: any | string) => { onError: (err) => {},
toast(<>{err.response.data.detail}</>, {
className: "!bg-red-500 !text-white",
});
},
}); });
useEffect(() => { useEffect(() => {
@ -218,7 +214,7 @@ export default function ComplainsDetails({
className=" bg-white hover:bg-white focus:bg-white" className=" bg-white hover:bg-white focus:bg-white"
/> />
</div> </div>
<div className="flex items-center px-8 space-x-2"> <div className="flex items-center space-x-2 px-8">
<Checkbox <Checkbox
checked={check} checked={check}
onCheckedChange={setCheck} onCheckedChange={setCheck}
@ -262,7 +258,7 @@ export default function ComplainsDetails({
onClick={() => onClick={() =>
router.push("/UserPanel/ControllerDashboard/Complaints") router.push("/UserPanel/ControllerDashboard/Complaints")
} }
className="flex gap-1 my-2 cursor-pointer text-blue lg:sticky top-20" className=" my-2 flex gap-1 cursor-pointer text-blue lg:sticky top-20"
> >
<span> <span>
<ArrowRight /> <ArrowRight />
@ -270,7 +266,7 @@ export default function ComplainsDetails({
<p>بازگشت</p> <p>بازگشت</p>
</button> </button>
<div className="flex items-start w-full gap-2 mt-2 max-lg:flex-col"> <div className="w-full flex max-lg:flex-col items-start mt-2 gap-2">
{/* 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]">
<div className=" max-lg:hidden bg-[#E9E9E9] rounded-md p-4 px-10 flex flex-col lg:h-full"> <div className=" max-lg:hidden bg-[#E9E9E9] rounded-md p-4 px-10 flex flex-col lg:h-full">
@ -287,11 +283,11 @@ export default function ComplainsDetails({
</div> </div>
</div> </div>
{/* 2 */} {/* 2 */}
<div className="flex flex-col self-stretch w-full gap-2 rounded-lg lg:w-2/3 "> <div className="w-full lg:w-2/3 self-stretch rounded-lg flex flex-col gap-2 ">
<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="relative flex flex-col w-full p-5 mt-2 border border-gray-400 rounded-md gap-y-1"> <div className="mt-2 flex flex-col gap-y-1 border rounded-md border-gray-400 w-full p-5 relative">
<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>
@ -325,7 +321,7 @@ export default function ComplainsDetails({
</> </>
) : ( ) : (
<> <>
<div className="relative flex flex-col p-5 mt-2 border border-gray-400 rounded-md gap-y-1 md:w-1/2"> <div className="mt-2 flex flex-col gap-y-1 border rounded-md border-gray-400 md:w-1/2 p-5 relative">
<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>
@ -356,7 +352,7 @@ export default function ComplainsDetails({
</span> </span>
</p> </p>
</div> </div>
<div className="relative flex flex-col p-5 mt-2 border border-gray-400 rounded-md gap-y-1 md:w-1/2"> <div className="mt-2 flex flex-col gap-y-1 border rounded-md border-gray-400 md:w-1/2 p-5 relative">
<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>
@ -392,14 +388,14 @@ export default function ComplainsDetails({
</div> </div>
<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 mt-4 gap-y-4"> <div className=" flex flex-col gap-y-4 mt-4">
{data.contents?.map((item: any) => { {data.contents?.map((item: any) => {
return ( return (
<div <div
key={item.id} key={item.id}
className="p-4 bg-white rounded-lg shadow-md " className=" bg-white p-4 rounded-lg shadow-md"
> >
<div className="flex items-center gap-4 "> <div className=" flex gap-4 items-center">
<p className=""> <p className="">
<Badge> <Badge>
{item.sender == 0 ? "شهروند" : "بازرس"} {item.sender == 0 ? "شهروند" : "بازرس"}
@ -421,7 +417,7 @@ export default function ComplainsDetails({
<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 items-center w-full gap-2 mt-2 text-xs max-md:flex-col"> <div className=" flex flex-wrap max-md:flex-col w-full items-center gap-2 text-xs mt-2">
{item?.media.map((item: any, index: number) => { {item?.media.map((item: any, index: number) => {
return ( return (
<div <div
@ -432,7 +428,7 @@ export default function ComplainsDetails({
onClick={() => onClick={() =>
openFileInNewTab(item.data, item.mimeType) openFileInNewTab(item.data, item.mimeType)
} }
className="flex items-center gap-2 truncate cursor-pointer " className=" cursor-pointer flex gap-2 truncate items-center"
> >
<File className=" w-6 h-6" /> <File className=" w-6 h-6" />
<p className=" max-w-[5rem] truncate"> <p className=" max-w-[5rem] truncate">
@ -479,7 +475,7 @@ export default function ComplainsDetails({
) : ( ) : (
<> <>
{getComplaintMutation.isPending && ( {getComplaintMutation.isPending && (
<div className="flex justify-center w-full h-full mt-20"> <div className="w-full h-full flex justify-center mt-20">
<Triangle <Triangle
visible={true} visible={true}

View File

@ -91,11 +91,7 @@ export default function InspectorOperations({
password: key2 ? key2 : (localStorage.getItem("privateKey") as string), password: key2 ? key2 : (localStorage.getItem("privateKey") as string),
}); });
}, },
onError: (err: any | string) => { onError: (err) => {},
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>) {
@ -203,7 +199,7 @@ export default function InspectorOperations({
/> />
)} )}
<div className="flex justify-between gap-2 mt-3 "> <div className=" flex justify-between mt-3 gap-2">
<FormField <FormField
control={form.control} control={form.control}
name="operation" name="operation"
@ -251,7 +247,7 @@ export default function InspectorOperations({
/> />
<Button <Button
disabled={possibleOperations.length == 0} disabled={possibleOperations.length == 0}
className="w-1/3 bg-blue" className=" bg-blue w-1/3"
type="submit" type="submit"
> >
ثبت ثبت

View File

@ -58,14 +58,16 @@ export default function Login() {
const loginMutation = useMutation({ const loginMutation = useMutation({
mutationFn: loginStaff, mutationFn: loginStaff,
onSuccess: (res) => { onSuccess: (res) => {},
router.push("/Verify");
localStorage.setItem("verificationToken", res);
},
onError: (err: any | string) => { onError: (err: any | string) => {
toast(<>{err.response.data.detail}</>, { if (err.response.status == 428) {
console.log(useData);
router.push("/Verify");
} else {
toast("مشکلی در ارسال درخواست به وجود آمد.", {
className: "!bg-red-500 !text-white", className: "!bg-red-500 !text-white",
}); });
}
}, },
}); });
@ -95,12 +97,12 @@ export default function Login() {
: null; : null;
return ( return (
<div className="grid w-screen h-screen bg-gray-200 place-content-center"> <div className=" w-screen h-screen grid place-content-center bg-gray-200 ">
<div <div
className="w-full sm:[20rem] md:[20rem] xl:w-[30rem] 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 sm:[20rem] md:[20rem] xl:w-[30rem] bg-white rounded-lg dark:border xl:p-0 dark:bg-gray-800 dark:border-gray-700 shadow-[0px_0px_15px_0px_#00000040]
h-fit" h-fit"
> >
<div className="flex flex-col justify-center h-full p-10 space-y-3 md:space-y-4 md:py-10 md:px-12 lg:px-16"> <div className="space-y-3 md:space-y-4 flex flex-col md:py-10 p-10 md:px-12 lg:px-16 h-full justify-center">
<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">
@ -110,7 +112,7 @@ export default function Login() {
<Form {...form}> <Form {...form}>
<form <form
onSubmit={form.handleSubmit(onSubmit)} onSubmit={form.handleSubmit(onSubmit)}
className="flex flex-col w-full " className="w-full flex flex-col "
> >
<FormField <FormField
control={form.control} control={form.control}
@ -156,13 +158,13 @@ export default function Login() {
</FormItem> </FormItem>
)} )}
/> />
<div className="flex items-center gap-3 mt-4"> <div className="flex gap-3 mt-4 items-center">
<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 flex-1 h-10 "> <FormItem className=" items-center h-10 flex-1">
{/* <FormLabel className="text-[#7C838A] text-sm font-medium mt-7"> {/* <FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
رمز عبور رمز عبور
</FormLabel> */} </FormLabel> */}
@ -174,7 +176,7 @@ export default function Login() {
)} )}
/> />
{isLoading ? ( {isLoading ? (
<div className="flex justify-center text-center w-36"> <div className=" w-36 flex justify-center text-center">
<ThreeDots <ThreeDots
visible={true} visible={true}
height="50" height="50"
@ -187,7 +189,7 @@ export default function Login() {
/> />
</div> </div>
) : ( ) : (
<div className="flex items-center justify-center gap-2 text-center "> <div className=" flex items-center justify-center text-center gap-2">
<Image <Image
alt="icon" alt="icon"
src={srcForImage as string} src={srcForImage as string}
@ -204,14 +206,14 @@ export default function Login() {
</div> </div>
)} )}
</div> </div>
<div className="flex justify-end w-full gap-2 mt-14"> <div className="flex justify-end gap-2 w-full mt-14">
<Button <Button
disabled={loginMutation.isPending} disabled={loginMutation.isPending}
type="submit" type="submit"
className="w-1/2 p-2 text-white transition bg-blue hover:bg-blue/90 md:w-1/3 rounded-xl" className="bg-blue hover:bg-blue/90 transition text-white w-1/2 md:w-1/3 p-2 rounded-xl"
> >
{loginMutation.isPending ? ( {loginMutation.isPending ? (
<div className="flex items-center justify-center gap-2"> <div className="flex justify-center items-center gap-2">
<Oval <Oval
visible={true} visible={true}
height="20" height="20"

View File

@ -42,7 +42,10 @@ export default function NavbarPanel() {
return ( return (
<div <div
className="fixed top-0 z-10 flex flex-row items-center justify-between w-full gap-3 px-8 py-4 shadow-md sm:items-center sm:gap-0 bg-blue max-md:px-4 " className="fixed flex justify-between items-center gap-3
flex-row sm:items-center sm:gap-0
w-full px-8 py-4 z-10 top-0 bg-blue max-md:px-4 shadow-md
"
> >
<div className=" flex items-center gap-8 max-md:gap-4"> <div className=" flex items-center gap-8 max-md:gap-4">
<div className=" md:hidden"> <div className=" md:hidden">
@ -54,7 +57,7 @@ export default function NavbarPanel() {
color="#fff" color="#fff"
/> />
</div> </div>
<p className="inline-block text-sm font-bold text-white bg-clip-text max-md:text-sm max-md:font-medium"> <p className="text-white inline-block bg-clip-text text-sm font-bold max-md:text-sm max-md:font-medium">
پنل کاربری {<span className=" max-md:hidden">|</span>} پنل کاربری {<span className=" max-md:hidden">|</span>}
</p> </p>
@ -124,8 +127,8 @@ export default function NavbarPanel() {
)} )}
</div> </div>
</div> </div>
<div className="flex items-center gap-4 "> <div className=" flex gap-4 items-center">
<h1 className="inline-block text-sm font-bold text-white bg-clip-text before:max-md:hidden max-md:text-xs max-md:font-medium"> <h1 className="text-white inline-block bg-clip-text before:max-md:hidden text-sm font-bold max-md:text-xs max-md:font-medium">
{data && ( {data && (
<> <>
{role === "Admin" {role === "Admin"
@ -134,7 +137,7 @@ export default function NavbarPanel() {
</> </>
)} )}
</h1> </h1>
<div className="p-1 rounded-md hover:bg-white/50"> <div className="hover:bg-white/50 p-1 rounded-md">
<LogOut <LogOut
onClick={() => { onClick={() => {
deleteCookie("Sootzani_Token"); deleteCookie("Sootzani_Token");

View File

@ -1,19 +0,0 @@
"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;

View File

@ -18,24 +18,14 @@ import {
} from "@/components/ui/alert-dialog"; } from "@/components/ui/alert-dialog";
import { IoMdClose } from "react-icons/io"; import { IoMdClose } from "react-icons/io";
import { useMediaQuery } from "react-responsive"; import { useMediaQuery } from "react-responsive";
export default function Search({ export default function Search({ mode }: { mode: string }) {
mode,
value,
action,
changeValue,
}: {
mode: string;
value: any;
action: (any: any) => any;
changeValue: (any: any) => any;
}) {
// useEffect(() => { // useEffect(() => {
// const isMobile = useMediaQuery({ query: "(max-width: 768px)" }); // const isMobile = useMediaQuery({ query: "(max-width: 768px)" });
// }, []); // }, []);
return ( return (
<div> <div>
{mode === "controller" || mode === "admin" ? ( {mode === "controller" || mode === "admin" ? (
<div className="relative flex items-center bg-gray-300 rounded-xl"> <div className="relative flex bg-gray-300 rounded-xl items-center">
<Input <Input
// type="search" // type="search"
id="default-search" id="default-search"
@ -48,23 +38,21 @@ export default function Search({
"w-full min-w-full bg-white lg:min-w-full h-11" "w-full min-w-full bg-white lg:min-w-full h-11"
} }
`} `}
value={value}
onChange={(e) => changeValue(e.target.value)}
placeholder="جستجو..." placeholder="جستجو..."
required required
/> />
{/* <Button {/* <Button
className="absolute left-0 w-auto h-auto bg-transparent text-slate-800" className="absolute left-0 bg-transparent h-auto w-auto text-slate-800"
> >
<CiSearch /> <CiSearch />
</Button> */} </Button> */}
<button onClick={action} className="absolute left-3"> <button className="absolute left-3">
<CiSearch /> <CiSearch />
</button> </button>
</div> </div>
) : ( ) : (
<> <>
<div className="relative flex items-center bg-gray-300 max-md:hidden rounded-xl"> <div className=" max-md:hidden relative flex bg-gray-300 rounded-xl items-center">
<Input <Input
// type="search" // type="search"
id="default-search" id="default-search"
@ -90,7 +78,7 @@ export default function Search({
<button <button
// variant="outline" // variant="outline"
// type="submit" // type="submit"
className="p-1 font-bold text-white rounded-md bg-gradient2" className=" bg-gradient2 text-white font-bold rounded-md p-1"
> >
<CiSearch /> <CiSearch />
</button> </button>
@ -102,7 +90,7 @@ export default function Search({
<p className="text-[#464646] text-base font-bold"> <p className="text-[#464646] text-base font-bold">
فرم جستجو فرم جستجو
</p> </p>
<AlertDialogCancel className="h-auto p-0 border-0"> <AlertDialogCancel className="p-0 border-0 h-auto">
<IoMdClose /> <IoMdClose />
</AlertDialogCancel> </AlertDialogCancel>
</AlertDialogTitle> </AlertDialogTitle>
@ -117,7 +105,7 @@ export default function Search({
required required
/> />
<button className="absolute text-black left-16"> <button className="absolute left-16 text-black">
<CiSearch /> <CiSearch />
</button> </button>
</AlertDialogDescription> </AlertDialogDescription>

View File

@ -25,7 +25,6 @@ import { toast } from "sonner";
export default function TabController() { export default function TabController() {
const saveData = useData((state) => state.saveData); const saveData = useData((state) => state.saveData);
const [selectedFile, setSelectedFile] = useState<any>(null); const [selectedFile, setSelectedFile] = useState<any>(null);
const [search, setSearch] = useState<any>(null);
const router = useRouter(); const router = useRouter();
const handleFileChange = (event: any) => { const handleFileChange = (event: any) => {
const file = event.target.files[0]; const file = event.target.files[0];
@ -52,10 +51,11 @@ export default function TabController() {
}); });
} }
}; };
console.log(search);
const [psblState, setPsblState] = useState(0); const [psblState, setPsblState] = useState(0);
const [selectedTab, setSelectedTab] = useState("0"); const [selectedTab, setSelectedTab] = useState("0");
const { const {
data: dataState, data: dataState,
isLoading: isLoadingState, isLoading: isLoadingState,
@ -69,27 +69,24 @@ export default function TabController() {
// const initialSelectedTab = dataState[0]?.value || ''; // const initialSelectedTab = dataState[0]?.value || '';
// setSelectedTab(initialSelectedTab); // setSelectedTab(initialSelectedTab);
const { data, isLoading, refetch } = useQuery({ const { data, isLoading, refetch } = useQuery({
queryKey: ["ComplaintsList" ,psblState,dataState], queryKey: ["ComplaintsList" ,psblState,dataState],
queryFn: () => queryFn: () => getComplaintsList(psblState),
getComplaintsList({ states: psblState, TrackingNumber: search }),
refetchOnWindowFocus: false, refetchOnWindowFocus: false,
}); });
const handelSearch = (event: any) => {
refetch();
};
// useEffect(() => { // useEffect(() => {
// // Handle the data after it has been updated // // Handle the data after it has been updated
// }, [data]); // }, [data]);
return ( return (
<div className="w-[95vw] lg:w-[82vw] xl:w-[70vw] 3xl:w-[65vw] mt-16 pt-9 mx-auto"> <div className="w-[95vw] lg:w-[82vw] xl:w-[70vw] 3xl:w-[65vw] mt-16 pt-9 mx-auto">
<p className="my-2 text-xs font-bold 3xl:ml-6 sm:text-sm md:hidden"> <p className="3xl:ml-6 text-xs sm:text-sm font-bold md:hidden my-2">
لیست شکایت ها لیست شکایت ها
</p> </p>
<Tabs <Tabs
defaultValue="0" defaultValue='0'
value={selectedTab} value={selectedTab}
// onClick={(value) => { // onClick={(value) => {
// setPsblState(value); // setPsblState(value);
@ -99,10 +96,10 @@ export default function TabController() {
className="" className=""
dir="rtl" dir="rtl"
> >
<div className="flex flex-col-reverse items-center justify-between w-full gap-4 mb-10 lg:flex-row lg:gap-5"> <div className="w-full flex flex-col-reverse lg:flex-row gap-4 lg:gap-5 justify-between items-center mb-10">
{/* Tab Title */} {/* Tab Title */}
<TabsList className="flex w-full gap-1 md:gap-4 lg:gap-3"> <TabsList className="w-full flex gap-1 md:gap-4 lg:gap-3">
<p className="text-xs font-bold 3xl:ml-6 sm:text-sm max-md:hidden"> <p className="3xl:ml-6 text-xs sm:text-sm font-bold max-md:hidden">
لیست شکایت ها | لیست شکایت ها |
</p> </p>
@ -127,12 +124,7 @@ export default function TabController() {
</TabsList> </TabsList>
{/* Search Box */} {/* Search Box */}
<Search <Search mode="controller" />
value={search}
changeValue={(data: any) => setSearch(data)}
mode="controller"
action={handelSearch}
/>
</div> </div>
{/* Tab Content */} {/* Tab Content */}
@ -140,6 +132,7 @@ export default function TabController() {
<TabsContent value={selectedTab} key={selectedTab}> <TabsContent value={selectedTab} key={selectedTab}>
<TableController checkKey={(item) => checkKey(item)} data={data} /> <TableController checkKey={(item) => checkKey(item)} data={data} />
</TabsContent> </TabsContent>
</Tabs> </Tabs>
</div> </div>
); );

View File

@ -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, Triangle } from "react-loader-spinner"; import { Oval } from "react-loader-spinner";
import { toast } from "sonner"; import { toast } from "sonner";
export default function Verify() { export default function Verify() {
@ -18,13 +18,12 @@ export default function Verify() {
const space = "\xa0"; const space = "\xa0";
const router = useRouter(); const router = useRouter();
const userData = useData((state) => state.data); const userData = useData((state) => state.data);
const [VerifyRole, setVerifyRole] = useState<any>("");
const verifyMutation = useMutation({ const verifyMutation = useMutation({
mutationFn: verifyStaff, mutationFn: verifyStaff,
onSuccess: (res) => { onSuccess: (res) => {
const decodedToken = jwtDecode<any>(res.jwtToken); const decodedToken = jwtDecode<any>(res);
setCookie("Sootzani_Token", res.jwtToken); setCookie("Sootzani_Token", res);
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"
@ -34,14 +33,41 @@ export default function Verify() {
router.push("/UserPanel/ControllerDashboard"); router.push("/UserPanel/ControllerDashboard");
} else if (userRole == "Admin") { } else if (userRole == "Admin") {
router.push("/UserPanel/AdminDashboard"); router.push("/UserPanel/AdminDashboard");
} else {
router.push("/UserPanel/CitizenDashboard");
} }
}, },
onError: (err: any | string) => { onError: (err: any) => {
toast(<>{err.response.data.detail}</>, { toast("کد تایید شما صحیح نمیباشد.", {
className: "!bg-red-500 !text-white", className: "!bg-red-500 !text-white",
}); });
}, },
}); });
const CitizenVerifyMutation = useMutation({
mutationFn: verifyCitizen,
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);
router.push("/UserPanel/CitizenDashboard");
},
onError: (err: any) => {},
});
const handelVerify = () => {
console.log(otp);
const payload = { ...userData, verificationCode: otp };
console.log(userData);
if (userData?.phoneNumber) {
CitizenVerifyMutation.mutate(payload);
} else {
verifyMutation.mutate(payload);
}
};
useEffect(() => { useEffect(() => {
useData.persist.rehydrate(); useData.persist.rehydrate();
@ -49,36 +75,19 @@ export default function Verify() {
useEffect(() => { useEffect(() => {
if (otp.length == 6) { if (otp.length == 6) {
const payload = { const payload = { ...userData, verificationCode: otp };
otpToken: localStorage.getItem("verificationToken"),
verificationCode: otp,
};
console.log(userData); console.log(userData);
verifyMutation.mutate(payload); verifyMutation.mutate(payload);
} }
}, [otp]); }, [otp]);
return ( return (
<div className="grid w-screen h-screen bg-gray-200 place-content-center"> <div className=" w-screen h-screen grid place-content-center bg-gray-200">
<div <div
className="w-full sm:[20rem] md:[20rem] xl:w-[30rem] 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 sm:[20rem] md:[20rem] xl:w-[30rem] bg-white rounded-lg dark:border xl:p-0 dark:bg-gray-800 dark:border-gray-700 shadow-[0px_0px_15px_0px_#00000040]
h-fit relative" h-fit"
> >
{verifyMutation.isPending && ( <div className="space-y-3 md:space-y-4 flex flex-col md:py-12 md:px-20 h-full justify-center">
<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 p-10 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">
تایید کد تایید کد
@ -93,25 +102,23 @@ export default function Verify() {
<input autoFocus={idx == 0} pattern="[0-9]*" {...props} /> <input autoFocus={idx == 0} pattern="[0-9]*" {...props} />
)} )}
containerStyle=" flex justify-center" containerStyle=" flex justify-center"
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"
verifyMutation.isSuccess && "border-green-600 transition-all"
}`}
/> />
</div> </div>
<label className="text-center label"> <label className="label text-center">
<span className="text-xs text-center text-blue/70 label-text"> <span className="text-xs text-blue/70 label-text text-center">
کد دریافت شده توسط پیامک را وارد نمایید. کد دریافت شده توسط پیامک را وارد نمایید.
</span> </span>
</label> </label>
{/* <div className="flex justify-end w-full gap-2 mt-14"> {/* <div className="flex justify-end gap-2 w-full mt-14">
<Button <Button
disabled={verifyMutation.isPending} disabled={verifyMutation.isPending}
onClick={handelVerify} onClick={handelVerify}
type="submit" type="submit"
className="w-1/2 p-2 text-white bg-blue hover:bg-blue/90 md:w-1/3 rounded-xl" className="bg-blue hover:bg-blue/90 text-white w-1/2 md:w-1/3 p-2 rounded-xl"
> >
{verifyMutation.isPending ? ( {verifyMutation.isPending ? (
<div className="flex items-center justify-center gap-2"> <div className="flex justify-center items-center gap-2">
<Oval <Oval
visible={true} visible={true}
height="20" height="20"

9
package-lock.json generated
View File

@ -44,7 +44,6 @@
"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",
"nextjs-toploader": "^1.6.4", "nextjs-toploader": "^1.6.4",
"npm": "^10.2.5", "npm": "^10.2.5",
@ -4557,14 +4556,6 @@
} }
} }
}, },
"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",

View File

@ -45,7 +45,6 @@
"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",
"nextjs-toploader": "^1.6.4", "nextjs-toploader": "^1.6.4",
"npm": "^10.2.5", "npm": "^10.2.5",

View File

@ -1,39 +1,8 @@
import axios from "axios"; import axios from "axios";
import { import { CookieValueTypes } from "cookies-next";
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) {
console.log(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;
@ -47,7 +16,8 @@ export async function loginStaff(payload: {
} }
export async function verifyStaff(payload: { export async function verifyStaff(payload: {
otpToken: string | null; username: string;
password: string;
verificationCode: string; verificationCode: string;
}) { }) {
const data = await axios.post("api/Authenticate/VerifyStaff", payload); const data = await axios.post("api/Authenticate/VerifyStaff", payload);
@ -96,16 +66,3 @@ export async function editProfile(payload: {
const data = await axios.put("api/Authenticate/Profile", payload); const data = await axios.put("api/Authenticate/Profile", payload);
return data.data; 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 = "/";
}
}

View File

@ -2,7 +2,6 @@
// import useToken from "@/store/useToken"; // import useToken from "@/store/useToken";
import axios from "axios"; import axios from "axios";
import { CookieValueTypes, getCookie } from "cookies-next"; import { CookieValueTypes, getCookie } from "cookies-next";
import { RefreshToken } from "./authenticateApi";
axios.defaults.baseURL = process.env.NEXT_PUBLIC_BASE_URL_APP; axios.defaults.baseURL = process.env.NEXT_PUBLIC_BASE_URL_APP;
@ -17,18 +16,10 @@ export async function getPossibleStates() {
return data.data; return data.data;
} }
export async function getComplaintsList({ export async function getComplaintsList(states: number = 0) {
states = 0,
TrackingNumber,
}: {
states: number;
TrackingNumber?: string;
}) {
// export async function getComplaintsList() { // export async function getComplaintsList() {
// const data = await axios.get(`api/Inspector/List`); // const data = await axios.get(`api/Inspector/List`);
const data = await axios.get(`api/Inspector/List?States=${states}`, { const data = await axios.get(`api/Inspector/List?States=${states}`);
params: { TrackingNumber: TrackingNumber },
});
return data.data; return data.data;
} }