Compare commits
No commits in common. "74246639e35535bcac33f977627b4dcd5720e35c" and "2fc9cc9951466c83ecaea81bbd57d8f8f55d4340" have entirely different histories.
74246639e3
...
2fc9cc9951
|
|
@ -1,8 +0,0 @@
|
||||||
import ChangePhoneNumber from "@/components/ChangePhoneNumber";
|
|
||||||
import React from "react";
|
|
||||||
|
|
||||||
function page() {
|
|
||||||
return <ChangePhoneNumber />;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default page;
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
import Profile from "@/components/ui/Profile";
|
|
||||||
import React from "react";
|
|
||||||
|
|
||||||
export default function page() {
|
|
||||||
return <Profile />;
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
import ChangePhoneNumber from "@/components/ChangePhoneNumber";
|
|
||||||
import React from "react";
|
|
||||||
|
|
||||||
function page() {
|
|
||||||
return <ChangePhoneNumber />;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default page;
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
import Profile from "@/components/ui/Profile";
|
|
||||||
import React from "react";
|
|
||||||
|
|
||||||
export default function page() {
|
|
||||||
return <Profile />;
|
|
||||||
}
|
|
||||||
|
|
@ -11,7 +11,7 @@ export default function RootLayout({
|
||||||
if (!token?.value) {
|
if (!token?.value) {
|
||||||
return redirect("/");
|
return redirect("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<NavbarPanel />
|
<NavbarPanel />
|
||||||
|
|
|
||||||
|
|
@ -42,9 +42,8 @@ import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import * as z from "zod";
|
import * as z from "zod";
|
||||||
import { Textarea } from "./ui/textarea";
|
import { Textarea } from "./ui/textarea";
|
||||||
import { Check, KeyRound } from "lucide-react";
|
import { Check } from "lucide-react";
|
||||||
import { Progress } from "./ui/progress";
|
import { Progress } from "./ui/progress";
|
||||||
import { cn } from "@/lib/utils";
|
|
||||||
|
|
||||||
const MAX_FILE_SIZE = 5242880; // 5 MB
|
const MAX_FILE_SIZE = 5242880; // 5 MB
|
||||||
// Edit Key Form
|
// Edit Key Form
|
||||||
|
|
@ -128,10 +127,6 @@ export default function AdminKeysManagement() {
|
||||||
toast("عملیات شما با موفقیت انجام شد. ", {
|
toast("عملیات شما با موفقیت انجام شد. ", {
|
||||||
className: "!bg-green-500 !text-white",
|
className: "!bg-green-500 !text-white",
|
||||||
});
|
});
|
||||||
} else if (res.failed > 0) {
|
|
||||||
toast("مشکلی در تغییر کلید به وجود آمد.", {
|
|
||||||
className: "!bg-red-500 !text-white",
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (intervalRef.current !== null) {
|
if (intervalRef.current !== null) {
|
||||||
clearInterval(intervalRef.current);
|
clearInterval(intervalRef.current);
|
||||||
|
|
@ -274,8 +269,8 @@ export default function AdminKeysManagement() {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const isChangingKey = localStorage.getItem("isChangingKey");
|
const isChangingKey = localStorage.getItem("isChangingKey");
|
||||||
if (isChangingKey) {
|
if (isChangingKey) {
|
||||||
// setTimeout(() => {}, 1000);
|
setTimeout(() => {}, 10000);
|
||||||
intervalRef.current = setInterval(refethKey, 2000);
|
intervalRef.current = setInterval(refethKey, 10000);
|
||||||
return () => {
|
return () => {
|
||||||
if (intervalRef.current !== null) {
|
if (intervalRef.current !== null) {
|
||||||
clearInterval(intervalRef.current);
|
clearInterval(intervalRef.current);
|
||||||
|
|
@ -324,9 +319,7 @@ export default function AdminKeysManagement() {
|
||||||
<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 ">
|
||||||
{polling && (
|
{polling && (
|
||||||
<div className=" w-full md:w-1/2 mx-auto mt-2">
|
<div className=" w-full md:w-1/2 mx-auto mt-2">
|
||||||
<p className=" font-bold test-sm">
|
<p className=" font-bold test-sm">درحال تغییر کلید ...</p>
|
||||||
درحال تغییر کلید({Math.floor((done * 100) / total)}%) ...
|
|
||||||
</p>
|
|
||||||
<Progress className=" mt-5" value={(done * 100) / total} />
|
<Progress className=" mt-5" value={(done * 100) / total} />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
@ -396,11 +389,11 @@ export default function AdminKeysManagement() {
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem className="w-full ">
|
<FormItem className="w-full ">
|
||||||
<FormLabel className="text-[#7C838A] text-sm font-medium ">
|
<FormLabel className="text-[#7C838A] text-sm font-medium ">
|
||||||
کلید خصوصی
|
کلید عمومی
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Textarea
|
<Textarea
|
||||||
placeholder="کلید خصوصی را وارد نمایید."
|
placeholder="کلید عمومی را وارد کنید"
|
||||||
{...field}
|
{...field}
|
||||||
className="bg-white resize-none"
|
className="bg-white resize-none"
|
||||||
dir="ltr"
|
dir="ltr"
|
||||||
|
|
@ -450,22 +443,13 @@ export default function AdminKeysManagement() {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={item.id}
|
key={item.id}
|
||||||
className={cn(
|
className={`flex flex-col justify-center gap-2 w-full md:w-[31%] lg:w-[23%] h-28 px-5 rounded-md shadow-md items-start bg-[#F5F5F5]
|
||||||
`flex flex-col justify-center gap-2 w-full md:w-[31%] lg:w-[23%] h-28 px-5 rounded-md shadow-md items-start bg-[#F5F5F5]
|
`}
|
||||||
`,
|
|
||||||
item?.isActive && " border-r-4 border-green-600"
|
|
||||||
)}
|
|
||||||
>
|
>
|
||||||
<div className=" flex gap-2 items-center">
|
<p className="text-sm font-normal leading-normal text-slate-500">
|
||||||
<div className=" p-2 bg-blue rounded-lg">
|
عنوان کلید:{" "}
|
||||||
<KeyRound className=" text-white" />
|
<span className=" text-slate-800">{item.title}</span>
|
||||||
</div>
|
</p>
|
||||||
<p className="text-sm font-normal leading-normal text-slate-500">
|
|
||||||
{/* عنوان کلید:{" "} */}
|
|
||||||
<span className=" text-slate-800">{item.title}</span>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* <p className="text-sm font-normal leading-normal text-slate-500">
|
{/* <p className="text-sm font-normal leading-normal text-slate-500">
|
||||||
آیدی بازرس:{" "}
|
آیدی بازرس:{" "}
|
||||||
<span className="self-end text-slate-800">
|
<span className="self-end text-slate-800">
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,6 @@ export default function AdminNews() {
|
||||||
const [imageNews, setImageNews] = useState("");
|
const [imageNews, setImageNews] = useState("");
|
||||||
const [page, setPage] = useState<any>(1);
|
const [page, setPage] = useState<any>(1);
|
||||||
const [totalCount, setTotalCount] = useState<any>(0);
|
const [totalCount, setTotalCount] = useState<any>(0);
|
||||||
const [totalPages, setTotalPages] = useState<any>(0);
|
|
||||||
const [keyIdDel, setKeyIdDel] = useState("");
|
const [keyIdDel, setKeyIdDel] = useState("");
|
||||||
|
|
||||||
const [openAdd, setOpenAdd] = React.useState(false);
|
const [openAdd, setOpenAdd] = React.useState(false);
|
||||||
|
|
@ -271,7 +270,7 @@ export default function AdminNews() {
|
||||||
onSuccess: (res) => {
|
onSuccess: (res) => {
|
||||||
setOpenAdd(false);
|
setOpenAdd(false);
|
||||||
|
|
||||||
refetch1();
|
refetch1();
|
||||||
|
|
||||||
toast("عملیات شما با موفقیت انجام شد. ", {
|
toast("عملیات شما با موفقیت انجام شد. ", {
|
||||||
className: "!bg-green-500 !text-white",
|
className: "!bg-green-500 !text-white",
|
||||||
|
|
@ -283,7 +282,7 @@ export default function AdminNews() {
|
||||||
description: "",
|
description: "",
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onError: (err: any | string) => {
|
onError: (err: any | string) => {
|
||||||
toast(<>{err.response.data.detail}</>, {
|
toast(<>{err.response.data.detail}</>, {
|
||||||
className: "!bg-red-500 !text-white",
|
className: "!bg-red-500 !text-white",
|
||||||
});
|
});
|
||||||
|
|
@ -334,7 +333,6 @@ export default function AdminNews() {
|
||||||
if (data1) {
|
if (data1) {
|
||||||
const headersData = JSON.parse(data1.headers["x-pagination"]);
|
const headersData = JSON.parse(data1.headers["x-pagination"]);
|
||||||
setTotalCount(headersData.TotalCount);
|
setTotalCount(headersData.TotalCount);
|
||||||
setTotalPages(headersData.TotalPages);
|
|
||||||
setPage(headersData.CurrentPage);
|
setPage(headersData.CurrentPage);
|
||||||
}
|
}
|
||||||
}, [data1]);
|
}, [data1]);
|
||||||
|
|
@ -348,7 +346,7 @@ export default function AdminNews() {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<div className="w-full min-h-[85vh] flex justify-center max-lg:pb-20">
|
<div className="w-full min-h-[85vh] flex justify-center pb-4">
|
||||||
<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 items-center justify-between w-full ">
|
<div className="flex flex-row items-center justify-between w-full ">
|
||||||
{/* 1 */}
|
{/* 1 */}
|
||||||
|
|
@ -791,7 +789,6 @@ export default function AdminNews() {
|
||||||
</AlertDialog>
|
</AlertDialog>
|
||||||
{!isListLoading && (
|
{!isListLoading && (
|
||||||
<Pagination
|
<Pagination
|
||||||
TotalPages={totalPages}
|
|
||||||
currentPage={page - 1}
|
currentPage={page - 1}
|
||||||
PageSize={5}
|
PageSize={5}
|
||||||
countPage={totalCount}
|
countPage={totalCount}
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ export default function AdminSlider() {
|
||||||
refetch: refetch1,
|
refetch: refetch1,
|
||||||
} = useQuery({
|
} = useQuery({
|
||||||
queryKey: ["SliderList"],
|
queryKey: ["SliderList"],
|
||||||
queryFn: () => GetAllSliders(),
|
queryFn: () => GetAllSliders(),
|
||||||
// refetchOnWindowFocus: false,
|
// refetchOnWindowFocus: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -195,116 +195,119 @@ export default function AdminSlider() {
|
||||||
});
|
});
|
||||||
// Edit Submit
|
// Edit Submit
|
||||||
|
|
||||||
// ............'Mutation' Change Slider Submit
|
|
||||||
const ChangeSliderMutation = useMutation({
|
// ............'Mutation' Change Slider Submit
|
||||||
mutationKey: ["ChangeSlider"],
|
const ChangeSliderMutation = useMutation({
|
||||||
mutationFn: UpdateSlider,
|
mutationKey: ["ChangeSlider"],
|
||||||
onSuccess: (res) => {
|
mutationFn: UpdateSlider,
|
||||||
setOpenEdit(false);
|
onSuccess: (res) => {
|
||||||
|
setOpenEdit(false);
|
||||||
refetch1();
|
|
||||||
|
|
||||||
toast("عملیات شما با موفقیت انجام شد. ", {
|
|
||||||
className: "!bg-green-500 !text-white",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onError: (err: any | string) => {
|
|
||||||
toast(<>{err.response.data.detail}</>, {
|
|
||||||
className: "!bg-red-500 !text-white",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
//Delete
|
|
||||||
const DeleteSliderMutation = useMutation({
|
|
||||||
mutationKey: ["DeleteSlider"],
|
|
||||||
mutationFn: DeleteSlider,
|
|
||||||
onSuccess: (res) => {
|
|
||||||
setOpenEdit(false);
|
|
||||||
refetch1();
|
|
||||||
toast("عملیات شما با موفقیت انجام شد. ", {
|
|
||||||
className: "!bg-green-500 !text-white",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onError: (err: any | string) => {
|
|
||||||
toast(<>{err.response.data.detail}</>, {
|
|
||||||
className: "!bg-red-500 !text-white",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Add
|
|
||||||
// ............'Mutation' Add Slider Submit
|
|
||||||
const AddSliderMutation = useMutation({
|
|
||||||
mutationKey: ["AddSlider"],
|
|
||||||
mutationFn: SubmitSlider,
|
|
||||||
onSuccess: (res) => {
|
|
||||||
setOpenAdd(false);
|
|
||||||
refetch1();
|
|
||||||
|
|
||||||
toast("عملیات شما با موفقیت انجام شد. ", {
|
|
||||||
className: "!bg-green-500 !text-white",
|
|
||||||
});
|
|
||||||
formAdd.reset({
|
|
||||||
titleSlider: "",
|
|
||||||
uploadImg: null,
|
|
||||||
urlSlider: "",
|
|
||||||
description: "",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onError: (err: any | string) => {
|
|
||||||
toast(<>{err.response.data.detail}</>, {
|
|
||||||
className: "!bg-red-500 !text-white",
|
|
||||||
});
|
|
||||||
formAdd.reset({
|
|
||||||
titleSlider: "",
|
|
||||||
uploadImg: null,
|
|
||||||
urlSlider: "",
|
|
||||||
description: "",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
function onSubmitEdit(data: EditSliderFormValues) {
|
|
||||||
const formData = new FormData();
|
|
||||||
formData.append("Title", data.titleSlider);
|
|
||||||
if (data?.uploadImg instanceof File) {
|
|
||||||
formData.append("Image", data.uploadImg);
|
|
||||||
}
|
|
||||||
formData.append("Url", data.urlSlider);
|
|
||||||
formData.append("Description", data.description);
|
|
||||||
// if (data?.media && data?.media?.length > 0) {
|
|
||||||
// for (let i = 0; i < data.media.length; i++) {
|
|
||||||
// formData.append("Medias", data.media[i]);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
ChangeSliderMutation.mutate({ id: keyId, payload: formData });
|
|
||||||
|
|
||||||
refetch1();
|
refetch1();
|
||||||
}
|
|
||||||
|
|
||||||
function onSubmitAdd(data: AddSliderFormValues) {
|
toast("عملیات شما با موفقیت انجام شد. ", {
|
||||||
const formData = new FormData();
|
className: "!bg-green-500 !text-white",
|
||||||
formData.append("Title", data.titleSlider);
|
});
|
||||||
formData.append("Url", data.urlSlider);
|
},
|
||||||
formData.append("Description", data.description);
|
onError: (err: any | string) => {
|
||||||
|
toast(<>{err.response.data.detail}</>, {
|
||||||
|
className: "!bg-red-500 !text-white",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
if (data?.uploadImg instanceof File) {
|
//Delete
|
||||||
formData.append("Image", data.uploadImg);
|
const DeleteSliderMutation = useMutation({
|
||||||
}
|
mutationKey: ["DeleteSlider"],
|
||||||
|
mutationFn: DeleteSlider,
|
||||||
|
onSuccess: (res) => {
|
||||||
|
setOpenEdit(false);
|
||||||
|
refetch1();
|
||||||
|
toast("عملیات شما با موفقیت انجام شد. ", {
|
||||||
|
className: "!bg-green-500 !text-white",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onError: (err: any | string) => {
|
||||||
|
toast(<>{err.response.data.detail}</>, {
|
||||||
|
className: "!bg-red-500 !text-white",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
AddSliderMutation.mutate(formData);
|
// Add
|
||||||
}
|
// ............'Mutation' Add Slider Submit
|
||||||
|
const AddSliderMutation = useMutation({
|
||||||
const resetFormAdd = () => {
|
mutationKey: ["AddSlider"],
|
||||||
|
mutationFn: SubmitSlider,
|
||||||
|
onSuccess: (res) => {
|
||||||
|
setOpenAdd(false);
|
||||||
|
refetch1();
|
||||||
|
|
||||||
|
toast("عملیات شما با موفقیت انجام شد. ", {
|
||||||
|
className: "!bg-green-500 !text-white",
|
||||||
|
});
|
||||||
formAdd.reset({
|
formAdd.reset({
|
||||||
titleSlider: "",
|
titleSlider: "",
|
||||||
uploadImg: null,
|
uploadImg: null,
|
||||||
urlSlider: "",
|
urlSlider: "",
|
||||||
description: "",
|
description: "",
|
||||||
});
|
});
|
||||||
};
|
|
||||||
const { resetField } = useForm();
|
},
|
||||||
|
onError: (err: any | string) => {
|
||||||
|
toast(<>{err.response.data.detail}</>, {
|
||||||
|
className: "!bg-red-500 !text-white",
|
||||||
|
});
|
||||||
|
formAdd.reset({
|
||||||
|
titleSlider: "",
|
||||||
|
uploadImg: null,
|
||||||
|
urlSlider: "",
|
||||||
|
description: "",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
function onSubmitEdit(data: EditSliderFormValues) {
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append("Title", data.titleSlider);
|
||||||
|
if (data?.uploadImg instanceof File) {
|
||||||
|
formData.append("Image", data.uploadImg);
|
||||||
|
}
|
||||||
|
formData.append("Url", data.urlSlider);
|
||||||
|
formData.append("Description", data.description);
|
||||||
|
// if (data?.media && data?.media?.length > 0) {
|
||||||
|
// for (let i = 0; i < data.media.length; i++) {
|
||||||
|
// formData.append("Medias", data.media[i]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
ChangeSliderMutation.mutate({id: keyId, payload: formData});
|
||||||
|
|
||||||
|
refetch1();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSubmitAdd(data: AddSliderFormValues) {
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append("Title", data.titleSlider);
|
||||||
|
formData.append("Url", data.urlSlider);
|
||||||
|
formData.append("Description", data.description);
|
||||||
|
|
||||||
|
if (data?.uploadImg instanceof File) {
|
||||||
|
formData.append("Image", data.uploadImg);
|
||||||
|
}
|
||||||
|
|
||||||
|
AddSliderMutation.mutate(formData);
|
||||||
|
}
|
||||||
|
|
||||||
|
const resetFormAdd = () => {
|
||||||
|
formAdd.reset({
|
||||||
|
titleSlider: "",
|
||||||
|
uploadImg: null,
|
||||||
|
urlSlider: "",
|
||||||
|
description: "",
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const { resetField } = useForm();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full min-h-[85vh] flex justify-center">
|
<div className="w-full min-h-[85vh] flex justify-center">
|
||||||
|
|
@ -334,12 +337,7 @@ export default function AdminSlider() {
|
||||||
<p className="text-[#464646] text-base font-bold">
|
<p className="text-[#464646] text-base font-bold">
|
||||||
افزودن اسلایدر
|
افزودن اسلایدر
|
||||||
</p>
|
</p>
|
||||||
<AlertDialogCancel
|
<AlertDialogCancel className="h-auto p-0 border-0" onClick={() => { resetFormAdd(); }}>
|
||||||
className="h-auto p-0 border-0"
|
|
||||||
onClick={() => {
|
|
||||||
resetFormAdd();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<IoMdClose />
|
<IoMdClose />
|
||||||
</AlertDialogCancel>
|
</AlertDialogCancel>
|
||||||
</AlertDialogTitle>
|
</AlertDialogTitle>
|
||||||
|
|
@ -475,12 +473,7 @@ export default function AdminSlider() {
|
||||||
>
|
>
|
||||||
افزودن
|
افزودن
|
||||||
</Button>
|
</Button>
|
||||||
<AlertDialogCancel
|
<AlertDialogCancel className="mt-0 text-white bg-blue rounded-xl" onClick={() => { resetFormAdd(); }}>
|
||||||
className="mt-0 text-white bg-blue rounded-xl"
|
|
||||||
onClick={() => {
|
|
||||||
resetFormAdd();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
بستن
|
بستن
|
||||||
</AlertDialogCancel>
|
</AlertDialogCancel>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -653,70 +646,63 @@ export default function AdminSlider() {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={item.id}
|
key={item.id}
|
||||||
className={`w-full lg:w-[48%] bg-[#F5F5F5] border rounded-lg flex flex-row shadow-md transition-all
|
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]
|
||||||
h-[20em] sm:h-[15em] max-sm:flex-col max-sm:gap-[3px]
|
|
||||||
`}
|
`}
|
||||||
>
|
>
|
||||||
<div className="w-1/2 h-full rounded-r-lg max-sm:h-1/2 max-md:w-1/3 max-sm:w-full">
|
<p className="text-sm font-normal leading-normal text-slate-500">
|
||||||
<Image
|
عنوان :<span className=" text-slate-800">{item.title}</span>
|
||||||
alt="picture"
|
</p>
|
||||||
src={`${process.env.NEXT_PUBLIC_BASE_URL_APP}${item?.image?.url}`}
|
<p className="text-sm font-normal leading-normal text-slate-500">
|
||||||
height={500}
|
توضیحات:
|
||||||
width={500}
|
<span className="self-end text-slate-800">
|
||||||
quality={100}
|
{item.description}
|
||||||
className="w-full h-full rounded-r-lg bg-cover object-cover"
|
</span>
|
||||||
/>
|
</p>
|
||||||
</div>
|
<Image
|
||||||
<div className="w-1/2 h-full flex flex-col p-3 justify-between max-md:justify-evenly max-md:w-2/3 max-sm:h-1/2 max-sm:w-full">
|
alt="img"
|
||||||
<div>
|
src={`${process.env.NEXT_PUBLIC_BASE_URL_APP}${item?.image?.url}`}
|
||||||
<p className="text-sm font-normal leading-normal text-slate-500">
|
width={100}
|
||||||
عنوان :
|
height={100}
|
||||||
<span className=" text-slate-800">{item.title}</span>
|
quality={100}
|
||||||
</p>
|
className="object-contain object-right w-full h-20 "
|
||||||
<p className="text-sm font-normal leading-normal text-slate-500">
|
/>
|
||||||
توضیحات:
|
|
||||||
<span className="self-end text-slate-800 line-clamp-4">
|
{/* <p className="text-sm font-normal leading-normal text-slate-500">
|
||||||
{item.description}
|
|
||||||
</span>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
{/* <p className="text-sm font-normal leading-normal text-slate-500">
|
|
||||||
محتوا:
|
محتوا:
|
||||||
<span className="self-end text-slate-800">
|
<span className="self-end text-slate-800">
|
||||||
{item.content}
|
{item.content}
|
||||||
</span>
|
</span>
|
||||||
</p> */}
|
</p> */}
|
||||||
|
|
||||||
<div className="flex items-end justify-end w-full gap-2">
|
<div className="flex items-end justify-end w-full gap-2">
|
||||||
<Switch
|
<Switch
|
||||||
dir="ltr"
|
dir="ltr"
|
||||||
checked={!item.isDeleted}
|
checked={!item.isDeleted}
|
||||||
onCheckedChange={() => {
|
onCheckedChange={() => {
|
||||||
DeleteSliderMutation.mutate({
|
DeleteSliderMutation.mutate({
|
||||||
id: item.id,
|
id: item.id,
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
id={item.id}
|
id={item.id}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<AlertDialogTrigger asChild>
|
<AlertDialogTrigger asChild>
|
||||||
{/* <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="self-end w-6 h-6 text-slate-600 hover:cursor-pointer"
|
||||||
// onClick={() => setKeyId(item?.id)}
|
// onClick={() => setKeyId(item?.id)}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
handleClickEdit(
|
handleClickEdit(
|
||||||
item?.id,
|
item?.id,
|
||||||
item?.title,
|
item?.title,
|
||||||
item?.description,
|
item?.description,
|
||||||
item?.url,
|
item?.url,
|
||||||
item?.image
|
item?.image
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</AlertDialogTrigger>
|
</AlertDialogTrigger>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,153 +0,0 @@
|
||||||
import React from "react";
|
|
||||||
import {
|
|
||||||
Dialog,
|
|
||||||
DialogContent,
|
|
||||||
DialogDescription,
|
|
||||||
DialogFooter,
|
|
||||||
DialogHeader,
|
|
||||||
DialogTitle,
|
|
||||||
DialogTrigger,
|
|
||||||
} from "@/components/ui/dialog";
|
|
||||||
import { X } from "lucide-react";
|
|
||||||
import { Button } from "./ui/button";
|
|
||||||
import { useForm } from "react-hook-form";
|
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
|
||||||
import { z } from "zod";
|
|
||||||
import {
|
|
||||||
Form,
|
|
||||||
FormControl,
|
|
||||||
FormDescription,
|
|
||||||
FormField,
|
|
||||||
FormItem,
|
|
||||||
FormLabel,
|
|
||||||
FormMessage,
|
|
||||||
} from "@/components/ui/form";
|
|
||||||
import { Input } from "@/components/ui/input";
|
|
||||||
import { useMutation } from "@tanstack/react-query";
|
|
||||||
import { changePassword } from "@/utils/authenticateApi";
|
|
||||||
import { deleteCookie } from "cookies-next";
|
|
||||||
import { toast } from "sonner";
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
export default function ChangePasswordDialog({
|
|
||||||
data,
|
|
||||||
open,
|
|
||||||
setOpen,
|
|
||||||
}: {
|
|
||||||
data?: any;
|
|
||||||
open: any;
|
|
||||||
setOpen: (state: any) => any;
|
|
||||||
}) {
|
|
||||||
const router = useRouter();
|
|
||||||
const ChangePasswordMutation = useMutation({
|
|
||||||
mutationKey: ["ChangePassword"],
|
|
||||||
mutationFn: changePassword,
|
|
||||||
onSuccess: (res) => {
|
|
||||||
deleteCookie("Sootzani_Admin_Token");
|
|
||||||
localStorage.removeItem("privateKey");
|
|
||||||
localStorage.removeItem("privatePassword");
|
|
||||||
router.push("/");
|
|
||||||
toast("رمز عبور شما با موفقیت تغییر یافت.", {
|
|
||||||
className: "!bg-green-500 !text-white",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onError: (err: any | string) => {
|
|
||||||
toast(<>{err.response.data.detail}</>, {
|
|
||||||
className: "!bg-red-500 !text-white",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const FormSchema = z.object({
|
|
||||||
oldPassword: z.string(),
|
|
||||||
newPassword: z.string(),
|
|
||||||
repeatedPassword: z.string(),
|
|
||||||
});
|
|
||||||
|
|
||||||
const form = useForm<z.infer<typeof FormSchema>>({
|
|
||||||
resolver: zodResolver(FormSchema),
|
|
||||||
});
|
|
||||||
|
|
||||||
function onSubmit(data: z.infer<typeof FormSchema>) {
|
|
||||||
if (data.newPassword !== data.repeatedPassword) {
|
|
||||||
toast("رمز عبور شما با هم مطابقت ندارد.", {
|
|
||||||
className: "!bg-red-500 !text-white",
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ChangePasswordMutation.mutate({
|
|
||||||
oldPassword: data.oldPassword,
|
|
||||||
newPassword: data.newPassword,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Dialog open={open} onOpenChange={setOpen}>
|
|
||||||
<DialogContent>
|
|
||||||
{" "}
|
|
||||||
<Form {...form}>
|
|
||||||
<form
|
|
||||||
onSubmit={form.handleSubmit(onSubmit)}
|
|
||||||
className="flex flex-col w-full mt-6 "
|
|
||||||
>
|
|
||||||
<DialogHeader>
|
|
||||||
<DialogTitle>تغییر رمز عبور</DialogTitle>
|
|
||||||
<DialogDescription>
|
|
||||||
<div className="flex flex-col w-full my-6 ">
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="oldPassword"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className="w-full">
|
|
||||||
<FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
|
|
||||||
رمز عبور فعلی
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input type="password" {...field} />
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="newPassword"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className="w-full">
|
|
||||||
<FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
|
|
||||||
رمز عبور جدید
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input type="password" {...field} />
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="repeatedPassword"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className="w-full">
|
|
||||||
<FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
|
|
||||||
تکرار رمز عبور
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input type="password" {...field} />
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</DialogDescription>
|
|
||||||
</DialogHeader>
|
|
||||||
<DialogDescription></DialogDescription>
|
|
||||||
<DialogFooter>
|
|
||||||
<Button type="submit">تایید و ادامه</Button>
|
|
||||||
</DialogFooter>{" "}
|
|
||||||
</form>
|
|
||||||
</Form>
|
|
||||||
</DialogContent>
|
|
||||||
</Dialog>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,129 +0,0 @@
|
||||||
"use client";
|
|
||||||
import { putChangePhoneNumber } from "@/utils/authenticateApi";
|
|
||||||
import { useMutation } from "@tanstack/react-query";
|
|
||||||
import React, { useEffect, useState } from "react";
|
|
||||||
import { toast } from "sonner";
|
|
||||||
import LoginIcon from "../public/img/login-icon.svg";
|
|
||||||
import Image from "next/image";
|
|
||||||
import OTPInput from "react-otp-input";
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
import { deleteCookie } from "cookies-next";
|
|
||||||
|
|
||||||
export default function ChangePhoneNumber() {
|
|
||||||
const [otp, setOtp] = useState("");
|
|
||||||
const [otp2, setOtp2] = useState("");
|
|
||||||
const [phoneNumber, setPhoneNumber] = useState<any>("");
|
|
||||||
const [newPhoneNumber, setNewPhoneNumber] = useState<any>("");
|
|
||||||
const space = "\xa0";
|
|
||||||
const router = useRouter();
|
|
||||||
const changePhoneNumberMutation = useMutation({
|
|
||||||
mutationKey: ["putChangePhoneNumber"],
|
|
||||||
mutationFn: putChangePhoneNumber,
|
|
||||||
onSuccess: (res) => {
|
|
||||||
deleteCookie("Sootzani_Admin_Token");
|
|
||||||
localStorage.removeItem("privateKey");
|
|
||||||
localStorage.removeItem("privatePassword");
|
|
||||||
router.push("/");
|
|
||||||
toast("شماره موبایل با موفقیت تغییر یافت.", {
|
|
||||||
className: "!bg-green-500 !text-white",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onError: (err: any | string) => {
|
|
||||||
toast(<>{err.response.data.detail}</>, {
|
|
||||||
className: "!bg-red-500 !text-white",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (otp.length == 6 && otp2.length == 6) {
|
|
||||||
const payload = {
|
|
||||||
token1: localStorage.getItem("ph_token") as string,
|
|
||||||
code1: otp,
|
|
||||||
token2: localStorage.getItem("ph_newToken") as string,
|
|
||||||
code2: otp2,
|
|
||||||
};
|
|
||||||
changePhoneNumberMutation.mutate(payload);
|
|
||||||
}
|
|
||||||
}, [otp,otp2]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const phoneNumber = localStorage.getItem("ph_phoneNumber");
|
|
||||||
const newPhoneNumber = localStorage.getItem("ph_newPhoneNumber");
|
|
||||||
setPhoneNumber(phoneNumber);
|
|
||||||
setNewPhoneNumber(newPhoneNumber);
|
|
||||||
}, []);
|
|
||||||
return (
|
|
||||||
<div className="grid w-screen h-screen bg-gray-200 place-content-center">
|
|
||||||
<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]
|
|
||||||
h-fit relative"
|
|
||||||
>
|
|
||||||
<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 " />
|
|
||||||
<p className="text-lg font-bold leading-tight tracking-tight text-blue dark:text-white">
|
|
||||||
کد شماره {phoneNumber}
|
|
||||||
</p>
|
|
||||||
<div className="w-full " dir="ltr">
|
|
||||||
<OTPInput
|
|
||||||
value={otp}
|
|
||||||
onChange={setOtp}
|
|
||||||
numInputs={6}
|
|
||||||
renderSeparator={<span>{space}</span>}
|
|
||||||
renderInput={(props, idx) => (
|
|
||||||
<input autoFocus={idx == 0} pattern="[0-9]*" {...props} />
|
|
||||||
)}
|
|
||||||
containerStyle=" flex justify-center"
|
|
||||||
inputStyle={` !w-10 rounded-md h-10 bg-[#F5F5F5] border border-blue/30 text-black `}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<p className="text-lg font-bold leading-tight tracking-tight text-blue dark:text-white">
|
|
||||||
کد شماره {newPhoneNumber}
|
|
||||||
</p>
|
|
||||||
<div className="w-full " dir="ltr">
|
|
||||||
<OTPInput
|
|
||||||
value={otp2}
|
|
||||||
onChange={setOtp2}
|
|
||||||
numInputs={6}
|
|
||||||
renderSeparator={<span>{space}</span>}
|
|
||||||
renderInput={(props, idx) => (
|
|
||||||
<input autoFocus={idx == 0} pattern="[0-9]*" {...props} />
|
|
||||||
)}
|
|
||||||
containerStyle=" flex justify-center"
|
|
||||||
inputStyle={` !w-10 rounded-md h-10 bg-[#F5F5F5] border border-blue/30 text-black `}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<label className="text-center label">
|
|
||||||
<span className="text-xs text-center text-blue/70 label-text">
|
|
||||||
کد دریافت شده توسط پیامک را وارد نمایید.
|
|
||||||
</span>
|
|
||||||
</label>
|
|
||||||
{/* <div className="flex justify-end w-full gap-2 mt-14">
|
|
||||||
<Button
|
|
||||||
disabled={verifyMutation.isPending}
|
|
||||||
onClick={handelVerify}
|
|
||||||
type="submit"
|
|
||||||
className="w-1/2 p-2 text-white bg-blue hover:bg-blue/90 md:w-1/3 rounded-xl"
|
|
||||||
>
|
|
||||||
{verifyMutation.isPending ? (
|
|
||||||
<div className="flex items-center justify-center gap-2">
|
|
||||||
<Oval
|
|
||||||
visible={true}
|
|
||||||
height="20"
|
|
||||||
width="20"
|
|
||||||
color="#fff"
|
|
||||||
ariaLabel="oval-loading"
|
|
||||||
wrapperStyle={{}}
|
|
||||||
wrapperClass=""
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
"تایید"
|
|
||||||
)}
|
|
||||||
</Button>
|
|
||||||
</div> */}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,199 +0,0 @@
|
||||||
import React from "react";
|
|
||||||
import {
|
|
||||||
Dialog,
|
|
||||||
DialogContent,
|
|
||||||
DialogDescription,
|
|
||||||
DialogFooter,
|
|
||||||
DialogHeader,
|
|
||||||
DialogTitle,
|
|
||||||
DialogTrigger,
|
|
||||||
} from "@/components/ui/dialog";
|
|
||||||
import { RefreshCcw, X } from "lucide-react";
|
|
||||||
import { Button } from "./ui/button";
|
|
||||||
import { useForm } from "react-hook-form";
|
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
|
||||||
import { z } from "zod";
|
|
||||||
import {
|
|
||||||
Form,
|
|
||||||
FormControl,
|
|
||||||
FormDescription,
|
|
||||||
FormField,
|
|
||||||
FormItem,
|
|
||||||
FormLabel,
|
|
||||||
FormMessage,
|
|
||||||
} from "@/components/ui/form";
|
|
||||||
import { Input } from "@/components/ui/input";
|
|
||||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
||||||
import { getCaptcha } from "@/utils/commonApi";
|
|
||||||
import { ThreeDots } from "react-loader-spinner";
|
|
||||||
import Image from "next/image";
|
|
||||||
import { postChangePhoneNumber } from "@/utils/authenticateApi";
|
|
||||||
import { toast } from "sonner";
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
export default function ChangePhoneNumberDialog({
|
|
||||||
data,
|
|
||||||
open,
|
|
||||||
setOpen,
|
|
||||||
}: {
|
|
||||||
data?: any;
|
|
||||||
open: any;
|
|
||||||
setOpen: (state: any) => any;
|
|
||||||
}) {
|
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
const {
|
|
||||||
data: CaptchaData,
|
|
||||||
isLoading,
|
|
||||||
refetch,
|
|
||||||
} = useQuery({
|
|
||||||
queryKey: ["Captcha"],
|
|
||||||
queryFn: () => getCaptcha(),
|
|
||||||
refetchOnWindowFocus: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
const changePhoneNumberMutation = useMutation({
|
|
||||||
mutationKey: ["postChangePhoneNumber"],
|
|
||||||
mutationFn: postChangePhoneNumber,
|
|
||||||
onSuccess: (res) => {
|
|
||||||
localStorage.setItem("ph_token", res.token);
|
|
||||||
localStorage.setItem("ph_newToken", res.newToken);
|
|
||||||
localStorage.setItem("ph_phoneNumber", res.phoneNumber);
|
|
||||||
localStorage.setItem("ph_newPhoneNumber", res.newPhoneNumber);
|
|
||||||
const userRole = localStorage.getItem("userRole");
|
|
||||||
if (userRole === "Admin") {
|
|
||||||
router.push(`/UserPanel/AdminDashboard/ChangePhoneNumber`);
|
|
||||||
} else {
|
|
||||||
router.push(`/UserPanel/ControllerDashboard/ChangePhoneNumber`);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onError: (err: any | string) => {
|
|
||||||
refetch();
|
|
||||||
toast(<>{err.response.data.detail}</>, {
|
|
||||||
className: "!bg-red-500 !text-white",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const FormSchema = z.object({
|
|
||||||
phoneNumber: z.string().min(1, {
|
|
||||||
message: "لطفا شماره موبایل را وارد نمایید.",
|
|
||||||
}),
|
|
||||||
captcha: z
|
|
||||||
.string({ required_error: "لطفا کد امنیتی را وارد نمایید." })
|
|
||||||
.length(5, { message: "لطفا کد امنیتی را به طور کامل وارد نمایید." }),
|
|
||||||
});
|
|
||||||
|
|
||||||
const form = useForm<z.infer<typeof FormSchema>>({
|
|
||||||
resolver: zodResolver(FormSchema),
|
|
||||||
});
|
|
||||||
|
|
||||||
function onSubmit(data: z.infer<typeof FormSchema>) {
|
|
||||||
const payload = {
|
|
||||||
newPhoneNumber: data.phoneNumber,
|
|
||||||
captcha: {
|
|
||||||
key: CaptchaData?.headers["captcha-key"],
|
|
||||||
value: data.captcha,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
changePhoneNumberMutation.mutate(payload);
|
|
||||||
}
|
|
||||||
|
|
||||||
const srcForImage = CaptchaData
|
|
||||||
? URL.createObjectURL(CaptchaData.data)
|
|
||||||
: null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Dialog open={open} onOpenChange={setOpen}>
|
|
||||||
<DialogContent>
|
|
||||||
{" "}
|
|
||||||
<Form {...form}>
|
|
||||||
<form onSubmit={form.handleSubmit(onSubmit)}>
|
|
||||||
<DialogHeader>
|
|
||||||
<DialogTitle>تغییر شماره موبایل</DialogTitle>
|
|
||||||
<DialogDescription>
|
|
||||||
<div className="flex flex-col w-full my-6 ">
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="phoneNumber"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className="w-full">
|
|
||||||
<FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
|
|
||||||
شماره موبایل جدید
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input
|
|
||||||
onClick={() => setOpen(true)}
|
|
||||||
type="text"
|
|
||||||
className=" text-base"
|
|
||||||
{...field}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<div className="flex items-center gap-3 mt-4">
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="captcha"
|
|
||||||
rules={{ required: true }}
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className="items-center flex-1 h-10 ">
|
|
||||||
{/* <FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
|
|
||||||
رمز عبور
|
|
||||||
</FormLabel> */}
|
|
||||||
<FormControl>
|
|
||||||
<Input
|
|
||||||
className=" text-base"
|
|
||||||
placeholder="کد امنیتی"
|
|
||||||
{...field}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
{isLoading ? (
|
|
||||||
<div className="flex justify-center text-center w-36">
|
|
||||||
<ThreeDots
|
|
||||||
visible={true}
|
|
||||||
height="50"
|
|
||||||
width="50"
|
|
||||||
color="#003778"
|
|
||||||
radius="9"
|
|
||||||
ariaLabel="three-dots-loading"
|
|
||||||
wrapperStyle={{}}
|
|
||||||
wrapperClass=""
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<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"
|
|
||||||
width={150}
|
|
||||||
height={20}
|
|
||||||
quality={100}
|
|
||||||
/>
|
|
||||||
<RefreshCcw
|
|
||||||
className="cursor-pointer "
|
|
||||||
onClick={() => refetch()}
|
|
||||||
color="#003778"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</DialogDescription>
|
|
||||||
</DialogHeader>
|
|
||||||
<DialogDescription></DialogDescription>
|
|
||||||
<DialogFooter>
|
|
||||||
<Button type="submit">تایید و ادامه</Button>
|
|
||||||
</DialogFooter>
|
|
||||||
</form>
|
|
||||||
</Form>
|
|
||||||
</DialogContent>
|
|
||||||
</Dialog>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -87,7 +87,7 @@ export default function Login() {
|
||||||
saveData({
|
saveData({
|
||||||
username: data.username,
|
username: data.username,
|
||||||
password: data.password,
|
password: data.password,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const srcForImage = CaptchaData
|
const srcForImage = CaptchaData
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ import { useMutation, useQuery } from "@tanstack/react-query";
|
||||||
import { DoorOpen, LogOut } from "lucide-react";
|
import { DoorOpen, LogOut } from "lucide-react";
|
||||||
import { deleteCookie, getCookie } from "cookies-next";
|
import { deleteCookie, getCookie } from "cookies-next";
|
||||||
import useSignalR from "@/hooks/useSignalR";
|
import useSignalR from "@/hooks/useSignalR";
|
||||||
import ProfileDropDown from "./ProfileDropDown";
|
|
||||||
|
|
||||||
export default function NavbarPanel() {
|
export default function NavbarPanel() {
|
||||||
const [isOpen, setOpen] = useState(false);
|
const [isOpen, setOpen] = useState(false);
|
||||||
|
|
@ -142,8 +141,17 @@ export default function NavbarPanel() {
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-4 ">
|
<div className="flex items-center gap-4 ">
|
||||||
<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="inline-block text-sm font-bold text-white bg-clip-text before:max-md:hidden max-md:text-xs max-md:font-medium">
|
||||||
<ProfileDropDown />
|
{data && (
|
||||||
|
<>
|
||||||
|
{role === "Admin"
|
||||||
|
? `${data?.title ? data.title : data.username} (ادمین)`
|
||||||
|
: `${data?.title ? data.title : data.username} (بازرس)`}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</h1>
|
</h1>
|
||||||
|
<div className="p-1 rounded-md hover:bg-white/50">
|
||||||
|
<LogOut onClick={logout} className="text-white cursor-pointer " />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,101 +0,0 @@
|
||||||
import React, { useEffect, useState } from "react";
|
|
||||||
|
|
||||||
import { CreditCard, LogOut, User, UserPlus, Users } from "lucide-react";
|
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import {
|
|
||||||
DropdownMenu,
|
|
||||||
DropdownMenuContent,
|
|
||||||
DropdownMenuGroup,
|
|
||||||
DropdownMenuItem,
|
|
||||||
DropdownMenuLabel,
|
|
||||||
DropdownMenuPortal,
|
|
||||||
DropdownMenuSeparator,
|
|
||||||
DropdownMenuShortcut,
|
|
||||||
DropdownMenuSub,
|
|
||||||
DropdownMenuSubContent,
|
|
||||||
DropdownMenuSubTrigger,
|
|
||||||
DropdownMenuTrigger,
|
|
||||||
} from "@/components/ui/dropdown-menu";
|
|
||||||
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, getCookie } from "cookies-next";
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
|
|
||||||
export default function ProfileDropDown() {
|
|
||||||
const router = useRouter();
|
|
||||||
const [role, setRole] = useState<any>(null);
|
|
||||||
const {
|
|
||||||
data: profileData,
|
|
||||||
isLoading,
|
|
||||||
refetch,
|
|
||||||
} = useQuery({
|
|
||||||
queryKey: ["Profile"],
|
|
||||||
queryFn: () => getProfile(),
|
|
||||||
});
|
|
||||||
|
|
||||||
const revokeMutation = useMutation({
|
|
||||||
mutationFn: revoke,
|
|
||||||
onSuccess: (res) => {},
|
|
||||||
onError: (err: any | string) => {},
|
|
||||||
});
|
|
||||||
|
|
||||||
const logout = () => {
|
|
||||||
revokeMutation.mutate({
|
|
||||||
refreshToken: getCookie("Sootzani_Admin_Refresh_Token"),
|
|
||||||
});
|
|
||||||
deleteCookie("Sootzani_Admin_Token");
|
|
||||||
localStorage.removeItem("privateKey");
|
|
||||||
localStorage.removeItem("privatePassword");
|
|
||||||
router.push("/");
|
|
||||||
};
|
|
||||||
useEffect(() => {
|
|
||||||
const userRole = localStorage.getItem("Sootzani_Role");
|
|
||||||
if (userRole == "Admin") {
|
|
||||||
setRole("AdminDashboard");
|
|
||||||
} else {
|
|
||||||
setRole("ControllerDashboard");
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const saveToken = useToken((state) => state.saveToken);
|
|
||||||
return (
|
|
||||||
<DropdownMenu dir="rtl">
|
|
||||||
<DropdownMenuTrigger
|
|
||||||
className=" max-sm:-mr-8 max-sm:text-xs w-12"
|
|
||||||
asChild
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
// variant="outline"
|
|
||||||
className=" truncate bg-white text-blue hover:bg-white w-32 flex justify-center items-center gap-2"
|
|
||||||
>
|
|
||||||
<User className=" w-5 h-5" />
|
|
||||||
{/* {profileData?.title ? profileData?.title : profileData?.userName} */}
|
|
||||||
<p className=" truncate self-end">
|
|
||||||
{" "}
|
|
||||||
{profileData?.firstName || profileData?.lastName
|
|
||||||
? profileData?.firstName + " " + profileData?.lastName
|
|
||||||
: profileData?.userName}
|
|
||||||
</p>
|
|
||||||
</Button>
|
|
||||||
</DropdownMenuTrigger>
|
|
||||||
<DropdownMenuContent className="w-56 sm:ml-10">
|
|
||||||
<DropdownMenuGroup>
|
|
||||||
<DropdownMenuItem
|
|
||||||
onClick={() => router.push(`/UserPanel/${role}/Profile`)}
|
|
||||||
>
|
|
||||||
<User className="w-4 h-4 ml-2" />
|
|
||||||
<span>پروفایل</span>
|
|
||||||
</DropdownMenuItem>
|
|
||||||
</DropdownMenuGroup>
|
|
||||||
<DropdownMenuSeparator />
|
|
||||||
<DropdownMenuItem onClick={logout}>
|
|
||||||
<LogOut className="w-4 h-4 ml-2" />
|
|
||||||
<span>خروج</span>
|
|
||||||
</DropdownMenuItem>
|
|
||||||
</DropdownMenuContent>
|
|
||||||
</DropdownMenu>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,202 +0,0 @@
|
||||||
"use client";
|
|
||||||
import React, { useEffect, useState } from "react";
|
|
||||||
|
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
|
||||||
import { useForm } from "react-hook-form";
|
|
||||||
import * as z from "zod";
|
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import {
|
|
||||||
Form,
|
|
||||||
FormControl,
|
|
||||||
FormDescription,
|
|
||||||
FormField,
|
|
||||||
FormItem,
|
|
||||||
FormLabel,
|
|
||||||
FormMessage,
|
|
||||||
} from "@/components/ui/form";
|
|
||||||
import { Input } from "@/components/ui/input";
|
|
||||||
import Link from "next/link";
|
|
||||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
||||||
import { editProfile, getProfile } from "@/utils/authenticateApi";
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
import { toast } from "sonner";
|
|
||||||
import { Oval } from "react-loader-spinner";
|
|
||||||
import ChangePhoneNumberDialog from "../ChangePhoneNumberDialog";
|
|
||||||
import ChangePasswordDialog from "../ChangePasswordDialog";
|
|
||||||
|
|
||||||
const FormSchema = z.object({
|
|
||||||
firstName: z.string().min(1, {
|
|
||||||
message: "لطفا نام خود را وارد نمایید.",
|
|
||||||
}),
|
|
||||||
lastName: z.string().min(1, {
|
|
||||||
message: "لطفا نام خانوادگی خود را وارد نمایید.",
|
|
||||||
}),
|
|
||||||
phoneNumber: z.string().optional(),
|
|
||||||
});
|
|
||||||
|
|
||||||
export default function Profile() {
|
|
||||||
const router = useRouter();
|
|
||||||
const [open, setOpen] = useState<boolean>(false);
|
|
||||||
const [open2, setOpen2] = useState<boolean>(false);
|
|
||||||
const {
|
|
||||||
data: profileData,
|
|
||||||
isLoading,
|
|
||||||
refetch,
|
|
||||||
} = useQuery({
|
|
||||||
queryKey: ["Profile"],
|
|
||||||
queryFn: () => getProfile(),
|
|
||||||
refetchOnWindowFocus: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
const editProfileMutation = useMutation({
|
|
||||||
mutationKey: ["editProfile"],
|
|
||||||
mutationFn: editProfile,
|
|
||||||
onSuccess: (res) => {
|
|
||||||
refetch();
|
|
||||||
toast("پروفایل شما با موفقیت ویرایش شد.", {
|
|
||||||
className: "!bg-green-500 !text-white",
|
|
||||||
});
|
|
||||||
router.push("/");
|
|
||||||
},
|
|
||||||
onError: (err: any | string) => {
|
|
||||||
toast(<>{err.response.data.detail}</>, {
|
|
||||||
className: "!bg-red-500 !text-white",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const form = useForm<z.infer<typeof FormSchema>>({
|
|
||||||
resolver: zodResolver(FormSchema),
|
|
||||||
});
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (profileData) {
|
|
||||||
form.setValue("firstName", profileData.firstName);
|
|
||||||
form.setValue("lastName", profileData.lastName);
|
|
||||||
form.setValue("phoneNumber", profileData.phoneNumber);
|
|
||||||
}
|
|
||||||
}, [profileData]);
|
|
||||||
|
|
||||||
function onSubmit(data: z.infer<typeof FormSchema>) {
|
|
||||||
const payload = data;
|
|
||||||
editProfileMutation.mutate(payload);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className=" w-full mx-auto mt-20 h-full pt-12 md:w-2/3 xl:w-1/2 p-8">
|
|
||||||
<div className="flex flex-col justify-center h-full space-y-4 md:space-y-4">
|
|
||||||
<h2 className=" w-full font-bold">اطلاعات هویتی</h2>
|
|
||||||
{profileData && (
|
|
||||||
<Form {...form}>
|
|
||||||
<form
|
|
||||||
onSubmit={form.handleSubmit(onSubmit)}
|
|
||||||
className="flex flex-col w-full mt-6 "
|
|
||||||
>
|
|
||||||
<div className="flex flex-row flex-wrap justify-between border p-4 rounded-md">
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="firstName"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className="w-full sm:w-[48%]">
|
|
||||||
<FormLabel className="text-[#7C838A] text-sm font-medium">
|
|
||||||
نام
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input
|
|
||||||
placeholder="نام خود را وارد نمایید"
|
|
||||||
{...field}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="lastName"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className="w-full sm:w-[48%] ">
|
|
||||||
<FormLabel className="text-[#7C838A] text-sm font-medium">
|
|
||||||
نام خانوادگی
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input
|
|
||||||
placeholder="نام خانوادگی خود را وارد نمایید"
|
|
||||||
{...field}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<div className="flex justify-end w-full gap-2 mt-8">
|
|
||||||
<Button
|
|
||||||
disabled={editProfileMutation.isPending}
|
|
||||||
type="submit"
|
|
||||||
className="w-32 p-2 text-white transition bg-blue hover:bg-blue/90 rounded-xl max-sm:text-xs"
|
|
||||||
>
|
|
||||||
{editProfileMutation.isPending ? (
|
|
||||||
<div className="flex items-center justify-center gap-2">
|
|
||||||
<Oval
|
|
||||||
visible={true}
|
|
||||||
height="20"
|
|
||||||
width="20"
|
|
||||||
color="#fff"
|
|
||||||
ariaLabel="oval-loading"
|
|
||||||
wrapperStyle={{}}
|
|
||||||
wrapperClass=""
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
"ذخیره"
|
|
||||||
)}
|
|
||||||
{/* ورود */}
|
|
||||||
</Button>
|
|
||||||
</div>{" "}
|
|
||||||
</div>
|
|
||||||
<h2 className=" w-full font-bold mt-5 mb-2">اطلاعات ورود</h2>
|
|
||||||
<div className=" border p-4 flex max-lg:flex-col justify-between rounded-md items-center">
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="phoneNumber"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className="w-full sm:w-[48%]">
|
|
||||||
<FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
|
|
||||||
شماره موبایل
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input type="text" {...field} readOnly />
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<div className="flex gap-2 max-md:justify-center max-md:mt-6 max-md:w-full">
|
|
||||||
<Button
|
|
||||||
type="button"
|
|
||||||
disabled={editProfileMutation.isPending}
|
|
||||||
onClick={() => setOpen(true)}
|
|
||||||
className="max-sm:w-1/2 w-32 p-2 max-sm:text-xs text-white transition bg-blue hover:bg-blue/90 rounded-xl"
|
|
||||||
>
|
|
||||||
تغییر شماره موبایل
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
type="button"
|
|
||||||
disabled={editProfileMutation.isPending}
|
|
||||||
onClick={() => setOpen2(true)}
|
|
||||||
className="max-sm:w-1/2 w-32 p-2 text-white transition bg-blue hover:bg-blue/90 rounded-xl max-sm:text-xs"
|
|
||||||
>
|
|
||||||
تغییر رمز عبور
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</Form>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<ChangePhoneNumberDialog open={open} setOpen={setOpen} />
|
|
||||||
<ChangePasswordDialog open={open2} setOpen={setOpen2} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -9,7 +9,7 @@ const buttonVariants = cva(
|
||||||
{
|
{
|
||||||
variants: {
|
variants: {
|
||||||
variant: {
|
variant: {
|
||||||
default: "bg-blue text-primary-foreground hover:bg-blue/90",
|
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
||||||
destructive:
|
destructive:
|
||||||
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
||||||
outline:
|
outline:
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ export function convertFullTime(date: string) {
|
||||||
const convertedDate = dayjs(date + "Z")
|
const convertedDate = dayjs(date + "Z")
|
||||||
.calendar("jalali")
|
.calendar("jalali")
|
||||||
.locale("fa")
|
.locale("fa")
|
||||||
.format(" HH:mm - YYYY/M/D");
|
.format(" HH:mm:ss - YYYY/M/D");
|
||||||
return convertedDate;
|
return convertedDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "sootzani",
|
"name": "sootzani",
|
||||||
"version": "0.2.18",
|
"version": "0.2.15",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "sootzani",
|
"name": "sootzani",
|
||||||
"version": "0.2.18",
|
"version": "0.2.15",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@hookform/resolvers": "^3.3.2",
|
"@hookform/resolvers": "^3.3.2",
|
||||||
"@microsoft/signalr": "^8.0.0",
|
"@microsoft/signalr": "^8.0.0",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "sootzani",
|
"name": "sootzani",
|
||||||
"version": "0.2.18",
|
"version": "0.2.15",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
|
|
|
||||||
|
|
@ -164,7 +164,7 @@ export async function UpdateWebContents({
|
||||||
// .....News.................................................
|
// .....News.................................................
|
||||||
export async function GetAllNews({
|
export async function GetAllNews({
|
||||||
PageNumber = 1,
|
PageNumber = 1,
|
||||||
PageSize = 4,
|
PageSize = 6,
|
||||||
}: {
|
}: {
|
||||||
PageNumber?: number;
|
PageNumber?: number;
|
||||||
PageSize?: number;
|
PageSize?: number;
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,7 @@ axios.interceptors.response.use(
|
||||||
},
|
},
|
||||||
async function (error) {
|
async function (error) {
|
||||||
const originalRequest = error.config;
|
const originalRequest = error.config;
|
||||||
if (error.response.status === 403) {
|
|
||||||
window.location.href = "/";
|
|
||||||
deleteCookie("Sootzani_Admin_Token");
|
|
||||||
deleteCookie("Sootzani_Admin_Refresh_Token");
|
|
||||||
localStorage.removeItem("privateKey");
|
|
||||||
}
|
|
||||||
if (error.response.status === 401) {
|
if (error.response.status === 401) {
|
||||||
if (!originalRequest._retry) {
|
if (!originalRequest._retry) {
|
||||||
originalRequest._retry = true;
|
originalRequest._retry = true;
|
||||||
|
|
@ -96,27 +91,6 @@ export async function verifyCitizen(payload: {
|
||||||
return data.data;
|
return data.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function postChangePhoneNumber(payload: {
|
|
||||||
newPhoneNumber: string;
|
|
||||||
captcha: {
|
|
||||||
key: string;
|
|
||||||
value: string;
|
|
||||||
};
|
|
||||||
}) {
|
|
||||||
const data = await axios.post("api/Authenticate/PhoneNumber", payload);
|
|
||||||
return data.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function putChangePhoneNumber(payload: {
|
|
||||||
token1: string;
|
|
||||||
code1: string | null;
|
|
||||||
token2: string;
|
|
||||||
code2: string | null;
|
|
||||||
}) {
|
|
||||||
const data = await axios.put("api/Authenticate/PhoneNumber", payload);
|
|
||||||
return data.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function changePassword(payload: {
|
export async function changePassword(payload: {
|
||||||
oldPassword: string;
|
oldPassword: string;
|
||||||
newPassword: string;
|
newPassword: string;
|
||||||
|
|
@ -133,9 +107,9 @@ export async function getProfile() {
|
||||||
export async function editProfile(payload: {
|
export async function editProfile(payload: {
|
||||||
firstName: string;
|
firstName: string;
|
||||||
lastName: string;
|
lastName: string;
|
||||||
nationalId?: string;
|
nationalId: string;
|
||||||
phoneNumber2?: string;
|
phoneNumber2: string;
|
||||||
title?: string;
|
title: string;
|
||||||
}) {
|
}) {
|
||||||
const data = await axios.put("api/Authenticate/Profile", payload);
|
const data = await axios.put("api/Authenticate/Profile", payload);
|
||||||
return data.data;
|
return data.data;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue