Citizen Panel, Request Steps done + bugs fixed
parent
b5c5d2963d
commit
85b14ee5e8
|
|
@ -0,0 +1,7 @@
|
||||||
|
import ComplainsDetails from "@/components/ComplainsDetails";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
export default function page({ params }: { params: any }) {
|
||||||
|
const id = params.id;
|
||||||
|
return <ComplainsDetails role="Inspector" id={id} />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
import TabController from "@/components/TabController";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
export default function page() {
|
||||||
|
return <TabController />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
export default function page() {
|
||||||
|
return <div>page</div>;
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,13 @@
|
||||||
import CitizenLogin from "@/components/CitizenLogin";
|
import CitizenLogin from "@/components/CitizenLogin";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
|
import { cookies } from "next/headers";
|
||||||
|
|
||||||
export default function page() {
|
export default function page() {
|
||||||
|
const cookieStore = cookies();
|
||||||
|
const token = cookieStore.get("Sootzani_Token");
|
||||||
|
if (token) {
|
||||||
|
redirect("/RequestStep2");
|
||||||
|
}
|
||||||
return <CitizenLogin />;
|
return <CitizenLogin />;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,14 @@
|
||||||
|
import CitizenLogin from "@/components/CitizenLogin";
|
||||||
import Login from "@/components/Login";
|
import Login from "@/components/Login";
|
||||||
|
import { cookies } from "next/headers";
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export default function page() {
|
export default function page() {
|
||||||
return (
|
const cookieStore = cookies();
|
||||||
<Login />
|
const token = cookieStore.get("Sootzani_Token");
|
||||||
);
|
if (token) {
|
||||||
|
redirect("/");
|
||||||
|
}
|
||||||
|
return <CitizenLogin />;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,6 @@ export default function RootLayout({
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
||||||
<NavbarPanel />
|
|
||||||
{children}
|
{children}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ import { Swiper, SwiperSlide } from "swiper/react";
|
||||||
import "swiper/css";
|
import "swiper/css";
|
||||||
import "swiper/css/pagination";
|
import "swiper/css/pagination";
|
||||||
// import required modules
|
// import required modules
|
||||||
import { Autoplay, Pagination, Navigation} from "swiper/modules";
|
import { Autoplay, Pagination, Navigation } from "swiper/modules";
|
||||||
import { sliderItems } from "@/constants";
|
import { sliderItems } from "@/constants";
|
||||||
|
|
||||||
export default function Landing() {
|
export default function Landing() {
|
||||||
|
|
@ -35,7 +35,6 @@ export default function Landing() {
|
||||||
clickable: true,
|
clickable: true,
|
||||||
}}
|
}}
|
||||||
modules={[Autoplay]}
|
modules={[Autoplay]}
|
||||||
|
|
||||||
className="mySwiper w-full h-full"
|
className="mySwiper w-full h-full"
|
||||||
>
|
>
|
||||||
{sliderItems.map((item) => {
|
{sliderItems.map((item) => {
|
||||||
|
|
@ -118,14 +117,14 @@ export default function Landing() {
|
||||||
className=" w-1/2 max-lg:w-full border rounded-lg flex flex-row shadow-md hover:shadow-none transition-all
|
className=" w-1/2 max-lg:w-full border rounded-lg flex flex-row shadow-md hover:shadow-none transition-all
|
||||||
max-lg:h-[14em] max-md:h-[12em] max-sm:h-[22em] max-sm:flex-col max-sm:gap-[3px]"
|
max-lg:h-[14em] max-md:h-[12em] max-sm:h-[22em] max-sm:flex-col max-sm:gap-[3px]"
|
||||||
>
|
>
|
||||||
<div className="w-1/2 h-full rounded-r-lg bg-rose-400 max-sm:h-1/2 max-md:w-1/3 max-sm:w-full">
|
<div className="w-1/2 h-full rounded-r-lg max-sm:h-1/2 max-md:w-1/3 max-sm:w-full">
|
||||||
<Image
|
<Image
|
||||||
alt="picture"
|
alt="picture"
|
||||||
src="/img/pic1.png"
|
src="/img/pic1.png"
|
||||||
height={500}
|
height={500}
|
||||||
width={500}
|
width={500}
|
||||||
style={{ objectFit: "fill", objectPosition: "center" }}
|
quality={100}
|
||||||
className="w-full h-full rounded-r-lg"
|
className="w-full h-full rounded-r-lg bg-cover object-cover object-top"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import React from "react";
|
import React, { useEffect } from "react";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
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";
|
||||||
|
|
@ -26,6 +26,8 @@ import { getCaptcha } from "@/utils/commonApi";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { Oval, ThreeDots } from "react-loader-spinner";
|
import { Oval, ThreeDots } from "react-loader-spinner";
|
||||||
import useData from "@/store/useData";
|
import useData from "@/store/useData";
|
||||||
|
import { getCookie } from "cookies-next";
|
||||||
|
import { isAuthorized } from "@/hooks/useAuthentication";
|
||||||
const FormSchema = z.object({
|
const FormSchema = z.object({
|
||||||
phoneNumber: z.string().min(1, {
|
phoneNumber: z.string().min(1, {
|
||||||
message: "لطفا شماره موبایل خود را وارد نمایید.",
|
message: "لطفا شماره موبایل خود را وارد نمایید.",
|
||||||
|
|
@ -83,6 +85,7 @@ export default function CitizenLogin() {
|
||||||
? URL.createObjectURL(CaptchaData.data)
|
? URL.createObjectURL(CaptchaData.data)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="w-full mt-12 sm:w-2/3 md:w-2/4 xl:w-1/3 bg-white rounded-lg dark:border xl:p-0 dark:bg-gray-800 dark:border-gray-700 shadow-[0px_0px_15px_0px_#00000040]
|
className="w-full mt-12 sm:w-2/3 md:w-2/4 xl:w-1/3 bg-white rounded-lg dark:border xl:p-0 dark:bg-gray-800 dark:border-gray-700 shadow-[0px_0px_15px_0px_#00000040]
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
"use client";
|
"use client";
|
||||||
import React, { useEffect } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import greenIcon from "../public/img/greenPoint.svg";
|
import greenIcon from "../public/img/greenPoint.svg";
|
||||||
import blueIcon from "../public/img/bluepoint.svg";
|
import blueIcon from "../public/img/bluepoint.svg";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
|
|
@ -11,7 +11,20 @@ import { convertDate } from "@/lib/utils";
|
||||||
import { Badge } from "./ui/badge";
|
import { Badge } from "./ui/badge";
|
||||||
import InspectorOperations from "./InspectorOperations";
|
import InspectorOperations from "./InspectorOperations";
|
||||||
import { postComplaintTracking } from "@/utils/citizenApi";
|
import { postComplaintTracking } from "@/utils/citizenApi";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogClose,
|
||||||
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
|
DialogFooter,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
DialogTrigger,
|
||||||
|
} from "@/components/ui/dialog";
|
||||||
|
import { Input } from "./ui/input";
|
||||||
|
import { toast } from "sonner";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
export default function ComplainsDetails({
|
export default function ComplainsDetails({
|
||||||
id,
|
id,
|
||||||
role,
|
role,
|
||||||
|
|
@ -21,45 +34,83 @@ export default function ComplainsDetails({
|
||||||
role: string;
|
role: string;
|
||||||
Data?: any;
|
Data?: any;
|
||||||
}) {
|
}) {
|
||||||
|
const [open, setOpen] = useState<boolean>(true);
|
||||||
|
const [password, setPassword] = useState<any>(true);
|
||||||
|
const router = useRouter();
|
||||||
const storeData = useData((state) => state.data);
|
const storeData = useData((state) => state.data);
|
||||||
let data;
|
let data;
|
||||||
|
|
||||||
const getComplaintMutation = useMutation<
|
const getComplaintMutation = useMutation({
|
||||||
any,
|
|
||||||
Error,
|
|
||||||
{ trackingNumber: string; password: string }
|
|
||||||
>({
|
|
||||||
mutationKey: ["Complaint", id],
|
mutationKey: ["Complaint", id],
|
||||||
mutationFn:
|
mutationFn: postComplaintTracking,
|
||||||
role == "Inspector"
|
onSuccess: (res) => {
|
||||||
? (getComplaint as any)
|
setOpen(false);
|
||||||
: (postComplaintTracking as any),
|
},
|
||||||
onSuccess: (res) => {},
|
onError: (err) => {
|
||||||
onError: (err) => {},
|
toast("رمز عبور شما صحیح نمیباشد.", {
|
||||||
|
className: "!bg-red-500 !text-white",
|
||||||
|
});
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const handelPassword = () => {
|
||||||
|
const payload = { ...storeData, password: password };
|
||||||
|
getComplaintMutation.mutate({ Data: payload });
|
||||||
|
};
|
||||||
console.log(storeData);
|
console.log(storeData);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (role == "Inspector") {
|
|
||||||
useData.persist.rehydrate();
|
useData.persist.rehydrate();
|
||||||
}
|
|
||||||
}, []);
|
}, []);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (storeData && role == "Inspector") {
|
// if (storeData && role == "Inspector") {
|
||||||
getComplaintMutation.mutate(storeData);
|
// getComplaintMutation.mutate(storeData);
|
||||||
}
|
// }
|
||||||
}, [storeData]);
|
}, [storeData]);
|
||||||
|
|
||||||
if (getComplaintMutation.isSuccess) {
|
if (getComplaintMutation.isSuccess) {
|
||||||
data = getComplaintMutation.data;
|
data = getComplaintMutation.data;
|
||||||
} else if (Data) {
|
|
||||||
data = Data;
|
|
||||||
}
|
}
|
||||||
console.log(Data);
|
if (open) {
|
||||||
|
return (
|
||||||
|
<Dialog open={open} onOpenChange={setOpen}>
|
||||||
|
<DialogContent dir="rtl" className="sm:max-w-[425px]">
|
||||||
|
<DialogHeader dir="rtl">
|
||||||
|
<DialogTitle dir="rtl">رمز عبور</DialogTitle>
|
||||||
|
<DialogDescription>
|
||||||
|
برای مشاهده درخواست پسورد خود را وارد نمایید.
|
||||||
|
</DialogDescription>
|
||||||
|
</DialogHeader>
|
||||||
|
<div className="grid w-full max-w-sm items-center gap-1.5">
|
||||||
|
{/* <Label htmlFor="picture">Picture</Label> */}
|
||||||
|
<Input
|
||||||
|
dir="rtl"
|
||||||
|
id="picture"
|
||||||
|
onChange={(e) => setPassword(e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<DialogFooter>
|
||||||
|
<Button
|
||||||
|
onClick={() => router.push("/Account/Complaints")}
|
||||||
|
type="button"
|
||||||
|
variant="outline"
|
||||||
|
className=" ml-2"
|
||||||
|
>
|
||||||
|
بازگشت
|
||||||
|
</Button>
|
||||||
|
{/* <DialogClose asChild> */}
|
||||||
|
<Button onClick={handelPassword} type="submit">
|
||||||
|
تایید
|
||||||
|
</Button>
|
||||||
|
{/* </DialogClose> */}
|
||||||
|
</DialogFooter>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{data ? (
|
{data ? (
|
||||||
<div className="w-full flex max-lg:flex-col gap-3 items-start">
|
<div className=" w-[95vw] lg:w-[82vw] xl:w-[70vw] 3xl:w-[65vw] flex max-lg:flex-col gap-3 items-start mt-5">
|
||||||
<div className="flex flex-col w-full lg:w-1/3 lg:order-2 gap-3 lg:sticky top-40">
|
<div className="flex flex-col w-full lg:w-1/3 lg:order-2 gap-3 lg:sticky top-40">
|
||||||
<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>
|
||||||
|
|
|
||||||
|
|
@ -195,7 +195,7 @@ export default function FollowResult() {
|
||||||
</div>
|
</div>
|
||||||
<ComplainsDetails
|
<ComplainsDetails
|
||||||
role="Citizen"
|
role="Citizen"
|
||||||
Data={complaintPrintMutation?.data}
|
// Data={complaintPrintMutation?.data}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ import { getCaptcha } from "@/utils/commonApi";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { Oval, ThreeDots } from "react-loader-spinner";
|
import { Oval, ThreeDots } from "react-loader-spinner";
|
||||||
import useData from "@/store/useData";
|
import useData from "@/store/useData";
|
||||||
|
import useToken from "@/store/useToken";
|
||||||
const FormSchema = z.object({
|
const FormSchema = z.object({
|
||||||
username: z.string().min(1, {
|
username: z.string().min(1, {
|
||||||
message: "لطفا نام کاربری را وارد نمایید.",
|
message: "لطفا نام کاربری را وارد نمایید.",
|
||||||
|
|
@ -44,6 +45,7 @@ export default function Login() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const saveData = useData((state) => state.saveData);
|
const saveData = useData((state) => state.saveData);
|
||||||
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: CaptchaData,
|
data: CaptchaData,
|
||||||
isLoading,
|
isLoading,
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,33 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import React from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { Input } from "./ui/input";
|
import { Input } from "./ui/input";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import { menuItems } from "@/constants";
|
import { menuItems } from "@/constants";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import Login from "./Login";
|
import Login from "./Login";
|
||||||
import { Button } from "./ui/button";
|
import { Button } from "./ui/button";
|
||||||
import { usePathname } from 'next/navigation'
|
import { usePathname } from "next/navigation";
|
||||||
import TopNav from "./TopNav";
|
import TopNav from "./TopNav";
|
||||||
|
import { isAuthorized } from "@/lib/utils";
|
||||||
|
import useToken from "@/store/useToken";
|
||||||
|
import { DropdownMenu } from "@radix-ui/react-dropdown-menu";
|
||||||
|
import ProfileDropDown from "./ProfileDropDown";
|
||||||
|
|
||||||
export default function Navbar() {
|
export default function Navbar() {
|
||||||
const pathname = usePathname()
|
const pathname = usePathname();
|
||||||
|
const isAuth = useToken((state) => state.token);
|
||||||
|
const [auth, setAuth] = useState<boolean>(isAuth);
|
||||||
|
useToken.persist.rehydrate();
|
||||||
|
useEffect(() => {
|
||||||
|
setAuth(isAuth);
|
||||||
|
}, [isAuth]);
|
||||||
return (
|
return (
|
||||||
<div className={`max-md:hidden left-0 right-0 top-0 z-10 ${pathname === "/" ? "absolute" : "sticky"}`}>
|
<div
|
||||||
|
className={`max-md:hidden left-0 right-0 top-0 z-10 ${
|
||||||
|
pathname === "/" ? "absolute" : "sticky"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
<TopNav />
|
<TopNav />
|
||||||
<div className=" bg-white h-16 shadow-md flex items-center justify-between py-2 px-8">
|
<div className=" bg-white h-16 shadow-md flex items-center justify-between py-2 px-8">
|
||||||
<div className=" flex ">
|
<div className=" flex ">
|
||||||
|
|
@ -35,28 +46,32 @@ export default function Navbar() {
|
||||||
</div>
|
</div>
|
||||||
<div className=" flex gap-5 items-center mr-8">
|
<div className=" flex gap-5 items-center mr-8">
|
||||||
{menuItems.map((item, index, array) => {
|
{menuItems.map((item, index, array) => {
|
||||||
|
if (array.length - 1 !== index) {
|
||||||
if (array.length - 1 !== index){
|
|
||||||
return (
|
return (
|
||||||
<Link key={item.id} href={item.href}>
|
<Link key={item.id} href={item.href}>
|
||||||
<div className=" text-sm font-bold">{item.name}</div>
|
<div className=" text-sm font-bold">{item.name}</div>
|
||||||
</Link>
|
</Link>
|
||||||
);
|
);
|
||||||
}else{
|
} else {
|
||||||
return (
|
return <></>;
|
||||||
<></>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{auth ? (
|
||||||
<Link href="/Login" >
|
<ProfileDropDown />
|
||||||
<Button className=" bg-blue hover:bg-blue/90 rounded-lg">
|
) : (
|
||||||
|
<Link href="/Login">
|
||||||
|
<Button
|
||||||
|
onClick={() =>
|
||||||
|
localStorage.setItem("Sootzani_Login_State", "true")
|
||||||
|
}
|
||||||
|
className=" bg-blue hover:bg-blue/90 rounded-lg"
|
||||||
|
>
|
||||||
ورود به پنل کاربری
|
ورود به پنل کاربری
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,19 @@ import Link from "next/link";
|
||||||
import { Button } from "./ui/button";
|
import { Button } from "./ui/button";
|
||||||
import TopNav from "./TopNav";
|
import TopNav from "./TopNav";
|
||||||
import { usePathname } from "next/navigation";
|
import { usePathname } from "next/navigation";
|
||||||
|
import useToken from "@/store/useToken";
|
||||||
|
import ProfileDropDown from "./ProfileDropDown";
|
||||||
|
|
||||||
// import { routes } from "../routes";
|
// import { routes } from "../routes";
|
||||||
|
|
||||||
export default function NavbarSm() {
|
export default function NavbarSm() {
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
|
const isAuth = useToken((state) => state.token);
|
||||||
|
const [auth, setAuth] = useState<boolean>(isAuth);
|
||||||
|
useToken.persist.rehydrate();
|
||||||
|
useEffect(() => {
|
||||||
|
setAuth(isAuth);
|
||||||
|
}, [isAuth]);
|
||||||
// useClickAway(ref, () => setOpen(false));
|
// useClickAway(ref, () => setOpen(false));
|
||||||
|
|
||||||
const [isOpen, setOpen] = useState(false);
|
const [isOpen, setOpen] = useState(false);
|
||||||
|
|
@ -26,12 +33,12 @@ export default function NavbarSm() {
|
||||||
<>
|
<>
|
||||||
<div
|
<div
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={`md:hidden w-full bg-white z-[100] flex flex-row justify-between items-center px-4
|
className={`md:hidden w-full bg-white z-[100] flex flex-row justify-between items-center pr-1 pl-4
|
||||||
sticky top-0
|
sticky top-0
|
||||||
shadow-md`}
|
shadow-md`}
|
||||||
>
|
>
|
||||||
<Hamburger toggled={isOpen} size={20} toggle={setOpen} />
|
<Hamburger toggled={isOpen} size={20} toggle={setOpen} direction="right"/>
|
||||||
|
{auth && <ProfileDropDown />}
|
||||||
{/* <Link href="/Login">
|
{/* <Link href="/Login">
|
||||||
<Button className=" bg-blue hover:bg-blue/90 rounded-lg text-xs ">
|
<Button className=" bg-blue hover:bg-blue/90 rounded-lg text-xs ">
|
||||||
ورود به پنل کاربری
|
ورود به پنل کاربری
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,86 @@
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
import {
|
||||||
|
Cloud,
|
||||||
|
CreditCard,
|
||||||
|
Github,
|
||||||
|
Keyboard,
|
||||||
|
LifeBuoy,
|
||||||
|
LogOut,
|
||||||
|
Mail,
|
||||||
|
MessageSquare,
|
||||||
|
Plus,
|
||||||
|
PlusCircle,
|
||||||
|
Settings,
|
||||||
|
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 } from "@/utils/authenticateApi";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import Link from "next/link";
|
||||||
|
import useToken from "@/store/useToken";
|
||||||
|
import { deleteCookie } from "cookies-next";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
|
||||||
|
export default function ProfileDropDown() {
|
||||||
|
const router = useRouter();
|
||||||
|
const {
|
||||||
|
data: profileData,
|
||||||
|
isLoading,
|
||||||
|
refetch,
|
||||||
|
} = useQuery({
|
||||||
|
queryKey: ["Profile"],
|
||||||
|
queryFn: () => getProfile(),
|
||||||
|
refetchOnWindowFocus: false,
|
||||||
|
});
|
||||||
|
const saveToken = useToken((state) => state.saveToken);
|
||||||
|
return (
|
||||||
|
<DropdownMenu dir="rtl">
|
||||||
|
<DropdownMenuTrigger className=" max-sm:-mr-8 max-sm:text-xs" asChild>
|
||||||
|
<Button variant="outline">{profileData?.userName}</Button>
|
||||||
|
</DropdownMenuTrigger>
|
||||||
|
<DropdownMenuContent className="w-56 sm:ml-10">
|
||||||
|
<DropdownMenuGroup>
|
||||||
|
<DropdownMenuItem>
|
||||||
|
<User className="ml-2 h-4 w-4" />
|
||||||
|
<Link href="/UserPanel/CitizenDashboard">
|
||||||
|
<span>مشاهده پروفایل</span>
|
||||||
|
</Link>
|
||||||
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem onClick={() => router.push("/Account/Complaints")}>
|
||||||
|
<CreditCard className="ml-2 h-4 w-4" />
|
||||||
|
<span>درخواست های اخیر</span>
|
||||||
|
</DropdownMenuItem>
|
||||||
|
</DropdownMenuGroup>
|
||||||
|
<DropdownMenuSeparator />
|
||||||
|
<DropdownMenuItem
|
||||||
|
onClick={() => {
|
||||||
|
saveToken(false);
|
||||||
|
deleteCookie("Sootzani_Token");
|
||||||
|
router.replace("/")
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<LogOut className="ml-2 h-4 w-4" />
|
||||||
|
<span>خروج</span>
|
||||||
|
</DropdownMenuItem>
|
||||||
|
</DropdownMenuContent>
|
||||||
|
</DropdownMenu>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -5,42 +5,42 @@ import Image from "next/image";
|
||||||
import Resultimg from "../public/img/result.png";
|
import Resultimg from "../public/img/result.png";
|
||||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
|
import { Button } from "./ui/button";
|
||||||
|
|
||||||
export default function Result() {
|
export default function Result() {
|
||||||
const trackingNumber = localStorage.getItem("trackingNumber");
|
const trackingNumber = localStorage.getItem("trackingNumber");
|
||||||
const password = localStorage.getItem("password");
|
const password = localStorage.getItem("password");
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
localStorage.removeItem("trackingNumber")
|
|
||||||
localStorage.removeItem("password")
|
|
||||||
}, [router]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full h-full sm:w-2/3 md:w-3/4 lg:w-1/2 max-sm:p-8 pt-12 ">
|
<div className="w-full h-full sm:w-2/3 md:w-3/4 lg:w-1/2 max-sm:p-8 pt-12 ">
|
||||||
<div className="h-full flex flex-col justify-center">
|
<div className="h-full flex flex-col justify-center">
|
||||||
<p
|
<p
|
||||||
className="text-sm font-medium leading-6 tracking-wide text-[#7C838A] dark:text-white
|
className="text-sm font-medium leading-6 tracking-wide text-[#7C838A] dark:text-white
|
||||||
3xl:text-base 3xl:font-bold ">
|
3xl:text-base 3xl:font-bold "
|
||||||
|
>
|
||||||
با تشکر از شما
|
با تشکر از شما
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p
|
<p
|
||||||
className="text-sm font-medium leading-6 tracking-wide text-[#7C838A] dark:text-white
|
className="text-sm font-medium leading-6 tracking-wide text-[#7C838A] dark:text-white
|
||||||
3xl:text-base 3xl:font-bold ">
|
3xl:text-base 3xl:font-bold "
|
||||||
|
>
|
||||||
درخواست شما با کد پیگیری
|
درخواست شما با کد پیگیری
|
||||||
<span className="text-slate-500 mx-2">
|
<span className="text-slate-500 mx-2">{`${trackingNumber}`}</span>و
|
||||||
{`${trackingNumber}`}
|
رمز عبور
|
||||||
</span>
|
<span className="text-slate-500 mx-2">{`${password}`}</span>
|
||||||
و رمز عبور
|
|
||||||
<span className="text-slate-500 mx-2">
|
|
||||||
{`${password}`}
|
|
||||||
</span>
|
|
||||||
در سامانه سوت زنی ثبت شده و شما می توانید نتیجه درخواست خود را از صفحه
|
در سامانه سوت زنی ثبت شده و شما می توانید نتیجه درخواست خود را از صفحه
|
||||||
پیگیری درخواست، با استفاده از کد رهگیری و رمز عبور مشاهده کنید.
|
پیگیری درخواست، با استفاده از کد رهگیری و رمز عبور مشاهده کنید.
|
||||||
</p>
|
</p>
|
||||||
|
{/* <div className="flex justify-center sm:justify-end gap-2 w-full mt-4">
|
||||||
|
<Button
|
||||||
|
type="submit"
|
||||||
|
className="w-1/2 sm:w-1/3 lg:w-1/4 bg-blue text-white p-2 rounded-xl text-center mb-4"
|
||||||
|
>
|
||||||
|
مشاهده درخواست ها
|
||||||
|
</Button>
|
||||||
|
</div> */}
|
||||||
<Image
|
<Image
|
||||||
alt="icon"
|
alt="icon"
|
||||||
src={Resultimg}
|
src={Resultimg}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
"use client";
|
"use client";
|
||||||
import React from "react";
|
import React, { useEffect } from "react";
|
||||||
|
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
|
|
@ -19,43 +19,84 @@ import { Input } from "@/components/ui/input";
|
||||||
import { toast } from "@/components/ui/use-toast";
|
import { toast } from "@/components/ui/use-toast";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import RequestStep2 from "./RequestStep2";
|
import RequestStep2 from "./RequestStep2";
|
||||||
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||||
|
import { editProfile, getProfile } from "@/utils/authenticateApi";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
|
||||||
const FormSchema = z.object({
|
const FormSchema = z.object({
|
||||||
firstName: z.string().min(2, {
|
firstName: z.string().min(1, {
|
||||||
message: "firstName must be at least 2 characters.",
|
message: "لطفا نام خود را وارد نمایید.",
|
||||||
}),
|
}),
|
||||||
lastName: z.string().min(2, {
|
lastName: z.string().min(1, {
|
||||||
message: "lastName must be at least 2 characters.",
|
message: "لطفا نام خانوادگی خود را وارد نمایید.",
|
||||||
}),
|
}),
|
||||||
nationalCode: z.number().min(10, {
|
nationalId: z
|
||||||
message: "nationalCode must be at least 10 characters.",
|
.string()
|
||||||
}),
|
.length(10, { message: "کد ملی معتبر نمی باشد." })
|
||||||
phoneNumber: z.number().min(11, {
|
.transform((value) => {
|
||||||
message: "phoneNumber must be at least 11 characters.",
|
const parsedNumber = Number(value);
|
||||||
|
if (Number.isNaN(parsedNumber)) {
|
||||||
|
throw new Error("کد ملی معتبر نمی باشد.");
|
||||||
|
} else if (
|
||||||
|
Number(parsedNumber) > 100000000 &&
|
||||||
|
Number(parsedNumber) < 999999999
|
||||||
|
) {
|
||||||
|
throw new Error("کد ملی معتبر نمی باشد.");
|
||||||
|
}
|
||||||
|
return parsedNumber;
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default function RequestStep1() {
|
export default function RequestStep1() {
|
||||||
const form = useForm<z.infer<typeof FormSchema>>({
|
const router = useRouter();
|
||||||
resolver: zodResolver(FormSchema),
|
const {
|
||||||
defaultValues: {
|
data: profileData,
|
||||||
firstName: "",
|
isLoading,
|
||||||
lastName: "",
|
refetch,
|
||||||
// nationalCode: ,
|
} = useQuery({
|
||||||
// phoneNumber: ,
|
queryKey: ["Profile"],
|
||||||
},
|
queryFn: () => getProfile(),
|
||||||
|
refetchOnWindowFocus: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
function onSubmit(data: z.infer<typeof FormSchema>) {
|
const editProfileMutation = useMutation({
|
||||||
toast({
|
mutationKey: ["editProfile"],
|
||||||
title: "You submitted the following values:",
|
mutationFn: editProfile,
|
||||||
description: (
|
onSuccess: (res) => {
|
||||||
<pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4">
|
router.push("/RequestStep2");
|
||||||
<code className="text-white">{JSON.stringify(data, null, 2)}</code>
|
localStorage.setItem("authorized", "true");
|
||||||
</pre>
|
},
|
||||||
),
|
onError: (error) => {},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const form = useForm<z.infer<typeof FormSchema>>({
|
||||||
|
resolver: zodResolver(FormSchema),
|
||||||
|
});
|
||||||
|
if (profileData?.firstName) {
|
||||||
|
console.log(111);
|
||||||
|
}
|
||||||
|
useEffect(() => {
|
||||||
|
if (profileData) {
|
||||||
|
form.setValue("firstName", profileData.firstName);
|
||||||
|
form.setValue("lastName", profileData.lastName);
|
||||||
|
form.setValue("nationalId", profileData.nationalId);
|
||||||
|
}
|
||||||
|
}, [profileData]);
|
||||||
|
|
||||||
|
console.log(form.getValues());
|
||||||
|
function onSubmit(data: z.infer<typeof FormSchema>) {
|
||||||
|
// toast({
|
||||||
|
// title: "You submitted the following values:",
|
||||||
|
// description: (
|
||||||
|
// <pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4">
|
||||||
|
// <code className="text-white">{JSON.stringify(data, null, 2)}</code>
|
||||||
|
// </pre>
|
||||||
|
// ),
|
||||||
|
// });
|
||||||
|
const strNationalId = String(data.nationalId);
|
||||||
|
const payload = { ...data, nationalId: strNationalId };
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
editProfileMutation.mutate(payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -64,9 +105,11 @@ export default function RequestStep1() {
|
||||||
<p className="text-sm md:text-base font-bold leading-tight tracking-tight text-blue dark:text-white">
|
<p className="text-sm md:text-base font-bold leading-tight tracking-tight text-blue dark:text-white">
|
||||||
لطفا جهت ارسال درخواست فرم زیر را تکمیل نمایید.
|
لطفا جهت ارسال درخواست فرم زیر را تکمیل نمایید.
|
||||||
</p>
|
</p>
|
||||||
<p className="text-sm md:text-base font-bold leading-tight tracking-tight text-red-500 dark:text-white">
|
{/* <p className="text-sm md:text-base font-bold leading-tight tracking-tight text-red-500 dark:text-white">
|
||||||
در صورت عدم تمایل به ثبت مشخصات شخصی می توانید به صفحه ی بعد مراجعه کنید.
|
در صورت عدم تمایل به ثبت مشخصات شخصی می توانید به صفحه ی بعد مراجعه
|
||||||
</p>
|
کنید.
|
||||||
|
</p> */}
|
||||||
|
{profileData && (
|
||||||
<Form {...form}>
|
<Form {...form}>
|
||||||
<form
|
<form
|
||||||
onSubmit={form.handleSubmit(onSubmit)}
|
onSubmit={form.handleSubmit(onSubmit)}
|
||||||
|
|
@ -82,7 +125,10 @@ export default function RequestStep1() {
|
||||||
نام
|
نام
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input placeholder="نام خود را وارد نمایید" {...field} />
|
<Input
|
||||||
|
placeholder="نام خود را وارد نمایید"
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -108,7 +154,7 @@ export default function RequestStep1() {
|
||||||
/>
|
/>
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="nationalCode"
|
name="nationalId"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem className="w-full sm:w-[48%]">
|
<FormItem className="w-full sm:w-[48%]">
|
||||||
<FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
|
<FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
|
||||||
|
|
@ -116,7 +162,7 @@ export default function RequestStep1() {
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input
|
||||||
type="number"
|
type="text"
|
||||||
placeholder="کد ملی خود را وارد نمایید "
|
placeholder="کد ملی خود را وارد نمایید "
|
||||||
{...field}
|
{...field}
|
||||||
/>
|
/>
|
||||||
|
|
@ -125,41 +171,19 @@ export default function RequestStep1() {
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<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="number"
|
|
||||||
placeholder="شماره تماس خود را وارد نمایید "
|
|
||||||
{...field}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex justify-center sm:justify-end gap-2 w-full mt-8">
|
<div className="flex justify-center sm:justify-end gap-2 w-full mt-8">
|
||||||
{/* <Button> */}
|
<Button
|
||||||
<Link
|
|
||||||
href="/RequestStep2"
|
|
||||||
type="submit"
|
type="submit"
|
||||||
className="w-1/2 sm:w-1/3 lg:w-1/4 bg-blue text-white p-2 rounded-xl text-center"
|
className="w-1/2 sm:w-1/3 lg:w-1/4 bg-blue text-white p-2 rounded-xl text-center"
|
||||||
>
|
>
|
||||||
صفحه ی بعد
|
صفحه ی بعد
|
||||||
</Link>
|
</Button>
|
||||||
{/* </Button> */}
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
"use client";
|
"use client";
|
||||||
import React, { useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
|
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
|
|
@ -36,9 +36,14 @@ import Image from "next/image";
|
||||||
import Img1 from "../public/img/logo.png";
|
import Img1 from "../public/img/logo.png";
|
||||||
|
|
||||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
import { postComplaintSubmit } from "@/utils/citizenApi";
|
import {
|
||||||
|
postAuthorizedComplaintSubmit,
|
||||||
|
postComplaintSubmit,
|
||||||
|
} from "@/utils/citizenApi";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { getCaptcha, getCategory } from "@/utils/commonApi";
|
import { getCaptcha, getCategory, getOrganizations } from "@/utils/commonApi";
|
||||||
|
import { ThreeDots } from "react-loader-spinner";
|
||||||
|
import useToken from "@/store/useToken";
|
||||||
|
|
||||||
const MAX_IMAGE_SIZE = 5242880; // 5 MB
|
const MAX_IMAGE_SIZE = 5242880; // 5 MB
|
||||||
const ALLOWED_IMAGE_TYPES = [
|
const ALLOWED_IMAGE_TYPES = [
|
||||||
|
|
@ -49,22 +54,20 @@ const ALLOWED_IMAGE_TYPES = [
|
||||||
];
|
];
|
||||||
|
|
||||||
const FormSchema = z.object({
|
const FormSchema = z.object({
|
||||||
subject: z.string().min(2, {
|
title: z.string().min(1, {
|
||||||
message: "subject must be at least 2 characters.",
|
message: "لطفا موضوع شکایت را وارد نمایید.",
|
||||||
}),
|
}),
|
||||||
organisation: z.string().min(2, {
|
OrganizationId: z.string({
|
||||||
message: "organisation must be at least 2 characters.",
|
required_error: "لطفا دستگاه مربوطه را انتخاب نمایید.",
|
||||||
}),
|
|
||||||
person: z.string().min(2, {
|
|
||||||
message: "personName must be at least 2 characters.",
|
|
||||||
}),
|
}),
|
||||||
|
person: z.string().optional(),
|
||||||
description: z
|
description: z
|
||||||
.string()
|
.string()
|
||||||
.min(5, {
|
.min(1, {
|
||||||
message: "description must be at least 5 characters.",
|
message: "لطفا توضیحات خود را بنویسید.",
|
||||||
})
|
})
|
||||||
.max(200, {
|
.max(300, {
|
||||||
message: "description must not be longer than 200 characters.",
|
message: "تعداد کاراکترها بیشتر از حد مجاز میباشد.",
|
||||||
}),
|
}),
|
||||||
uploadFile: z
|
uploadFile: z
|
||||||
.custom<FileList>((val) => val instanceof FileList, "Required")
|
.custom<FileList>((val) => val instanceof FileList, "Required")
|
||||||
|
|
@ -73,7 +76,8 @@ const FormSchema = z.object({
|
||||||
.refine(
|
.refine(
|
||||||
(files) => Array.from(files).every((file) => file.size <= MAX_IMAGE_SIZE),
|
(files) => Array.from(files).every((file) => file.size <= MAX_IMAGE_SIZE),
|
||||||
`Each file size should be less than 5 MB.`
|
`Each file size should be less than 5 MB.`
|
||||||
),
|
)
|
||||||
|
.nullish(),
|
||||||
// .refine(
|
// .refine(
|
||||||
// (files) =>
|
// (files) =>
|
||||||
// Array.from(files).every((file) =>
|
// Array.from(files).every((file) =>
|
||||||
|
|
@ -82,38 +86,49 @@ const FormSchema = z.object({
|
||||||
// "Only these types are allowed .jpg, .jpeg, .png and .webp"
|
// "Only these types are allowed .jpg, .jpeg, .png and .webp"
|
||||||
// ),
|
// ),
|
||||||
categoryId: z.string({
|
categoryId: z.string({
|
||||||
required_error: "Please select an category to display.",
|
required_error: "لطفا دسته بندی را انتخاب نمایید.",
|
||||||
}),
|
}),
|
||||||
captchaValue: z.string().min(4, {
|
captchaValue: z.string().min(1, {
|
||||||
message: "captcha must be at least 4 characters.",
|
message: "لطفا کد امنیتی را وارد نمایید.ئ",
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
interface Organization {
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
isDeleted: string;
|
||||||
|
id: string;
|
||||||
|
}
|
||||||
|
|
||||||
// Form Hook
|
// Form Hook
|
||||||
export default function RequestStep2() {
|
export default function RequestStep2() {
|
||||||
// const [trackingComplaint, setTrackingComplaint] = useState({});
|
// const [trackingComplaint, setTrackingComplaint] = useState({});
|
||||||
|
const isAuth = useToken((state) => state.token);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
useEffect(() => {
|
||||||
|
useToken.persist.rehydrate();
|
||||||
|
}, []);
|
||||||
const complaintSubmitMutation = useMutation({
|
const complaintSubmitMutation = useMutation({
|
||||||
mutationKey: ["complaintSubmit"],
|
mutationKey: ["complaintSubmit"],
|
||||||
mutationFn: postComplaintSubmit,
|
mutationFn: postComplaintSubmit,
|
||||||
|
|
||||||
onSuccess: (res) => {
|
onSuccess: (res) => {
|
||||||
console.log(res);
|
|
||||||
localStorage.setItem("trackingNumber", res.trackingNumber);
|
localStorage.setItem("trackingNumber", res.trackingNumber);
|
||||||
localStorage.setItem("password", res.password);
|
localStorage.setItem("password", res.password);
|
||||||
|
|
||||||
// alert("Success");
|
|
||||||
console.log("Success Step2");
|
|
||||||
router.push("/RequestResult");
|
router.push("/RequestResult");
|
||||||
// router.push("/RequestResult", { data: trackingComplaint });
|
|
||||||
// return (res)
|
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {},
|
||||||
console.log(error);
|
});
|
||||||
console.log(error?.message);
|
|
||||||
|
const authorizedComplaintSubmitMutation = useMutation({
|
||||||
|
mutationKey: ["authorizedComplaintSubmit"],
|
||||||
|
mutationFn: postAuthorizedComplaintSubmit,
|
||||||
|
onSuccess: (res) => {
|
||||||
|
localStorage.setItem("trackingNumber", res.trackingNumber);
|
||||||
|
localStorage.setItem("password", res.password);
|
||||||
|
localStorage.removeItem("authorized");
|
||||||
|
router.push("/RequestResult");
|
||||||
},
|
},
|
||||||
|
onError: (error) => {},
|
||||||
});
|
});
|
||||||
|
|
||||||
// All Category
|
// All Category
|
||||||
|
|
@ -122,8 +137,17 @@ export default function RequestStep2() {
|
||||||
queryFn: () => getCategory(),
|
queryFn: () => getCategory(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { data: organizationsData } = useQuery({
|
||||||
|
queryKey: ["organizations"],
|
||||||
|
queryFn: () => getOrganizations(),
|
||||||
|
});
|
||||||
|
|
||||||
// Captcha
|
// Captcha
|
||||||
const { data: CaptchaData, isLoading } = useQuery({
|
const {
|
||||||
|
data: CaptchaData,
|
||||||
|
isLoading,
|
||||||
|
refetch,
|
||||||
|
} = useQuery({
|
||||||
queryKey: ["Captcha"],
|
queryKey: ["Captcha"],
|
||||||
queryFn: () => getCaptcha(),
|
queryFn: () => getCaptcha(),
|
||||||
});
|
});
|
||||||
|
|
@ -136,8 +160,7 @@ export default function RequestStep2() {
|
||||||
const form = useForm<z.infer<typeof FormSchema>>({
|
const form = useForm<z.infer<typeof FormSchema>>({
|
||||||
resolver: zodResolver(FormSchema),
|
resolver: zodResolver(FormSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
subject: "",
|
title: "",
|
||||||
organisation: "",
|
|
||||||
person: "",
|
person: "",
|
||||||
description: "",
|
description: "",
|
||||||
captchaValue: "",
|
captchaValue: "",
|
||||||
|
|
@ -146,34 +169,34 @@ export default function RequestStep2() {
|
||||||
});
|
});
|
||||||
|
|
||||||
function onSubmit(data: z.infer<typeof FormSchema>) {
|
function onSubmit(data: z.infer<typeof FormSchema>) {
|
||||||
// toast({
|
|
||||||
// title: "You submitted the following values:",
|
|
||||||
// description: (
|
|
||||||
// <pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4">
|
|
||||||
// <code className="text-white">{JSON.stringify(data, null, 2)}</code>
|
|
||||||
// </pre>
|
|
||||||
// ),
|
|
||||||
// });
|
|
||||||
|
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("Title", data.subject);
|
formData.append("Title", data.title);
|
||||||
formData.append("Text", data.description);
|
formData.append("Text", data.description);
|
||||||
formData.append("CategoryId", data.categoryId);
|
formData.append("CategoryId", data.categoryId);
|
||||||
formData.append("Medias", data.uploadFile[0]);
|
if (data?.uploadFile && data?.uploadFile?.length > 0) {
|
||||||
|
for (let i = 0; i < data.uploadFile.length; i++) {
|
||||||
|
formData.append("Medias", data.uploadFile[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
formData.append("Captcha.Value", data.captchaValue);
|
formData.append("Captcha.Value", data.captchaValue);
|
||||||
formData.append("Captcha.Key", CaptchaData?.headers["captcha-key"]);
|
formData.append("Captcha.Key", CaptchaData?.headers["captcha-key"]);
|
||||||
|
formData.append("Complaining", data.person ? data.person : "");
|
||||||
|
formData.append("OrganizationId", data.OrganizationId);
|
||||||
|
if (isAuth) {
|
||||||
|
authorizedComplaintSubmitMutation.mutate({
|
||||||
|
Data: formData,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
complaintSubmitMutation.mutate({
|
complaintSubmitMutation.mutate({
|
||||||
Data: formData,
|
Data: formData,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
refetch();
|
||||||
resetField("Title");
|
resetField("Title");
|
||||||
resetField("Text");
|
resetField("Text");
|
||||||
resetField("Medias");
|
resetField("Medias");
|
||||||
resetField("CategoryId");
|
resetField("CategoryId");
|
||||||
resetField("Captcha.Value");
|
resetField("Captcha.Value");
|
||||||
|
|
||||||
console.log("submited");
|
|
||||||
console.log(data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const { resetField } = useForm();
|
const { resetField } = useForm();
|
||||||
|
|
@ -192,7 +215,7 @@ export default function RequestStep2() {
|
||||||
>
|
>
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="subject"
|
name="title"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
|
<FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
|
||||||
|
|
@ -211,19 +234,41 @@ export default function RequestStep2() {
|
||||||
<div className="flex flex-row flex-wrap justify-between">
|
<div className="flex flex-row flex-wrap justify-between">
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="organisation"
|
name="OrganizationId"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem className="w-full sm:w-[48%]">
|
<FormItem className=" w-full sm:w-[48%]">
|
||||||
<FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
|
<FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
|
||||||
*دستگاه مربوطه
|
*دستگاه مربوطه
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
|
<Select
|
||||||
|
onValueChange={field.onChange}
|
||||||
|
defaultValue={field.value}
|
||||||
|
dir="rtl"
|
||||||
|
>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<SelectTrigger
|
||||||
placeholder="دستگاه مربوطه را انتخاب کنید"
|
className=" bg-slate-200 !text-[#7C838A]"
|
||||||
{...field}
|
dir="rtl"
|
||||||
|
>
|
||||||
|
<SelectValue
|
||||||
|
className=""
|
||||||
|
placeholder="دستگاه مربوطه را انتخاب نمایید."
|
||||||
/>
|
/>
|
||||||
|
</SelectTrigger>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<SelectContent dir="rtl">
|
||||||
|
<SelectGroup>
|
||||||
|
{organizationsData?.map((item: any) => {
|
||||||
|
return (
|
||||||
|
<SelectItem value={item.id}>
|
||||||
|
{item.title}
|
||||||
|
</SelectItem>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</SelectGroup>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
<FormMessage className=" mt-2" />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
@ -281,6 +326,7 @@ export default function RequestStep2() {
|
||||||
<Select
|
<Select
|
||||||
onValueChange={field.onChange}
|
onValueChange={field.onChange}
|
||||||
defaultValue={field.value}
|
defaultValue={field.value}
|
||||||
|
dir="rtl"
|
||||||
>
|
>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<SelectTrigger className="bg-slate-200">
|
<SelectTrigger className="bg-slate-200">
|
||||||
|
|
@ -295,7 +341,7 @@ export default function RequestStep2() {
|
||||||
))}
|
))}
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
<FormMessage />
|
<FormMessage className=" mt-2" />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
@ -324,7 +370,7 @@ export default function RequestStep2() {
|
||||||
return (
|
return (
|
||||||
<FormItem className="w-full sm:w-[48%]">
|
<FormItem className="w-full sm:w-[48%]">
|
||||||
<FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
|
<FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
|
||||||
آپلود تصویر
|
پیوست
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
{/* File Upload */}
|
{/* File Upload */}
|
||||||
<FormControl>
|
<FormControl>
|
||||||
|
|
@ -367,12 +413,12 @@ export default function RequestStep2() {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{/* Captcha */}
|
{/* Captcha */}
|
||||||
<div className="flex flex-row flex-wrap justify-between">
|
<div className="flex flex-row justify-between items-center w-full lg:w-[48%] gap-2">
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="captchaValue"
|
name="captchaValue"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem className="w-full sm:w-[48%]">
|
<FormItem className="w-full ">
|
||||||
<FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
|
<FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
|
||||||
*کد امنیتی
|
*کد امنیتی
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
|
|
@ -387,31 +433,40 @@ export default function RequestStep2() {
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="w-full sm:w-[48%] flex items-center justify-start">
|
{isLoading ? (
|
||||||
{!isLoading && (
|
<div className=" w-2/3 max-w[11rem] flex justify-center text-center">
|
||||||
|
<ThreeDots
|
||||||
|
visible={true}
|
||||||
|
height="50"
|
||||||
|
width="50"
|
||||||
|
color="#003778"
|
||||||
|
radius="9"
|
||||||
|
ariaLabel="three-dots-loading"
|
||||||
|
wrapperStyle={{}}
|
||||||
|
wrapperClass=""
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className=" w-2/3 max-w[11rem] flex justify-end text-center">
|
||||||
<Image
|
<Image
|
||||||
alt="icon"
|
alt="icon"
|
||||||
src={srcForImage as string}
|
src={srcForImage as string}
|
||||||
className="w-3/5 h-12 rounded-md shadow-md"
|
className=" h-12 rounded-md shadow-md w-36"
|
||||||
width={150}
|
width={150}
|
||||||
height={20}
|
height={20}
|
||||||
quality={100}
|
quality={100}
|
||||||
/>
|
/>
|
||||||
)}
|
|
||||||
{/* <Image src={Img1} alt="1" width={50} height={50} /> */}
|
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex justify-center sm:justify-end gap-2 w-full mt-4">
|
<div className="flex justify-center sm:justify-end gap-2 w-full mt-4">
|
||||||
{/* <Link> */}
|
|
||||||
<Button
|
<Button
|
||||||
// href="/RequestResult"
|
|
||||||
type="submit"
|
type="submit"
|
||||||
className="w-1/2 sm:w-1/3 lg:w-1/4 bg-blue text-white p-2 rounded-xl text-center mb-4"
|
className="w-1/2 sm:w-1/3 lg:w-1/4 bg-blue text-white p-2 rounded-xl text-center mb-4"
|
||||||
>
|
>
|
||||||
ارسال درخواست
|
ارسال درخواست
|
||||||
</Button>
|
</Button>
|
||||||
{/* </Link> */}
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
|
|
|
||||||
|
|
@ -21,22 +21,17 @@ import { useRouter } from "next/navigation";
|
||||||
import { Decrypt } from "@/lib/utils";
|
import { Decrypt } from "@/lib/utils";
|
||||||
import useData from "@/store/useData";
|
import useData from "@/store/useData";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
|
import { getComplaints } from "@/utils/citizenApi";
|
||||||
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 router = useRouter();
|
const router = useRouter();
|
||||||
const handleFileChange = (event: any) => {
|
const { data, isLoading } = useQuery({
|
||||||
const file = event.target.files[0];
|
queryKey: ["CitizenList"],
|
||||||
const reader = new FileReader();
|
queryFn: () => getComplaints(),
|
||||||
reader.onload = (e) => {
|
refetchOnWindowFocus: false,
|
||||||
const contents = e?.target?.result;
|
});
|
||||||
// Process the contents of the file here
|
|
||||||
setSelectedFile(contents);
|
|
||||||
console.log(contents);
|
|
||||||
};
|
|
||||||
|
|
||||||
reader.readAsText(file);
|
|
||||||
};
|
|
||||||
const checkKey = (item: any) => {
|
const checkKey = (item: any) => {
|
||||||
const dcKey = Decrypt(item.cipherKeyInspector, selectedFile);
|
const dcKey = Decrypt(item.cipherKeyInspector, selectedFile);
|
||||||
if (dcKey != false && dcKey != null) {
|
if (dcKey != false && dcKey != null) {
|
||||||
|
|
@ -51,11 +46,7 @@ export default function TabController() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const { data, isLoading, refetch } = useQuery({
|
|
||||||
queryKey: ["ComplaintsList"],
|
|
||||||
queryFn: () => getComplaintsList(),
|
|
||||||
refetchOnWindowFocus: false,
|
|
||||||
});
|
|
||||||
console.log(data);
|
console.log(data);
|
||||||
const newComplaints = data?.filter((item: any) => item.status == 0);
|
const newComplaints = data?.filter((item: any) => item.status == 0);
|
||||||
const inProgressComplaints = data?.filter((item: any) => item.status == 1);
|
const inProgressComplaints = data?.filter((item: any) => item.status == 1);
|
||||||
|
|
@ -70,7 +61,7 @@ export default function TabController() {
|
||||||
return (
|
return (
|
||||||
<div className="w-[95vw] lg:w-[82vw] xl:w-[70vw] 3xl:w-[65vw] mt-8 pt-9">
|
<div className="w-[95vw] lg:w-[82vw] xl:w-[70vw] 3xl:w-[65vw] mt-8 pt-9">
|
||||||
<Dialog>
|
<Dialog>
|
||||||
<DialogTrigger className=" appearance-none" asChild>
|
{/* <DialogTrigger className=" appearance-none" asChild>
|
||||||
<Button
|
<Button
|
||||||
// onClick={handelVerify}
|
// onClick={handelVerify}
|
||||||
type="submit"
|
type="submit"
|
||||||
|
|
@ -78,7 +69,7 @@ export default function TabController() {
|
||||||
>
|
>
|
||||||
+ بارگذاری کلید جدید
|
+ بارگذاری کلید جدید
|
||||||
</Button>
|
</Button>
|
||||||
</DialogTrigger>
|
</DialogTrigger> */}
|
||||||
<Tabs defaultValue="tab1" className="" dir="rtl">
|
<Tabs defaultValue="tab1" className="" dir="rtl">
|
||||||
<div className="w-full flex flex-col-reverse lg:flex-row gap-4 lg:gap-5 justify-between items-center mb-10">
|
<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 */}
|
||||||
|
|
@ -91,7 +82,7 @@ export default function TabController() {
|
||||||
value="tab1"
|
value="tab1"
|
||||||
className="hover:border-b-2 border-b-blue"
|
className="hover:border-b-2 border-b-blue"
|
||||||
>
|
>
|
||||||
جدید (2)
|
ثبت شده
|
||||||
</TabsTrigger>
|
</TabsTrigger>
|
||||||
<TabsTrigger
|
<TabsTrigger
|
||||||
value="tab2"
|
value="tab2"
|
||||||
|
|
@ -168,13 +159,13 @@ export default function TabController() {
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<div className="grid w-full max-w-sm items-center gap-1.5">
|
<div className="grid w-full max-w-sm items-center gap-1.5">
|
||||||
{/* <Label htmlFor="picture">Picture</Label> */}
|
{/* <Label htmlFor="picture">Picture</Label> */}
|
||||||
<Input
|
{/* <Input
|
||||||
dir="rtl"
|
dir="rtl"
|
||||||
id="picture"
|
id="picture"
|
||||||
onChange={handleFileChange}
|
onChange={handleFileChange}
|
||||||
type="file"
|
type="file"
|
||||||
accept=".txt"
|
accept=".txt"
|
||||||
/>
|
/> */}
|
||||||
</div>
|
</div>
|
||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
<DialogClose asChild>
|
<DialogClose asChild>
|
||||||
|
|
|
||||||
|
|
@ -47,11 +47,12 @@ export default function TableController({
|
||||||
checkKey,
|
checkKey,
|
||||||
}: {
|
}: {
|
||||||
data: Complaint[];
|
data: Complaint[];
|
||||||
checkKey: (item:any) => any;
|
checkKey: (item: any) => any;
|
||||||
}) {
|
}) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
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 [open, setOpen] = useState<boolean>(false);
|
||||||
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];
|
||||||
|
|
@ -78,17 +79,6 @@ export default function TableController({
|
||||||
// };
|
// };
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Dialog>
|
|
||||||
{/* <DialogTrigger className=" appearance-none" asChild>
|
|
||||||
<Button
|
|
||||||
// onClick={handelVerify}
|
|
||||||
type="submit"
|
|
||||||
className="bg-blue hover:bg-blue/90 text-white w-36 p-2 rounded-xl"
|
|
||||||
>
|
|
||||||
بارگذاری کلید جدید
|
|
||||||
</Button>
|
|
||||||
</DialogTrigger> */}
|
|
||||||
|
|
||||||
<Table className="border-[1px] border-solid border-muted rounded-md ">
|
<Table className="border-[1px] border-solid border-muted rounded-md ">
|
||||||
{/* <TableCaption>A list of your recent invoices.</TableCaption> */}
|
{/* <TableCaption>A list of your recent invoices.</TableCaption> */}
|
||||||
<TableHeader>
|
<TableHeader>
|
||||||
|
|
@ -103,15 +93,15 @@ export default function TableController({
|
||||||
{data?.map((item: Complaint, index: number) => {
|
{data?.map((item: Complaint, index: number) => {
|
||||||
return (
|
return (
|
||||||
<TableRow
|
<TableRow
|
||||||
onClick={
|
|
||||||
() => checkKey(item)
|
|
||||||
// saveData({
|
|
||||||
// trackingNumber: item.trackingNumber,
|
|
||||||
// password: Decrypt(item.cipherKeyInspector),
|
|
||||||
// })
|
|
||||||
}
|
|
||||||
className=" hover:bg-gray-200 cursor-pointer"
|
className=" hover:bg-gray-200 cursor-pointer"
|
||||||
key={item.id}
|
key={item.id}
|
||||||
|
onClick={() => {
|
||||||
|
router.push(`/Account/Complaints/${item.id}`);
|
||||||
|
// setOpen(true);
|
||||||
|
saveData({
|
||||||
|
trackingNumber: item.trackingNumber,
|
||||||
|
});
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{/* <Link
|
{/* <Link
|
||||||
href={`/UserPanel/ControllerDashboard/Complaints/${item.id}`}
|
href={`/UserPanel/ControllerDashboard/Complaints/${item.id}`}
|
||||||
|
|
@ -124,7 +114,7 @@ export default function TableController({
|
||||||
{convertDate(item.registeredAt)}
|
{convertDate(item.registeredAt)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className="w-2/12">
|
<TableCell className="w-2/12">
|
||||||
{item?.category ? item.category.title : "-"}
|
{item?.title ? item.title : "-"}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className="w-7/12">-</TableCell>
|
<TableCell className="w-7/12">-</TableCell>
|
||||||
{/* </Link> */}
|
{/* </Link> */}
|
||||||
|
|
@ -133,42 +123,6 @@ export default function TableController({
|
||||||
})}
|
})}
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
{/* <DialogTrigger asChild>
|
|
||||||
<Button variant="outline">Edit Profile</Button>
|
|
||||||
</DialogTrigger> */}
|
|
||||||
<DialogContent dir="rtl" className="sm:max-w-[425px]">
|
|
||||||
<DialogHeader dir="rtl">
|
|
||||||
<DialogTitle dir="rtl">بارگذاری کلید خصوصی</DialogTitle>
|
|
||||||
<DialogDescription>
|
|
||||||
لطفا کلید خصوصی خود را آپلود نمایید.
|
|
||||||
</DialogDescription>
|
|
||||||
</DialogHeader>
|
|
||||||
<div className="grid w-full max-w-sm items-center gap-1.5">
|
|
||||||
{/* <Label htmlFor="picture">Picture</Label> */}
|
|
||||||
<Input
|
|
||||||
dir="rtl"
|
|
||||||
id="picture"
|
|
||||||
onChange={handleFileChange}
|
|
||||||
type="file"
|
|
||||||
accept=".txt"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<DialogFooter>
|
|
||||||
<DialogClose asChild>
|
|
||||||
<Button
|
|
||||||
onClick={() => {
|
|
||||||
if (selectedFile) {
|
|
||||||
toast("کلید شما با موفقیت بارگذاری شد.");
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
type="submit"
|
|
||||||
>
|
|
||||||
ذخیره
|
|
||||||
</Button>
|
|
||||||
</DialogClose>
|
|
||||||
</DialogFooter>
|
|
||||||
</DialogContent>
|
|
||||||
</Dialog>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,11 @@ export default function TopNav() {
|
||||||
pathname === "/" ? "bg-transparent" : "bg-white"
|
pathname === "/" ? "bg-transparent" : "bg-white"
|
||||||
} `}
|
} `}
|
||||||
>
|
>
|
||||||
<p className="bg-gradient-to-r from-gradient1 to-gradient2 inline-block text-transparent bg-clip-text text-xs max-md:hidden font-bold">
|
<p className="bg-gradient-to-r from-gradient1 to-gradient2 inline-block text-transparent bg-clip-text text-xs max-md:hidden font-bold max-sm:text-xs">
|
||||||
سال 1402 | مهارم تورم، رشد تولید
|
سال 1402 | مهارم تورم، رشد تولید
|
||||||
</p>
|
</p>
|
||||||
{/* <p>Current pathname: {pathname}</p> */}
|
{/* <p>Current pathname: {pathname}</p> */}
|
||||||
<div className="flex items-center gap-10">
|
<div className="flex items-center gap-2">
|
||||||
<div className=" flex items-center gap-3 md:ml-4">
|
<div className=" flex items-center gap-3 md:ml-4">
|
||||||
<p className="bg-gradient-to-r from-gradient1 to-gradient2 inline-block text-transparent bg-clip-text text-xs max-md:text-xs font-bold">
|
<p className="bg-gradient-to-r from-gradient1 to-gradient2 inline-block text-transparent bg-clip-text text-xs max-md:text-xs font-bold">
|
||||||
امروز: چهارشنبه 24 آبان 1402
|
امروز: چهارشنبه 24 آبان 1402
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import useData from "@/store/useData";
|
||||||
import { JwtPayload, jwtDecode } from "jwt-decode";
|
import { JwtPayload, jwtDecode } from "jwt-decode";
|
||||||
import { setCookie } from "cookies-next";
|
import { setCookie } from "cookies-next";
|
||||||
import { Oval } from "react-loader-spinner";
|
import { Oval } from "react-loader-spinner";
|
||||||
|
import useToken from "@/store/useToken";
|
||||||
|
|
||||||
export default function Verify() {
|
export default function Verify() {
|
||||||
const [otp, setOtp] = useState("");
|
const [otp, setOtp] = useState("");
|
||||||
|
|
@ -18,29 +19,31 @@ export default function Verify() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const userData = useData((state) => state.data);
|
const userData = useData((state) => state.data);
|
||||||
const [VerifyRole, setVerifyRole] = useState<any>("");
|
const [VerifyRole, setVerifyRole] = useState<any>("");
|
||||||
const verifyMutation = useMutation({
|
const saveToken = useToken((state) => state.saveToken);
|
||||||
mutationFn: verifyStaff,
|
// const verifyMutation = useMutation({
|
||||||
onSuccess: (res) => {
|
// mutationFn: verifyStaff,
|
||||||
const decodedToken = jwtDecode<any>(res);
|
// onSuccess: (res) => {
|
||||||
setCookie("Sootzani_Token", res);
|
// const decodedToken = jwtDecode<any>(res);
|
||||||
const userRole =
|
// setCookie("Sootzani_Token", res);
|
||||||
decodedToken[
|
// const userRole =
|
||||||
"http://schemas.microsoft.com/ws/2008/06/identity/claims/role"
|
// decodedToken[
|
||||||
];
|
// "http://schemas.microsoft.com/ws/2008/06/identity/claims/role"
|
||||||
localStorage.setItem("Sootzani_Role", userRole);
|
// ];
|
||||||
if (userRole == "Inspector") {
|
// localStorage.setItem("Sootzani_Role", userRole);
|
||||||
router.push("/UserPanel/ControllerDashboard");
|
// if (userRole == "Inspector") {
|
||||||
} else if (userRole == "Admin") {
|
// router.push("/UserPanel/ControllerDashboard");
|
||||||
router.push("/UserPanel/AdminDashboard");
|
// } else if (userRole == "Admin") {
|
||||||
} else {
|
// router.push("/UserPanel/AdminDashboard");
|
||||||
router.push("/UserPanel/CitizenDashboard");
|
// } else {
|
||||||
}
|
// router.push("/UserPanel/CitizenDashboard");
|
||||||
},
|
// }
|
||||||
onError: (err: any) => {},
|
// },
|
||||||
});
|
// onError: (err: any) => {},
|
||||||
|
// });
|
||||||
const CitizenVerifyMutation = useMutation({
|
const CitizenVerifyMutation = useMutation({
|
||||||
mutationFn: verifyCitizen,
|
mutationFn: verifyCitizen,
|
||||||
onSuccess: (res) => {
|
onSuccess: (res) => {
|
||||||
|
saveToken(true);
|
||||||
const decodedToken = jwtDecode<any>(res);
|
const decodedToken = jwtDecode<any>(res);
|
||||||
setCookie("Sootzani_Token", res);
|
setCookie("Sootzani_Token", res);
|
||||||
const userRole =
|
const userRole =
|
||||||
|
|
@ -48,7 +51,13 @@ export default function Verify() {
|
||||||
"http://schemas.microsoft.com/ws/2008/06/identity/claims/role"
|
"http://schemas.microsoft.com/ws/2008/06/identity/claims/role"
|
||||||
];
|
];
|
||||||
localStorage.setItem("Sootzani_Role", userRole);
|
localStorage.setItem("Sootzani_Role", userRole);
|
||||||
router.push("/UserPanel/CitizenDashboard");
|
const justLogin = localStorage.getItem("Sootzani_Login_State");
|
||||||
|
if (justLogin) {
|
||||||
|
router.push("/");
|
||||||
|
localStorage.removeItem("Sootzani_Login_State");
|
||||||
|
} else {
|
||||||
|
router.push("/RequestStep1");
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onError: (err: any) => {},
|
onError: (err: any) => {},
|
||||||
});
|
});
|
||||||
|
|
@ -57,11 +66,7 @@ export default function Verify() {
|
||||||
console.log(otp);
|
console.log(otp);
|
||||||
const payload = { ...userData, verificationCode: otp };
|
const payload = { ...userData, verificationCode: otp };
|
||||||
console.log(userData);
|
console.log(userData);
|
||||||
if (userData?.phoneNumber) {
|
|
||||||
CitizenVerifyMutation.mutate(payload);
|
CitizenVerifyMutation.mutate(payload);
|
||||||
} else {
|
|
||||||
verifyMutation.mutate(payload);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -103,12 +108,12 @@ export default function Verify() {
|
||||||
</label>
|
</label>
|
||||||
<div className="flex justify-end gap-2 w-full mt-14">
|
<div className="flex justify-end gap-2 w-full mt-14">
|
||||||
<Button
|
<Button
|
||||||
disabled={verifyMutation.isPending}
|
disabled={CitizenVerifyMutation.isPending}
|
||||||
onClick={handelVerify}
|
onClick={handelVerify}
|
||||||
type="submit"
|
type="submit"
|
||||||
className="bg-blue hover:bg-blue/90 text-white w-1/2 md:w-1/3 p-2 rounded-xl"
|
className="bg-blue hover:bg-blue/90 text-white w-1/2 md:w-1/3 p-2 rounded-xl"
|
||||||
>
|
>
|
||||||
{verifyMutation.isPending ? (
|
{CitizenVerifyMutation.isPending ? (
|
||||||
<div className="flex justify-center items-center gap-2">
|
<div className="flex justify-center items-center gap-2">
|
||||||
<Oval
|
<Oval
|
||||||
visible={true}
|
visible={true}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ export const boxItems = [
|
||||||
icon: "/img/box1.svg",
|
icon: "/img/box1.svg",
|
||||||
icon2: "/img/box1-hover.svg",
|
icon2: "/img/box1-hover.svg",
|
||||||
description: "ارسال درخواست نارضایتی از پرسنل",
|
description: "ارسال درخواست نارضایتی از پرسنل",
|
||||||
link: "/RequestStep1",
|
link: "/RequestStep2",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
|
|
|
||||||
11
lib/utils.ts
11
lib/utils.ts
|
|
@ -4,6 +4,7 @@ import dayjs from "dayjs";
|
||||||
import utc from "dayjs/plugin/utc";
|
import utc from "dayjs/plugin/utc";
|
||||||
import jalaliday from "jalaliday";
|
import jalaliday from "jalaliday";
|
||||||
import JSEncrypt from "jsencrypt";
|
import JSEncrypt from "jsencrypt";
|
||||||
|
import { getCookie } from "cookies-next";
|
||||||
|
|
||||||
dayjs.extend(jalaliday);
|
dayjs.extend(jalaliday);
|
||||||
dayjs.extend(utc);
|
dayjs.extend(utc);
|
||||||
|
|
@ -40,3 +41,13 @@ dEqG/38xFdYTFEekexcHnT/Vt1MW4/j76vBJHYWuAJU=
|
||||||
const decrypted = decryptor.decrypt(encryptedData);
|
const decrypted = decryptor.decrypt(encryptedData);
|
||||||
return decrypted;
|
return decrypted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function isAuthorized() {
|
||||||
|
const token = getCookie("Sootzani_Token");
|
||||||
|
if (token) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ type Store = {
|
||||||
const useToken = create<Store>()(
|
const useToken = create<Store>()(
|
||||||
persist(
|
persist(
|
||||||
(set) => ({
|
(set) => ({
|
||||||
token: "",
|
token: false,
|
||||||
saveToken: (payload) => {
|
saveToken: (payload: any) => {
|
||||||
set({ token: payload });
|
set({ token: payload });
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,9 @@ module.exports = {
|
||||||
backgroundImage: {
|
backgroundImage: {
|
||||||
mainBg: "url('/img/bg.png')",
|
mainBg: "url('/img/bg.png')",
|
||||||
},
|
},
|
||||||
|
objectPosition: {
|
||||||
|
"custom": "top 10px right 10px",
|
||||||
|
},
|
||||||
screens: {
|
screens: {
|
||||||
"3xl": "1600px",
|
"3xl": "1600px",
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { CookieValueTypes } from "cookies-next";
|
import { CookieValueTypes, getCookie } from "cookies-next";
|
||||||
|
|
||||||
axios.defaults.baseURL = "https://sootzaniapi.shetabdahi.ir/";
|
axios.defaults.baseURL = "https://sootzaniapi.shetabdahi.ir/";
|
||||||
|
|
||||||
|
|
@ -52,7 +52,10 @@ export async function changePassword(payload: {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getProfile() {
|
export async function getProfile() {
|
||||||
const data = await axios.get("api/Authenticate/Profile");
|
const token = getCookie("Sootzani_Token");
|
||||||
|
const data = await axios.get("api/Authenticate/Profile", {
|
||||||
|
headers: { Authorization: `Bearer ${token}` },
|
||||||
|
});
|
||||||
return data.data;
|
return data.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -60,9 +63,11 @@ export async function editProfile(payload: {
|
||||||
firstName: string;
|
firstName: string;
|
||||||
lastName: string;
|
lastName: string;
|
||||||
nationalId: string;
|
nationalId: string;
|
||||||
phoneNumber2: string;
|
title?: string;
|
||||||
title: string;
|
|
||||||
}) {
|
}) {
|
||||||
const data = await axios.put("api/Authenticate/Profile", payload);
|
const token = getCookie("Sootzani_Token");
|
||||||
|
const data = await axios.put("api/Authenticate/Profile", payload, {
|
||||||
|
headers: { Authorization: `Bearer ${token}` },
|
||||||
|
});
|
||||||
return data.data;
|
return data.data;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,29 @@
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { CookieValueTypes } from "cookies-next";
|
import { CookieValueTypes, getCookie } from "cookies-next";
|
||||||
|
|
||||||
axios.defaults.baseURL = "https://sootzaniapi.shetabdahi.ir/";
|
axios.defaults.baseURL = "https://sootzaniapi.shetabdahi.ir/";
|
||||||
|
|
||||||
|
axios.interceptors.request.use(function (config) {
|
||||||
|
const token = getCookie("Sootzani_Token");
|
||||||
|
config.headers.Authorization = token ? `Bearer ${token}` : "";
|
||||||
|
return config;
|
||||||
|
});
|
||||||
// Post Complaints
|
// Post Complaints
|
||||||
export async function postComplaintSubmit({ Data }: { Data: FormData }) {
|
export async function postComplaintSubmit({ Data }: { Data: FormData }) {
|
||||||
const data = await axios.post(`api/Citizen`, Data);
|
const data = await axios.post(`api/Citizen`, Data);
|
||||||
return data.data;
|
return data.data;
|
||||||
}
|
}
|
||||||
|
export async function postAuthorizedComplaintSubmit({
|
||||||
|
Data,
|
||||||
|
}: {
|
||||||
|
Data: FormData;
|
||||||
|
}) {
|
||||||
|
const token = getCookie("Sootzani_Token");
|
||||||
|
const data = await axios.post(`api/Citizen/Authorized`, Data, {
|
||||||
|
headers: { Authorization: `Bearer ${token}` },
|
||||||
|
});
|
||||||
|
return data.data;
|
||||||
|
}
|
||||||
|
|
||||||
// Post 1 Complaints
|
// Post 1 Complaints
|
||||||
export async function postComplaintTracking({
|
export async function postComplaintTracking({
|
||||||
|
|
@ -24,3 +40,8 @@ export async function postComplaintsDetails(payload: FormData) {
|
||||||
const data = await axios.post(`api/Citizen/Operate`, payload);
|
const data = await axios.post(`api/Citizen/Operate`, payload);
|
||||||
return data.data;
|
return data.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getComplaints() {
|
||||||
|
const data = await axios.get("api/Citizen/List");
|
||||||
|
return data.data;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,20 @@
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { CookieValueTypes } from "cookies-next";
|
import { CookieValueTypes } from "cookies-next";
|
||||||
|
|
||||||
|
|
||||||
// Get Category
|
// Get Category
|
||||||
export async function getCategory() {
|
export async function getCategory() {
|
||||||
const data = await axios.get(
|
const data = await axios.get("api/Common/Categories");
|
||||||
"api/Common/Categories",
|
|
||||||
);
|
|
||||||
return data.data;
|
return data.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getOrganizations() {
|
||||||
|
const data = await axios.get("api/Common/Organizations");
|
||||||
|
return data.data;
|
||||||
|
}
|
||||||
|
|
||||||
// Get Captcha
|
// Get Captcha
|
||||||
export async function getCaptcha() {
|
export async function getCaptcha() {
|
||||||
const data = await axios.get(
|
const data = await axios.get("api/Common/Captcha", { responseType: "blob" });
|
||||||
"api/Common/Captcha", {responseType:'blob'}
|
console.log(data);
|
||||||
);
|
|
||||||
console.log(data)
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
import axios from "axios";
|
||||||
|
import { CookieValueTypes, getCookie } from "cookies-next";
|
||||||
|
|
||||||
|
axios.defaults.baseURL = "https://sootzaniapi.shetabdahi.ir/";
|
||||||
Loading…
Reference in New Issue