From b01ea3201e4e9108f94ad0c9f162012a8cb06b4a Mon Sep 17 00:00:00 2001 From: Hossein Rahmani Date: Thu, 4 Jan 2024 12:38:44 +0330 Subject: [PATCH] Additional files deleted + some Improvements --- app/CallUs/page.tsx | 8 - app/CitizenLogin/page.tsx | 6 - app/FollowResult/page.tsx | 8 - app/FollowUp/page.tsx | 8 - app/RequestResult/page.tsx | 8 - app/RequestStep1/page.tsx | 8 - app/RequestStep2/page.tsx | 8 - .../(Citizen)/CitizenDashboard/layout.tsx | 16 - .../(Citizen)/CitizenDashboard/page.tsx | 7 - .../ControllerDashboard/layout.tsx | 3 +- app/components/Landing.tsx | 189 -------- app/layout.tsx | 2 +- components/BoxDashboard.tsx | 25 +- components/CallUs.tsx | 68 --- components/CitizenLogin.tsx | 199 --------- components/ComplainsDetails.tsx | 105 ++++- components/ControllerDashboard.tsx | 43 +- components/Counter.tsx | 84 ---- components/FollowUp.tsx | 172 ------- components/LineChart.tsx | 98 +++- components/Map.tsx | 48 -- components/Reports.tsx | 87 ++++ components/ReportsController.tsx | 109 +---- components/RequestResult.tsx | 52 --- components/RequestStep1.tsx | 166 ------- components/RequestStep2.tsx | 421 ------------------ components/SubmitRequest.tsx | 59 --- components/TabController.tsx | 2 +- components/TableController.tsx | 128 +++--- components/VerticalChart.tsx | 173 +++++-- components/ui/scroll-area.tsx | 48 ++ components/ui/separator.tsx | 31 ++ constants/colors.tsx | 65 +++ package-lock.json | 104 +++++ package.json | 5 + tailwind.config.js | 2 +- utils/infoApi.ts | 19 + 37 files changed, 790 insertions(+), 1794 deletions(-) delete mode 100644 app/CallUs/page.tsx delete mode 100644 app/CitizenLogin/page.tsx delete mode 100644 app/FollowResult/page.tsx delete mode 100644 app/FollowUp/page.tsx delete mode 100644 app/RequestResult/page.tsx delete mode 100644 app/RequestStep1/page.tsx delete mode 100644 app/RequestStep2/page.tsx delete mode 100644 app/UserPanel/(Citizen)/CitizenDashboard/layout.tsx delete mode 100644 app/UserPanel/(Citizen)/CitizenDashboard/page.tsx delete mode 100644 app/components/Landing.tsx delete mode 100644 components/CallUs.tsx delete mode 100644 components/CitizenLogin.tsx delete mode 100644 components/Counter.tsx delete mode 100644 components/FollowUp.tsx delete mode 100644 components/Map.tsx create mode 100644 components/Reports.tsx delete mode 100644 components/RequestResult.tsx delete mode 100644 components/RequestStep1.tsx delete mode 100644 components/RequestStep2.tsx delete mode 100644 components/SubmitRequest.tsx create mode 100644 components/ui/scroll-area.tsx create mode 100644 components/ui/separator.tsx create mode 100644 constants/colors.tsx create mode 100644 utils/infoApi.ts diff --git a/app/CallUs/page.tsx b/app/CallUs/page.tsx deleted file mode 100644 index fc7d628..0000000 --- a/app/CallUs/page.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import React from "react"; -import CallUs from "@/components/CallUs"; - -export default function page() { - return ( - - ); -} diff --git a/app/CitizenLogin/page.tsx b/app/CitizenLogin/page.tsx deleted file mode 100644 index 09d9d8f..0000000 --- a/app/CitizenLogin/page.tsx +++ /dev/null @@ -1,6 +0,0 @@ -import CitizenLogin from "@/components/CitizenLogin"; -import React from "react"; - -export default function page() { - return ; -} diff --git a/app/FollowResult/page.tsx b/app/FollowResult/page.tsx deleted file mode 100644 index cc633c7..0000000 --- a/app/FollowResult/page.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import React from "react"; -import FollowResult from "@/components/FollowResult"; - -export default function page() { - return ( - - ); -} diff --git a/app/FollowUp/page.tsx b/app/FollowUp/page.tsx deleted file mode 100644 index 1921e79..0000000 --- a/app/FollowUp/page.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import React from "react"; -import FollowUp from "@/components/FollowUp"; - -export default function page() { - return ( - - ); -} diff --git a/app/RequestResult/page.tsx b/app/RequestResult/page.tsx deleted file mode 100644 index ba2ecf9..0000000 --- a/app/RequestResult/page.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import React from "react"; -import Result from "@/components/RequestResult"; - -export default function page() { - return ( - - ); -} diff --git a/app/RequestStep1/page.tsx b/app/RequestStep1/page.tsx deleted file mode 100644 index b7916d7..0000000 --- a/app/RequestStep1/page.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import React from "react"; -import RequestStep1 from "@/components/RequestStep1"; - -export default function page() { - return ( - - ); -} diff --git a/app/RequestStep2/page.tsx b/app/RequestStep2/page.tsx deleted file mode 100644 index c97600b..0000000 --- a/app/RequestStep2/page.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import React from "react"; -import RequestStep2 from "@/components/RequestStep2"; - -export default function page() { - return ( - - ); -} diff --git a/app/UserPanel/(Citizen)/CitizenDashboard/layout.tsx b/app/UserPanel/(Citizen)/CitizenDashboard/layout.tsx deleted file mode 100644 index 1c0558a..0000000 --- a/app/UserPanel/(Citizen)/CitizenDashboard/layout.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import NavbarPanel from "@/components/NavbarPanel"; - -export default function RootLayout({ - children, - }: { - children: React.ReactNode; - }) { - return ( - <> - - - {children} - - ) - -} \ No newline at end of file diff --git a/app/UserPanel/(Citizen)/CitizenDashboard/page.tsx b/app/UserPanel/(Citizen)/CitizenDashboard/page.tsx deleted file mode 100644 index cb2be10..0000000 --- a/app/UserPanel/(Citizen)/CitizenDashboard/page.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import React from 'react' - -export default function page() { - return ( -
page
- ) -} diff --git a/app/UserPanel/(Controller)/ControllerDashboard/layout.tsx b/app/UserPanel/(Controller)/ControllerDashboard/layout.tsx index a727181..29df5bc 100644 --- a/app/UserPanel/(Controller)/ControllerDashboard/layout.tsx +++ b/app/UserPanel/(Controller)/ControllerDashboard/layout.tsx @@ -1,7 +1,6 @@ import NavbarPanel from "@/components/NavbarPanel"; import { cookies } from "next/headers"; import { redirect } from "next/navigation"; - export default function RootLayout({ children, }: { @@ -15,7 +14,7 @@ export default function RootLayout({ return ( <> -
{children}
+
{children}
); } diff --git a/app/components/Landing.tsx b/app/components/Landing.tsx deleted file mode 100644 index 48ceedd..0000000 --- a/app/components/Landing.tsx +++ /dev/null @@ -1,189 +0,0 @@ -"use client"; -import React from "react"; -import Navbar from "../../components/Navbar"; -import Counter from "../../components/Counter"; -import SubmitRequest from "../../components/SubmitRequest"; -import { boxItems, newsItems } from "@/constants"; -import Image from "next/image"; -import { cn } from "@/lib/utils"; -import Link from "next/link"; -import bgimg from "../../public/img/bg.png"; -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 { Autoplay, Pagination, Navigation} from "swiper/modules"; -import { sliderItems } from "@/constants"; - -export default function Landing() { - return ( -
-
- - {sliderItems.map((item) => { - return ( - - bg - - ); - })} - -
- -
-
- {boxItems.map((item, index) => { - return ( - -

- {item.description} -

-

- {item.name} -

- - icon - - icon - - ); - })} -
- - {/* News */} -
- آخرین اخبار -
-
- {/* Right News */} -
-
- picture -
- -
-

- اخبار -

-

- 24 آذر ماه 1402 -

-

- شروع به کار سامانه سوت زنی -

-

- این سامانه با هدف نظارت بر عملکرد پرستل و نهادهای مرتبط با امور - مردمی در شهرداری استان یزد در زمستان 1402 شروع به فعالیت نموده - است ... -

- - بیشتر بخوانید{" "} - -
-
- {/* Left News */} -
- {newsItems.map((item, index) => { - return ( -
-
-

- {item.title} -

-

- {item.date} -

-
-

- {item.content} -

-
- ); - })} -
-
-
- {/* Counter */} - - {/*SubmitRequest */} - - {/* Footer */} -
-
- ); -} diff --git a/app/layout.tsx b/app/layout.tsx index a806a1b..aae73fd 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -9,7 +9,7 @@ import { Toaster as SonnerToaster } from "@/components/ui/sonner"; const inter = Inter({ subsets: ["latin"] }); export const metadata: Metadata = { - title: "Create Next App", + title: "سوت زنی", description: "Generated by create next app", }; diff --git a/components/BoxDashboard.tsx b/components/BoxDashboard.tsx index 57c8181..cfdf88d 100644 --- a/components/BoxDashboard.tsx +++ b/components/BoxDashboard.tsx @@ -1,16 +1,25 @@ import React from "react"; -export default function BoxDashboard() { +export default function BoxDashboard({ + value, + title, +}: { + value: string; + title: string; +}) { return (
-

- تعداد درخواست ها 30 روز گذشته -

+
+

+ {value} +

+

{title}

+
); } diff --git a/components/CallUs.tsx b/components/CallUs.tsx deleted file mode 100644 index 8975c75..0000000 --- a/components/CallUs.tsx +++ /dev/null @@ -1,68 +0,0 @@ -"use client"; -import Image from "next/image"; -import React from "react"; -import mapImg from "../public/img/map.png"; - -import { callUsItems } from "@/constants"; -import { cn } from "@/lib/utils"; -import Map from "./Map"; - -export default function CallUs(props: any) { - const { position, zoom } = props; - return ( -
-
-
- {/*  Logo1 */} - - -
- -
-
- {callUsItems.map((item) => { - return ( -
-
- - {item.icon} - - -

- {item.title} -

-

- {item.description} -

-

- {item.description2} -

-
-
- ); - })} -
-
-
-
- ); -} diff --git a/components/CitizenLogin.tsx b/components/CitizenLogin.tsx deleted file mode 100644 index 6afaccc..0000000 --- a/components/CitizenLogin.tsx +++ /dev/null @@ -1,199 +0,0 @@ -"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>({ - resolver: zodResolver(FormSchema), - }); - - function onSubmit(data: z.infer) { - 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 ( -
-
- icon - -

- احراز هویت -

- -
- - ( - - - شماره موبایل - - - - - {/* - This is your public display name. - */} - - - )} - /> -
- ( - - {/* - رمز عبور - */} - - - - - - )} - /> - {isLoading ? ( -
- -
- ) : ( -
- icon -
- )} -
-
- -
- - -
-
- ); -} diff --git a/components/ComplainsDetails.tsx b/components/ComplainsDetails.tsx index 3c15e9a..10c7572 100644 --- a/components/ComplainsDetails.tsx +++ b/components/ComplainsDetails.tsx @@ -11,6 +11,8 @@ import { convertDate } from "@/lib/utils"; import { Badge } from "./ui/badge"; import InspectorOperations from "./InspectorOperations"; import { postComplaintTracking } from "@/utils/citizenApi"; +import { ArrowDownToLine, File } from "lucide-react"; +import { Separator } from "./ui/separator"; export default function ComplainsDetails({ id, @@ -55,12 +57,82 @@ export default function ComplainsDetails({ } else if (Data) { data = Data; } + + const handleOpenFile = (file) => { + const fileURL = URL.createObjectURL( + new Blob([atob(file.data)], { type: file.mimeType }) + ); + window.open(fileURL, "_blank"); + }; + const openFileInNewTab = (base64Data: any, fileType: any) => { + const blob = b64toBlob(base64Data, fileType); + const blobUrl = URL.createObjectURL(blob); + const newTab = window.open(); + if (newTab) { + newTab.document.write( + 'File Preview' + ); + + // Check the file type and handle accordingly + if (fileType.includes("image")) { + newTab.document.write( + `File Preview` + ); + } else if (fileType === "application/pdf") { + newTab.document.write( + `` + ); + } else { + newTab.document.write( + `Open in New Tab` + ); + } + + newTab.document.write(""); + newTab.document.close(); + + URL.revokeObjectURL(blobUrl); + } else { + console.error("Unable to open a new tab."); + } + }; + + const downloadFile = (base64Data, fileName, fileType) => { + const blob = b64toBlob(base64Data, fileType); + const blobUrl = URL.createObjectURL(blob); + + const link = document.createElement("a"); + link.href = blobUrl; + link.download = fileName; + link.click(); + + URL.revokeObjectURL(blobUrl); + }; + + const b64toBlob = (b64Data, contentType = "", sliceSize = 512) => { + const byteCharacters = atob(b64Data); + const byteArrays = []; + + for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) { + const slice = byteCharacters.slice(offset, offset + sliceSize); + + const byteNumbers = new Array(slice.length); + for (let i = 0; i < slice.length; i++) { + byteNumbers[i] = slice.charCodeAt(i); + } + + const byteArray = new Uint8Array(byteNumbers); + byteArrays.push(byteArray); + } + + return new Blob(byteArrays, { type: contentType }); + }; console.log(Data); return ( <> {data ? (
-
+

گزارش شکایت

@@ -134,11 +206,40 @@ export default function ComplainsDetails({

- متن:{" "} {item.text ? item.text : "-"}
+ {item.media.length !== 0 && } +
+
+ {item?.media.map((item: any) => { + return ( + + ); + })} +
+
); })} diff --git a/components/ControllerDashboard.tsx b/components/ControllerDashboard.tsx index e72b739..a75946a 100644 --- a/components/ControllerDashboard.tsx +++ b/components/ControllerDashboard.tsx @@ -6,50 +6,49 @@ import { HorizontalChart } from "./HorizontalChart"; import { getComplaintsList } from "@/utils/inspectorApi"; import { useQuery } from "@tanstack/react-query"; import useDecrypt from "@/hooks/useDecrypt"; +import { getInfo } from "@/utils/infoApi"; export default function ControllerDashboard() { const { data, isLoading, refetch } = useQuery({ - queryKey: ["ComplaintsList"], - queryFn: () => getComplaintsList(), + queryKey: ["Infos"], + queryFn: () => getInfo(), refetchOnWindowFocus: false, }); console.log(data); const [decryptedMessage, errorMessage] = useDecrypt( "gJoT9AqK7wk1MZFSD04yXXfF36fzsOL+RYtJfySrEnQeJ7VoaL7pmOU6nB3+0+PQcaxIi3hf1AHjzIB0Cn5oHgKROeoI4XslhAezZk23QhtIU4HUF1wpeOJfA+4hWyRfbh4fI9774sa/KL47VaBbrNM/rvBxk6hjlKx5mTb3hqM=" ); - console.log(decryptedMessage); - if (data) { - } - console.log(errorMessage); - if (data) { - } + return ( -
+
{/* Lg Show */} -
-
- - +
+
+ {data?.singletons.map((item: any) => { + return ; + })}
-
- +
+ {data?.charts.map((item: any) => { + return ( + + ); + })}
-
+ {/*
-
- -
-
+ +
*/} {/* max Lg show */} -
+ {/*
@@ -67,7 +66,7 @@ export default function ControllerDashboard() {
-
+
*/}
); } diff --git a/components/Counter.tsx b/components/Counter.tsx deleted file mode 100644 index 9263b12..0000000 --- a/components/Counter.tsx +++ /dev/null @@ -1,84 +0,0 @@ -import React from 'react' -import { counterItems } from '@/constants' -// import patern from "../public/img/paternSvg.png" - -// 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'; - -export default function Counter() { - return ( -
-
-
- {counterItems.map((item) => { - return ( -
-

{item.count}

-

{item.name}

-
- ); - })} -{/* - - {counterItems.map((item) => { - return ( - -

{item.count}

-

{item.name}

-
- ); - })} - - {/* Slide 1 */} - - {/*
*/} - - -
- - -
-
- ) -} diff --git a/components/FollowUp.tsx b/components/FollowUp.tsx deleted file mode 100644 index 3d9854e..0000000 --- a/components/FollowUp.tsx +++ /dev/null @@ -1,172 +0,0 @@ -"use client"; -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 { - 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 { 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({ - 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.", - }), -}); - -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"); - console.log("Success FollowUp"); - - // 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: { - trackingNumber: "", - password: "", - }, - }); - - function onSubmit(data: z.infer) { - // toast({ - // title: "You submitted the following values:", - // description: ( - //
-    //       {JSON.stringify(data, null, 2)}
-    //     
- // ), - // }); - - console.log(data); - - localStorage.setItem("trackingNumber2", data.trackingNumber); - localStorage.setItem("password2", data.password); - - complaintTrackingMutation.mutate({ - Data: { trackingNumber: data.trackingNumber, password: data.password }, - }); - } - return ( -
-
-

- لطفا جهت پیگیری درخواست و مشاهده وضعیت آن کد رهگیری و رمز عبور خود را - وارد نمایید. -

- -
- -
- ( - - - کد پیگیری - - - - - - - )} - /> - - ( - - - رمز عبور - - - - - - - )} - /> -
- -
- -
-
- -
-
- ); -} diff --git a/components/LineChart.tsx b/components/LineChart.tsx index ef91e71..71e3b24 100644 --- a/components/LineChart.tsx +++ b/components/LineChart.tsx @@ -10,10 +10,18 @@ import { Title, Tooltip, Legend, + ChartOptions, } from "chart.js"; import { Line } from "react-chartjs-2"; import { faker } from "@faker-js/faker"; - +import dayjs from "dayjs"; +import utc from "dayjs/plugin/utc"; +import jalaliday from "jalaliday"; +import { backgroundColor, borderColor } from "@/constants/colors"; +import ChartDataLabels from "chartjs-plugin-datalabels"; +dayjs.extend(jalaliday); +dayjs.extend(utc); +ChartJS.defaults.font.family = "Yekan"; ChartJS.register( CategoryScale, LinearScale, @@ -21,21 +29,22 @@ ChartJS.register( LineElement, Title, Tooltip, - Legend + Legend, + ChartDataLabels ); -export const options = { - responsive: true, - plugins: { - legend: { - position: "top" as const, - }, - title: { - display: true, - text: "Chart.js Line Chart", - }, - }, -}; +// export const options = { +// responsive: true, +// plugins: { +// legend: { +// position: "top" as const, +// }, +// title: { +// display: true, +// text: "Chart.js Line Chart", +// }, +// }, +// }; const labels = ["January", "February", "March", "April", "May", "June", "July"]; @@ -57,8 +66,61 @@ export const data = { ], }; -export default function LineChart() { - return ( - - ); +interface Values { + title: string; + value: string; + displayValue: string; + parameters: any; +} + +export default function LineChart({ + chartData, + chartTitle, +}: { + chartData: { title: string; icon: string; values: Values[] }[]; + chartTitle: string; +}) { + const options: ChartOptions<"line"> = { + responsive: true, + maintainAspectRatio: false, + scales: { x: { ticks: { autoSkip: false } } }, + plugins: { + legend: { + position: "top" as const, + }, + title: { + display: true, + text: chartTitle, + position: "bottom", + }, + datalabels: { + display: true, + color: "black", + align: "end", + anchor: "end", + font: { size: 12 }, + formatter: function (value, context) { + console.log(context.dataset); + return value == 0 ? "" : value; + }, + }, + }, + }; + + const data = { + labels: chartData[0].values.map((item) => { + return item.title; + }), + datasets: chartData.map((item: any, index: number) => { + return { + label: item.title, + data: item.values.map((item) => item.value), + backgroundColor: backgroundColor[index], + borderColor: borderColor[index], + borderWidth: 1, + }; + }), + }; + + return ; } diff --git a/components/Map.tsx b/components/Map.tsx deleted file mode 100644 index e808ce5..0000000 --- a/components/Map.tsx +++ /dev/null @@ -1,48 +0,0 @@ -"use client"; -import React, { useEffect, useRef } from "react"; -import { MapContainer, TileLayer, Marker, Popup } from "react-leaflet"; -import L from "leaflet"; -// import MarkerIcon from "../../node_modules/leaflet/dist/images/marker-icon.png"; -// import MarkerShadow from "../../node_modules/leaflet/dist/images/marker-shadow.png"; -import "leaflet/dist/leaflet.css"; -import { any } from "zod"; - -const Map = () => { - const markerRef = useRef(null); - - useEffect(() => { - if (markerRef.current) { - markerRef.current.openPopup() - } - }, []); - - return ( - - - - داروخانه چمران - - - ); -}; - -export default Map; diff --git a/components/Reports.tsx b/components/Reports.tsx new file mode 100644 index 0000000..f94519a --- /dev/null +++ b/components/Reports.tsx @@ -0,0 +1,87 @@ +"use client"; +import React, { useEffect, useState } from "react"; +import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; +import LineChart from "./LineChart"; + +import { BsBarChartLineFill } from "react-icons/bs"; +import { BsBarChartLine } from "react-icons/bs"; +import VerticalChart from "./VerticalChart"; +import { HorizontalChart } from "./HorizontalChart"; +import { getInfo, getInfoList } from "@/utils/infoApi"; +import { useQueries, useQuery } from "@tanstack/react-query"; +import useChart from "@/hooks/useChart"; + +export default function Reports({ data }) { + console.log(data); + const [first, setfirst] = useState(false); + const Queries: any = useQueries({ + queries: data?.map((item: any) => ({ + queryKey: ["user", item.code], + queryFn: () => getInfo(item.code), + })), + }); + const codes = data.map((item: any) => item.code); + console.log(codes); + console.log(Queries[0]); + const charts = Queries.map((item: any) => item.data); + const successfulRequests = Queries.filter((item) => item.isSuccess == true); + return ( +
+ {successfulRequests.length == data.length && ( + +
+ {/* Tab Title */} + + {data?.map((item: any) => { + return ( + + {item.title} + {/* نمودار شماره یک */} + + ); + })} + +
+ +
+ {charts?.map((item: any, index) => { + return ( + + + + ); + })} + {/* Tab Content */} + {/* + + + + + + + + + + + + + + */} +
+
+ )} +
+ ); +} diff --git a/components/ReportsController.tsx b/components/ReportsController.tsx index 6f2cd54..3322c9a 100644 --- a/components/ReportsController.tsx +++ b/components/ReportsController.tsx @@ -1,5 +1,5 @@ -"use client" -import React from "react"; +"use client"; +import React, { useEffect, useState } from "react"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import LineChart from "./LineChart"; @@ -7,100 +7,23 @@ import { BsBarChartLineFill } from "react-icons/bs"; import { BsBarChartLine } from "react-icons/bs"; import { VerticalChart } from "./VerticalChart"; import { HorizontalChart } from "./HorizontalChart"; +import { getInfo, getInfoList } from "@/utils/infoApi"; +import { useQueries, useQuery } from "@tanstack/react-query"; +import useChart from "@/hooks/useChart"; +import Reports from "./Reports"; export default function ReportsController() { + const { data, isLoading, refetch, isSuccess } = useQuery({ + queryKey: ["InfoList"], + queryFn: () => getInfoList(), + refetchOnWindowFocus: false, + }); + const [first, setfirst] = useState(false); + + console.log(data); return ( -
- -
- {/* Tab Title */} - - - {" "} - نمودار شماره یک - - - {" "} - نمودار شماره 2 - - - {" "} - نمودار شماره 3 - - - {" "} - نمودار شماره 4 - - - {" "} - نمودار شماره 5 - - - {" "} - نمودار شماره 6 - - - - {" "} - نمودار شماره 7 - - - - {" "} - نمودار شماره 8 - - - - -
- -
- {/* Tab Content */} - - - - - - - - - - - - - - - -
-
+
+ {data && }
); } diff --git a/components/RequestResult.tsx b/components/RequestResult.tsx deleted file mode 100644 index 81e994c..0000000 --- a/components/RequestResult.tsx +++ /dev/null @@ -1,52 +0,0 @@ -"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 ( -
-
-

- با تشکر از شما -

- -

- درخواست شما با کد پیگیری - - {`${trackingNumber}`} - - و رمز عبور - - {`${password}`} - - در سامانه سوت زنی ثبت شده و شما می توانید نتیجه درخواست خود را از صفحه - پیگیری درخواست، با استفاده از کد رهگیری و رمز عبور مشاهده کنید. -

- - icon -
-
- ); -} diff --git a/components/RequestStep1.tsx b/components/RequestStep1.tsx deleted file mode 100644 index 5f99518..0000000 --- a/components/RequestStep1.tsx +++ /dev/null @@ -1,166 +0,0 @@ -"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 Link from "next/link"; -import RequestStep2 from "./RequestStep2"; - -const FormSchema = z.object({ - firstName: z.string().min(2, { - message: "firstName must be at least 2 characters.", - }), - lastName: z.string().min(2, { - message: "lastName must be at least 2 characters.", - }), - 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.", - }), -}); - -export default function RequestStep1() { - const form = useForm>({ - resolver: zodResolver(FormSchema), - defaultValues: { - firstName: "", - lastName: "", - // nationalCode: , - // phoneNumber: , - }, - }); - - function onSubmit(data: z.infer) { - toast({ - title: "You submitted the following values:", - description: ( -
-          {JSON.stringify(data, null, 2)}
-        
- ), - }); - console.log(data); - } - - return ( -
-
-

- لطفا جهت ارسال درخواست فرم زیر را تکمیل نمایید. -

-

- در صورت عدم تمایل به ثبت مشخصات شخصی می توانید به صفحه ی بعد مراجعه کنید. -

-
- -
- ( - - - نام - - - - - - - )} - /> - ( - - - نام خانوادگی - - - - - - - )} - /> - ( - - - کد ملی - - - - - - - )} - /> - - ( - - - شماره تماس - - - - - - - )} - /> -
- -
- {/* */} -
-
- -
-
- ); -} diff --git a/components/RequestStep2.tsx b/components/RequestStep2.tsx deleted file mode 100644 index 1789dea..0000000 --- a/components/RequestStep2.tsx +++ /dev/null @@ -1,421 +0,0 @@ -"use client"; -import React, { useState } 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 { - 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, { - message: "subject must be at least 2 characters.", - }), - 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.", - }), - description: z - .string() - .min(5, { - message: "description must be at least 5 characters.", - }) - .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"); - console.log("Success Step2"); - 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: { - subject: "", - organisation: "", - person: "", - description: "", - captchaValue: "", - // uploadFile: null, - }, - }); - - function onSubmit(data: z.infer) { - // toast({ - // title: "You submitted the following values:", - // description: ( - //
-    //       {JSON.stringify(data, null, 2)}
-    //     
- // ), - // }); - - 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); - } - - const { resetField } = useForm(); - - return ( -
-
-

- لطفا جهت ارسال درخواست فرم زیر را تکمیل نمایید. -

- -
- - ( - - - *موضوع شکایت - - - - - - - )} - /> -
- ( - - - *دستگاه مربوطه - - - - - - - )} - /> - - ( - - - فرد مربوطه - - - - - - - )} - /> -
- - ( - - - توضیحات - - -