Compare commits

..

No commits in common. "f0d4d976ca08e51fd9c512edcad53e7727f1eaca" and "08f9fd2fa5c8d4fd7e71b318b0637f81e9802e98" have entirely different histories.

16 changed files with 124 additions and 774 deletions

View File

@ -2,6 +2,7 @@ import ReportsController from '@/components/ReportsController'
import React from 'react' import React from 'react'
export default function page() { export default function page() {
const a = useMut
return ( return (
<ReportsController /> <ReportsController />
) )

View File

@ -10,49 +10,31 @@ import Link from "next/link";
import bgimg from "../../public/img/bg.png"; import bgimg from "../../public/img/bg.png";
import Footer from "@/components/Footer"; import Footer from "@/components/Footer";
// Import Swiper React components
import { Swiper, SwiperSlide } from "swiper/react";
// Import Swiper styles
import "swiper/css";
import "swiper/css/pagination";
// import required modules
import { Pagination } from "swiper/modules";
import { sliderItems } from "@/constants";
export default function Landing() { export default function Landing() {
return ( return (
<div> <div>
<div className="w-screen bg-top lg:bg-center bg-no-repeat h-[13rem] sm:h-[20rem] md:h-[24rem] xl:h-[33rem]"> <div
<Swiper style={{
slidesPerView={1} // backgroundSize: "cover",
spaceBetween={0} // backgroundSize: "100%"
pagination={{ }}
clickable: true, className="w-full bg-top lg:bg-center bg-no-repeat h-[13rem] sm:h-[20rem] md:h-[24rem] xl:h-[33rem]"
}} >
<Image
className="mySwiper w-full h-full" alt="bg"
> src={bgimg}
{sliderItems.map((item) => { // width={20}
return ( // height={20}
<SwiperSlide key={item.id}> quality={100}
<Image className=" w-full h-full bg-cover"
alt="bg" />
src={bgimg} {/* <Navbar /> */}
// width={20} </div>
// height={20}
quality={100}
className=" w-full h-full bg-cover"
/>
</SwiperSlide>
);
})}
</Swiper>
</div>
<div className="3xl:w-[60%] w-[75%] mx-auto max-md:mt-5"> <div className="3xl:w-[60%] w-[75%] mx-auto max-md:mt-5">
<div className="flex justify-between gap-6 w-full mx-auto -mt-24 max-md:mt-0 max-sm:flex-wrap max-sm:justify-around "> <div className="flex justify-between gap-6 w-full mx-auto -mt-24 max-md:mt-0 max-sm:flex-wrap max-sm:justify-around ">
{boxItems.map((item, index) => { {boxItems.map((item, index) => {
return ( return (
<Link <Link
className="group bg-white shadow-md rounded-lg p-10 h-64 w-64 flex items-end justify-center z-10 relative className="group bg-white shadow-md rounded-lg p-10 h-64 w-64 flex items-end justify-center z-10 relative
hover:bg-blue transition-all duration-700 ease-in-out text-center hover:bg-blue transition-all duration-700 ease-in-out text-center
@ -94,6 +76,7 @@ export default function Landing() {
className=" w-[45%] h-[45%] hidden group-hover:flex" className=" w-[45%] h-[45%] hidden group-hover:flex"
/> />
</Link> </Link>
); );
})} })}
</div> </div>
@ -172,11 +155,13 @@ export default function Landing() {
</div> </div>
</div> </div>
</div> </div>
{/* Counter */} {/* Counter */}
<Counter /> <Counter />
{/*SubmitRequest */} {/*SubmitRequest */}
<SubmitRequest /> <SubmitRequest />
{/* Footer */}
<Footer /> <Footer />
</div> </div>
); );

View File

@ -89,5 +89,3 @@
width: 100%; width: 100%;
height: 100vh; height: 100vh;
} }

View File

@ -25,7 +25,7 @@ export default function RootLayout({
<Navbar /> <Navbar />
<NavbarSm /> <NavbarSm />
<div className="flex justify-center overflow-x-hidden">{children}</div> <div className="flex justify-center ">{children}</div>
<Toaster /> <Toaster />
</Provider> </Provider>

View File

@ -1,9 +1,7 @@
"use client"; import React from "react";
import React, { useEffect, useState } from "react";
import Image from "next/image"; import Image from "next/image";
import Resultimg from "../public/img/followResult.png"; import Resultimg from "../public/img/followResult.png";
import Link from "next/link"; import Link from "next/link";
import { useRouter } from "next/navigation";
import { import {
AlertDialog, AlertDialog,
@ -18,63 +16,18 @@ import {
} from "@/components/ui/alert-dialog"; } from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { IoMdClose } from "react-icons/io"; import { IoMdClose } from "react-icons/io";
import { postComplaintTracking } from "@/utils/citizenApi";
import { useMutation } from "@tanstack/react-query";
export default function FollowResult() { export default function FollowResult() {
const router = useRouter();
const [trackingNumber, setTrackingNumber] = useState<any>();
const [password, setPassword] = useState<any>();
const [complaintData, setComplaintData] = useState<any>();
useEffect(() => {
setTrackingNumber(localStorage.getItem("trackingNumber2"));
setPassword(localStorage.getItem("password2"));
}, []);
const complaintPrintMutation = useMutation({
mutationKey: ["complaintPrint"],
mutationFn: postComplaintTracking,
onSuccess: (res) => {
console.log(res);
alert("SuccessPrint");
console.log(res);
setComplaintData(res)
console.log(complaintData);
},
onError: (error) => {
console.log(error);
console.log(error?.message);
},
});
function onSubmit() {
console.log("SuccessPrinttttttttttt");
complaintPrintMutation.mutate({
Data: { trackingNumber: trackingNumber, password: password },
});
}
function handlePrint() {
window.print();
}
return ( return (
<div className="w-full h-full sm:w-2/3 md:w-3/4 lg:w-1/2 max-sm:p-8 pt-12"> <div className="w-full h-full sm:w-2/3 md:w-3/4 lg:w-1/2 max-sm:p-8 pt-12">
<div className="h-full flex flex-col justify-center"> <div className="h-full flex flex-col justify-center">
<p <p
className="text-sm font-medium leading-6 tracking-wide text-[#7C838A] dark:text-white className="text-sm font-medium leading-6 tracking-wide text-[#7C838A] dark:text-white
3xl:text-base 3xl:font-bold " 3xl:text-base 3xl:font-bold "
> >
درخواست شما با کد رهگیری درخواست شما با کد رهگیری 1243230783 و رمز عبور 12422 در دست بررسی و
<span className="text-slate-500 mx-2">{`${trackingNumber}`}</span>و اقدام می باشد. در صورت تمایل می توانید با شماره تلفن 0353286545 جهت
رمز عبور پشتیبانی تماس حاصل کنید.
<span className="text-slate-500 mx-2">{`${password}`}</span>
در دست بررسی و اقدام می باشد. در صورت تمایل می توانید با شماره تلفن
0353286545 جهت پشتیبانی تماس حاصل کنید.
</p> </p>
<div className="flex justify-center sm:justify-end gap-2 w-full mt-8"> <div className="flex justify-center sm:justify-end gap-2 w-full mt-8">
@ -83,72 +36,34 @@ export default function FollowResult() {
<Button <Button
variant="outline" variant="outline"
type="submit" 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-1/2 sm:w-1/3 lg:w-1/4 bg-blue text-white p-2 rounded-xl text-center"
> >
پرینت درخواست پرینت درخواست
</Button> </Button>
</AlertDialogTrigger> </AlertDialogTrigger>
<AlertDialogContent> <AlertDialogContent>
<AlertDialogHeader> <AlertDialogHeader>
<AlertDialogTitle> <AlertDialogTitle>
<p className="text-[#464646] text-base font-bold"> <p className="text-[#464646] text-base font-bold">گزارش شکایات</p>
گزارش شکایات
</p>
<AlertDialogCancel className="p-0 border-0 h-auto"> <AlertDialogCancel className="p-0 border-0 h-auto"><IoMdClose /></AlertDialogCancel>
<IoMdClose />
</AlertDialogCancel>
</AlertDialogTitle> </AlertDialogTitle>
<AlertDialogDescription> <AlertDialogDescription>
{complaintPrintMutation.isSuccess && ( <p className="text-[#464646] text-sm font-medium"> موضوع شکایت: <span className="text-[#7C838A] text-sm font-medium">متن تستی</span></p>
<> <p className="text-[#464646] text-sm font-medium"> موضوع شکایت: <span className="text-[#7C838A] text-sm font-medium">متن تستی</span></p>
{" "} <p className="text-[#464646] text-sm font-medium"> موضوع شکایت: <span className="text-[#7C838A] text-sm font-medium">متن تستی</span></p>
<p className="text-[#464646] text-sm font-medium"> <p className="text-[#464646] text-sm font-medium"> موضوع شکایت:</p>
{" "} <br/>
موضوع شکایت:{" "} <p className="text-[#464646] text-sm font-medium">درخواست شما با کد رهگیری 1243230783 و رمز عبور 12422 در دست بررسی و اقدام می باشد. در صورت تمایل می توانید با شماره تلفن 0353286545 جهت پشتیبانی تماس حاصل کنید. </p>
<span className="text-[#7C838A] text-sm font-medium">
{`${complaintData?.title}`}
</span>
</p>
<p className="text-[#464646] text-sm font-medium">
{" "}
موضوع شکایت:{" "}
<span className="text-[#7C838A] text-sm font-medium">
متن تستی
</span>
</p>
<p className="text-[#464646] text-sm font-medium">
{" "}
موضوع شکایت:{" "}
<span className="text-[#7C838A] text-sm font-medium">
متن تستی
</span>
</p>
<p className="text-[#464646] text-sm font-medium">
{" "}
موضوع شکایت:
</p>
<br />
<p className="text-[#464646] text-sm font-medium">
درخواست شما با کد رهگیری 1243230783 و رمز عبور 12422 در
دست بررسی و اقدام می باشد. در صورت تمایل می توانید با
شماره تلفن 0353286545 جهت پشتیبانی تماس حاصل کنید.{" "}
</p>
</>
)}
</AlertDialogDescription> </AlertDialogDescription>
</AlertDialogHeader> </AlertDialogHeader>
<AlertDialogFooter> <AlertDialogFooter>
{/* <AlertDialogCancel>Cancel</AlertDialogCancel> */} {/* <AlertDialogCancel>Cancel</AlertDialogCancel> */}
<Button <AlertDialogAction className="bg-blue text-white w-1/2 sm:w-1/6">پرینت گزارش</AlertDialogAction>
className="bg-blue text-white w-1/2 sm:w-1/6"
onClick={handlePrint}
>
پرینت گزارش
</Button>
</AlertDialogFooter> </AlertDialogFooter>
</AlertDialogContent> </AlertDialogContent>
</AlertDialog> </AlertDialog>

View File

@ -4,8 +4,6 @@ import React from "react";
import { zodResolver } from "@hookform/resolvers/zod"; import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form"; import { useForm } from "react-hook-form";
import * as z from "zod"; import * as z from "zod";
import { useRouter } from "next/navigation";
import { useMutation } from "@tanstack/react-query";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { import {
@ -24,11 +22,10 @@ import { Textarea } from "@/components/ui/textarea";
import Image from "next/image"; import Image from "next/image";
import Link from "next/link"; import Link from "next/link";
import FollowResult from "./FollowResult"; import FollowResult from "./FollowResult";
import { postComplaintTracking } from "@/utils/citizenApi";
const FormSchema = z.object({ const FormSchema = z.object({
trackingNumber: z.string().min(2, { fllowCode: z.string().min(2, {
message: "trackingNumber must be at least 2 characters.", message: "fllowCode must be at least 2 characters.",
}), }),
password: z.string().min(4, { password: z.string().min(4, {
message: "Password must be at least 4 characters.", message: "Password must be at least 4 characters.",
@ -36,48 +33,10 @@ const FormSchema = z.object({
}); });
export default function FollowUp() { 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<z.infer<typeof FormSchema>>({ const form = useForm<z.infer<typeof FormSchema>>({
resolver: zodResolver(FormSchema), resolver: zodResolver(FormSchema),
defaultValues: { defaultValues: {
trackingNumber: "", fllowCode: "",
password: "", password: "",
}, },
}); });
@ -91,15 +50,7 @@ export default function FollowUp() {
</pre> </pre>
), ),
}); });
console.log(data); console.log(data);
localStorage.setItem("trackingNumber2", data.trackingNumber);
localStorage.setItem("password2", data.password);
complaintTrackingMutation.mutate({
Data: { trackingNumber: data.trackingNumber, password: data.password },
});
} }
return ( return (
<div className="w-full h-full sm:w-2/3 md:w-2/4 max-sm:p-8 pt-12"> <div className="w-full h-full sm:w-2/3 md:w-2/4 max-sm:p-8 pt-12">
@ -117,7 +68,7 @@ export default function FollowUp() {
<div className="flex flex-row flex-wrap justify-between"> <div className="flex flex-row flex-wrap justify-between">
<FormField <FormField
control={form.control} control={form.control}
name="trackingNumber" name="fllowCode"
render={({ field }) => ( render={({ field }) => (
<FormItem className=" w-full lg:w-[48%]"> <FormItem className=" w-full lg:w-[48%]">
<FormLabel className="text-[#7C838A] text-sm font-medium"> <FormLabel className="text-[#7C838A] text-sm font-medium">
@ -155,13 +106,13 @@ export default function FollowUp() {
</div> </div>
<div className="flex justify-center sm:justify-end gap-2 w-full mt-8"> <div className="flex justify-center sm:justify-end gap-2 w-full mt-8">
<Button <Link href="/FollowResult"
// href="/FollowResult"
type="submit" type="submit"
className="bg-blue text-white min-w-max w-1/2 sm:w-1/3 lg:w-1/4 p-2 rounded-xl text-center" className="bg-blue text-white min-w-max w-1/2 sm:w-1/3 lg:w-1/4 p-2 rounded-xl text-center"
> >
پیگیری درخواست پیگیری درخواست
</Button> </Link>
</div> </div>
</form> </form>
</Form> </Form>

View File

@ -15,7 +15,7 @@ export default function Navbar() {
const pathname = usePathname() const pathname = usePathname()
return ( return (
<div className={`max-md:hidden left-0 right-0 top-0 z-10 ${pathname === "/" ? "absolute" : "sticky"}`}> <div className={`max-md:hidden left-0 right-0 top-0 ${pathname === "/" ? "absolute" : "sticky"}`}>
<TopNav /> <TopNav />
<div className=" bg-white h-20 shadow-md flex items-center justify-between py-2 px-8"> <div className=" bg-white h-20 shadow-md flex items-center justify-between py-2 px-8">

View File

@ -1,15 +0,0 @@
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 (
<Button onClick={handlePrint}> Print </Button>
//the onClick function is built into React to look for a click event!
)
}

View File

@ -1,51 +1,23 @@
"use client"; import React from "react";
import React, { useEffect } from "react";
import Image from "next/image"; import Image from "next/image";
import Resultimg from "../public/img/result.png"; import Resultimg from "../public/img/result.png";
import { useQuery, useQueryClient } from "@tanstack/react-query";
import { useRouter } from "next/navigation";
export default function Result() { 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 ( return (
<div className="w-full h-full sm:w-2/3 md:w-3/4 lg:w-1/2 max-sm:p-8 pt-12 "> <div className="w-full h-full sm:w-2/3 md:w-3/4 lg:w-1/2 max-sm:p-8 pt-12 ">
<div className="h-full flex flex-col justify-center"> <div className="h-full flex flex-col justify-center">
<p
className="text-sm font-medium leading-6 tracking-wide text-[#7C838A] dark:text-white <p className="text-sm font-medium leading-6 tracking-wide text-[#7C838A] dark:text-white
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 ">
با تشکر از شما درخواست شما با کد پیگیری 258945885 و رمز عبور 5845 در سامانه سوت زنی
ثبت شده و شما می توانید نتیجه درخواست خود را از صفحه پیگیری درخواست،
با استفاده از کد رهگیری و رمز عبور مشاهده کنید.
</p> </p>
<p <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" />
className="text-sm font-medium leading-6 tracking-wide text-[#7C838A] dark:text-white
3xl:text-base 3xl:font-bold ">
درخواست شما با کد پیگیری
<span className="text-slate-500 mx-2">
{`${trackingNumber}`}
</span>
و رمز عبور
<span className="text-slate-500 mx-2">
{`${password}`}
</span>
در سامانه سوت زنی ثبت شده و شما می توانید نتیجه درخواست خود را از صفحه
پیگیری درخواست، با استفاده از کد رهگیری و رمز عبور مشاهده کنید.
</p>
<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> </div>
); );

View File

@ -1,5 +1,5 @@
"use client"; "use client";
import React, { useState } from "react"; import React from "react";
import { zodResolver } from "@hookform/resolvers/zod"; import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form"; import { useForm } from "react-hook-form";
@ -15,38 +15,12 @@ import {
FormLabel, FormLabel,
FormMessage, FormMessage,
} from "@/components/ui/form"; } from "@/components/ui/form";
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectLabel,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { Input } from "@/components/ui/input"; import { Input } from "@/components/ui/input";
import { toast } from "@/components/ui/use-toast"; import { toast } from "@/components/ui/use-toast";
import { Textarea } from "@/components/ui/textarea"; import { Textarea } from "@/components/ui/textarea";
import { Label } from "@/components/ui/label";
import Link from "next/link"; import Link from "next/link";
import RequestResult from "./RequestResult"; 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({ const FormSchema = z.object({
subject: z.string().min(2, { subject: z.string().min(2, {
@ -66,72 +40,9 @@ const FormSchema = z.object({
.max(200, { .max(200, {
message: "description must not be longer than 200 characters.", message: "description must not be longer than 200 characters.",
}), }),
uploadFile: 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.`)
.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() { 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<z.infer<typeof FormSchema>>({ const form = useForm<z.infer<typeof FormSchema>>({
resolver: zodResolver(FormSchema), resolver: zodResolver(FormSchema),
defaultValues: { defaultValues: {
@ -139,44 +50,21 @@ export default function RequestStep2() {
organisation: "", organisation: "",
person: "", person: "",
description: "", description: "",
captchaValue: "",
// uploadFile: null,
}, },
}); });
function onSubmit(data: z.infer<typeof FormSchema>) { function onSubmit(data: z.infer<typeof FormSchema>) {
// toast({ toast({
// title: "You submitted the following values:", title: "You submitted the following values:",
// description: ( description: (
// <pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4"> <pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4">
// <code className="text-white">{JSON.stringify(data, null, 2)}</code> <code className="text-white">{JSON.stringify(data, null, 2)}</code>
// </pre> </pre>
// ), ),
// });
const formData = new FormData();
formData.append("Title", data.subject);
formData.append("Text", data.description);
formData.append("CategoryId", data.categoryId);
formData.append("Medias", data.uploadFile[0]);
formData.append("Captcha.Value", data.captchaValue);
formData.append("Captcha.Key", CaptchaData?.headers["captcha-key"]);
complaintSubmitMutation.mutate({
Data: formData,
}); });
resetField("Title");
resetField("Text");
resetField("Medias");
resetField("CategoryId");
resetField("Captcha.Value");
console.log("submited");
console.log(data); console.log(data);
} }
const { resetField } = useForm();
return ( return (
<div className="w-full h-full sm:w-2/3 md:w-2/4 max-sm:p-8 pt-12"> <div className="w-full h-full sm:w-2/3 md:w-2/4 max-sm:p-8 pt-12">
<div className="space-y-3 md:space-y-4 h-full flex flex-col justify-center"> <div className="space-y-3 md:space-y-4 h-full flex flex-col justify-center">
@ -189,6 +77,7 @@ export default function RequestStep2() {
onSubmit={form.handleSubmit(onSubmit)} onSubmit={form.handleSubmit(onSubmit)}
className="w-full flex flex-col mt-6" className="w-full flex flex-col mt-6"
> >
<FormField <FormField
control={form.control} control={form.control}
name="subject" name="subject"
@ -258,7 +147,7 @@ export default function RequestStep2() {
<FormControl> <FormControl>
<Textarea <Textarea
placeholder="متن توضیحات خود را بنویسید" placeholder="متن توضیحات خود را بنویسید"
className="resize-none mb-3" className="resize-none"
{...field} {...field}
/> />
</FormControl> </FormControl>
@ -267,150 +156,16 @@ export default function RequestStep2() {
)} )}
/> />
<div className="flex flex-row flex-wrap justify-between"> <div className="flex justify-center sm:justify-end gap-2 w-full mt-8">
{/* Select Option */} {/* <Button> */}
<FormField <Link
control={form.control} href="/RequestResult"
name="categoryId"
render={({ field }) => (
<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}
>
<FormControl>
<SelectTrigger className="bg-slate-200">
<SelectValue placeholder=" دسته بندی ها" />
</SelectTrigger>
</FormControl>
<SelectContent>
{categoryData?.map((catItems: any, index: any) => (
<SelectItem key={index} value={catItems.id}>
{catItems.title}
</SelectItem>
))}
</SelectContent>
</Select>
<FormMessage />
</FormItem>
)}
/>
{/* uploadFile */}
<FormField
control={form.control}
name="uploadFile"
render={({ field: { onChange }, ...field }) => {
// Get current uploadFile value (always watched updated)
const uploadFile = form.watch("uploadFile");
{
console.log(uploadFile);
}
var filenames: string[] | undefined = undefined;
if (uploadFile) {
// 1. covert to File[] using Array.from
const files: File[] = Array.from(uploadFile);
// 2. now you can use array methods on files;
filenames = files.map((file) => file?.name);
{
console.log(filenames);
}
}
return (
<FormItem className="w-full sm:w-[48%]">
<FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
آپلود تصویر
</FormLabel>
{/* File Upload */}
<FormControl>
<Input
type="file"
className="mb-3"
accept="image/*"
multiple={true}
disabled={form.formState.isSubmitting}
{...field}
onChange={(event) => {
// Triggered when user uploaded a new file
// FileList is immutable, so we need to create a new one
const dataTransfer = new DataTransfer();
// Add old images
// if (images) {
// Array.from(images).forEach((image) =>
// dataTransfer.items.add(image)
// );
// }
// Add newly uploaded images
Array.from(event.target.files!).forEach((image) =>
dataTransfer.items.add(image)
);
// Validate and update uploaded file
const newFiles = dataTransfer.files;
onChange(newFiles);
}}
/>
</FormControl>
{/* Show File Name */}
{/* <FormDescription>{`${filenames}`}</FormDescription> */}
<FormMessage />
</FormItem>
);
}}
/>
</div>
{/* Captcha */}
<div className="flex flex-row flex-wrap justify-between">
<div className="w-full sm:w-[48%] flex items-center justify-start">
{!isLoading && (
<Image
alt="icon"
src={srcForImage as string}
className="w-3/5 h-12 rounded-md shadow-md"
width={150}
height={20}
quality={100}
/>
)}
{/* <Image src={Img1} alt="1" width={50} height={50} /> */}
</div>
<FormField
control={form.control}
name="captchaValue"
render={({ field }) => (
<FormItem className="w-full sm:w-[48%]">
<FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
*کد کپچا
</FormLabel>
<FormControl>
<Input
placeholder="کد تصویر روبرو را وارد کنید "
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</div>
<div className="flex justify-center sm:justify-end gap-2 w-full mt-4">
{/* <Link> */}
<Button
// href="/RequestResult"
type="submit" type="submit"
className="w-1/2 sm:w-1/3 lg:w-1/4 bg-blue text-white p-2 rounded-xl text-center mb-4" className="w-1/2 sm:w-1/3 lg:w-1/4 bg-blue text-white p-2 rounded-xl text-center"
> >
ارسال درخواست ارسال درخواست
</Button> </Link>
{/* </Link> */} {/* </Button> */}
</div> </div>
</form> </form>
</Form> </Form>

View File

@ -1,164 +0,0 @@
"use client"
import * as React from "react"
import {
CaretSortIcon,
CheckIcon,
ChevronDownIcon,
ChevronUpIcon,
} from "@radix-ui/react-icons"
import * as SelectPrimitive from "@radix-ui/react-select"
import { cn } from "@/lib/utils"
const Select = SelectPrimitive.Root
const SelectGroup = SelectPrimitive.Group
const SelectValue = SelectPrimitive.Value
const SelectTrigger = React.forwardRef<
React.ElementRef<typeof SelectPrimitive.Trigger>,
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>
>(({ className, children, ...props }, ref) => (
<SelectPrimitive.Trigger
ref={ref}
className={cn(
"flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
className
)}
{...props}
>
{children}
<SelectPrimitive.Icon asChild>
<CaretSortIcon className="h-4 w-4 opacity-50" />
</SelectPrimitive.Icon>
</SelectPrimitive.Trigger>
))
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName
const SelectScrollUpButton = React.forwardRef<
React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>
>(({ className, ...props }, ref) => (
<SelectPrimitive.ScrollUpButton
ref={ref}
className={cn(
"flex cursor-default items-center justify-center py-1",
className
)}
{...props}
>
<ChevronUpIcon />
</SelectPrimitive.ScrollUpButton>
))
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName
const SelectScrollDownButton = React.forwardRef<
React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>
>(({ className, ...props }, ref) => (
<SelectPrimitive.ScrollDownButton
ref={ref}
className={cn(
"flex cursor-default items-center justify-center py-1",
className
)}
{...props}
>
<ChevronDownIcon />
</SelectPrimitive.ScrollDownButton>
))
SelectScrollDownButton.displayName =
SelectPrimitive.ScrollDownButton.displayName
const SelectContent = React.forwardRef<
React.ElementRef<typeof SelectPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
>(({ className, children, position = "popper", ...props }, ref) => (
<SelectPrimitive.Portal>
<SelectPrimitive.Content
ref={ref}
className={cn(
"relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
position === "popper" &&
"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
className
)}
position={position}
{...props}
>
<SelectScrollUpButton />
<SelectPrimitive.Viewport
className={cn(
"p-1",
position === "popper" &&
"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
)}
>
{children}
</SelectPrimitive.Viewport>
<SelectScrollDownButton />
</SelectPrimitive.Content>
</SelectPrimitive.Portal>
))
SelectContent.displayName = SelectPrimitive.Content.displayName
const SelectLabel = React.forwardRef<
React.ElementRef<typeof SelectPrimitive.Label>,
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>
>(({ className, ...props }, ref) => (
<SelectPrimitive.Label
ref={ref}
className={cn("px-2 py-1.5 text-sm font-semibold", className)}
{...props}
/>
))
SelectLabel.displayName = SelectPrimitive.Label.displayName
const SelectItem = React.forwardRef<
React.ElementRef<typeof SelectPrimitive.Item>,
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>
>(({ className, children, ...props }, ref) => (
<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",
className
)}
{...props}
>
<span className="absolute right-2 flex h-3.5 w-3.5 items-center justify-center">
<SelectPrimitive.ItemIndicator>
<CheckIcon className="h-4 w-4" />
</SelectPrimitive.ItemIndicator>
</span>
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
</SelectPrimitive.Item>
))
SelectItem.displayName = SelectPrimitive.Item.displayName
const SelectSeparator = React.forwardRef<
React.ElementRef<typeof SelectPrimitive.Separator>,
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>
>(({ className, ...props }, ref) => (
<SelectPrimitive.Separator
ref={ref}
className={cn("-mx-1 my-1 h-px bg-muted", className)}
{...props}
/>
))
SelectSeparator.displayName = SelectPrimitive.Separator.displayName
export {
Select,
SelectGroup,
SelectValue,
SelectTrigger,
SelectContent,
SelectLabel,
SelectItem,
SelectSeparator,
SelectScrollUpButton,
SelectScrollDownButton,
}

View File

@ -12,7 +12,7 @@ const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
className={cn( className={cn(
`flex w-full rounded-md border border-input px-3 py-2 ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 `flex w-full rounded-md border border-input px-3 py-2 ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50
text-black text-opacity-50 text-xs font-normal bg-slate-200 text-black text-opacity-50 text-xs font-normal bg-slate-200
3xl:min-h-[150px] min-h-[100px]`, 3xl:min-h-[198px] min-h-[150px]`,
className className
)} )}
ref={ref} ref={ref}

69
package-lock.json generated
View File

@ -13,7 +13,6 @@
"@radix-ui/react-dropdown-menu": "^2.0.6", "@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-icons": "^1.3.0", "@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-label": "^2.0.2", "@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-select": "^2.0.0",
"@radix-ui/react-slot": "^1.0.2", "@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-tabs": "^1.0.4", "@radix-ui/react-tabs": "^1.0.4",
"@radix-ui/react-toast": "^1.1.5", "@radix-ui/react-toast": "^1.1.5",
@ -489,14 +488,6 @@
"node": ">= 8" "node": ">= 8"
} }
}, },
"node_modules/@radix-ui/number": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@radix-ui/number/-/number-1.0.1.tgz",
"integrity": "sha512-T5gIdVO2mmPW3NNhjNgEP3cqMXjXL9UbO0BzWcXfvdBs+BohbQxvd/K5hSVKmn9/lbTdsQVKbUcP5WLCwvUbBg==",
"dependencies": {
"@babel/runtime": "^7.13.10"
}
},
"node_modules/@radix-ui/primitive": { "node_modules/@radix-ui/primitive": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/@radix-ui/primitive/-/primitive-1.0.1.tgz", "resolved": "https://registry.npmjs.org/@radix-ui/primitive/-/primitive-1.0.1.tgz",
@ -989,49 +980,6 @@
} }
} }
}, },
"node_modules/@radix-ui/react-select": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@radix-ui/react-select/-/react-select-2.0.0.tgz",
"integrity": "sha512-RH5b7af4oHtkcHS7pG6Sgv5rk5Wxa7XI8W5gvB1N/yiuDGZxko1ynvOiVhFM7Cis2A8zxF9bTOUVbRDzPepe6w==",
"dependencies": {
"@babel/runtime": "^7.13.10",
"@radix-ui/number": "1.0.1",
"@radix-ui/primitive": "1.0.1",
"@radix-ui/react-collection": "1.0.3",
"@radix-ui/react-compose-refs": "1.0.1",
"@radix-ui/react-context": "1.0.1",
"@radix-ui/react-direction": "1.0.1",
"@radix-ui/react-dismissable-layer": "1.0.5",
"@radix-ui/react-focus-guards": "1.0.1",
"@radix-ui/react-focus-scope": "1.0.4",
"@radix-ui/react-id": "1.0.1",
"@radix-ui/react-popper": "1.1.3",
"@radix-ui/react-portal": "1.0.4",
"@radix-ui/react-primitive": "1.0.3",
"@radix-ui/react-slot": "1.0.2",
"@radix-ui/react-use-callback-ref": "1.0.1",
"@radix-ui/react-use-controllable-state": "1.0.1",
"@radix-ui/react-use-layout-effect": "1.0.1",
"@radix-ui/react-use-previous": "1.0.1",
"@radix-ui/react-visually-hidden": "1.0.3",
"aria-hidden": "^1.1.1",
"react-remove-scroll": "2.5.5"
},
"peerDependencies": {
"@types/react": "*",
"@types/react-dom": "*",
"react": "^16.8 || ^17.0 || ^18.0",
"react-dom": "^16.8 || ^17.0 || ^18.0"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
},
"@types/react-dom": {
"optional": true
}
}
},
"node_modules/@radix-ui/react-slot": { "node_modules/@radix-ui/react-slot": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/@radix-ui/react-slot/-/react-slot-1.0.2.tgz", "resolved": "https://registry.npmjs.org/@radix-ui/react-slot/-/react-slot-1.0.2.tgz",
@ -1184,23 +1132,6 @@
} }
} }
}, },
"node_modules/@radix-ui/react-use-previous": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@radix-ui/react-use-previous/-/react-use-previous-1.0.1.tgz",
"integrity": "sha512-cV5La9DPwiQ7S0gf/0qiD6YgNqM5Fk97Kdrlc5yBcrF3jyEZQwm7vYFqMo4IfeHgJXsRaMvLABFtd0OVEmZhDw==",
"dependencies": {
"@babel/runtime": "^7.13.10"
},
"peerDependencies": {
"@types/react": "*",
"react": "^16.8 || ^17.0 || ^18.0"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
}
}
},
"node_modules/@radix-ui/react-use-rect": { "node_modules/@radix-ui/react-use-rect": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/@radix-ui/react-use-rect/-/react-use-rect-1.0.1.tgz", "resolved": "https://registry.npmjs.org/@radix-ui/react-use-rect/-/react-use-rect-1.0.1.tgz",

View File

@ -14,7 +14,6 @@
"@radix-ui/react-dropdown-menu": "^2.0.6", "@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-icons": "^1.3.0", "@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-label": "^2.0.2", "@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-select": "^2.0.0",
"@radix-ui/react-slot": "^1.0.2", "@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-tabs": "^1.0.4", "@radix-ui/react-tabs": "^1.0.4",
"@radix-ui/react-toast": "^1.1.5", "@radix-ui/react-toast": "^1.1.5",

View File

@ -6,30 +6,54 @@ axios.defaults.baseURL = "https://sootzaniapi.shetabdahi.ir/";
// Post Complaints // Post Complaints
export async function postComplaintSubmit( {Data} : {Data: FormData;}) { export async function postComplaintSubmit( {token , Data} : {
token: CookieValueTypes;
Data: { Title: string; Text: string ; CategoryId:string ; Medias?: any ; 'Captcha.Key': string ; 'Captcha.Value':string ; relevantDevice : number , relevantPerson:string};
}) {
const data = await axios.post( const data = await axios.post(
`api/Citizen`, `api/Citizen`,
Data, Data,
{
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "multipart/form-data"
},
}
); );
return data.data; return data.data;
} }
// Post 1 Complaints // Post 1 Complaints
export async function postComplaintTracking({Data} : { export async function postComplaintTracking({token , Data} : {
token: CookieValueTypes;
Data: { trackingNumber: string; password :string;} Data: { trackingNumber: string; password :string;}
}) { }) {
const data = await axios.post( const data = await axios.post(
`api/Citizen/Get`, `api/Citizen/Get`,
Data, Data,
{
headers: {
Authorization: `Bearer ${token}`,
},
}
); );
return data.data; return data.data;
} }
// Post Complaints Details "citizen / Oprate" // Post Complaints Details "citizen / Oprate"
export async function postComplaintsDetails( {Data} : {Data: FormData;}) { export async function postComplaintsDetails( {token , Data} : {
token: CookieValueTypes;
Data: { TrackingNumber: string; Text: string ; Medias?: any ; Operation: number ; Password:string};
}) {
const data = await axios.post( const data = await axios.post(
`api/Citizen/Operate`, `api/Citizen`,
Data, Data,
{
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "multipart/form-data"
},
}
); );
return data.data; return data.data;
} }

View File

@ -1,22 +1,20 @@
import axios from "axios"; import axios from "axios";
import { CookieValueTypes } from "cookies-next"; import { CookieValueTypes } from "cookies-next";
axios.defaults.baseURL = "https://sootzaniapi.shetabdahi.ir/";
// Get Category // Get Category
export async function getCategory() { export async function getCategory({ token }: { token: CookieValueTypes }) {
const data = await axios.get( const data = await axios.get("api/Common/Categories", {
"api/Common/Categories", headers: {
); Authorization: `Bearer ${token}`,
return data.data; },
} });
return data.data;
}
// Get Captcha
// Get Captcha
export async function getCaptcha() { export async function getCaptcha() {
const data = await axios.get( const data = await axios.get("api/Common/Captcha", { responseType: "blob" });
"api/Common/Captcha", {responseType:'blob'} return data;
); }
console.log(data)
return data;
}