Part of Inspector & Citizen Operations done
parent
4381d3a7f3
commit
cd8c85a6a2
|
|
@ -0,0 +1,6 @@
|
|||
import CitizenLogin from "@/components/CitizenLogin";
|
||||
import React from "react";
|
||||
|
||||
export default function page() {
|
||||
return <CitizenLogin />;
|
||||
}
|
||||
|
|
@ -1,13 +1,18 @@
|
|||
import ComplainsDetails from '@/components/ComplainsDetails'
|
||||
import React from 'react'
|
||||
|
||||
export default function page({params}:{params:any}) {
|
||||
import ComplainsDetails from "@/components/ComplainsDetails";
|
||||
import React from "react";
|
||||
|
||||
export default function page({ params }: { params: any }) {
|
||||
const id = params.id;
|
||||
{ console.log(params);}
|
||||
{ console.log(id);}
|
||||
{
|
||||
console.log(params);
|
||||
}
|
||||
{
|
||||
console.log(id);
|
||||
}
|
||||
|
||||
return (
|
||||
<ComplainsDetails id={id} />
|
||||
)
|
||||
<div className="w-[90vw] sm:w-[90vw] lg:w-[85vw] xl:w-[75vw] 3xl:w-[70vw] mt-16 sm:mt-8 pt-9 mx-auto mb-10">
|
||||
<ComplainsDetails role="Inspector" id={id} />;
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,199 @@
|
|||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useForm } from "react-hook-form";
|
||||
import * as z from "zod";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormDescription,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
} from "@/components/ui/form";
|
||||
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { toast } from "@/components/ui/use-toast";
|
||||
import Image from "next/image";
|
||||
import LoginIcon from "../public/img/login-icon.svg";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import { loginStaff, logisterCitizen } from "@/utils/authenticateApi";
|
||||
import { getCaptcha } from "@/utils/commonApi";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { Oval, ThreeDots } from "react-loader-spinner";
|
||||
import useData from "@/store/useData";
|
||||
const FormSchema = z.object({
|
||||
phoneNumber: z.string().min(1, {
|
||||
message: "لطفا شماره موبایل خود را وارد نمایید.",
|
||||
}),
|
||||
captcha: z
|
||||
.string({ required_error: "لطفا کد امنیتی را وارد نمایید." })
|
||||
.length(5, { message: "لطفا کد امنیتی را به طور کامل وارد نمایید." }),
|
||||
});
|
||||
|
||||
export default function CitizenLogin() {
|
||||
const router = useRouter();
|
||||
const saveData = useData((state) => state.saveData);
|
||||
|
||||
const {
|
||||
data: CaptchaData,
|
||||
isLoading,
|
||||
refetch,
|
||||
} = useQuery({
|
||||
queryKey: ["Captcha"],
|
||||
queryFn: () => getCaptcha(),
|
||||
refetchOnWindowFocus: false,
|
||||
});
|
||||
|
||||
const loginMutation = useMutation({
|
||||
mutationFn: logisterCitizen,
|
||||
onSuccess: (res) => {},
|
||||
onError: (err: any) => {
|
||||
if (err.response.status == 428) {
|
||||
console.log(useData);
|
||||
router.push("/Verify");
|
||||
localStorage.setItem("VerifyRole", "citizen");
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const form = useForm<z.infer<typeof FormSchema>>({
|
||||
resolver: zodResolver(FormSchema),
|
||||
});
|
||||
|
||||
function onSubmit(data: z.infer<typeof FormSchema>) {
|
||||
const payload = {
|
||||
phoneNumber: data.phoneNumber,
|
||||
captcha: {
|
||||
key: CaptchaData?.headers["captcha-key"],
|
||||
value: data.captcha,
|
||||
},
|
||||
};
|
||||
loginMutation.mutate(payload);
|
||||
saveData({
|
||||
phoneNumber: data.phoneNumber,
|
||||
});
|
||||
}
|
||||
|
||||
const srcForImage = CaptchaData
|
||||
? 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]
|
||||
h-full max-md:p-8 pt-12 mb-10"
|
||||
>
|
||||
<div className="space-y-3 md:space-y-4 flex flex-col md:py-10 md:px-12 lg:px-16 h-full justify-center">
|
||||
<Image alt="icon" src={LoginIcon} className="self-center w-1/3 " />
|
||||
|
||||
<p className="text-lg font-bold leading-tight tracking-tight text-blue dark:text-white">
|
||||
احراز هویت
|
||||
</p>
|
||||
|
||||
<Form {...form}>
|
||||
<form
|
||||
onSubmit={form.handleSubmit(onSubmit)}
|
||||
className="w-full flex flex-col "
|
||||
>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="phoneNumber"
|
||||
rules={{ required: true }}
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel className="text-[#7C838A] text-sm font-medium">
|
||||
شماره موبایل
|
||||
</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
className="mb-4"
|
||||
placeholder="شماره موبایل خود را وارد نمایید"
|
||||
{...field}
|
||||
/>
|
||||
</FormControl>
|
||||
{/* <FormDescription>
|
||||
This is your public display name.
|
||||
</FormDescription> */}
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<div className="flex gap-4 mt-4 items-center">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="captcha"
|
||||
rules={{ required: true }}
|
||||
render={({ field }) => (
|
||||
<FormItem className=" items-center h-10 flex-1">
|
||||
{/* <FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
|
||||
رمز عبور
|
||||
</FormLabel> */}
|
||||
<FormControl>
|
||||
<Input placeholder="کد امنیتی" {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
{isLoading ? (
|
||||
<div className=" w-36 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=" flex justify-center text-center">
|
||||
<Image
|
||||
alt="icon"
|
||||
src={srcForImage as string}
|
||||
className=" h-12 rounded-md shadow-md w-36"
|
||||
width={150}
|
||||
height={20}
|
||||
quality={100}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex justify-end gap-2 w-full mt-14">
|
||||
<Button
|
||||
disabled={loginMutation.isPending}
|
||||
type="submit"
|
||||
className="bg-blue hover:bg-blue/90 transition text-white w-1/2 md:w-1/3 p-2 rounded-xl"
|
||||
>
|
||||
{loginMutation.isPending ? (
|
||||
<div className="flex justify-center items-center gap-2">
|
||||
<Oval
|
||||
visible={true}
|
||||
height="20"
|
||||
width="20"
|
||||
color="#fff"
|
||||
ariaLabel="oval-loading"
|
||||
wrapperStyle={{}}
|
||||
wrapperClass=""
|
||||
/>
|
||||
{/* <p>در حال انجام ...</p> */}
|
||||
</div>
|
||||
) : (
|
||||
"تایید"
|
||||
)}
|
||||
{/* ورود */}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
</Form>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -5,40 +5,62 @@ import blueIcon from "../public/img/bluepoint.svg";
|
|||
import Image from "next/image";
|
||||
import { ComplainDetailsItems } from "@/constants";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { getComplaint } from "@/utils/inspectorApi";
|
||||
import { OperateByInspector, getComplaint } from "@/utils/inspectorApi";
|
||||
import useData from "@/store/useData";
|
||||
import { convertDate } from "@/lib/utils";
|
||||
import { Badge } from "./ui/badge";
|
||||
import InspectorOperations from "./InspectorOperations";
|
||||
import { postComplaintTracking } from "@/utils/citizenApi";
|
||||
|
||||
export default function ComplainsDetails({ id }: { id: number }) {
|
||||
const complainData = useData((state) => state.data);
|
||||
const getComplaintMutation = useMutation({
|
||||
export default function ComplainsDetails({
|
||||
id,
|
||||
role,
|
||||
Data,
|
||||
}: {
|
||||
id?: number;
|
||||
role: string;
|
||||
Data?: any;
|
||||
}) {
|
||||
const storeData = useData((state) => state.data);
|
||||
let data;
|
||||
|
||||
const getComplaintMutation = useMutation<
|
||||
any,
|
||||
Error,
|
||||
{ trackingNumber: string; password: string }
|
||||
>({
|
||||
mutationKey: ["Complaint", id],
|
||||
mutationFn: getComplaint,
|
||||
mutationFn:
|
||||
role == "Inspector"
|
||||
? (getComplaint as any)
|
||||
: (postComplaintTracking as any),
|
||||
onSuccess: (res) => {},
|
||||
onError: (err) => {},
|
||||
});
|
||||
console.log(complainData);
|
||||
|
||||
console.log(storeData);
|
||||
|
||||
useEffect(() => {
|
||||
if (role == "Inspector") {
|
||||
useData.persist.rehydrate();
|
||||
}
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
if (complainData) {
|
||||
getComplaintMutation.mutate(complainData);
|
||||
if (storeData && role == "Inspector") {
|
||||
getComplaintMutation.mutate(storeData);
|
||||
}
|
||||
}, [complainData]);
|
||||
let data;
|
||||
}, [storeData]);
|
||||
if (getComplaintMutation.isSuccess) {
|
||||
console.log(getComplaintMutation.data);
|
||||
data = getComplaintMutation.data;
|
||||
console.log(data);
|
||||
} else if (Data) {
|
||||
data = Data;
|
||||
}
|
||||
console.log(Data);
|
||||
return (
|
||||
<div className="w-[95vw] lg:w-[82vw] xl:w-[70vw] 3xl:w-[65vw] mt-16 sm:mt-8 pt-9 mx-auto mb-10">
|
||||
<>
|
||||
{data ? (
|
||||
<div className="w-full flex gap-3 items-start">
|
||||
<div className="flex flex-col w-1/3 order-2 gap-3 !sticky top-40 ">
|
||||
<div className="w-full flex max-lg:flex-col gap-3 items-start">
|
||||
<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>
|
||||
<div className="mt-2">
|
||||
|
|
@ -80,12 +102,18 @@ export default function ComplainsDetails({ id }: { id: number }) {
|
|||
0353286545 جهت پشتیبانی تماس حاصل کنید.{" "}
|
||||
</p> */}
|
||||
</div>
|
||||
<div className=" order-2 bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col">
|
||||
<p className="text-[#464646] text-base font-bold">انجام عملیات</p>
|
||||
<InspectorOperations />
|
||||
<div className=" max-lg:hidden order-2 bg-[#E9E9E9] rounded-md p-4 px-10 flex flex-col">
|
||||
<p className="text-[#464646] text-base font-bold mb-1">
|
||||
انجام عملیات
|
||||
</p>
|
||||
<InspectorOperations
|
||||
updateData={() => getComplaintMutation.mutate(storeData)}
|
||||
role={role}
|
||||
complaintData={data}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className=" w-2/3 bg-[#E9E9E9] p-4 px-10 rounded-lg">
|
||||
<div className="w-full lg:w-2/3 self-stretch bg-[#E9E9E9] p-4 px-10 rounded-lg">
|
||||
<p className="text-[#464646] text-base font-bold">روند شکایت</p>
|
||||
<div className=" flex flex-col gap-y-4 mt-4">
|
||||
{data.contents?.map((item: any) => {
|
||||
|
|
@ -102,13 +130,16 @@ export default function ComplainsDetails({ id }: { id: number }) {
|
|||
</span>
|
||||
</p>
|
||||
</div>
|
||||
<div className=" text-[#7C838A] mt-2">
|
||||
متن: {item.text ? item.text : "-"}
|
||||
<div className=" text-[#464646] mt-2">
|
||||
متن:{" "}
|
||||
<span className="text-[#7C838A]">
|
||||
{item.text ? item.text : "-"}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
{data.contents?.map((item: any) => {
|
||||
{/* {data.contents?.map((item: any) => {
|
||||
return (
|
||||
<div className=" bg-white p-4 rounded-lg shadow-md">
|
||||
<div className=" flex gap-4 items-center">
|
||||
|
|
@ -127,88 +158,18 @@ export default function ComplainsDetails({ id }: { id: number }) {
|
|||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
{data.contents?.map((item: any) => {
|
||||
return (
|
||||
<div className=" bg-white p-4 rounded-lg shadow-md">
|
||||
<div className=" flex gap-4 items-center">
|
||||
<p className="">
|
||||
<Badge>{item.sender == 0 ? "شهروند" : "بازرس"}</Badge>
|
||||
})} */}
|
||||
</div>
|
||||
</div>
|
||||
<div className=" lg:hidden order-2 w-full bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col">
|
||||
<p className="text-[#464646] text-base font-bold mb-1">
|
||||
انجام عملیات
|
||||
</p>
|
||||
<p className="">
|
||||
تاریخ :
|
||||
<span className="text-[#7C838A]">
|
||||
{convertDate(item.dateTime)}
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
<div className=" text-[#7C838A] mt-2">
|
||||
متن: {item.text ? item.text : "-"}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
{data.contents?.map((item: any) => {
|
||||
return (
|
||||
<div className=" bg-white p-4 rounded-lg shadow-md">
|
||||
<div className=" flex gap-4 items-center">
|
||||
<p className="">
|
||||
<Badge>{item.sender == 0 ? "شهروند" : "بازرس"}</Badge>
|
||||
</p>
|
||||
<p className="">
|
||||
تاریخ :
|
||||
<span className="text-[#7C838A]">
|
||||
{convertDate(item.dateTime)}
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
<div className=" text-[#7C838A] mt-2">
|
||||
متن: {item.text ? item.text : "-"}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
{data.contents?.map((item: any) => {
|
||||
return (
|
||||
<div className=" bg-white p-4 rounded-lg shadow-md">
|
||||
<div className=" flex gap-4 items-center">
|
||||
<p className="">
|
||||
<Badge>{item.sender == 0 ? "شهروند" : "بازرس"}</Badge>
|
||||
</p>
|
||||
<p className="">
|
||||
تاریخ :
|
||||
<span className="text-[#7C838A]">
|
||||
{convertDate(item.dateTime)}
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
<div className=" text-[#7C838A] mt-2">
|
||||
متن: {item.text ? item.text : "-"}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
{data.contents?.map((item: any) => {
|
||||
return (
|
||||
<div className=" bg-white p-4 rounded-lg shadow-md">
|
||||
<div className=" flex gap-4 items-center">
|
||||
<p className="">
|
||||
<Badge>{item.sender == 0 ? "شهروند" : "بازرس"}</Badge>
|
||||
</p>
|
||||
<p className="">
|
||||
تاریخ :
|
||||
<span className="text-[#7C838A]">
|
||||
{convertDate(item.dateTime)}
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
<div className=" text-[#7C838A] mt-2">
|
||||
متن: {item.text ? item.text : "-"}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
<InspectorOperations
|
||||
updateData={() => getComplaintMutation.mutate(storeData)}
|
||||
role={role}
|
||||
complaintData={data}
|
||||
/>
|
||||
</div>
|
||||
{/* Left */}
|
||||
{/* <div className="w-full md:w-1/3 bg-white shadow-lg rounded-md pt-3 px-4 flex flex-row md:flex-col max-md:flex-wrap">
|
||||
|
|
@ -253,6 +214,6 @@ export default function ComplainsDetails({ id }: { id: number }) {
|
|||
) : (
|
||||
""
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,8 @@ import { postComplaintTracking } from "@/utils/citizenApi";
|
|||
import { useMutation } from "@tanstack/react-query";
|
||||
import { useReactToPrint } from "react-to-print";
|
||||
|
||||
import '../app/print-styles.css';
|
||||
import "../app/print-styles.css";
|
||||
import ComplainsDetails from "./ComplainsDetails";
|
||||
|
||||
export default function FollowResult() {
|
||||
const router = useRouter();
|
||||
|
|
@ -31,31 +32,30 @@ export default function FollowResult() {
|
|||
const [password, setPassword] = useState<any>();
|
||||
const [complaintData, setComplaintData] = useState<any>();
|
||||
|
||||
|
||||
// Print component Data
|
||||
const componentRef = useRef<HTMLDivElement>(null);
|
||||
const handlePrint = useReactToPrint({
|
||||
content: () => componentRef.current
|
||||
content: () => componentRef.current,
|
||||
});
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
setTrackingNumber(localStorage.getItem("trackingNumber2"));
|
||||
setPassword(localStorage.getItem("password2"));
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (trackingNumber && password) {
|
||||
complaintPrintMutation.mutate({
|
||||
Data: { trackingNumber: trackingNumber, password: password },
|
||||
});
|
||||
}
|
||||
}, [trackingNumber, password]);
|
||||
|
||||
const complaintPrintMutation = useMutation({
|
||||
mutationKey: ["complaintPrint"],
|
||||
mutationFn: postComplaintTracking,
|
||||
|
||||
onSuccess: (res) => {
|
||||
console.log(res);
|
||||
// alert("SuccessPrint");
|
||||
console.log("Success Folllow Result");
|
||||
console.log(res);
|
||||
|
||||
setComplaintData(res);
|
||||
console.log(complaintData);
|
||||
},
|
||||
onError: (error) => {
|
||||
console.log(error);
|
||||
|
|
@ -66,18 +66,22 @@ export default function FollowResult() {
|
|||
function onSubmit() {
|
||||
console.log("SuccessPrinttttttttttt");
|
||||
|
||||
complaintPrintMutation.mutate({
|
||||
Data: { trackingNumber: trackingNumber, password: password },
|
||||
});
|
||||
// complaintPrintMutation.mutate({
|
||||
// Data: { trackingNumber: trackingNumber, password: password },
|
||||
// });
|
||||
}
|
||||
// const possibleOperations = complaintPrintMutation.data?.possibleOperations;
|
||||
// const selectOptions = Operations.filter((item, index) =>
|
||||
// possibleOperations.includes(index)
|
||||
// );
|
||||
|
||||
|
||||
const printableContent = 'This is the content to be printed.';
|
||||
|
||||
const printableContent = "This is the content to be printed.";
|
||||
console.log(complaintPrintMutation?.data);
|
||||
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
|
||||
<>
|
||||
<div className="w-[90vw] sm:w-[90vw] lg:w-[85vw] xl:w-[75vw] 3xl:w-[70vw] max-sm:mt-16 pt-4 mx-auto mb-10">
|
||||
{/* <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"
|
||||
>
|
||||
|
|
@ -87,16 +91,17 @@ const printableContent = 'This is the content to be printed.';
|
|||
<span className="text-slate-500 mx-2">{`${password}`}</span>
|
||||
در دست بررسی و اقدام می باشد. در صورت تمایل می توانید با شماره تلفن
|
||||
0353286545 جهت پشتیبانی تماس حاصل کنید.
|
||||
</p>
|
||||
|
||||
<div className="flex justify-center sm:justify-end gap-2 w-full mt-8">
|
||||
</p> */}
|
||||
{complaintPrintMutation?.data ? (
|
||||
<>
|
||||
<div className="flex justify-center sm:justify-end gap-2 mb-2">
|
||||
<AlertDialog>
|
||||
<AlertDialogTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
type="submit"
|
||||
onClick={() => onSubmit()}
|
||||
className="w-1/2 sm:w-1/3 lg:w-1/4 bg-blue text-white p-2 rounded-xl text-center"
|
||||
className="w-fit bg-blue text-white p-2 rounded-xl text-center"
|
||||
>
|
||||
پرینت درخواست
|
||||
</Button>
|
||||
|
|
@ -129,7 +134,12 @@ const printableContent = 'This is the content to be printed.';
|
|||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div dir="rtl" className=" font-[yekan]" id="details" ref={componentRef} >
|
||||
<div
|
||||
dir="rtl"
|
||||
className=" font-[yekan]"
|
||||
id="details"
|
||||
ref={componentRef}
|
||||
>
|
||||
<p className="text-[#464646] text-sm font-medium">
|
||||
{" "}
|
||||
موضوع شکایت:{" "}
|
||||
|
|
@ -156,10 +166,10 @@ const printableContent = 'This is the content to be printed.';
|
|||
<span className="text-slate-500 mx-2">{`${trackingNumber}`}</span>
|
||||
و رمز عبور
|
||||
<span className="text-slate-500 mx-2">{`${password}`}</span>
|
||||
در دست بررسی و اقدام می باشد. در صورت تمایل می توانید با
|
||||
شماره تلفن 0353286545 جهت پشتیبانی تماس حاصل کنید.
|
||||
در دست بررسی و اقدام می باشد. در صورت تمایل می
|
||||
توانید با شماره تلفن 0353286545 جهت پشتیبانی تماس
|
||||
حاصل کنید.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
)}
|
||||
</AlertDialogDescription>
|
||||
|
|
@ -172,18 +182,26 @@ const printableContent = 'This is the content to be printed.';
|
|||
>
|
||||
پرینت گزارش
|
||||
</Button>
|
||||
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</div>
|
||||
<ComplainsDetails
|
||||
role="Citizen"
|
||||
Data={complaintPrintMutation?.data}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
|
||||
<Image
|
||||
{/* <Image
|
||||
alt="icon"
|
||||
src={Resultimg}
|
||||
className="self-center w-3/5 mt-5 sm:w-[23em] sm:h-[20em] 3xl:w-3/5 3xl:h-[30em] object-contain"
|
||||
/>
|
||||
</div>
|
||||
/> */}
|
||||
{/* </div> */}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,36 +15,103 @@ import {
|
|||
FormMessage,
|
||||
} from "@/components/ui/form";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { toast } from "@/components/ui/use-toast";
|
||||
import { Label } from "./ui/label";
|
||||
import { Input } from "./ui/input";
|
||||
import { RadioGroup, RadioGroupItem } from "./ui/radio-group";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectGroup,
|
||||
SelectItem,
|
||||
SelectLabel,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
import { Operations } from "@/constants";
|
||||
import useData from "@/store/useData";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { OperateByInspector } from "@/utils/inspectorApi";
|
||||
import { toast } from "sonner";
|
||||
import { postComplaintsDetails } from "@/utils/citizenApi";
|
||||
|
||||
const FormSchema = z.object({
|
||||
bio: z
|
||||
.string()
|
||||
.min(10, {
|
||||
message: "Bio must be at least 10 characters.",
|
||||
export default function InspectorOperations({
|
||||
complaintData,
|
||||
role,
|
||||
updateData,
|
||||
}: {
|
||||
complaintData: any;
|
||||
role: string;
|
||||
updateData: () => any;
|
||||
}) {
|
||||
const FormSchema = z.object({
|
||||
text: z
|
||||
.string({ required_error: "لطفا متن خود را وارد نمایید." })
|
||||
.min(8, {
|
||||
message: "Bio must be at least 8 characters.",
|
||||
})
|
||||
.max(160, {
|
||||
.max(260, {
|
||||
message: "Bio must not be longer than 30 characters.",
|
||||
}),
|
||||
});
|
||||
...(role == "Inspector" && {
|
||||
type: z.enum(["private", "public"], {
|
||||
required_error: "لطفا وضعیت عملیات را انتخاب نمایید.",
|
||||
}),
|
||||
}),
|
||||
operation: z.string({
|
||||
required_error: "Please select an email to display.",
|
||||
}),
|
||||
media: z
|
||||
.custom<FileList>((val) => val instanceof FileList, "Required")
|
||||
// .refine((files) => files.length > 0, `Required`)
|
||||
.refine((files) => files.length <= 5, `Maximum of 5 File are allowed.`)
|
||||
.nullish(),
|
||||
});
|
||||
const password = useData((state) => state.data.password);
|
||||
const possibleOperations = complaintData?.possibleOperations;
|
||||
const selectOptions = Operations.filter((item, index) =>
|
||||
possibleOperations.includes(index)
|
||||
);
|
||||
|
||||
export default function InspectorOperations() {
|
||||
const form = useForm<z.infer<typeof FormSchema>>({
|
||||
resolver: zodResolver(FormSchema),
|
||||
defaultValues: {
|
||||
operation:
|
||||
selectOptions.length == 1 ? String(selectOptions[0].value) : undefined,
|
||||
},
|
||||
});
|
||||
|
||||
const OperationMutation = useMutation({
|
||||
mutationKey: ["Operation"],
|
||||
mutationFn:
|
||||
role == "Inspector" ? OperateByInspector : postComplaintsDetails,
|
||||
onSuccess: (res) => {
|
||||
toast("عملیات شما با موفقیت انجام شد. ", {
|
||||
className: "!bg-green-500 !text-white",
|
||||
});
|
||||
},
|
||||
onError: (err) => {},
|
||||
});
|
||||
|
||||
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>
|
||||
),
|
||||
});
|
||||
console.log(data);
|
||||
const formData = new FormData();
|
||||
formData.append("text", data.text);
|
||||
formData.append("trackingNumber", complaintData.trackingNumber);
|
||||
formData.append("Operation", data.operation);
|
||||
if (data.type) {
|
||||
formData.append("IsPublic", data.type == "public" ? "true" : "false");
|
||||
}
|
||||
if (role == "Inspector") {
|
||||
formData.append("EncodedKey", password);
|
||||
} else {
|
||||
formData.append("password", localStorage.getItem("password2") as string);
|
||||
}
|
||||
if (data?.media && data?.media?.length > 0) {
|
||||
for (let i = 0; i < data.media.length; i++) {
|
||||
formData.append("Medias", data.media[i]);
|
||||
}
|
||||
}
|
||||
OperationMutation.mutate(formData);
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
@ -52,13 +119,13 @@ export default function InspectorOperations() {
|
|||
<form onSubmit={form.handleSubmit(onSubmit)} className="">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="bio"
|
||||
name="text"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel className="">متن</FormLabel>
|
||||
<FormControl>
|
||||
<Textarea
|
||||
placeholder="Tell us a little bit about yourself"
|
||||
placeholder="متن خود را وارد نمایید"
|
||||
className="resize-none bg-white"
|
||||
{...field}
|
||||
/>
|
||||
|
|
@ -70,10 +137,33 @@ export default function InspectorOperations() {
|
|||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<div className="grid w-full max-w-sm items-center gap-1.5 mt-1">
|
||||
{/* <div className="grid w-full max-w-sm items-center gap-1.5 mt-1">
|
||||
<Label htmlFor="picture">پیوست</Label>
|
||||
<Input multiple id="picture" type="file" className=" bg-white" />
|
||||
</div>
|
||||
</div> */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="media"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>پیوست</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
accept=".jpg, .jpeg, .png, .svg, .gif, .mp4 , .pdf"
|
||||
type="file"
|
||||
onChange={(e) => {
|
||||
field.onChange(e.target.files ? e.target.files : null);
|
||||
console.log(e.target.files);
|
||||
}}
|
||||
multiple
|
||||
className=" bg-white"
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
{role == "Inspector" && (
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="type"
|
||||
|
|
@ -103,8 +193,56 @@ export default function InspectorOperations() {
|
|||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<div className=" flex justify-end mt-1">
|
||||
<Button className=" bg-blue" type="submit">
|
||||
)}
|
||||
|
||||
<div className=" flex justify-between mt-3 gap-2">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="operation"
|
||||
render={({ field }) => (
|
||||
<FormItem className=" flex-1">
|
||||
{/* <FormLabel>Email</FormLabel> */}
|
||||
<Select
|
||||
onValueChange={field.onChange}
|
||||
defaultValue={field.value}
|
||||
dir="rtl"
|
||||
>
|
||||
<FormControl>
|
||||
<SelectTrigger
|
||||
className=" bg-white h-10 !placeholder:text-xs text-xs"
|
||||
dir="rtl"
|
||||
>
|
||||
<SelectValue
|
||||
className=" text-xs"
|
||||
placeholder="نوع عملیات را انتخاب نمایید."
|
||||
/>
|
||||
</SelectTrigger>
|
||||
</FormControl>
|
||||
<SelectContent dir="rtl">
|
||||
<SelectGroup>
|
||||
<SelectLabel>عملیات</SelectLabel>
|
||||
{selectOptions.map((item) => {
|
||||
return (
|
||||
<SelectItem value={String(item.value)}>
|
||||
{item.name}
|
||||
</SelectItem>
|
||||
);
|
||||
})}
|
||||
</SelectGroup>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
{/* <FormDescription>
|
||||
You can manage email addresses in your{" "}
|
||||
</FormDescription> */}
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<Button
|
||||
disabled={possibleOperations.length == 0}
|
||||
className=" bg-blue w-1/3"
|
||||
type="submit"
|
||||
>
|
||||
ثبت
|
||||
</Button>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -368,7 +368,6 @@ export default function RequestStep2() {
|
|||
</div>
|
||||
{/* Captcha */}
|
||||
<div className="flex flex-row flex-wrap justify-between">
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="captchaValue"
|
||||
|
|
@ -401,7 +400,6 @@ export default function RequestStep2() {
|
|||
)}
|
||||
{/* <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">
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ export default function Search({ mode }: { mode: string }) {
|
|||
className={`mb-0 h-8 bg-[#D6D8DE66] border-none focus-visible:none rounded-lg
|
||||
block w-full min-w-[13rem] lg:min-w-[16rem] text-xs text-black
|
||||
text-opacity-60 dark:text-white
|
||||
${mode === "controller" && "h-12 max-lg:min-w-[95vw]"}
|
||||
${mode === "controller" && "h-14 max-lg:min-w-[95vw]"}
|
||||
${
|
||||
mode === "admin" &&
|
||||
"w-full min-w-full bg-white lg:min-w-full h-11"
|
||||
|
|
|
|||
|
|
@ -80,9 +80,9 @@ export default function TabController() {
|
|||
</Button>
|
||||
</DialogTrigger>
|
||||
<Tabs defaultValue="tab1" className="" dir="rtl">
|
||||
<div className="w-full flex flex-col-reverse lg:flex-row gap-4 lg:gap-12 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 */}
|
||||
<TabsList className="w-full lg:w-2/3 flex gap-1 md:gap-4 lg:gap-7">
|
||||
<TabsList className="w-full flex gap-1 md:gap-4 lg:gap-7">
|
||||
<p className="3xl:ml-6 text-xs sm:text-sm font-bold">
|
||||
لیست شکایت ها |
|
||||
</p>
|
||||
|
|
@ -108,6 +108,12 @@ export default function TabController() {
|
|||
<TabsTrigger
|
||||
value="tab4"
|
||||
className="hover:border-b-2 border-b-blue"
|
||||
>
|
||||
پاسخ داده شده
|
||||
</TabsTrigger>
|
||||
<TabsTrigger
|
||||
value="tab5"
|
||||
className="hover:border-b-2 border-b-blue"
|
||||
>
|
||||
پایان یافته
|
||||
</TabsTrigger>
|
||||
|
|
@ -140,6 +146,13 @@ export default function TabController() {
|
|||
</TabsContent>
|
||||
|
||||
<TabsContent value="tab4">
|
||||
<TableController
|
||||
checkKey={(item: any) => checkKey(item)}
|
||||
data={citizenRepliedComplaints}
|
||||
/>
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="tab5">
|
||||
<TableController
|
||||
checkKey={(item: any) => checkKey(item)}
|
||||
data={finishedComplaints}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import React, { useEffect, useState } from "react";
|
|||
import LoginIcon from "../public/img/login-icon.svg";
|
||||
import OtpInput from "react-otp-input";
|
||||
import { Button } from "./ui/button";
|
||||
import { verifyStaff } from "@/utils/authenticateApi";
|
||||
import { verifyCitizen, verifyStaff } from "@/utils/authenticateApi";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { useRouter } from "next/navigation";
|
||||
import useData from "@/store/useData";
|
||||
|
|
@ -17,7 +17,7 @@ export default function Verify() {
|
|||
const space = "\xa0";
|
||||
const router = useRouter();
|
||||
const userData = useData((state) => state.data);
|
||||
|
||||
const [VerifyRole, setVerifyRole] = useState<any>("");
|
||||
const verifyMutation = useMutation({
|
||||
mutationFn: verifyStaff,
|
||||
onSuccess: (res) => {
|
||||
|
|
@ -38,11 +38,30 @@ export default function Verify() {
|
|||
},
|
||||
onError: (err: any) => {},
|
||||
});
|
||||
const CitizenVerifyMutation = useMutation({
|
||||
mutationFn: verifyCitizen,
|
||||
onSuccess: (res) => {
|
||||
const decodedToken = jwtDecode<any>(res);
|
||||
setCookie("Sootzani_Token", res);
|
||||
const userRole =
|
||||
decodedToken[
|
||||
"http://schemas.microsoft.com/ws/2008/06/identity/claims/role"
|
||||
];
|
||||
localStorage.setItem("Sootzani_Role", userRole);
|
||||
router.push("/UserPanel/CitizenDashboard");
|
||||
},
|
||||
onError: (err: any) => {},
|
||||
});
|
||||
|
||||
const handelVerify = () => {
|
||||
console.log(otp);
|
||||
const payload = { ...userData, verificationCode: otp };
|
||||
console.log(userData);
|
||||
if (userData?.phoneNumber) {
|
||||
CitizenVerifyMutation.mutate(payload);
|
||||
} else {
|
||||
verifyMutation.mutate(payload);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
|
@ -68,7 +87,7 @@ export default function Verify() {
|
|||
renderInput={(props, idx) => (
|
||||
<input
|
||||
autoFocus={idx == 0}
|
||||
inputmode="decimal"
|
||||
inputMode="decimal"
|
||||
pattern="[0-9]*"
|
||||
{...props}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -123,12 +123,12 @@ const SelectItem = React.forwardRef<
|
|||
<SelectPrimitive.Item
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
||||
"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<span className="absolute right-2 flex h-3.5 w-3.5 items-center justify-center">
|
||||
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
||||
<SelectPrimitive.ItemIndicator>
|
||||
<CheckIcon className="h-4 w-4" />
|
||||
</SelectPrimitive.ItemIndicator>
|
||||
|
|
|
|||
|
|
@ -37,12 +37,20 @@ export const boxItems = [
|
|||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "مشاهده آمار",
|
||||
icon: "/img/box3.svg",
|
||||
icon2: "/img/box3-hover.svg",
|
||||
description: "مشاهده آمار و گزارشات درخواست ها",
|
||||
link: "/",
|
||||
name: "ثبت شکایت(شناس)",
|
||||
icon: "/img/box1.svg",
|
||||
icon2: "/img/box1-hover.svg",
|
||||
description: "ارسال درخواست نارضایتی از پرسنل",
|
||||
link: "/CitizenLogin",
|
||||
},
|
||||
// {
|
||||
// id: 3,
|
||||
// name: "مشاهده آمار",
|
||||
// icon: "/img/box3.svg",
|
||||
// icon2: "/img/box3-hover.svg",
|
||||
// description: "مشاهده آمار و گزارشات درخواست ها",
|
||||
// link: "/",
|
||||
// },
|
||||
];
|
||||
|
||||
export const newsItems = [
|
||||
|
|
@ -133,7 +141,11 @@ export const ControllerMenuItems = [
|
|||
|
||||
export const AdminMenuItems = [
|
||||
{ id: 1, name: "داشبورد", href: "/UserPanel/AdminDashboard" },
|
||||
{ id: 2, name: "مدیریت کاربران", href: "/UserPanel/AdminDashboard/Management" },
|
||||
{
|
||||
id: 2,
|
||||
name: "مدیریت کاربران",
|
||||
href: "/UserPanel/AdminDashboard/Management",
|
||||
},
|
||||
{ id: 2, name: "تنظیمات", href: "/UserPanel/AdminDashboard" },
|
||||
{ id: 3, name: "گزارشات و آمار", href: "/UserPanel/AdminDashboard" },
|
||||
];
|
||||
|
|
@ -190,7 +202,6 @@ export const ComplainDetailsItems = [
|
|||
},
|
||||
];
|
||||
|
||||
|
||||
export const AdminCardItems = [
|
||||
{ id: 1, name: "تعداد گزارشات ارسال شده", count: "100" },
|
||||
{ id: 2, name: "تعداد گزارشات ارسال شده", count: "200" },
|
||||
|
|
@ -202,7 +213,7 @@ export const AdminTableItems = [
|
|||
{
|
||||
id: 1,
|
||||
name: "محمد یزدی زاده",
|
||||
phone:"09134504190",
|
||||
phone: "09134504190",
|
||||
useRole: "ادمین",
|
||||
date: "1402/09/05",
|
||||
desc: "واحد روابط عمومی شهرداری",
|
||||
|
|
@ -210,9 +221,20 @@ export const AdminTableItems = [
|
|||
{
|
||||
id: 2,
|
||||
name: "محسن یزدی پناه",
|
||||
phone:"09134504190",
|
||||
phone: "09134504190",
|
||||
useRole: "ادمین",
|
||||
date: "1402/09/05",
|
||||
desc: "واحد روابط عمومی شهرداری",
|
||||
},
|
||||
];
|
||||
|
||||
export const Operations = [
|
||||
{value:0,name:"ثبت شده"},
|
||||
{value:1,name:"دیدن"},
|
||||
{value:2,name:"درخواست توضیحات"},
|
||||
{value:3,name:"پاسخ شهروند"},
|
||||
{value:4,name:"لغو درخواست"},
|
||||
{value:5,name:"افزودن جزییات"},
|
||||
{value:6,name:"پایان درخواست"},
|
||||
{value:7,name:"شروع مجدد درخواست"},
|
||||
];
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ export function convertDate(date: string) {
|
|||
.calendar("jalali")
|
||||
.locale("fa")
|
||||
.format("YYYY/M/DD");
|
||||
console.log(convertDate);
|
||||
return convertedDate;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,8 +25,7 @@ export async function verifyStaff(payload: {
|
|||
}
|
||||
|
||||
export async function logisterCitizen(payload: {
|
||||
username: string;
|
||||
password: string;
|
||||
phoneNumber: string;
|
||||
captcha: {
|
||||
key: string;
|
||||
value: string;
|
||||
|
|
@ -38,10 +37,7 @@ export async function logisterCitizen(payload: {
|
|||
|
||||
export async function verifyCitizen(payload: {
|
||||
phoneNumber: string;
|
||||
captcha: {
|
||||
key: string;
|
||||
value: string;
|
||||
};
|
||||
verificationCode: string;
|
||||
}) {
|
||||
const data = await axios.post("api/Authenticate/VerifyCitizen", payload);
|
||||
return data.data;
|
||||
|
|
|
|||
|
|
@ -3,33 +3,24 @@ import { CookieValueTypes } from "cookies-next";
|
|||
|
||||
axios.defaults.baseURL = "https://sootzaniapi.shetabdahi.ir/";
|
||||
|
||||
|
||||
|
||||
// Post Complaints
|
||||
export async function postComplaintSubmit( {Data} : {Data: FormData;}) {
|
||||
const data = await axios.post(
|
||||
`api/Citizen`,
|
||||
Data,
|
||||
);
|
||||
export async function postComplaintSubmit({ Data }: { Data: FormData }) {
|
||||
const data = await axios.post(`api/Citizen`, Data);
|
||||
return data.data;
|
||||
}
|
||||
}
|
||||
|
||||
// Post 1 Complaints
|
||||
export async function postComplaintTracking({Data} : {
|
||||
Data: { trackingNumber: string; password :string;}
|
||||
}) {
|
||||
const data = await axios.post(
|
||||
`api/Citizen/Get`,
|
||||
// Post 1 Complaints
|
||||
export async function postComplaintTracking({
|
||||
Data,
|
||||
);
|
||||
}: {
|
||||
Data: { trackingNumber: string; password: string };
|
||||
}) {
|
||||
const data = await axios.post(`api/Citizen/Get`, Data);
|
||||
return data.data;
|
||||
}
|
||||
|
||||
// Post Complaints Details "citizen / Oprate"
|
||||
export async function postComplaintsDetails( {Data} : {Data: FormData;}) {
|
||||
const data = await axios.post(
|
||||
`api/Citizen/Operate`,
|
||||
Data,
|
||||
);
|
||||
export async function postComplaintsDetails(payload: FormData) {
|
||||
const data = await axios.post(`api/Citizen/Operate`, payload);
|
||||
return data.data;
|
||||
}
|
||||
|
|
@ -24,10 +24,9 @@ export async function getComplaint(payload: {
|
|||
return data.data;
|
||||
}
|
||||
|
||||
export async function OperateByInspector(payload: {
|
||||
trackingNumber: string;
|
||||
password: string;
|
||||
}) {
|
||||
const data = await axios.post(`api/Inspector/Operate`, payload);
|
||||
export async function OperateByInspector(payload: FormData) {
|
||||
const data = await axios.post(`api/Inspector/Operate`, payload, {
|
||||
headers: { "Content-Type": "multipart/form-data" },
|
||||
});
|
||||
return data.data;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue