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