From fb16a96ac4314f83fdbfdd08c512ca24f9b2ed25 Mon Sep 17 00:00:00 2001 From: Hossein Rahmani Date: Mon, 1 Jan 2024 00:32:17 +0330 Subject: [PATCH] Part of Inspector panel done --- .env | 1 + app/layout.tsx | 5 +- components/ComplainsDetails.tsx | 320 ++++++++++++++++++++++------- components/ControllerDashboard.tsx | 27 ++- components/InspectorOperations.tsx | 114 ++++++++++ components/RequestStep1.tsx | 2 +- components/TabController.tsx | 199 +++++++++++++++--- components/TableController.tsx | 187 ++++++++++++++--- components/Verify.tsx | 2 +- components/ui/badge.tsx | 36 ++++ components/ui/dialog.tsx | 122 +++++++++++ components/ui/radio-group.tsx | 44 ++++ components/ui/sonner.tsx | 31 +++ hooks/useDecrypt.tsx | 47 +++++ lib/utils.ts | 45 +++- package-lock.json | 137 ++++++++++++ package.json | 6 + store/useData.ts | 9 - tailwind.config.js | 2 +- utils/inspectorApi.ts | 3 +- 20 files changed, 1176 insertions(+), 163 deletions(-) create mode 100644 components/InspectorOperations.tsx create mode 100644 components/ui/badge.tsx create mode 100644 components/ui/dialog.tsx create mode 100644 components/ui/radio-group.tsx create mode 100644 components/ui/sonner.tsx create mode 100644 hooks/useDecrypt.tsx diff --git a/.env b/.env index e69de29..2d0c1a9 100644 --- a/.env +++ b/.env @@ -0,0 +1 @@ +NEXT_PUBLIC_BASE_URL_APP="https://sootzaniapi.shetabdahi.ir/" \ No newline at end of file diff --git a/app/layout.tsx b/app/layout.tsx index ee7408c..99afec3 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -5,7 +5,7 @@ import { Toaster } from "@/components/ui/toaster"; import Navbar from "@/components/Navbar"; import NavbarSm from "@/components/NavbarSm"; import Provider from "../utils/Provider"; - +import { Toaster as SonnerToaster } from "@/components/ui/sonner"; const inter = Inter({ subsets: ["latin"] }); export const metadata: Metadata = { @@ -25,9 +25,10 @@ export default function RootLayout({ -
{children}
+
{children}
+ diff --git a/components/ComplainsDetails.tsx b/components/ComplainsDetails.tsx index 55ea5a2..ac73c3a 100644 --- a/components/ComplainsDetails.tsx +++ b/components/ComplainsDetails.tsx @@ -1,86 +1,258 @@ -import React from "react"; +"use client"; +import React, { useEffect } from "react"; import greenIcon from "../public/img/greenPoint.svg"; 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 useData from "@/store/useData"; +import { convertDate } from "@/lib/utils"; +import { Badge } from "./ui/badge"; +import InspectorOperations from "./InspectorOperations"; export default function ComplainsDetails({ id }: { id: number }) { + const complainData = useData((state) => state.data); + const getComplaintMutation = useMutation({ + mutationKey: ["Complaint", id], + mutationFn: getComplaint, + onSuccess: (res) => {}, + onError: (err) => {}, + }); + console.log(complainData); + useEffect(() => { + useData.persist.rehydrate(); + }, []); + useEffect(() => { + if (complainData) { + getComplaintMutation.mutate(complainData); + } + }, [complainData]); + let data; + if (getComplaintMutation.isSuccess) { + console.log(getComplaintMutation.data); + data = getComplaintMutation.data; + console.log(data); + } return ( -
- -
- {/* Right */} -
-

گزارش شکایات

-
-

- {" "} - موضوع شکایت:{" "} - - متن تستی - -

-

- {" "} - موضوع شکایت:{" "} - - متن تستی - -

-

- {" "} - موضوع شکایت:{" "} - - متن تستی - -

-

موضوع شکایت:

-
-

- درخواست شما با کد رهگیری 1243230783 و رمز عبور 12422 در دست بررسی و - اقدام می باشد. در صورت تمایل می توانید با شماره تلفن 0353286545 جهت - پشتیبانی تماس حاصل کنید.{" "} -

-
- - {/* Left */} -
-

- وضعیت درخواست -

- - {/* 1 */} - {ComplainDetailsItems.map((item, index, array) => { - return ( -
-
-
- {item.title} -
-
- {item.desc} -
-
- {item.date}
{item.time} -
-
- -
-
- greenIcon -
-
-
+
+ {data ? ( +
+
+
+

گزارش شکایت

+
+

+ موضوع شکایت:{" "} + + {data.title} + +

+

+ دستگاه مربوطه:{" "} + + {/* {data.title} */} + +

+

+ پرسنل مربوطه:{" "} + + {/* {data.title} */} + +

+

+ زمان ثبت:{" "} + + {convertDate(data.registeredAt)} + +

+ {/*

+ {" "} + موضوع شکایت:{" "} + + متن تستی + +

*/}
- ); - })} + {/*

+ درخواست شما با کد رهگیری {data.trackingNumber} و رمز عبور 12422 در + دست بررسی و اقدام می باشد. در صورت تمایل می توانید با شماره تلفن + 0353286545 جهت پشتیبانی تماس حاصل کنید.{" "} +

*/} +
+
+

انجام عملیات

+ +
+
+
+

روند شکایت

+
+ {data.contents?.map((item: any) => { + return ( +
+
+

+ {item.sender == 0 ? "شهروند" : "بازرس"} +

+

+ تاریخ : + + {convertDate(item.dateTime)} + +

+
+
+ متن: {item.text ? item.text : "-"} +
+
+ ); + })} + {data.contents?.map((item: any) => { + return ( +
+
+

+ {item.sender == 0 ? "شهروند" : "بازرس"} +

+

+ تاریخ : + + {convertDate(item.dateTime)} + +

+
+
+ متن: {item.text ? item.text : "-"} +
+
+ ); + })} + {data.contents?.map((item: any) => { + return ( +
+
+

+ {item.sender == 0 ? "شهروند" : "بازرس"} +

+

+ تاریخ : + + {convertDate(item.dateTime)} + +

+
+
+ متن: {item.text ? item.text : "-"} +
+
+ ); + })} + {data.contents?.map((item: any) => { + return ( +
+
+

+ {item.sender == 0 ? "شهروند" : "بازرس"} +

+

+ تاریخ : + + {convertDate(item.dateTime)} + +

+
+
+ متن: {item.text ? item.text : "-"} +
+
+ ); + })} + {data.contents?.map((item: any) => { + return ( +
+
+

+ {item.sender == 0 ? "شهروند" : "بازرس"} +

+

+ تاریخ : + + {convertDate(item.dateTime)} + +

+
+
+ متن: {item.text ? item.text : "-"} +
+
+ ); + })} + {data.contents?.map((item: any) => { + return ( +
+
+

+ {item.sender == 0 ? "شهروند" : "بازرس"} +

+

+ تاریخ : + + {convertDate(item.dateTime)} + +

+
+
+ متن: {item.text ? item.text : "-"} +
+
+ ); + })} +
+
+ {/* Left */} + {/*
+

+ وضعیت درخواست +

+ + {ComplainDetailsItems.map((item, index, array) => { + return ( +
+
+
+ {item.title} +
+
+ {item.desc} +
+
+ {item.date}
{item.time} +
+
+ +
+
+ greenIcon +
+
+
+
+ ); + })} +
*/}
-
+ ) : ( + "" + )}
); } diff --git a/components/ControllerDashboard.tsx b/components/ControllerDashboard.tsx index 69ee524..103628d 100644 --- a/components/ControllerDashboard.tsx +++ b/components/ControllerDashboard.tsx @@ -1,22 +1,28 @@ -"use client" +"use client"; import React from "react"; import BoxDashboard from "./BoxDashboard"; import LineChart from "./LineChart"; import { HorizontalChart } from "./HorizontalChart"; import { getComplaintsList } from "@/utils/inspectorApi"; import { useQuery } from "@tanstack/react-query"; +import useDecrypt from "@/hooks/useDecrypt"; export default function ControllerDashboard() { - const { - data, - isLoading, - refetch, - } = useQuery({ - queryKey: ["ComplaintsList"], - queryFn: () => getComplaintsList(), - refetchOnWindowFocus: false, - }); + const { data, isLoading, refetch } = useQuery({ + queryKey: ["ComplaintsList"], + queryFn: () => getComplaintsList(), + 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 */} @@ -62,7 +68,6 @@ export default function ControllerDashboard() {
-
); } diff --git a/components/InspectorOperations.tsx b/components/InspectorOperations.tsx new file mode 100644 index 0000000..404fb41 --- /dev/null +++ b/components/InspectorOperations.tsx @@ -0,0 +1,114 @@ +"use client"; + +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 { 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"; + +const FormSchema = z.object({ + bio: z + .string() + .min(10, { + message: "Bio must be at least 10 characters.", + }) + .max(160, { + message: "Bio must not be longer than 30 characters.", + }), +}); + +export default function InspectorOperations() { + const form = useForm>({ + resolver: zodResolver(FormSchema), + }); + + function onSubmit(data: z.infer) { + toast({ + title: "You submitted the following values:", + description: ( +
+          {JSON.stringify(data, null, 2)}
+        
+ ), + }); + } + + return ( +
+ + ( + + متن + +