- درخواست شما با کد رهگیری 1243230783 و رمز عبور 12422 در دست بررسی و
- اقدام می باشد. در صورت تمایل می توانید با شماره تلفن 0353286545 جهت
- پشتیبانی تماس حاصل کنید.
+ درخواست شما با کد رهگیری
+ {`${trackingNumber}`}و
+ رمز عبور
+ {`${password}`}
+ در دست بررسی و اقدام می باشد. در صورت تمایل می توانید با شماره تلفن
+ 0353286545 جهت پشتیبانی تماس حاصل کنید.
@@ -36,34 +83,72 @@ export default function FollowResult() {
-
گزارش شکایات
-
-
+
+ گزارش شکایات
+
+
+
+
+
-
موضوع شکایت: متن تستی
-
موضوع شکایت: متن تستی
-
موضوع شکایت: متن تستی
-
موضوع شکایت:
-
-
درخواست شما با کد رهگیری 1243230783 و رمز عبور 12422 در دست بررسی و اقدام می باشد. در صورت تمایل می توانید با شماره تلفن 0353286545 جهت پشتیبانی تماس حاصل کنید.
+ درخواست شما با کد رهگیری 1243230783 و رمز عبور 12422 در
+ دست بررسی و اقدام می باشد. در صورت تمایل می توانید با
+ شماره تلفن 0353286545 جهت پشتیبانی تماس حاصل کنید.{" "}
+
+ >
+ )}
{/* Cancel */}
- پرینت گزارش
+
diff --git a/components/FollowUp.tsx b/components/FollowUp.tsx
index 7f1c4c4..bd7a0b1 100644
--- a/components/FollowUp.tsx
+++ b/components/FollowUp.tsx
@@ -4,6 +4,8 @@ import React from "react";
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form";
import * as z from "zod";
+import { useRouter } from "next/navigation";
+import { useMutation } from "@tanstack/react-query";
import { Button } from "@/components/ui/button";
import {
@@ -22,10 +24,11 @@ import { Textarea } from "@/components/ui/textarea";
import Image from "next/image";
import Link from "next/link";
import FollowResult from "./FollowResult";
+import { postComplaintTracking } from "@/utils/citizenApi";
const FormSchema = z.object({
- fllowCode: z.string().min(2, {
- message: "fllowCode must be at least 2 characters.",
+ trackingNumber: z.string().min(2, {
+ message: "trackingNumber must be at least 2 characters.",
}),
password: z.string().min(4, {
message: "Password must be at least 4 characters.",
@@ -33,10 +36,48 @@ const FormSchema = z.object({
});
export default function FollowUp() {
+ const router = useRouter();
+
+ const complaintTrackingMutation = useMutation({
+ mutationKey: ["complaintTracking"],
+ mutationFn: postComplaintTracking,
+
+ onSuccess: (res) => {
+ const result = res;
+ console.log(res);
+ console.log(result);
+
+ alert("Success");
+
+ // router.push("/FollowResult");
+ router.push("/FollowResult", {data: JSON.stringify( result ) });
+
+ // router.push(
+ // "/FollowResult",
+ // {
+ // data: JSON.stringify(result),
+ // },
+ // );
+
+ // router.push({
+ // pathname : '/FollowResult',
+ // query : {
+ // data: JSON.stringify( result ) ;
+ // },
+ // });
+
+ // return (res)
+ },
+ onError: (error) => {
+ console.log(error);
+ console.log(error?.message);
+ },
+ });
+
const form = useForm>({
resolver: zodResolver(FormSchema),
defaultValues: {
- fllowCode: "",
+ trackingNumber: "",
password: "",
},
});
@@ -50,7 +91,15 @@ export default function FollowUp() {
),
});
+
console.log(data);
+
+ localStorage.setItem("trackingNumber2", data.trackingNumber);
+ localStorage.setItem("password2", data.password);
+
+ complaintTrackingMutation.mutate({
+ Data: { trackingNumber: data.trackingNumber, password: data.password },
+ });
}
return (
@@ -68,7 +117,7 @@ export default function FollowUp() {
(
@@ -106,13 +155,13 @@ export default function FollowUp() {
diff --git a/components/PrintPage.tsx b/components/PrintPage.tsx
new file mode 100644
index 0000000..c4e1a12
--- /dev/null
+++ b/components/PrintPage.tsx
@@ -0,0 +1,15 @@
+import React from 'react'
+import { Button } from './ui/button'
+
+export default function PrintPage() {
+ function handlePrint() {
+ window.print()
+ //the window.print() command is what is telling the browser to print the page
+ }
+ return (
+
+//the onClick function is built into React to look for a click event!
+
+ )
+}
+
\ No newline at end of file
diff --git a/components/RequestResult.tsx b/components/RequestResult.tsx
index e655fdf..81e994c 100644
--- a/components/RequestResult.tsx
+++ b/components/RequestResult.tsx
@@ -1,23 +1,51 @@
-import React from "react";
+"use client";
+
+import React, { useEffect } from "react";
import Image from "next/image";
import Resultimg from "../public/img/result.png";
+import { useQuery, useQueryClient } from "@tanstack/react-query";
+import { useRouter } from "next/navigation";
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 (
-
-
با تشکر از شما
-
-
- درخواست شما با کد پیگیری 258945885 و رمز عبور 5845 در سامانه سوت زنی
- ثبت شده و شما می توانید نتیجه درخواست خود را از صفحه پیگیری درخواست،
- با استفاده از کد رهگیری و رمز عبور مشاهده کنید.
+ با تشکر از شما
-
+
+ درخواست شما با کد پیگیری
+
+ {`${trackingNumber}`}
+
+ و رمز عبور
+
+ {`${password}`}
+
+ در سامانه سوت زنی ثبت شده و شما می توانید نتیجه درخواست خود را از صفحه
+ پیگیری درخواست، با استفاده از کد رهگیری و رمز عبور مشاهده کنید.
+
+
+
);
diff --git a/components/RequestStep2.tsx b/components/RequestStep2.tsx
index 25cc457..e8e914e 100644
--- a/components/RequestStep2.tsx
+++ b/components/RequestStep2.tsx
@@ -1,5 +1,5 @@
"use client";
-import React from "react";
+import React, { useState } from "react";
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form";
@@ -15,12 +15,38 @@ import {
FormLabel,
FormMessage,
} from "@/components/ui/form";
+
+import {
+ Select,
+ SelectContent,
+ SelectGroup,
+ SelectItem,
+ SelectLabel,
+ SelectTrigger,
+ SelectValue,
+} from "@/components/ui/select";
+
import { Input } from "@/components/ui/input";
import { toast } from "@/components/ui/use-toast";
import { Textarea } from "@/components/ui/textarea";
-
+import { Label } from "@/components/ui/label";
import Link from "next/link";
import RequestResult from "./RequestResult";
+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 { useRouter } from "next/navigation";
+import { getCaptcha, getCategory } from "@/utils/commonApi";
+
+const MAX_IMAGE_SIZE = 5242880; // 5 MB
+const ALLOWED_IMAGE_TYPES = [
+ "image/jpeg",
+ "image/png",
+ "image/webp",
+ "image/jpg",
+];
const FormSchema = z.object({
subject: z.string().min(2, {
@@ -40,9 +66,72 @@ const FormSchema = z.object({
.max(200, {
message: "description must not be longer than 200 characters.",
}),
+ uploadFile: z
+ .custom((val) => val instanceof FileList, "Required")
+ .refine((files) => files.length > 0, `Required`)
+ .refine((files) => files.length <= 5, `Maximum of 5 File are allowed.`)
+ .refine(
+ (files) => Array.from(files).every((file) => file.size <= MAX_IMAGE_SIZE),
+ `Each file size should be less than 5 MB.`
+ )
+ .refine(
+ (files) =>
+ Array.from(files).every((file) =>
+ ALLOWED_IMAGE_TYPES.includes(file.type)
+ ),
+ "Only these types are allowed .jpg, .jpeg, .png and .webp"
+ ),
+ categoryId: z.string({
+ required_error: "Please select an category to display.",
+ }),
+ captchaValue: z.string().min(4, {
+ message: "captcha must be at least 4 characters.",
+ }),
});
+// Form Hook
export default function RequestStep2() {
+ // const [trackingComplaint, setTrackingComplaint] = useState({});
+
+ const router = useRouter();
+
+ const complaintSubmitMutation = useMutation({
+ mutationKey: ["complaintSubmit"],
+ mutationFn: postComplaintSubmit,
+
+ onSuccess: (res) => {
+ console.log(res);
+ localStorage.setItem("trackingNumber", res.trackingNumber);
+ localStorage.setItem("password", res.password);
+
+ alert("Success");
+ router.push("/RequestResult");
+ // router.push("/RequestResult", { data: trackingComplaint });
+ // return (res)
+ },
+ onError: (error) => {
+ console.log(error);
+ console.log(error?.message);
+ },
+ });
+
+ // All Category
+ const { data: categoryData } = useQuery({
+ queryKey: ["Category"],
+ queryFn: () => getCategory(),
+ });
+
+ // Captcha
+ const { data: CaptchaData, isLoading } = useQuery({
+ queryKey: ["Captcha"],
+ queryFn: () => getCaptcha(),
+ });
+ // console.log(captchaData);
+
+ const srcForImage = CaptchaData
+ ? URL.createObjectURL(CaptchaData.data)
+ : null;
+
const form = useForm>({
resolver: zodResolver(FormSchema),
defaultValues: {
@@ -50,34 +139,56 @@ export default function RequestStep2() {
organisation: "",
person: "",
description: "",
+ captchaValue: "",
+ // uploadFile: null,
},
});
function onSubmit(data: z.infer) {
- toast({
- title: "You submitted the following values:",
- description: (
-
- {JSON.stringify(data, null, 2)}
-
- ),
+ // toast({
+ // title: "You submitted the following values:",
+ // description: (
+ //