Compare commits

...

8 Commits

37 changed files with 1351 additions and 1057 deletions

7
.dockerignore Normal file
View File

@ -0,0 +1,7 @@
Dockerfile
.dockerignore
node_modules
npm-debug.log
README.md
.next
.git

49
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,49 @@
name: build
on:
push:
tags:
- "v*.*.*"
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
${{ secrets.DOCKER_REGISTRY }}oyoon-admin
# generate Docker tags based on the following events/attributes
tags: |
type=ref,event=branch
type=semver,pattern={{major}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{version}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ${{ secrets.DOCKER_REGISTRY }}
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
context: "{{defaultContext}}"
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

59
Dockerfile Normal file
View File

@ -0,0 +1,59 @@
FROM node:18-alpine AS base
# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app
# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \
else echo "Lockfile not found." && exit 1; \
fi
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
# ENV NEXT_TELEMETRY_DISABLED 1
RUN yarn build
# If using npm comment out above and use below instead
# RUN npm run build
# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app
ENV NODE_ENV production
# Uncomment the following line in case you want to disable telemetry during runtime.
# ENV NEXT_TELEMETRY_DISABLED 1
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 6679
ENV PORT 6679
CMD ["node", "server.js"]

View File

@ -1,16 +1,22 @@
import NavbarPanel from "@/components/NavbarPanel"; import NavbarPanel from "@/components/NavbarPanel";
import { cookies } from "next/headers";
import { redirect } from "next/navigation";
export default function RootLayout({ export default function RootLayout({
children, children,
}: { }: {
children: React.ReactNode; children: React.ReactNode;
}) { }) {
return ( const cookieStore = cookies();
<> const token = cookieStore.get("Sootzani_Token");
if (!token?.value) {
<NavbarPanel /> return redirect("/");
{children} }
</>
)
return (
<>
<NavbarPanel />
{children}
</>
);
} }

View File

@ -1,8 +1,7 @@
import AdminDashboard from "@/components/AdminDashboard"; import AdminDashboard from "@/components/AdminDashboard";
import ControllerDashboard from "@/components/ControllerDashboard";
import React from "react"; import React from "react";
export default function page() { export default function page() {
return ( return <ControllerDashboard />;
<AdminDashboard />
);
} }

View File

@ -3,16 +3,10 @@ import React from "react";
export default function page({ params }: { params: any }) { export default function page({ params }: { params: any }) {
const id = params.id; const id = params.id;
{
console.log(params);
}
{
console.log(id);
}
return ( return (
<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"> <div className="w-[90vw] sm:w-[90vw] lg:w-[85vw] xl:w-[75vw] 3xl:w-[70vw] mt-10 sm:mt-8 pt-9 mx-auto mb-10">
<ComplainsDetails role="Inspector" id={id} />; <ComplainsDetails role="Inspector" id={id} />
</div> </div>
); );
} }

View File

@ -6,11 +6,12 @@ export default function RootLayout({
}: { }: {
children: React.ReactNode; children: React.ReactNode;
}) { }) {
// const cookieStore = cookies(); const cookieStore = cookies();
// const token = cookieStore.get("Sootzani-Token"); const token = cookieStore.get("Sootzani_Token");
// if (!token.value) { if (!token?.value) {
// return redirect("/"); return redirect("/");
// } }
return ( return (
<> <>
<NavbarPanel /> <NavbarPanel />

View File

@ -9,7 +9,7 @@ import { Toaster as SonnerToaster } from "@/components/ui/sonner";
const inter = Inter({ subsets: ["latin"] }); const inter = Inter({ subsets: ["latin"] });
export const metadata: Metadata = { export const metadata: Metadata = {
title: "سوت زنی", title: "عیون",
description: "Generated by create next app", description: "Generated by create next app",
}; };
@ -20,9 +20,9 @@ export default function RootLayout({
}) { }) {
return ( return (
<html lang="fa" dir="rtl"> <html lang="fa" dir="rtl">
<body className="font-[yekan] "> <body className="font-[yekan] bg-white">
<Provider> <Provider>
{children} {children}
<Toaster /> <Toaster />
<SonnerToaster /> <SonnerToaster />
</Provider> </Provider>

View File

@ -1,5 +1,4 @@
import Image from "next/image"; import Image from "next/image";
import CitizenLogin from "../components/CitizenLogin";
import Login from "@/components/Login"; import Login from "@/components/Login";
export default function Home() { export default function Home() {

View File

@ -1,7 +1,7 @@
"use client"; "use client";
import React, { useState, useRef, useEffect } from "react"; import React, { useState, useRef, useEffect } from "react";
import { useMutation, useQuery, RefetchOptions } from "@tanstack/react-query"; import { useMutation, useQuery } from "@tanstack/react-query";
import { import {
GetAllCategories, GetAllCategories,
GetSingleCategory, GetSingleCategory,
@ -11,7 +11,6 @@ import {
} from "@/utils/adminApi"; } from "@/utils/adminApi";
import { FaRegEdit } from "react-icons/fa"; import { FaRegEdit } from "react-icons/fa";
import { IoMdClose } from "react-icons/io"; import { IoMdClose } from "react-icons/io";
import { RiDeleteBin6Line } from "react-icons/ri";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
import { ThreeDots } from "react-loader-spinner"; import { ThreeDots } from "react-loader-spinner";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
@ -232,7 +231,7 @@ export default function AdminCategories() {
console.log(data); console.log(data);
} }
return ( return (
<div className="w-full bg-[#F5F5F5] min-h-[85vh] flex justify-center"> <div className="w-full min-h-[85vh] flex justify-center">
<div className="w-[95vw] lg:w-[85vw] 3xl:w-[70vw] mt-8 max-sm:mt-16 pt-9 "> <div className="w-[95vw] lg:w-[85vw] 3xl:w-[70vw] mt-8 max-sm:mt-16 pt-9 ">
<div className="flex w-full justify-between flex-row "> <div className="flex w-full justify-between flex-row ">
{/* 1 */} {/* 1 */}
@ -418,7 +417,7 @@ export default function AdminCategories() {
return ( return (
<div <div
key={item.id} key={item.id}
className={`flex flex-col justify-center gap-2 w-full lg:w-[49%] h-28 px-5 rounded-md shadow-md items-start className={`flex flex-col justify-center gap-2 w-full lg:w-[49%] h-28 px-5 rounded-md shadow-md items-start bg-[#F5F5F5]
`} `}
> >
<p className=" text-slate-500 text-sm font-normal leading-normal"> <p className=" text-slate-500 text-sm font-normal leading-normal">
@ -435,7 +434,7 @@ export default function AdminCategories() {
<div className="w-full flex justify-end items-end gap-2"> <div className="w-full flex justify-end items-end gap-2">
<Switch <Switch
dir="ltr" dir="ltr"
checked={item.isDeleted} checked={!item.isDeleted}
onCheckedChange={() => { onCheckedChange={() => {
DeleteCatMutation.mutate({ DeleteCatMutation.mutate({
id: item.id, id: item.id,

View File

@ -36,6 +36,7 @@ import { toast } from "sonner";
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 { Textarea } from "./ui/textarea";
const MAX_FILE_SIZE = 5242880; // 5 MB const MAX_FILE_SIZE = 5242880; // 5 MB
// Edit Key Form // Edit Key Form
@ -76,8 +77,8 @@ export default function AdminKeysManagement() {
const [openAdd, setOpenAdd] = React.useState(false); const [openAdd, setOpenAdd] = React.useState(false);
const [openEdit, setOpenEdit] = React.useState(false); const [openEdit, setOpenEdit] = React.useState(false);
const inputPubRef = useRef<HTMLInputElement | null>(null); const inputPubRef = useRef<HTMLTextAreaElement | null>(null);
const inputPrvRef = useRef<HTMLInputElement | null>(null); const inputPrvRef = useRef<HTMLTextAreaElement | null>(null);
// ..............Read .txt // ..............Read .txt
const [selectedFile, setSelectedFile] = useState<any>(null); const [selectedFile, setSelectedFile] = useState<any>(null);
@ -138,17 +139,10 @@ export default function AdminKeysManagement() {
console.log("bcbcbbcbcbccc" + selectedFile); console.log("bcbcbbcbcbccc" + selectedFile);
console.log("bcbcbbcbcbccccc" + data1[0]?.id); console.log("bcbcbbcbcbccccc" + data1[0]?.id);
// if (keyId) {
ChangeKeyMutation.mutate({ ChangeKeyMutation.mutate({
privateKey: selectedFile, privateKey: selectedFile,
publicKeyId: keyId, publicKeyId: keyId,
// publicKeyId: data1?.id,
}); });
// }
// else{
// console.error("keyId is undefined");
// }
} }
// Add Form // Add Form
@ -210,6 +204,7 @@ export default function AdminKeysManagement() {
error: Error1, error: Error1,
isLoading: isListLoading, isLoading: isListLoading,
refetch: refetch1, refetch: refetch1,
isSuccess: isSuccess1,
} = useQuery({ } = useQuery({
queryKey: ["KeysList"], queryKey: ["KeysList"],
queryFn: () => GetKeys(), queryFn: () => GetKeys(),
@ -223,6 +218,7 @@ export default function AdminKeysManagement() {
error: Error2, error: Error2,
isLoading: isNewKeyLoading, isLoading: isNewKeyLoading,
refetch: refetch2, refetch: refetch2,
isSuccess: isSuccess2,
} = useQuery({ } = useQuery({
queryKey: ["GenerateKey"], queryKey: ["GenerateKey"],
queryFn: () => GenerateKeyPair(), queryFn: () => GenerateKeyPair(),
@ -236,6 +232,11 @@ export default function AdminKeysManagement() {
refetch2(); refetch2();
console.log(data2); console.log(data2);
}; };
useEffect(() => {
if (isSuccess2) {
formAdd.setValue("publicKey", data2?.publicKey);
}
}, [isSuccess2]);
useEffect(() => { useEffect(() => {
if (inputPubRef.current && inputPrvRef.current) { if (inputPubRef.current && inputPrvRef.current) {
@ -244,28 +245,39 @@ export default function AdminKeysManagement() {
} }
}, [handleClickGenerate]); }, [handleClickGenerate]);
const saveTextFile = () => {
const textToSave = data2?.privateKey ?? "";
const fileName = "privateKey.txt";
const handleClickAddKey = () => { // Create a Blob containing the file data
// refetch2(); const blob = new Blob([textToSave], { type: "text/plain" });
console.log(data1);
// Create a link element
const link = document.createElement("a");
// Set the download attribute and create a URL for the Blob
link.download = fileName;
link.href = window.URL.createObjectURL(blob);
// Append the link to the document and trigger the click event
document.body.appendChild(link);
link.click();
// Remove the link from the document
document.body.removeChild(link);
}; };
useEffect(() => {
if (AddKeyMutation.isSuccess) {
saveTextFile();
}
}, [AddKeyMutation.isSuccess]);
return ( return (
<div className="w-full bg-[#F5F5F5] min-h-[85vh] flex justify-center"> <div className="w-full min-h-[85vh] flex justify-center">
<div className="w-[95vw] lg:w-[85vw] 3xl:w-[70vw] mt-8 max-sm:mt-16 pt-9 "> <div className="w-[95vw] lg:w-[85vw] 3xl:w-[70vw] mt-8 max-sm:mt-16 pt-9 ">
{/* 1 */} {/* 1 */}
<AlertDialog open={openAdd} onOpenChange={setOpenAdd}> <AlertDialog open={openAdd} onOpenChange={setOpenAdd}>
<AlertDialogTrigger asChild> <AlertDialogContent className=" ">
<Button
variant="outline"
onClick={handleClickAddKey}
className="bg-orange-500 text-white"
// disabled={isNewKeyLoading}
>
افزودن کلید جدید
</Button>
</AlertDialogTrigger>
<AlertDialogContent className=" w-full max-w-6xl h-full max-h-[90vh] lg:max-h-[70vh]">
<AlertDialogHeader> <AlertDialogHeader>
<AlertDialogTitle> <AlertDialogTitle>
<p className="text-[#464646] text-base font-bold"> <p className="text-[#464646] text-base font-bold">
@ -277,150 +289,79 @@ export default function AdminKeysManagement() {
</AlertDialogTitle> </AlertDialogTitle>
<AlertDialogDescription> <AlertDialogDescription>
<div className="w-full "> <div className=" w-full flex justify-between">
<div className="w-full text-right text-neutral-600 text-lg font-bold mb-4">
ایجاد جفت کلید جدید
</div>
{isNewKeyLoading ? (
<div className="felx justify-center items-center self-center">
<ThreeDots
visible={true}
height="50"
width="100"
color="#003778"
radius="9"
ariaLabel="three-dots-loading"
wrapperStyle={{}}
wrapperClass=""
/>
</div>
) : (
<div>
<Button
variant="outline"
onClick={handleClickGenerate}
disabled={isNewKeyLoading}
className="my-2"
>
{" "}
ایجاد جفت کلید
</Button>
{isNewKeyLoading ? (
<div className="felx justify-center items-center self-center h-full">
<ThreeDots
visible={true}
height="20"
width="50"
color="#003778"
radius="9"
ariaLabel="three-dots-loading"
wrapperStyle={{}}
wrapperClass=""
/>
</div>
) : (
<div
className="flex flex-row flex-wrap justify-between"
id="KeyFetch"
>
<div className=" w-full lg:w-[48%]">
<p className="text-[#7C838A] text-sm font-semibold">
کلید عمومی :
</p>
{/* <p className="text-slate-700 text-sm text-left mb-4">
{data2?.publicKey}
</p> */}
<Input
name="pubKey"
ref={inputPubRef}
// value={data2?.publicKey}
readOnly={true}
className="text-slate-700 text-sm text-left mb-4 w-full bg-white"
/>
</div>
<div className=" w-full lg:w-[48%]">
<p className="text-[#7C838A] text-sm font-semibold">
کلید خصوصی :
</p>
{/* <p className="text-slate-700 text-sm text-left mb-4">
{data2?.privateKey}
</p> */}
<Input
ref={inputPrvRef}
name="privKey"
// value={data2?.privateKey}
readOnly={true}
className="text-slate-700 text-sm text-left mb-4 w-full bg-white"
/>
</div>
</div>
)}
</div>
)}
<div className="w-full text-right text-neutral-600 text-lg font-bold mt-4 mb-2"> <div className="w-full text-right text-neutral-600 text-lg font-bold mt-4 mb-2">
افزودن کلید جدید افزودن کلید جدید
</div> </div>
<Form {...formAdd}> <Button
<form variant="outline"
onSubmit={formAdd.handleSubmit(onSubmitAdd)} onClick={handleClickGenerate}
className="w-full flex flex-col mt-6 " disabled={isNewKeyLoading}
> className="my-2"
<div className="flex flex-row flex-wrap justify-between"> >
<FormField {" "}
control={formAdd.control} ایجاد جفت کلید
name="title" </Button>
render={({ field }) => (
<FormItem className=" w-full lg:w-[48%]">
<FormLabel className="text-[#7C838A] text-sm font-medium">
عنوان کلید
</FormLabel>
<FormControl>
<Input
placeholder="عنوان کلید را وارد نمایید"
{...field}
className="bg-white"
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={formAdd.control}
name="publicKey"
render={({ field }) => (
<FormItem className=" w-full lg:w-[48%]">
<FormLabel className="text-[#7C838A] text-sm font-medium ">
کلید عمومی
</FormLabel>
<FormControl>
<Input
placeholder="کلید عمومی را وارد کنید"
{...field}
className="bg-white"
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</div>
<div className="flex justify-center sm:justify-end gap-2 w-full mt-8">
<Button
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"
>
افزودن کلید
</Button>
</div>
</form>
</Form>
</div> </div>
<Form {...formAdd}>
<form
onSubmit={formAdd.handleSubmit(onSubmitAdd)}
className="w-full flex flex-col mt-6 "
>
<div className="flex flex-col flex-wrap justify-between">
<FormField
control={formAdd.control}
name="title"
render={({ field }) => (
<FormItem className=" w-full ">
<FormLabel className="text-[#7C838A] text-sm font-medium">
عنوان کلید
</FormLabel>
<FormControl>
<Input
placeholder="عنوان کلید را وارد نمایید"
{...field}
className="bg-white"
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={formAdd.control}
name="publicKey"
render={({ field }) => (
<FormItem className=" w-full">
<FormLabel className="text-[#7C838A] text-sm font-medium ">
کلید عمومی
</FormLabel>
<FormControl>
<Textarea
placeholder="کلید عمومی را وارد کنید"
{...field}
className="bg-white resize-none"
dir="ltr"
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</div>
<div className="flex justify-center sm:justify-end gap-2 w-full mt-8">
<Button
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"
>
افزودن کلید
</Button>
</div>
</form>
</Form>
</AlertDialogDescription> </AlertDialogDescription>
</AlertDialogHeader> </AlertDialogHeader>
<AlertDialogFooter> <AlertDialogFooter>
@ -428,74 +369,84 @@ export default function AdminKeysManagement() {
{/* <AlertDialogAction>Continue</AlertDialogAction> */} {/* <AlertDialogAction>Continue</AlertDialogAction> */}
</AlertDialogFooter> </AlertDialogFooter>
</AlertDialogContent> </AlertDialogContent>
</AlertDialog>
{/* 2 */} {/* 2 */}
<div className="w-full text-right text-neutral-600 text-lg font-bold my-4"> <div className=" w-full flex justify-between items-center mt-1">
لیست کلیدها <div className="w-full text-right text-neutral-600 text-lg font-bold my-4">
</div> لیست کلیدها
<div className="w-full flex flex-row flex-wrap justify-between gap-8 md:gap-4 "> </div>
{data1?.map((item: any) => { <AlertDialogTrigger asChild>
return ( <Button
<div variant="outline"
key={item.id} className="bg-orange-500 hover:bg-orange-500/80 text-white hover:text-white"
className={`flex flex-col justify-center gap-2 w-full lg:w-[49%] h-28 px-5 rounded-md shadow-md items-start // disabled={isNewKeyLoading}
`}
> >
<p className=" text-slate-500 text-sm font-normal leading-normal"> افزودن کلید جدید
عنوان کلید : </Button>
<span className=" text-slate-800">{item.title}</span> </AlertDialogTrigger>
</p> </div>
<p className=" text-slate-500 text-sm font-normal leading-normal"> <div className="w-full flex flex-row flex-wrap justify-between gap-8 md:gap-4 ">
آی دی بازرس : {data1?.map((item: any) => {
<span className=" text-slate-800 self-end"> return (
{item.inspectorId} <div
</span> key={item.id}
</p> className={`flex flex-col justify-center gap-2 w-full lg:w-[49%] h-28 px-5 rounded-md shadow-md items-start bg-[#F5F5F5]
`}
>
<p className=" text-slate-500 text-sm font-normal leading-normal">
عنوان کلید:{" "}
<span className=" text-slate-800">{item.title}</span>
</p>
<p className=" text-slate-500 text-sm font-normal leading-normal">
آیدی بازرس:{" "}
<span className=" text-slate-800 self-end">
{item.inspectorId}
</span>
</p>
<AlertDialog open={openEdit} onOpenChange={setOpenEdit}> <AlertDialog open={openEdit} onOpenChange={setOpenEdit}>
<AlertDialogTrigger asChild> <AlertDialogTrigger asChild>
{/* <Button variant="outline">Show Dialog</Button> */} {/* <Button variant="outline">Show Dialog</Button> */}
<FaRegEdit <FaRegEdit
aria-hidden="true" aria-hidden="true"
className="w-6 h-6 text-slate-600 hover:cursor-pointer self-end" className="w-6 h-6 text-slate-600 hover:cursor-pointer self-end"
onClick={() => setKeyId(item?.id)} onClick={() => setKeyId(item?.id)}
/> />
</AlertDialogTrigger> </AlertDialogTrigger>
<AlertDialogContent className=" w-full max-w-3xl h-full lg:max-h-[20em] max-h-[23em]"> <AlertDialogContent className=" w-full max-w-3xl h-full lg:max-h-[20em] max-h-[23em]">
<AlertDialogHeader> <AlertDialogHeader>
<AlertDialogTitle>تغییر کلید</AlertDialogTitle> <AlertDialogTitle>تغییر کلید</AlertDialogTitle>
<AlertDialogDescription> <AlertDialogDescription>
<Form {...formEdit}> <Form {...formEdit}>
<form <form
onSubmit={formEdit.handleSubmit(onSubmitEdit)} onSubmit={formEdit.handleSubmit(onSubmitEdit)}
className="w-full flex flex-col mt-6 " className="w-full flex flex-col mt-6 "
> >
<div className="flex flex-row flex-wrap justify-between"> <div className="flex flex-row flex-wrap justify-between">
<FormField <FormField
control={formEdit.control} control={formEdit.control}
name="uploadPrivateKey" name="uploadPrivateKey"
render={({ field }) => ( render={({ field }) => (
<FormItem className=" w-full"> <FormItem className=" w-full">
<FormLabel className="text-[#7C838A] text-sm font-medium mb-2"> <FormLabel className="text-[#7C838A] text-sm font-medium mb-2">
پیوست (کلید خصوصی) پیوست (کلید خصوصی)
</FormLabel> </FormLabel>
<FormControl> <FormControl>
<Input <Input
required={true} required={true}
type="file" type="file"
accept=".txt" accept=".txt"
className="bg-slate-300 mt-2" className="bg-slate-300 mt-2"
// {...field} // {...field}
onChange={handleFileChange} onChange={handleFileChange}
/> />
</FormControl> </FormControl>
<FormMessage /> <FormMessage />
</FormItem> </FormItem>
)} )}
/> />
{/* <FormField {/* <FormField
control={formEdit.control} control={formEdit.control}
name="publicKeyId" name="publicKeyId"
render={({ field }) => ( render={({ field }) => (
@ -515,41 +466,42 @@ export default function AdminKeysManagement() {
</FormItem> </FormItem>
)} )}
/> */} /> */}
</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 <Button
// href="/FollowResult" // href="/FollowResult"
type="submit" type="submit"
className="bg-blue text-white min-w-max p-2 rounded-xl text-center hover:bg-white hover:text-slate-800" className="bg-blue text-white min-w-max p-2 rounded-xl text-center hover:bg-white hover:text-slate-800"
> >
تغییر کلید تغییر کلید
</Button> </Button>
{/* <AlertDialogAction {/* <AlertDialogAction
type="submit" type="submit"
className="bg-blue text-white min-w-max p-2 rounded-xl text-center hover:bg-white hover:text-slate-800" className="bg-blue text-white min-w-max p-2 rounded-xl text-center hover:bg-white hover:text-slate-800"
> >
تغییر کلید تغییر کلید
</AlertDialogAction> */} </AlertDialogAction> */}
<AlertDialogCancel className="bg-blue text-white rounded-xl mt-0"> <AlertDialogCancel className="bg-blue text-white rounded-xl mt-0">
بستن بستن
</AlertDialogCancel> </AlertDialogCancel>
</div> </div>
</form> </form>
</Form> </Form>
</AlertDialogDescription> </AlertDialogDescription>
</AlertDialogHeader> </AlertDialogHeader>
<AlertDialogFooter> <AlertDialogFooter>
{/* <AlertDialogAction>Continue</AlertDialogAction> */} {/* <AlertDialogAction>Continue</AlertDialogAction> */}
</AlertDialogFooter> </AlertDialogFooter>
</AlertDialogContent> </AlertDialogContent>
</AlertDialog> </AlertDialog>
</div> </div>
); );
})} })}
</div> </div>
</AlertDialog>
</div> </div>
</div> </div>
); );

View File

@ -234,7 +234,7 @@ export default function AdminOrganizations() {
console.log(data); console.log(data);
} }
return ( return (
<div className="w-full bg-[#F5F5F5] min-h-[85vh] flex justify-center"> <div className="w-full min-h-[85vh] flex justify-center">
<div className="w-[95vw] lg:w-[85vw] 3xl:w-[70vw] mt-8 max-sm:mt-16 pt-9 "> <div className="w-[95vw] lg:w-[85vw] 3xl:w-[70vw] mt-8 max-sm:mt-16 pt-9 ">
<div className="flex w-full justify-between flex-row "> <div className="flex w-full justify-between flex-row ">
{/* 1 */} {/* 1 */}
@ -421,7 +421,7 @@ export default function AdminOrganizations() {
return ( return (
<div <div
key={item.id} key={item.id}
className={`flex flex-col justify-center gap-2 w-full lg:w-[49%] h-28 px-5 rounded-md shadow-md items-start className={`flex flex-col justify-center gap-2 w-full lg:w-[49%] h-28 px-5 rounded-md shadow-md items-start bg-[#F5F5F5]
`} `}
> >
<p className=" text-slate-500 text-sm font-normal leading-normal"> <p className=" text-slate-500 text-sm font-normal leading-normal">
@ -438,7 +438,7 @@ export default function AdminOrganizations() {
<div className="w-full flex justify-end items-end gap-2"> <div className="w-full flex justify-end items-end gap-2">
<Switch <Switch
dir="ltr" dir="ltr"
checked={item.isDeleted} checked={!item.isDeleted}
onCheckedChange={() => { onCheckedChange={() => {
DeleteOrgMutation.mutate({ DeleteOrgMutation.mutate({
id: item.id, id: item.id,

View File

@ -1,5 +1,5 @@
"use client"; "use client";
import React, { useEffect } from "react"; import React, { useEffect, useState } from "react";
import greenIcon from "../public/img/greenPoint.svg"; import greenIcon from "../public/img/greenPoint.svg";
import blueIcon from "../public/img/bluepoint.svg"; import blueIcon from "../public/img/bluepoint.svg";
import Image from "next/image"; import Image from "next/image";
@ -7,13 +7,29 @@ import { ComplainDetailsItems } from "@/constants";
import { useMutation } from "@tanstack/react-query"; import { useMutation } from "@tanstack/react-query";
import { OperateByInspector, getComplaint } from "@/utils/inspectorApi"; import { OperateByInspector, getComplaint } from "@/utils/inspectorApi";
import useData from "@/store/useData"; import useData from "@/store/useData";
import { convertDate } from "@/lib/utils"; import { Decrypt, convertDate, convertFullTime } from "@/lib/utils";
import { Badge } from "./ui/badge"; import { Badge } from "./ui/badge";
import InspectorOperations from "./InspectorOperations"; import InspectorOperations from "./InspectorOperations";
import { postComplaintTracking } from "@/utils/citizenApi"; import { ArrowDownToLine, ArrowRight, File } from "lucide-react";
import { ArrowDownToLine, File } from "lucide-react";
import { Separator } from "./ui/separator"; import { Separator } from "./ui/separator";
import secureLocalStorage from "react-secure-storage";
import { Checkbox } from "./ui/checkbox";
import { Button } from "@/components/ui/button";
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
import { Input } from "./ui/input";
import { toast } from "sonner";
import { useRouter } from "next/navigation";
import { Triangle } from "react-loader-spinner";
export default function ComplainsDetails({ export default function ComplainsDetails({
id, id,
role, role,
@ -24,46 +40,47 @@ export default function ComplainsDetails({
Data?: any; Data?: any;
}) { }) {
const storeData = useData((state) => state.data); const storeData = useData((state) => state.data);
const [open, setOpen] = useState<boolean>(true);
const [check, setCheck] = useState<any>(false);
const [complaintData, setComplaintData] = useState<any>("");
const [selectedFile, setSelectedFile] = useState<any>(null);
const [key, setKey] = useState<any>(null);
const router = useRouter();
let data; let data;
const getComplaintMutation = useMutation< const getComplaintMutation = useMutation({
any,
Error,
{ trackingNumber: string; password: string }
>({
mutationKey: ["Complaint", id], mutationKey: ["Complaint", id],
mutationFn: mutationFn: getComplaint,
role == "Inspector" onSuccess: (res) => {
? (getComplaint as any) localStorage.setItem("trackingNumber", res.trackingNumber);
: (postComplaintTracking as any), },
onSuccess: (res) => {},
onError: (err) => {}, onError: (err) => {},
}); });
console.log(storeData);
useEffect(() => { useEffect(() => {
if (role == "Inspector") { const storedData = localStorage.getItem("CompliantData");
useData.persist.rehydrate(); const data = JSON.parse(storedData as string);
const pw = localStorage.getItem("privateKey") as string;
localStorage.setItem("trackingNumber", data.trackingNumber);
if (pw != null) {
getComplaintMutation.mutate({
trackingNumber: data.trackingNumber,
password: pw,
});
setOpen(false);
} }
}, []); }, []);
useEffect(() => { useEffect(() => {
if (storeData && role == "Inspector") { const storedData = localStorage.getItem("CompliantData");
getComplaintMutation.mutate(storeData); const data = JSON.parse(storedData as string);
} setComplaintData(data);
}, [storeData]); }, []);
if (getComplaintMutation.isSuccess) { if (getComplaintMutation.isSuccess) {
data = getComplaintMutation.data; data = getComplaintMutation.data;
} 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 openFileInNewTab = (base64Data: any, fileType: any) => {
const blob = b64toBlob(base64Data, fileType); const blob = b64toBlob(base64Data, fileType);
const blobUrl = URL.createObjectURL(blob); const blobUrl = URL.createObjectURL(blob);
@ -97,7 +114,7 @@ export default function ComplainsDetails({
} }
}; };
const downloadFile = (base64Data, fileName, fileType) => { const downloadFile = (base64Data: any, fileName: any, fileType: any) => {
const blob = b64toBlob(base64Data, fileType); const blob = b64toBlob(base64Data, fileType);
const blobUrl = URL.createObjectURL(blob); const blobUrl = URL.createObjectURL(blob);
@ -109,7 +126,7 @@ export default function ComplainsDetails({
URL.revokeObjectURL(blobUrl); URL.revokeObjectURL(blobUrl);
}; };
const b64toBlob = (b64Data, contentType = "", sliceSize = 512) => { const b64toBlob = (b64Data: any, contentType = "", sliceSize = 512) => {
const byteCharacters = atob(b64Data); const byteCharacters = atob(b64Data);
const byteArrays = []; const byteArrays = [];
@ -127,136 +144,441 @@ export default function ComplainsDetails({
return new Blob(byteArrays, { type: contentType }); return new Blob(byteArrays, { type: contentType });
}; };
console.log(Data);
const handleFileChange = (event: any) => {
const file = event.target.files[0];
const reader = new FileReader();
reader.onload = (e) => {
const contents = e?.target?.result;
setSelectedFile(contents);
};
reader.readAsText(file);
};
const checkKey2 = (item: any) => {
const dcKey = Decrypt(item.cipherKeyInspector, selectedFile);
console.log(dcKey);
if (dcKey != false && dcKey != null) {
if (check) {
localStorage.setItem("privateKey", dcKey);
}
localStorage.setItem("trackingNumber", item.trackingNumber);
setKey(dcKey);
getComplaintMutation.mutate({
trackingNumber: item.trackingNumber,
password: dcKey as string,
});
setOpen(false);
} else {
toast("کلید شما معتبر نمی باشد.", {
className: "!bg-red-500 !text-white",
});
}
};
data = getComplaintMutation?.data;
return ( return (
<> <>
{data ? ( <AlertDialog open={open} onOpenChange={setOpen}>
<div className="w-full flex max-lg:flex-col gap-3 items-start"> <AlertDialogContent dir="rtl" className="">
<div className="flex flex-col w-full lg:w-1/3 lg:order-2 gap-3 lg:sticky top-20"> <AlertDialogHeader dir="rtl">
<div className=" bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col"> <AlertDialogTitle dir="rtl">بارگذاری کلید خصوصی</AlertDialogTitle>
<p className="text-[#464646] text-base font-bold">گزارش شکایت</p> <AlertDialogDescription>
<div className="mt-2"> برای مشاهده شکایت لطفا کلید خود را آپلود نمایید.
<p className="text-[#2e2a2a] text-sm font-medium"> </AlertDialogDescription>
موضوع شکایت:{" "} </AlertDialogHeader>
<span className="text-[#7C838A] text-sm font-medium"> <div className="grid w-full max-w-sm items-center gap-1.5 px-8">
{data.title} <Input
</span> dir="rtl"
id="picture"
onChange={handleFileChange}
type="file"
accept=".txt"
className=" bg-white hover:bg-white focus:bg-white"
/>
</div>
<div className="flex items-center space-x-2 px-8">
<Checkbox
checked={check}
onCheckedChange={setCheck}
id="terms"
className=" ml-2"
/>
<label
htmlFor="terms"
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
>
ذخیره کلید برای استفاده در زمان های بعدی
</label>
</div>
<AlertDialogFooter className=" gap-y-2 max-md:w-full max-md:flex max-md:flex-col">
{/* <DialogClose asChild></DialogClose> */}
<Button
variant="outline"
onClick={() => {
router.push("/UserPanel/ControllerDashboard/Complaints");
}}
type="submit"
className=" md:ml-2"
>
بازگشت
</Button>
<Button
className=" bg-blue hover:bg-blue/90"
onClick={() => {
checkKey2(complaintData);
}}
type="submit"
>
ذخیره
</Button>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
{getComplaintMutation.data && !getComplaintMutation.isPending ? (
<>
<button
onClick={() =>
router.push("/UserPanel/ControllerDashboard/Complaints")
}
className=" my-2 flex gap-1 cursor-pointer text-blue "
>
<span>
<ArrowRight />
</span>
<p>بازگشت</p>
</button>
<div className="w-full flex max-lg:flex-col items-start mt-2 gap-2">
<div className="flex flex-col w-full lg:w-1/3 gap-3 lg:sticky top-24">
<div className=" max-lg:hidden bg-[#E9E9E9] rounded-md p-4 px-10 flex flex-col">
<p className="text-[#464646] text-base font-bold mb-1">
انجام عملیات
</p> </p>
<p className="text-[#464646] text-sm font-medium"> <InspectorOperations
دستگاه مربوطه:{" "} updateData={(data) => getComplaintMutation.mutate(data)}
<span className="text-[#7C838A] text-sm font-medium"> role={role}
{/* {data.title} */} complaintData={data}
</span> id={id}
</p> key2={key}
<p className="text-[#464646] text-sm font-medium"> />
پرسنل مربوطه:{" "}
<span className="text-[#7C838A] text-sm font-medium">
{/* {data.title} */}
</span>
</p>
<p className="text-[#464646] text-sm font-medium">
زمان ثبت:{" "}
<span className="text-[#7C838A] text-sm font-medium">
{convertDate(data.registeredAt)}
</span>
</p>
{/* <p className="text-[#464646] text-sm font-medium">
{" "}
موضوع شکایت:{" "}
<span className="text-[#7C838A] text-sm font-medium">
متن تستی
</span>
</p> */}
</div> </div>
{/* <p className="text-[#464646] text-sm font-medium text-justify">
درخواست شما با کد رهگیری {data.trackingNumber} و رمز عبور 12422 در
دست بررسی و اقدام می باشد. در صورت تمایل می توانید با شماره تلفن
0353286545 جهت پشتیبانی تماس حاصل کنید.{" "}
</p> */}
</div> </div>
<div className=" max-lg:hidden order-2 bg-[#E9E9E9] rounded-md p-4 px-10 flex flex-col"> <div className="w-full lg:w-2/3 self-stretch rounded-lg flex flex-col gap-2 ">
<div className=" bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col md:flex-row gap-2 items-center justify-center">
{data.user == null ? (
<>
<div className="mt-2 flex flex-col gap-y-1 border rounded-md border-gray-400 w-full p-5 relative">
<p className=" absolute -top-3 right-2 bg-[#E9E9E9] px-2 text-sm text-gray-500">
اطلاعات کلی
</p>
<p className="text-[#2e2a2a] text-sm font-medium">
موضوع شکایت:{" "}
<span className="text-[#7C838A] text-sm font-medium">
{data?.title}
</span>
</p>
<p className="text-[#464646] text-sm font-medium">
دستگاه مربوطه:{" "}
<span className="text-[#7C838A] text-sm font-medium">
{data?.complaintOrganization
? data?.complaintOrganization.title
: "-"}
</span>
</p>
<p className="text-[#464646] text-sm font-medium">
فرد مربوطه:{" "}
<span className="text-[#7C838A] text-sm font-medium">
{data.complaining ? data.complaining : "-"}
</span>
</p>
<p className="text-[#464646] text-sm font-medium">
زمان ثبت:{" "}
<span className="text-[#7C838A] text-sm font-medium">
{convertFullTime(data.registeredAt)}
</span>
</p>
</div>
</>
) : (
<>
<div className="mt-2 flex flex-col gap-y-1 border rounded-md border-gray-400 md:w-1/2 p-5 relative">
<p className=" absolute -top-3 right-2 bg-[#E9E9E9] px-2 text-sm text-gray-500">
اطلاعات کلی
</p>
<p className="text-[#2e2a2a] text-sm font-medium">
موضوع شکایت:{" "}
<span className="text-[#7C838A] text-sm font-medium">
{data?.title}
</span>
</p>
<p className="text-[#464646] text-sm font-medium">
دستگاه مربوطه:{" "}
<span className="text-[#7C838A] text-sm font-medium">
{data?.complaintOrganization
? data?.complaintOrganization.title
: "-"}
</span>
</p>
<p className="text-[#464646] text-sm font-medium">
فرد مربوطه:{" "}
<span className="text-[#7C838A] text-sm font-medium">
{data.complaining ? data.complaining : "-"}
</span>
</p>
<p className="text-[#464646] text-sm font-medium">
زمان ثبت:{" "}
<span className="text-[#7C838A] text-sm font-medium">
{convertFullTime(data.registeredAt)}
</span>
</p>
</div>
<div className="mt-2 flex flex-col gap-y-1 border rounded-md border-gray-400 md:w-1/2 p-5 relative">
<p className=" absolute -top-3 right-2 bg-[#E9E9E9] px-2 text-sm text-gray-500">
اطلاعات شاکی
</p>
<p className="text-[#2e2a2a] text-sm font-medium">
نام:{" "}
<span className="text-[#7C838A] text-sm font-medium">
{data.user?.firstName ? data.user?.firstName : "-"}
</span>
</p>
<p className="text-[#464646] text-sm font-medium">
نام خانوادگی:{" "}
<span className="text-[#7C838A] text-sm font-medium">
{data.user?.lastName ? data.user?.lastName : "-"}
</span>
</p>
<p className="text-[#464646] text-sm font-medium">
کدملی:{" "}
<span className="text-[#7C838A] text-sm font-medium">
{data.user?.nationalId ? data.user?.nationalId : "-"}
</span>
</p>
<p className="text-[#464646] text-sm font-medium">
شماره موبایل:{" "}
<span className="text-[#7C838A] text-sm font-medium">
{data.user?.phoneNumber
? data.user?.phoneNumber
: "-"}
</span>
</p>
</div>
</>
)}
</div>
<div className="bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col">
<p className="text-[#464646] text-base font-bold">روند شکایت</p>
<div className=" flex flex-col gap-y-4 mt-4">
{data.contents?.map((item: any) => {
return (
<div
key={item.id}
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-[#464646] mt-2">
<span className="text-[#7C838A]">
{item.text ? item.text : "-"}
</span>
</div>
{item.media.length !== 0 && (
<Separator className=" mt-2 mb-1" />
)}
<div className=" text-[#464646] mt-2">
<div className=" flex flex-wrap max-md:flex-col w-full items-center gap-2 text-xs mt-2">
{item?.media.map((item: any, index: number) => {
return (
<div
key={index}
className=" bg-gray-100 text-[#7C838A] w-full md:w-[30%] rounded-md h-12 p-2 flex justify-between gap-3 items-center"
>
<a
onClick={() =>
openFileInNewTab(item.data, item.mimeType)
}
className=" cursor-pointer flex gap-2 truncate items-center"
>
<File className=" w-6 h-6" />
<p className=" max-w-[5rem] truncate">
{item.title}
</p>
</a>
<ArrowDownToLine
className=" cursor-pointer"
onClick={() =>
downloadFile(
item.data,
item.title,
item.mimeType
)
}
/>
</div>
);
})}
</div>
</div>
</div>
);
})}
{data.contents?.map((item: any) => {
return (
<div
key={item.id}
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-[#464646] mt-2">
<span className="text-[#7C838A]">
{item.text ? item.text : "-"}
</span>
</div>
{item.media.length !== 0 && (
<Separator className=" mt-2 mb-1" />
)}
<div className=" text-[#464646] mt-2">
<div className=" flex flex-wrap max-md:flex-col w-full items-center gap-2 text-xs mt-2">
{item?.media.map((item: any, index: number) => {
return (
<div
key={index}
className=" bg-gray-100 text-[#7C838A] w-full md:w-[30%] rounded-md h-12 p-2 flex justify-between gap-3 items-center"
>
<a
onClick={() =>
openFileInNewTab(item.data, item.mimeType)
}
className=" cursor-pointer flex gap-2 truncate items-center"
>
<File className=" w-6 h-6" />
<p className=" max-w-[5rem] truncate">
{item.title}
</p>
</a>
<ArrowDownToLine
className=" cursor-pointer"
onClick={() =>
downloadFile(
item.data,
item.title,
item.mimeType
)
}
/>
</div>
);
})}
</div>
</div>
</div>
);
})}
{data.contents?.map((item: any) => {
return (
<div
key={item.id}
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-[#464646] mt-2">
<span className="text-[#7C838A]">
{item.text ? item.text : "-"}
</span>
</div>
{item.media.length !== 0 && (
<Separator className=" mt-2 mb-1" />
)}
<div className=" text-[#464646] mt-2">
<div className=" flex flex-wrap max-md:flex-col w-full items-center gap-2 text-xs mt-2">
{item?.media.map((item: any, index: number) => {
return (
<div
key={index}
className=" bg-gray-100 text-[#7C838A] w-full md:w-[30%] rounded-md h-12 p-2 flex justify-between gap-3 items-center"
>
<a
onClick={() =>
openFileInNewTab(item.data, item.mimeType)
}
className=" cursor-pointer flex gap-2 truncate items-center"
>
<File className=" w-6 h-6" />
<p className=" max-w-[5rem] truncate">
{item.title}
</p>
</a>
<ArrowDownToLine
className=" cursor-pointer"
onClick={() =>
downloadFile(
item.data,
item.title,
item.mimeType
)
}
/>
</div>
);
})}
</div>
</div>
</div>
);
})}
</div>
</div>
</div>
<div className=" lg:hidden order-2 w-full bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col mt-2">
<p className="text-[#464646] text-base font-bold mb-1"> <p className="text-[#464646] text-base font-bold mb-1">
انجام عملیات انجام عملیات
</p> </p>
<InspectorOperations <InspectorOperations
updateData={() => getComplaintMutation.mutate(storeData)} updateData={(data) => getComplaintMutation.mutate(data)}
role={role} role={role}
complaintData={data} complaintData={data}
id={id}
key2={key}
/> />
</div> </div>
</div> {/* Left */}
<div className="w-full lg:w-2/3 self-stretch bg-[#E9E9E9] p-4 px-10 rounded-lg"> {/* <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">
<p className="text-[#464646] text-base font-bold">روند شکایت</p>
<div className=" flex flex-col gap-y-4 mt-4">
{data.contents?.map((item: any) => {
return (
<div
key={item.id}
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-[#464646] mt-2">
<span className="text-[#7C838A]">
{item.text ? item.text : "-"}
</span>
</div>
{item.media.length !== 0 && <Separator className=" mt-2" />}
<div className=" text-[#464646] mt-2">
<div className=" flex flex-wrap max-md:flex-col w-full items-center gap-2 text-xs mt-2">
{item?.media.map((item: any) => {
return (
<div className=" bg-gray-100 text-[#7C838A] w-full md:w-40 rounded-md p-2 flex justify-between gap-2 ">
<a
onClick={() =>
openFileInNewTab(item.data, item.mimeType)
}
className=" cursor-pointer flex gap-2 truncate items-center"
>
<File />
<p className=" truncate">{item.title}</p>
</a>
<ArrowDownToLine
className=" cursor-pointer"
onClick={() =>
downloadFile(
item.data,
item.title,
item.mimeType
)
}
/>
</div>
);
})}
</div>
</div>
</div>
);
})}
</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>
<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">
<p className="text-[#464646] text-base font-bold mb-3"> <p className="text-[#464646] text-base font-bold mb-3">
وضعیت درخواست وضعیت درخواست
</p> </p>
@ -294,9 +616,24 @@ export default function ComplainsDetails({
); );
})} })}
</div> */} </div> */}
</div> </div>
</>
) : ( ) : (
"" <>
{getComplaintMutation.isPending && (
<div className="w-full h-full flex justify-center mt-20">
<Triangle
visible={true}
height="100"
width="100"
color="#003778"
ariaLabel="triangle-loading"
wrapperStyle={{}}
wrapperClass=""
/>
</div>
)}
</>
)} )}
</> </>
); );

View File

@ -24,15 +24,21 @@ export default function ControllerDashboard() {
{/* Lg Show */} {/* Lg Show */}
<div className="w-full mb-6 flex-col gap-0 flex"> <div className="w-full mb-6 flex-col gap-0 flex">
<div className="w-full flex flex-row flex-wrap mx-auto justify-center gap-8 mb-10"> <div className="w-full flex flex-row flex-wrap mx-auto justify-center gap-8 mb-10">
{data?.singletons.map((item: any) => { {data?.singletons.map((item: any, index: number) => {
return <BoxDashboard value={item.value} title={item.title} />; return (
<BoxDashboard key={index} value={item.value} title={item.title} />
);
})} })}
</div> </div>
<div className=" bg-[#EFEFEF80] rounded-lg flex justify-center shadow-md"> <div className=" bg-[#EFEFEF80] rounded-lg flex justify-center shadow-md">
{data?.charts.map((item: any) => { {data?.charts.map((item: any, index: number) => {
return ( return (
<LineChart chartTitle={item.chartTitle} chartData={item.series} /> <LineChart
key={index}
chartTitle={item.chartTitle}
chartData={item.series}
/>
); );
})} })}
</div> </div>

View File

@ -1,214 +0,0 @@
"use client";
import React, { useEffect, useState, useRef } from "react";
import Image from "next/image";
import Resultimg from "../public/img/followResult.png";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { ThreeDots } from "react-loader-spinner";
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/button";
import { IoMdClose } from "react-icons/io";
import { postComplaintTracking } from "@/utils/citizenApi";
import { useMutation } from "@tanstack/react-query";
import { useReactToPrint } from "react-to-print";
import "../app/print-styles.css";
import ComplainsDetails from "./ComplainsDetails";
export default function FollowResult() {
const router = useRouter();
const [trackingNumber, setTrackingNumber] = useState<any>();
const [password, setPassword] = useState<any>();
const [complaintData, setComplaintData] = useState<any>();
const [printStyle, setPrintStyle] = useState<boolean>(true);
// Print component Data
const componentRef = useRef<HTMLDivElement>(null);
const handlePrint = useReactToPrint({
content: () => componentRef.current,
// onBeforePrint() {
// setPrintStyle(!printStyle);
// },
// onAfterPrint() {
// setPrintStyle(!printStyle)
// },
});
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) => {
setComplaintData(res);
},
onError: (error) => {
console.log(error);
console.log(error?.message);
},
});
function onSubmit() {
console.log("SuccessPrinttttttttttt");
// 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.";
console.log(complaintPrintMutation?.data);
return (
<>
<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"
>
درخواست شما با کد رهگیری
<span className="text-slate-500 mx-2">{`${trackingNumber}`}</span>و
رمز عبور
<span className="text-slate-500 mx-2">{`${password}`}</span>
در دست بررسی و اقدام می باشد. در صورت تمایل می توانید با شماره تلفن
0353286545 جهت پشتیبانی تماس حاصل کنید.
</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-fit bg-blue text-white p-2 rounded-xl text-center"
>
پرینت درخواست
</Button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>
<p className="text-[#464646] text-base font-bold">
گزارش شکایات
</p>
<AlertDialogCancel className="p-0 border-0 h-auto">
<IoMdClose />
</AlertDialogCancel>
</AlertDialogTitle>
<AlertDialogDescription className="h-full px-0 py-0 sm:px-0 sm:pt-0 ">
{complaintPrintMutation.isPending ? (
<div className="felx justify-center items-center self-center h-full">
<ThreeDots
visible={true}
height="80"
width="100"
color="#003778"
radius="9"
ariaLabel="three-dots-loading"
wrapperStyle={{}}
wrapperClass=""
/>
</div>
) : (
<div
dir="rtl"
className=" font-[yekan] px-10 py-4 sm:px-28 sm:pt-9 "
id="details"
ref={componentRef}
// style={{ border: printStyle ? 'none' : '5px solid black' , margin: printStyle ? 'auto': '1em' }}
>
<p className="text-[#464646] text-sm font-medium">
{" "}
موضوع شکایت:{" "}
<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">
{`${complaintData?.contents[0]?.text}`}
</span>
</p>
<br />
<p className="text-[#464646] text-sm font-medium">
{" "}
جزئیات شکایت:
</p>
<br />
<p className="text-[#464646] text-sm font-medium">
درخواست شما با کد رهگیری
<span className="text-slate-500 mx-2">{`${trackingNumber}`}</span>
و رمز عبور
<span className="text-slate-500 mx-2">{`${password}`}</span>
در دست بررسی و اقدام می باشد. در صورت تمایل می
توانید با شماره تلفن 0353286545 جهت پشتیبانی تماس
حاصل کنید.
</p>
</div>
)}
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<Button
className="bg-blue text-white w-1/2 sm:w-1/6"
onClick={handlePrint}
>
پرینت گزارش
</Button>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</div>
<ComplainsDetails
role="Citizen"
Data={complaintPrintMutation?.data}
/>
</>
) : (
""
)}
{/* <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>
</>
);
}

View File

@ -11,20 +11,20 @@ export default function Footer() {
// <div classNameName="flex justify-center items-center w-full bg-blue "> // <div classNameName="flex justify-center items-center w-full bg-blue ">
<footer className="bg-blue dark:bg-gray-900"> <footer className="bg-blue dark:bg-gray-900">
<div <div className="mx-auto w-full max-w-screen-3xl px-4 py-7 md:px-8 md:py-8 lg:pt-14 lg:pb-7 lg:px-11 ">
className="mx-auto w-full max-w-screen-3xl px-4 py-7 md:px-8 md:py-8 lg:pt-14 lg:pb-7 lg:px-11 "
>
<div className="md:flex md:justify-between w-full "> <div className="md:flex md:justify-between w-full ">
<div className="grid gap-10 sm:gap-16 md:gap-20 lg:gap-28 grid-cols-1 w-full md:grid-cols-2 md:w-3/4 lg:w-2/4" > <div className="grid gap-10 sm:gap-16 md:gap-20 lg:gap-28 grid-cols-1 w-full md:grid-cols-2 md:w-3/4 lg:w-2/4">
<div> <div>
<h2 className="text-white text-sm sm:text-base font-bold mb-4 "> <h2 className="text-white text-sm sm:text-base font-bold mb-4 ">
درباره سامانه سوت زنی درباره سامانه عیون
</h2> </h2>
{aboutFooterItems.map((item) => { {aboutFooterItems.map((item) => {
return ( return (
<div key={item.id}> <div key={item.id}>
<p className=" text-white text-xs md:text-sm font-normal md:leading-7">{item.name}</p> <p className=" text-white text-xs md:text-sm font-normal md:leading-7">
{item.name}
</p>
</div> </div>
); );
})} })}
@ -38,7 +38,9 @@ export default function Footer() {
{footerItems.map((item, index, array) => { {footerItems.map((item, index, array) => {
return ( return (
<Link key={item.id} href={item.href}> <Link key={item.id} href={item.href}>
<div className=" text-white text-xs md:text-sm font-normal leading-6 mb-3">{item.name}</div> <div className=" text-white text-xs md:text-sm font-normal leading-6 mb-3">
{item.name}
</div>
</Link> </Link>
); );
})} })}
@ -73,7 +75,7 @@ export default function Footer() {
<hr className=" border-gray-200 sm:mx-auto dark:border-gray-700 mt-5 sm:mt-10" /> <hr className=" border-gray-200 sm:mx-auto dark:border-gray-700 mt-5 sm:mt-10" />
<div className="sm:flex sm:items-center sm:justify-between"> <div className="sm:flex sm:items-center sm:justify-between">
<p className="text-white text-xs font-normal mt-4"> <p className="text-white text-xs font-normal mt-4">
تمامی حقوق مادی و معنوی این وب سایت متعلق به سوت زنی میباشد. تمامی حقوق مادی و معنوی این وب سایت متعلق به عیون میباشد.
</p> </p>
</div> </div>
</div> </div>

View File

@ -29,36 +29,34 @@ import {
} from "@/components/ui/select"; } from "@/components/ui/select";
import { Operations } from "@/constants"; import { Operations } from "@/constants";
import useData from "@/store/useData"; import useData from "@/store/useData";
import { useMutation } from "@tanstack/react-query"; import { useMutation, useQueryClient } from "@tanstack/react-query";
import { OperateByInspector } from "@/utils/inspectorApi"; import { OperateByInspector } from "@/utils/inspectorApi";
import { toast } from "sonner"; import { toast } from "sonner";
import { postComplaintsDetails } from "@/utils/citizenApi"; import secureLocalStorage from "react-secure-storage";
import { Decrypt } from "@/lib/utils";
export default function InspectorOperations({ export default function InspectorOperations({
complaintData, complaintData,
role, role,
updateData, updateData,
id,
key2,
}: { }: {
complaintData: any; complaintData: any;
role: string; role: string;
updateData: () => any; updateData: (data: any) => any;
id: any;
key2: any;
}) { }) {
const FormSchema = z.object({ const FormSchema = z.object({
text: z text: z.string({ required_error: "لطفا متن خود را وارد نمایید." }),
.string({ required_error: "لطفا متن خود را وارد نمایید." })
.min(8, {
message: "Bio must be at least 8 characters.",
})
.max(260, {
message: "Bio must not be longer than 30 characters.",
}),
...(role == "Inspector" && { ...(role == "Inspector" && {
type: z.enum(["private", "public"], { type: z.enum(["private", "public"], {
required_error: "لطفا وضعیت عملیات را انتخاب نمایید.", required_error: "لطفا وضعیت عملیات را انتخاب نمایید.",
}), }),
}), }),
operation: z.string({ operation: z.string({
required_error: "Please select an email to display.", required_error: "لطفا نوع عملیات را انتخاب نمایید.",
}), }),
media: z media: z
.custom<FileList>((val) => val instanceof FileList, "Required") .custom<FileList>((val) => val instanceof FileList, "Required")
@ -67,33 +65,43 @@ export default function InspectorOperations({
.nullish(), .nullish(),
}); });
const password = useData((state) => state.data.password); const password = useData((state) => state.data.password);
const possibleOperations = complaintData?.possibleOperations; const possibleOperations = complaintData?.possibleOperationsWithDescription;
const selectOptions = Operations.filter((item, index) => const queryClient = useQueryClient();
possibleOperations.includes(index)
);
console.log(possibleOperations);
const form = useForm<z.infer<typeof FormSchema>>({ const form = useForm<z.infer<typeof FormSchema>>({
resolver: zodResolver(FormSchema), resolver: zodResolver(FormSchema),
defaultValues: { defaultValues: {
operation: operation:
selectOptions.length == 1 ? String(selectOptions[0].value) : undefined, possibleOperations.length == 1
? String(possibleOperations[0].value)
: undefined,
}, },
}); });
const OperationMutation = useMutation({ const OperationMutation = useMutation({
mutationKey: ["Operation"], mutationKey: ["Operation"],
mutationFn: mutationFn: OperateByInspector,
role == "Inspector" ? OperateByInspector : postComplaintsDetails,
onSuccess: (res) => { onSuccess: (res) => {
toast("عملیات شما با موفقیت انجام شد. ", { toast("عملیات شما با موفقیت انجام شد. ", {
className: "!bg-green-500 !text-white", className: "!bg-green-500 !text-white",
}); });
const tk = localStorage.getItem("trackingNumber");
updateData({
trackingNumber: complaintData.trackingNumber,
password: key2 ? key2 : (localStorage.getItem("privateKey") as string),
});
}, },
onError: (err) => {}, onError: (err) => {},
}); });
function onSubmit(data: z.infer<typeof FormSchema>) { function onSubmit(data: z.infer<typeof FormSchema>) {
console.log(data); const storedData = JSON.parse(
localStorage.getItem("CompliantData") as string
);
console.log(storedData);
console.log(key2);
const dcKey = Decrypt(storedData.cipherKeyInspector, key2);
const formData = new FormData(); const formData = new FormData();
formData.append("text", data.text); formData.append("text", data.text);
formData.append("trackingNumber", complaintData.trackingNumber); formData.append("trackingNumber", complaintData.trackingNumber);
@ -101,11 +109,10 @@ export default function InspectorOperations({
if (data.type) { if (data.type) {
formData.append("IsPublic", data.type == "public" ? "true" : "false"); formData.append("IsPublic", data.type == "public" ? "true" : "false");
} }
if (role == "Inspector") { formData.append(
formData.append("EncodedKey", password); "EncodedKey",
} else { key2 ? key2 : (localStorage.getItem("privateKey") as string)
formData.append("password", localStorage.getItem("password2") as string); );
}
if (data?.media && data?.media?.length > 0) { if (data?.media && data?.media?.length > 0) {
for (let i = 0; i < data.media.length; i++) { for (let i = 0; i < data.media.length; i++) {
formData.append("Medias", data.media[i]); formData.append("Medias", data.media[i]);
@ -172,7 +179,7 @@ export default function InspectorOperations({
<FormControl dir="rtl"> <FormControl dir="rtl">
<RadioGroup <RadioGroup
onValueChange={field.onChange} onValueChange={field.onChange}
defaultValue={field.value} // defaultValue={field.value}
className="flex space-y-1 text-sm" className="flex space-y-1 text-sm"
> >
<FormItem className="flex items-center space-x-3 space-y-0"> <FormItem className="flex items-center space-x-3 space-y-0">
@ -221,10 +228,13 @@ export default function InspectorOperations({
<SelectContent dir="rtl"> <SelectContent dir="rtl">
<SelectGroup> <SelectGroup>
<SelectLabel>عملیات</SelectLabel> <SelectLabel>عملیات</SelectLabel>
{selectOptions.map((item) => { {possibleOperations.map((item: any) => {
return ( return (
<SelectItem value={String(item.value)}> <SelectItem
{item.name} key={item.value}
value={String(item.value)}
>
{item.description}
</SelectItem> </SelectItem>
); );
})} })}

View File

@ -114,7 +114,7 @@ export default function LineChart({
datasets: chartData.map((item: any, index: number) => { datasets: chartData.map((item: any, index: number) => {
return { return {
label: item.title, label: item.title,
data: item.values.map((item) => item.value), data: item.values.map((item: any) => item.value),
backgroundColor: backgroundColor[index], backgroundColor: backgroundColor[index],
borderColor: borderColor[index], borderColor: borderColor[index],
borderWidth: 1, borderWidth: 1,

View File

@ -17,7 +17,6 @@ import {
} from "@/components/ui/form"; } from "@/components/ui/form";
import { Input } from "@/components/ui/input"; import { Input } from "@/components/ui/input";
import { toast } from "@/components/ui/use-toast";
import Image from "next/image"; import Image from "next/image";
import LoginIcon from "../public/img/login-icon.svg"; import LoginIcon from "../public/img/login-icon.svg";
import { useMutation, useQuery } from "@tanstack/react-query"; import { useMutation, useQuery } from "@tanstack/react-query";
@ -26,6 +25,9 @@ import { getCaptcha } from "@/utils/commonApi";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
import { Oval, ThreeDots } from "react-loader-spinner"; import { Oval, ThreeDots } from "react-loader-spinner";
import useData from "@/store/useData"; import useData from "@/store/useData";
import { toast } from "sonner";
import { errorMessages } from "@/constants";
import { RefreshCcw } from "lucide-react";
const FormSchema = z.object({ const FormSchema = z.object({
username: z.string().min(1, { username: z.string().min(1, {
message: "لطفا نام کاربری را وارد نمایید.", message: "لطفا نام کاربری را وارد نمایید.",
@ -57,10 +59,14 @@ export default function Login() {
const loginMutation = useMutation({ const loginMutation = useMutation({
mutationFn: loginStaff, mutationFn: loginStaff,
onSuccess: (res) => {}, onSuccess: (res) => {},
onError: (err: any) => { onError: (err: any | string) => {
if (err.response.status == 428) { if (err.response.status == 428) {
console.log(useData); console.log(useData);
router.push("/Verify"); router.push("/Verify");
} else {
toast("مشکلی در ارسال درخواست به وجود آمد.", {
className: "!bg-red-500 !text-white",
});
} }
}, },
}); });
@ -70,6 +76,7 @@ export default function Login() {
}); });
function onSubmit(data: z.infer<typeof FormSchema>) { function onSubmit(data: z.infer<typeof FormSchema>) {
refetch();
const payload = { const payload = {
username: data.username, username: data.username,
password: data.password, password: data.password,
@ -90,12 +97,12 @@ export default function Login() {
: null; : null;
return ( return (
<div className=" w-screen h-screen grid place-content-center "> <div className=" w-screen h-screen grid place-content-center bg-gray-200 ">
<div <div
className="w-full sm:[20rem] md:[20rem] xl:w-[30rem] bg-white rounded-lg dark:border xl:p-0 dark:bg-gray-800 dark:border-gray-700 shadow-[0px_0px_15px_0px_#00000040] className="w-full sm:[20rem] md:[20rem] xl:w-[30rem] bg-white rounded-lg dark:border xl:p-0 dark:bg-gray-800 dark:border-gray-700 shadow-[0px_0px_15px_0px_#00000040]
h-fit" h-fit"
> >
<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"> <div className="space-y-3 md:space-y-4 flex flex-col md:py-10 p-10 md:px-12 lg:px-16 h-full justify-center">
<Image alt="icon" src={LoginIcon} className="self-center w-1/3 " /> <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 className="text-lg font-bold leading-tight tracking-tight text-blue dark:text-white">
@ -151,7 +158,7 @@ export default function Login() {
</FormItem> </FormItem>
)} )}
/> />
<div className="flex gap-4 mt-4 items-center"> <div className="flex gap-3 mt-4 items-center">
<FormField <FormField
control={form.control} control={form.control}
name="captcha" name="captcha"
@ -182,7 +189,7 @@ export default function Login() {
/> />
</div> </div>
) : ( ) : (
<div className=" flex justify-center text-center"> <div className=" flex items-center justify-center text-center gap-2">
<Image <Image
alt="icon" alt="icon"
src={srcForImage as string} src={srcForImage as string}
@ -191,6 +198,11 @@ export default function Login() {
height={20} height={20}
quality={100} quality={100}
/> />
<RefreshCcw
className=" cursor-pointer"
onClick={() => refetch()}
color="#003778"
/>
</div> </div>
)} )}
</div> </div>

View File

@ -1,36 +1,102 @@
"use client"; "use client";
import React, { useEffect, useState } from "react"; import React, { useEffect, useRef, useState } from "react";
import Link from "next/link"; import Link from "next/link";
import { AdminMenuItems, ControllerMenuItems } from "@/constants"; import { AdminMenuItems, ControllerMenuItems } from "@/constants";
import { usePathname } from "next/navigation"; import { usePathname, useRouter } from "next/navigation";
import { Squash as Hamburger } from "hamburger-react";
import { AnimatePresence, motion } from "framer-motion";
import { getProfile } from "@/utils/authenticateApi";
import { useQuery } from "@tanstack/react-query";
import { DoorOpen, LogOut } from "lucide-react";
import { deleteCookie } from "cookies-next";
export default function NavbarPanel() { export default function NavbarPanel() {
const [isOpen, setOpen] = useState(false);
const ref = useRef(null);
const router = useRouter();
const pathname = usePathname(); const pathname = usePathname();
const [role, setRole] = useState<string | null>(""); const [role, setRole] = useState<string | null>("");
useEffect(() => { useEffect(() => {
const userRole = localStorage.getItem("Sootzani_Role"); const userRole = localStorage.getItem("Sootzani_Role");
setRole(userRole); setRole(userRole);
}, []); }, []);
console.log(role); const { data, isLoading, refetch } = useQuery({
queryKey: ["Profile"],
queryFn: () => getProfile(),
refetchOnWindowFocus: false,
});
const menus = { const menus = {
Admin: AdminMenuItems, Admin: AdminMenuItems,
Inspector: ControllerMenuItems, Inspector: ControllerMenuItems,
}; };
const selectedMenu = menus[role as keyof typeof menus]; const selectedMenu = menus[role as keyof typeof menus];
return ( return (
<div <div
className="fixed flex flex-col-reverse justify-between items-start gap-3 className="fixed flex justify-between items-center gap-3
sm:flex-row sm:items-center sm:gap-0 flex-row sm:items-center sm:gap-0
w-full px-8 py-4 z-10 top-0 bg-blue max-md:px-4 shadow-md w-full px-8 py-4 z-10 top-0 bg-blue max-md:px-4 shadow-md
" "
> >
<div className=" flex items-center gap-8 max-md:gap-4"> <div className=" flex items-center gap-8 max-md:gap-4">
<p className="text-white inline-block bg-clip-text text-sm font-bold max-md:text-xs max-md:font-medium"> <div className=" md:hidden">
پنل کاربری | <Hamburger
toggled={isOpen}
size={20}
toggle={setOpen}
direction="right"
color="#fff"
/>
</div>
<p className="text-white inline-block bg-clip-text text-sm font-bold max-md:text-sm max-md:font-medium">
پنل کاربری {<span className=" max-md:hidden">|</span>}
</p> </p>
<div className="flex flex-row gap-7 max-md:gap-3"> <AnimatePresence>
{isOpen && (
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
transition={{ duration: 0.2 }}
className="fixed z-[100] left-0 shadow-4xl right-0 top-[3rem] p-5 bg-gradient-to-b from-blue to-white border-b border-b-white/20"
>
<ul className="grid gap-2 ">
{selectedMenu.map((item, idx, array) => {
// const { Icon } = item;
const lastItem = array.length - 1;
return (
<motion.li
initial={{ scale: 0, opacity: 0 }}
animate={{ scale: 1, opacity: 1 }}
transition={{
type: "spring",
stiffness: 260,
damping: 20,
delay: 0.1 + idx / 10,
}}
key={item.name}
className=" w-full p-[0.08rem] rounded-xl bg-gradient-to-tr from-neutral-800 via-white to-neutral-700"
>
<Link
onClick={() => setOpen((prev) => !prev)}
className={`flex items-center justify-between w-full p-3 rounded-xl text-white
${lastItem === idx ? "bg-blue" : "bg-blue"} `}
href={item.href}
>
<span className="flex gap-1 text-sm">{item.name}</span>
{/* <Icon className="text-xl" /> */}
</Link>
</motion.li>
);
})}
</ul>
</motion.div>
)}
</AnimatePresence>
<div className="flex flex-row gap-7 max-md:gap-3 max-md:hidden">
{role && ( {role && (
<> <>
{selectedMenu.map( {selectedMenu.map(
@ -50,28 +116,29 @@ export default function NavbarPanel() {
)} )}
</> </>
)} )}
{/* {AdminMenuItems.map((item) => {
return (
<Link key={item.id} href={item.href}>
<p
className="text-white font-normal text-sm max-md:text-xs
hover:bg-white/50 rounded-sm p-1
animate-out duration-300 "
>
{item.name}
</p>
</Link>
);
})} */}
</div> </div>
</div> </div>
<div className=" flex gap-4 items-center">
<h1 className="text-white inline-block bg-clip-text before:max-md:hidden text-sm font-bold max-md:text-xs max-md:font-medium"> <h1 className="text-white inline-block bg-clip-text before:max-md:hidden text-sm font-bold max-md:text-xs max-md:font-medium">
{role === "Admin" {data && (
? "نام و نام خانوادگی (ادمین)" <>
: "نام و نام خانوادگی (بازرس)"} {role === "Admin"
</h1> ? `${data?.title ? data.title : data.username} (ادمین)`
: `${data?.title ? data.title : data.username} (بازرس)`}
</>
)}
</h1>
<div className="hover:bg-white/50 p-1 rounded-md">
<LogOut
onClick={() => {
deleteCookie("Sootzani_Token");
localStorage.removeItem("privateKey");
router.push("/");
}}
className=" text-white cursor-pointer"
/>
</div>
</div>
</div> </div>
); );
} }

View File

@ -9,9 +9,8 @@ import VerticalChart from "./VerticalChart";
import { HorizontalChart } from "./HorizontalChart"; import { HorizontalChart } from "./HorizontalChart";
import { getInfo, getInfoList } from "@/utils/infoApi"; import { getInfo, getInfoList } from "@/utils/infoApi";
import { useQueries, useQuery } from "@tanstack/react-query"; import { useQueries, useQuery } from "@tanstack/react-query";
import useChart from "@/hooks/useChart";
export default function Reports({ data }) { export default function Reports({ data }: { data: any }) {
console.log(data); console.log(data);
const [first, setfirst] = useState<any>(false); const [first, setfirst] = useState<any>(false);
const Queries: any = useQueries({ const Queries: any = useQueries({
@ -24,7 +23,9 @@ export default function Reports({ data }) {
console.log(codes); console.log(codes);
console.log(Queries[0]); console.log(Queries[0]);
const charts = Queries.map((item: any) => item.data); const charts = Queries.map((item: any) => item.data);
const successfulRequests = Queries.filter((item) => item.isSuccess == true); const successfulRequests = Queries.filter(
(item: any) => item.isSuccess == true
);
return ( return (
<div className=""> <div className="">
{successfulRequests.length == data.length && ( {successfulRequests.length == data.length && (
@ -52,9 +53,13 @@ export default function Reports({ data }) {
</div> </div>
<div className="w-full md:w-3/5 flex justify-between items-center "> <div className="w-full md:w-3/5 flex justify-between items-center ">
{charts?.map((item: any, index) => { {charts?.map((item: any, index: number) => {
return ( return (
<TabsContent value={codes[index]} className="w-full"> <TabsContent
key={index}
value={codes[index]}
className="w-full"
>
<VerticalChart <VerticalChart
chartTitle={item.charts[0].chartTitle} chartTitle={item.charts[0].chartTitle}
chartData={item.charts[0].series} chartData={item.charts[0].series}

View File

@ -1,15 +1,7 @@
"use client"; "use client";
import React, { useEffect, useState } from "react"; 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 { getInfo, getInfoList } from "@/utils/infoApi";
import { useQueries, useQuery } from "@tanstack/react-query"; import { useQueries, useQuery } from "@tanstack/react-query";
import useChart from "@/hooks/useChart";
import Reports from "./Reports"; import Reports from "./Reports";
export default function ReportsController() { export default function ReportsController() {

View File

@ -68,130 +68,90 @@ export default function TabController() {
const finishedComplaints = data?.filter((item: any) => item.status == 4); const finishedComplaints = data?.filter((item: any) => item.status == 4);
console.log(newComplaints); console.log(newComplaints);
return ( return (
<div className="w-[95vw] lg:w-[82vw] xl:w-[70vw] 3xl:w-[65vw] mt-8 pt-9 mx-auto"> <div className="w-[95vw] lg:w-[82vw] xl:w-[70vw] 3xl:w-[65vw] mt-16 pt-9 mx-auto">
<Dialog> <p className="3xl:ml-6 text-xs sm:text-sm font-bold md:hidden my-2">
<DialogTrigger className=" appearance-none" asChild> لیست شکایت ها
<Button </p>
// onClick={handelVerify} <Tabs defaultValue="tab1" className="" dir="rtl">
type="submit" <div className="w-full flex flex-col-reverse lg:flex-row gap-4 lg:gap-5 justify-between items-center mb-10">
className="bg-brown hover:bg-brown/90 text-white w-36 p-2 rounded-xl mt-6 md:mt-12 mb-2" {/* Tab Title */}
> <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 max-md:hidden">
</Button> لیست شکایت ها |
</DialogTrigger> </p>
<Tabs defaultValue="tab1" className="" dir="rtl">
<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 flex gap-1 md:gap-4 lg:gap-7">
<p className="3xl:ml-6 text-xs sm:text-sm font-bold">
لیست شکایت ها |
</p>
<TabsTrigger <TabsTrigger
value="tab1" value="tab1"
className="hover:border-b-2 border-b-blue" className="hover:border-b-2 border-b-blue max-md:flex-1"
> >
جدید جدید
</TabsTrigger> </TabsTrigger>
<TabsTrigger <TabsTrigger
value="tab2" value="tab2"
className="hover:border-b-2 border-b-blue" className="hover:border-b-2 border-b-blue max-md:flex-1"
> >
در انتظار پاسخ در انتظار پاسخ
</TabsTrigger> </TabsTrigger>
<TabsTrigger <TabsTrigger
value="tab3" value="tab3"
className="hover:border-b-2 border-b-blue" className="hover:border-b-2 border-b-blue max-md:flex-1"
> >
در حال بررسی در حال بررسی
</TabsTrigger> </TabsTrigger>
<TabsTrigger <TabsTrigger
value="tab4" value="tab4"
className="hover:border-b-2 border-b-blue" className="hover:border-b-2 border-b-blue max-md:flex-1"
> >
پاسخ داده شده پاسخ داده شده
</TabsTrigger> </TabsTrigger>
<TabsTrigger <TabsTrigger
value="tab5" value="tab5"
className="hover:border-b-2 border-b-blue" className="hover:border-b-2 border-b-blue max-md:flex-1"
> >
پایان یافته پایان یافته
</TabsTrigger> </TabsTrigger>
</TabsList> </TabsList>
{/* Search Box */} {/* Search Box */}
<Search mode="controller" /> <Search mode="controller" />
</div> </div>
{/* Tab Content */} {/* Tab Content */}
<TabsContent value="tab1"> <TabsContent value="tab1">
<TableController <TableController
checkKey={(item: any) => checkKey(item)} checkKey={(item: any) => checkKey(item)}
data={newComplaints} data={newComplaints}
/> />
</TabsContent> </TabsContent>
<TabsContent value="tab2"> <TabsContent value="tab2">
<TableController <TableController
checkKey={(item: any) => checkKey(item)} checkKey={(item: any) => checkKey(item)}
data={waitingForCitizenResponseComplaints} data={waitingForCitizenResponseComplaints}
/> />
</TabsContent> </TabsContent>
<TabsContent value="tab3"> <TabsContent value="tab3">
<TableController <TableController
checkKey={(item: any) => checkKey(item)} checkKey={(item: any) => checkKey(item)}
data={inProgressComplaints} data={inProgressComplaints}
/> />
</TabsContent> </TabsContent>
<TabsContent value="tab4"> <TabsContent value="tab4">
<TableController <TableController
checkKey={(item: any) => checkKey(item)} checkKey={(item: any) => checkKey(item)}
data={citizenRepliedComplaints} data={citizenRepliedComplaints}
/> />
</TabsContent> </TabsContent>
<TabsContent value="tab5"> <TabsContent value="tab5">
<TableController <TableController
checkKey={(item: any) => checkKey(item)} checkKey={(item: any) => checkKey(item)}
data={finishedComplaints} data={finishedComplaints}
/> />
</TabsContent> </TabsContent>
</Tabs> </Tabs>
<DialogContent dir="rtl" className="sm:max-w-[425px]">
<DialogHeader dir="rtl">
<DialogTitle dir="rtl">بارگذاری کلید خصوصی</DialogTitle>
<DialogDescription>
لطفا کلید خصوصی خود را آپلود نمایید.
</DialogDescription>
</DialogHeader>
<div className="grid w-full max-w-sm items-center gap-1.5">
{/* <Label htmlFor="picture">Picture</Label> */}
<Input
dir="rtl"
id="picture"
onChange={handleFileChange}
type="file"
accept=".txt"
/>
</div>
<DialogFooter>
<DialogClose asChild>
<Button
onClick={() => {
toast("کلید شما با موفقیت ذخیره شد.", {
className: "!bg-green-500 !text-white",
});
}}
type="submit"
>
ذخیره
</Button>
</DialogClose>
</DialogFooter>
</DialogContent>
</Dialog>
</div> </div>
); );
} }

View File

@ -28,6 +28,8 @@ import { Input } from "./ui/input";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
import { toast } from "sonner"; import { toast } from "sonner";
import { ScrollArea } from "./ui/scroll-area"; import { ScrollArea } from "./ui/scroll-area";
import secureLocalStorage from "react-secure-storage";
import { Checkbox } from "./ui/checkbox";
interface Complaint { interface Complaint {
id: string; id: string;
trackingNumber: string; trackingNumber: string;
@ -37,6 +39,11 @@ interface Complaint {
title: string; title: string;
description: string; description: string;
}; };
complaintOrganization: {
id: string;
title: string;
description: string;
};
status: number; status: number;
registeredAt: string; registeredAt: string;
lastChanged: string; lastChanged: string;
@ -53,8 +60,8 @@ export default function TableController({
const saveData = useData((state) => state.saveData); const saveData = useData((state) => state.saveData);
const [selectedFile, setSelectedFile] = useState<any>(null); const [selectedFile, setSelectedFile] = useState<any>(null);
const [open, setOpen] = useState<boolean>(false); const [open, setOpen] = useState<boolean>(false);
const [roData, setRowData] = useState<boolean>(false); const [rowData, setRowData] = useState<Complaint | null>(null);
const [check, setCheck] = useState<any>(false);
const router = useRouter(); const router = useRouter();
const handleFileChange = (event: any) => { const handleFileChange = (event: any) => {
@ -62,13 +69,13 @@ export default function TableController({
const reader = new FileReader(); const reader = new FileReader();
reader.onload = (e) => { reader.onload = (e) => {
const contents = e?.target?.result; const contents = e?.target?.result;
// Process the contents of the file here
setSelectedFile(contents); setSelectedFile(contents);
console.log(contents); console.log(contents);
}; };
reader.readAsText(file); reader.readAsText(file);
}; };
const checkKey2 = (item: any) => { const checkKey2 = (item: any) => {
const dcKey = Decrypt(item.cipherKeyInspector, selectedFile); const dcKey = Decrypt(item.cipherKeyInspector, selectedFile);
if (dcKey != false && dcKey != null) { if (dcKey != false && dcKey != null) {
@ -76,11 +83,16 @@ export default function TableController({
trackingNumber: item.trackingNumber, trackingNumber: item.trackingNumber,
password: Decrypt(item.cipherKeyInspector, selectedFile), password: Decrypt(item.cipherKeyInspector, selectedFile),
}); });
secureLocalStorage.setItem("trackingNumber", item.trackingNumber);
secureLocalStorage.setItem(
"privateKey",
Decrypt(item.cipherKeyInspector, selectedFile)
);
router.push(`/UserPanel/ControllerDashboard/Complaints/${item.id}`); router.push(`/UserPanel/ControllerDashboard/Complaints/${item.id}`);
} else { } else {
} }
}; };
console.log(check);
return ( return (
<div> <div>
<Table className="border-[1px] border-solid border-muted rounded-md w-full min-w-[40rem] overflow-y-auto scrollbar-thumb-gray-600 scrollbar-track-gray-100 scrollbar-thin"> <Table className="border-[1px] border-solid border-muted rounded-md w-full min-w-[40rem] overflow-y-auto scrollbar-thumb-gray-600 scrollbar-track-gray-100 scrollbar-thin">
@ -89,6 +101,7 @@ export default function TableController({
<TableRow> <TableRow>
<TableHead>ردیف</TableHead> <TableHead>ردیف</TableHead>
<TableHead>تاریخ</TableHead> <TableHead>تاریخ</TableHead>
<TableHead>کد پیگیری</TableHead>
<TableHead>موضوع</TableHead> <TableHead>موضوع</TableHead>
<TableHead>دستگاه مربوطه</TableHead> <TableHead>دستگاه مربوطه</TableHead>
</TableRow> </TableRow>
@ -97,13 +110,12 @@ export default function TableController({
{data?.map((item: Complaint, index: number) => { {data?.map((item: Complaint, index: number) => {
return ( return (
<TableRow <TableRow
onClick={ onClick={() => {
() => checkKey(item) localStorage.setItem("CompliantData", JSON.stringify(item));
// saveData({ router.push(
// trackingNumber: item.trackingNumber, `/UserPanel/ControllerDashboard/Complaints/${item.id}`
// password: Decrypt(item.cipherKeyInspector), );
// }) }}
}
className=" hover:bg-gray-200 cursor-pointer" className=" hover:bg-gray-200 cursor-pointer"
key={item.id} key={item.id}
> >
@ -117,10 +129,15 @@ export default function TableController({
<TableCell className="w-2/12"> <TableCell className="w-2/12">
{convertDate(item.registeredAt)} {convertDate(item.registeredAt)}
</TableCell> </TableCell>
<TableCell className="w-2/12">{item.trackingNumber}</TableCell>
<TableCell className="w-2/12"> <TableCell className="w-2/12">
{item?.title ? item.title : "-"} {item?.title ? item.title : "-"}
</TableCell> </TableCell>
<TableCell className="w-7/12">-</TableCell> <TableCell className="w-5/12">
{item?.complaintOrganization
? item?.complaintOrganization.title
: "-"}
</TableCell>
{/* </Link> */} {/* </Link> */}
</TableRow> </TableRow>
); );
@ -145,19 +162,25 @@ export default function TableController({
accept=".txt" accept=".txt"
/> />
</div> </div>
<div className="flex items-center space-x-2">
<Checkbox
checked={check}
onCheckedChange={setCheck}
id="terms"
className=" ml-2"
/>
<label
htmlFor="terms"
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
>
ذخیره کلید برای دفعات بعد
</label>
</div>
<DialogFooter> <DialogFooter>
<DialogClose asChild> <DialogClose asChild></DialogClose>
<Button <Button onClick={() => checkKey2(rowData)} type="submit">
onClick={() => { ذخیره
if (selectedFile) { </Button>
toast("کلید شما با موفقیت بارگذاری شد.");
}
}}
type="submit"
>
ذخیره
</Button>
</DialogClose>
</DialogFooter> </DialogFooter>
</DialogContent> </DialogContent>
</Dialog> </Dialog>

View File

@ -11,6 +11,7 @@ import useData from "@/store/useData";
import { JwtPayload, jwtDecode } from "jwt-decode"; import { JwtPayload, jwtDecode } from "jwt-decode";
import { setCookie } from "cookies-next"; import { setCookie } from "cookies-next";
import { Oval } from "react-loader-spinner"; import { Oval } from "react-loader-spinner";
import { toast } from "sonner";
export default function Verify() { export default function Verify() {
const [otp, setOtp] = useState(""); const [otp, setOtp] = useState("");
@ -36,7 +37,11 @@ export default function Verify() {
router.push("/UserPanel/CitizenDashboard"); router.push("/UserPanel/CitizenDashboard");
} }
}, },
onError: (err: any) => {}, onError: (err: any) => {
toast("کد تایید شما صحیح نمیباشد.", {
className: "!bg-red-500 !text-white",
});
},
}); });
const CitizenVerifyMutation = useMutation({ const CitizenVerifyMutation = useMutation({
mutationFn: verifyCitizen, mutationFn: verifyCitizen,
@ -68,8 +73,16 @@ export default function Verify() {
useData.persist.rehydrate(); useData.persist.rehydrate();
}, []); }, []);
useEffect(() => {
if (otp.length == 6) {
const payload = { ...userData, verificationCode: otp };
console.log(userData);
verifyMutation.mutate(payload);
}
}, [otp]);
return ( return (
<div className=" w-screen h-screen grid place-content-center "> <div className=" w-screen h-screen grid place-content-center bg-gray-200">
<div <div
className="w-full sm:[20rem] md:[20rem] xl:w-[30rem] bg-white rounded-lg dark:border xl:p-0 dark:bg-gray-800 dark:border-gray-700 shadow-[0px_0px_15px_0px_#00000040] className="w-full sm:[20rem] md:[20rem] xl:w-[30rem] bg-white rounded-lg dark:border xl:p-0 dark:bg-gray-800 dark:border-gray-700 shadow-[0px_0px_15px_0px_#00000040]
h-fit" h-fit"
@ -86,12 +99,7 @@ export default function Verify() {
numInputs={6} numInputs={6}
renderSeparator={<span>{space}</span>} renderSeparator={<span>{space}</span>}
renderInput={(props, idx) => ( renderInput={(props, idx) => (
<input <input autoFocus={idx == 0} pattern="[0-9]*" {...props} />
autoFocus={idx == 0}
inputMode="decimal"
pattern="[0-9]*"
{...props}
/>
)} )}
containerStyle=" flex justify-center" containerStyle=" flex justify-center"
inputStyle=" !w-10 rounded-md h-10 bg-[#F5F5F5] border border-blue/30 text-black" inputStyle=" !w-10 rounded-md h-10 bg-[#F5F5F5] border border-blue/30 text-black"
@ -102,7 +110,7 @@ export default function Verify() {
کد دریافت شده توسط پیامک را وارد نمایید. کد دریافت شده توسط پیامک را وارد نمایید.
</span> </span>
</label> </label>
<div className="flex justify-end gap-2 w-full mt-14"> {/* <div className="flex justify-end gap-2 w-full mt-14">
<Button <Button
disabled={verifyMutation.isPending} disabled={verifyMutation.isPending}
onClick={handelVerify} onClick={handelVerify}
@ -120,67 +128,12 @@ export default function Verify() {
wrapperStyle={{}} wrapperStyle={{}}
wrapperClass="" wrapperClass=""
/> />
{/* <p>در حال انجام ...</p> */}
</div> </div>
) : ( ) : (
"تایید" "تایید"
)} )}
</Button> </Button>
</div> </div> */}
{/* <Form {...form}>
<form
onSubmit={form.handleSubmit(onSubmit)}
className="w-full flex flex-col "
>
<FormField
control={form.control}
name="username"
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>
)}
/>
<FormField
control={form.control}
name="password"
render={({ field }) => (
<FormItem>
<FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
رمز عبور
</FormLabel>
<FormControl>
<Input placeholder="رمز عبور خود را وارد کنید" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<div className="flex justify-end gap-2 w-full mt-14">
<Button
type="submit"
className="bg-blue text-white w-1/2 md:w-1/3 p-2 rounded-xl"
>
ورود
</Button>
</div>
</form>
</Form> */}
</div> </div>
</div> </div>
</div> </div>

View File

@ -36,7 +36,7 @@ interface Values {
title: string; title: string;
value: string; value: string;
} }
function getRandomColor(n) { function getRandomColor(n: number) {
var letters = "0123456789ABCDEF".split(""); var letters = "0123456789ABCDEF".split("");
var color = "#"; var color = "#";
var colors = []; var colors = [];
@ -133,7 +133,7 @@ function BarChart({
datasets: chartData.map((item: any, index: number) => { datasets: chartData.map((item: any, index: number) => {
return { return {
label: item.title, label: item.title,
data: item.values.map((item) => item.value), data: item.values.map((item: any) => item.value),
backgroundColor: backgroundColor[index], backgroundColor: backgroundColor[index],
borderColor: borderColor[index], borderColor: borderColor[index],
borderWidth: 1, borderWidth: 1,
@ -141,7 +141,9 @@ function BarChart({
}), }),
}; };
// console.log(data); // console.log(data);
return <Bar dir="rtl" className="min-h-[20rem]" options={options} data={data} />; return (
<Bar dir="rtl" className="min-h-[20rem]" options={options} data={data} />
);
} }
export default BarChart; export default BarChart;

View File

@ -1,16 +1,16 @@
"use client" "use client";
import * as React from "react" import * as React from "react";
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog" import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
import { cn } from "@/lib/utils" import { cn } from "@/lib/utils";
import { buttonVariants } from "@/components/ui/button" import { buttonVariants } from "@/components/ui/button";
const AlertDialog = AlertDialogPrimitive.Root const AlertDialog = AlertDialogPrimitive.Root;
const AlertDialogTrigger = AlertDialogPrimitive.Trigger const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
const AlertDialogPortal = AlertDialogPrimitive.Portal const AlertDialogPortal = AlertDialogPrimitive.Portal;
const AlertDialogOverlay = React.forwardRef< const AlertDialogOverlay = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Overlay>, React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
@ -24,8 +24,8 @@ const AlertDialogOverlay = React.forwardRef<
{...props} {...props}
ref={ref} ref={ref}
/> />
)) ));
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
const AlertDialogContent = React.forwardRef< const AlertDialogContent = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Content>, React.ElementRef<typeof AlertDialogPrimitive.Content>,
@ -36,11 +36,10 @@ const AlertDialogContent = React.forwardRef<
<AlertDialogPrimitive.Content <AlertDialogPrimitive.Content
ref={ref} ref={ref}
className={cn( className={cn(
`fixed left-[50%] top-[50%] z-50 grid w-full max-w-4xl translate-x-[-50%] translate-y-[-50%] gap-4 border duration-200 `fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border duration-200
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]: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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2
data-[state=open]:slide-in-from-top-[48%] rounded-lg data-[state=open]:slide-in-from-top-[48%] rounded-lg content-between p-0 bg-opacity-30 bg-[#FFFFF999] filter
h-full max-h-[32em] content-between p-0 bg-opacity-30 bg-[#FFFFF999] filter
shadow-[0px_0px_30px_0px_rgba(0,0,0,0.3)] shadow-[0px_0px_30px_0px_rgba(0,0,0,0.3)]
`, `,
className className
@ -48,8 +47,8 @@ const AlertDialogContent = React.forwardRef<
{...props} {...props}
/> />
</AlertDialogPortal> </AlertDialogPortal>
)) ));
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
const AlertDialogHeader = ({ const AlertDialogHeader = ({
className, className,
@ -62,8 +61,8 @@ const AlertDialogHeader = ({
)} )}
{...props} {...props}
/> />
) );
AlertDialogHeader.displayName = "AlertDialogHeader" AlertDialogHeader.displayName = "AlertDialogHeader";
const AlertDialogFooter = ({ const AlertDialogFooter = ({
className, className,
@ -76,8 +75,8 @@ const AlertDialogFooter = ({
)} )}
{...props} {...props}
/> />
) );
AlertDialogFooter.displayName = "AlertDialogFooter" AlertDialogFooter.displayName = "AlertDialogFooter";
const AlertDialogTitle = React.forwardRef< const AlertDialogTitle = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Title>, React.ElementRef<typeof AlertDialogPrimitive.Title>,
@ -85,11 +84,14 @@ const AlertDialogTitle = React.forwardRef<
>(({ className, ...props }, ref) => ( >(({ className, ...props }, ref) => (
<AlertDialogPrimitive.Title <AlertDialogPrimitive.Title
ref={ref} ref={ref}
className={cn("text-lg font-semibold bg-white flex justify-between items-center px-6 py-3 rounded-t-lg border-b-[0.5px] border-[#8F8F8F] border-solid", className)} className={cn(
"text-lg font-semibold bg-white flex justify-between items-center px-6 py-3 rounded-t-lg border-b-[0.5px] border-[#8F8F8F] border-solid",
className
)}
{...props} {...props}
/> />
)) ));
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
const AlertDialogDescription = React.forwardRef< const AlertDialogDescription = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Description>, React.ElementRef<typeof AlertDialogPrimitive.Description>,
@ -97,12 +99,15 @@ const AlertDialogDescription = React.forwardRef<
>(({ className, ...props }, ref) => ( >(({ className, ...props }, ref) => (
<AlertDialogPrimitive.Description <AlertDialogPrimitive.Description
ref={ref} ref={ref}
className={cn("text-sm text-muted-foreground flex flex-col items-start text-justify px-10 py-4 sm:px-28 sm:pt-9 ", className)} className={cn(
"text-sm text-muted-foreground flex flex-col items-start text-justify px-10 py-4 ",
className
)}
{...props} {...props}
/> />
)) ));
AlertDialogDescription.displayName = AlertDialogDescription.displayName =
AlertDialogPrimitive.Description.displayName AlertDialogPrimitive.Description.displayName;
const AlertDialogAction = React.forwardRef< const AlertDialogAction = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Action>, React.ElementRef<typeof AlertDialogPrimitive.Action>,
@ -113,8 +118,8 @@ const AlertDialogAction = React.forwardRef<
className={cn(buttonVariants(), className)} className={cn(buttonVariants(), className)}
{...props} {...props}
/> />
)) ));
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
const AlertDialogCancel = React.forwardRef< const AlertDialogCancel = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Cancel>, React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
@ -129,8 +134,8 @@ const AlertDialogCancel = React.forwardRef<
)} )}
{...props} {...props}
/> />
)) ));
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
export { export {
AlertDialog, AlertDialog,
@ -144,4 +149,4 @@ export {
AlertDialogDescription, AlertDialogDescription,
AlertDialogAction, AlertDialogAction,
AlertDialogCancel, AlertDialogCancel,
} };

View File

@ -0,0 +1,30 @@
"use client"
import * as React from "react"
import * as CheckboxPrimitive from "@radix-ui/react-checkbox"
import { Check } from "lucide-react"
import { cn } from "@/lib/utils"
const Checkbox = React.forwardRef<
React.ElementRef<typeof CheckboxPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
>(({ className, ...props }, ref) => (
<CheckboxPrimitive.Root
ref={ref}
className={cn(
"peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-blue data-[state=checked]:text-primary-foreground",
className
)}
{...props}
>
<CheckboxPrimitive.Indicator
className={cn("flex items-center justify-center text-current")}
>
<Check className="h-4 w-4" />
</CheckboxPrimitive.Indicator>
</CheckboxPrimitive.Root>
))
Checkbox.displayName = CheckboxPrimitive.Root.displayName
export { Checkbox }

View File

@ -56,21 +56,21 @@ export const boxItems = [
export const newsItems = [ export const newsItems = [
{ {
id: 1, id: 1,
title: "شروع به کار سامانه سوت زنی", title: "شروع به کار سامانه عیون",
content: content:
"این سامانه با هدف نظارت بر عملکرد پرستل و نهادهای مرتبط با امور مردمی در شهرداری استان یزد در زمستان 1402 شروع به فعالیت نموده است ...", "این سامانه با هدف نظارت بر عملکرد پرستل و نهادهای مرتبط با امور مردمی در شهرداری استان یزد در زمستان 1402 شروع به فعالیت نموده است ...",
date: "24 آذر ماه 1402", date: "24 آذر ماه 1402",
}, },
{ {
id: 2, id: 2,
title: "شروع به کار سامانه سوت زنی", title: "شروع به کار سامانه عیون",
content: content:
"این سامانه با هدف نظارت بر عملکرد پرستل و نهادهای مرتبط با امور مردمی در شهرداری استان یزد در زمستان 1402 شروع به فعالیت نموده است ...", "این سامانه با هدف نظارت بر عملکرد پرستل و نهادهای مرتبط با امور مردمی در شهرداری استان یزد در زمستان 1402 شروع به فعالیت نموده است ...",
date: "24 آذر ماه 1402", date: "24 آذر ماه 1402",
}, },
{ {
id: 3, id: 3,
title: "شروع به کار سامانه سوت زنی ", title: "شروع به کار سامانه عیون ",
content: content:
"این سامانه با هدف نظارت بر عملکرد پرستل و نهادهای مرتبط با امور مردمی در شهرداری استان یزد در زمستان 1402 شروع به فعالیت نموده است ...", "این سامانه با هدف نظارت بر عملکرد پرستل و نهادهای مرتبط با امور مردمی در شهرداری استان یزد در زمستان 1402 شروع به فعالیت نموده است ...",
date: "24 آذر ماه 1402", date: "24 آذر ماه 1402",
@ -99,8 +99,8 @@ export const aboutFooterItems = [
}, },
]; ];
export const footerItems = [ export const footerItems = [
{ id: 1, name: "قوانین مربوط به سوت زنی", href: "/" }, { id: 1, name: "قوانین مربوط به عیون", href: "/" },
{ id: 2, name: "ارسال گزارش در سامانه سوت زنی قوه قضاییه", href: "/" }, { id: 2, name: "ارسال گزارش در سامانه عیون قوه قضاییه", href: "/" },
{ id: 3, name: "وب سایت قوه قضاییه", href: "/" }, { id: 3, name: "وب سایت قوه قضاییه", href: "/" },
{ id: 4, name: " وب سایت ریاست جمهوری", href: "/" }, { id: 4, name: " وب سایت ریاست جمهوری", href: "/" },
]; ];
@ -141,8 +141,12 @@ export const ControllerMenuItems = [
export const AdminMenuItems = [ export const AdminMenuItems = [
{ id: 1, name: "داشبورد", href: "/UserPanel/AdminDashboard" }, { id: 1, name: "داشبورد", href: "/UserPanel/AdminDashboard" },
{ id: 2, name: "مدیریت کاربران", href: "/UserPanel/AdminDashboard/UserManagement" }, // { id: 2, name: "مدیریت کاربران", href: "/UserPanel/AdminDashboard/UserManagement" },
{ id: 3, name: "مدیریت کلید ها", href: "/UserPanel/AdminDashboard/KeysManagement" }, {
id: 3,
name: "مدیریت کلید ها",
href: "/UserPanel/AdminDashboard/KeysManagement",
},
{ id: 4, name: "سازمان ها", href: "/UserPanel/AdminDashboard/Organizations" }, { id: 4, name: "سازمان ها", href: "/UserPanel/AdminDashboard/Organizations" },
{ id: 5, name: "دسته بندی ها", href: "/UserPanel/AdminDashboard/Categories" }, { id: 5, name: "دسته بندی ها", href: "/UserPanel/AdminDashboard/Categories" },
]; ];
@ -226,12 +230,19 @@ export const AdminTableItems = [
]; ];
export const Operations = [ export const Operations = [
{value:0,name:"ثبت شده"}, { value: 0, name: "ثبت شده" },
{value:1,name:"دیدن"}, { value: 1, name: "دیدن" },
{value:2,name:"درخواست توضیحات"}, { value: 2, name: "درخواست توضیحات" },
{value:3,name:"پاسخ شهروند"}, { value: 3, name: "پاسخ شهروند" },
{value:4,name:"لغو درخواست"}, { value: 4, name: "لغو درخواست" },
{value:5,name:"افزودن جزییات"}, { value: 5, name: "افزودن جزییات" },
{value:6,name:"پایان درخواست"}, { value: 6, name: "پایان درخواست" },
{value:7,name:"شروع مجدد درخواست"}, { value: 7, name: "شروع مجدد درخواست" },
]; ];
export const errorMessages = {
500: "خطایی رخ داد. لطفا از اتصال اینترنت خود اطمینان حاصل نمایید.",
400: "مشکلی در ارسال درخواست به وجود آمد.",
480: "لطفا تمام اطلاعات خواسته شده را وارد نمایید.",
428: "کد فعالسازی را وارد نمایید.",
};

8
docker-compose.yml Normal file
View File

@ -0,0 +1,8 @@
version: '3.8'
services:
web:
image: ${DOCKER_REGISTRY:-docker.shetabdahi.ir/}oyoon-admin
restart: always
ports:
- "127.0.0.1:6679:6679"

View File

@ -19,22 +19,15 @@ export function convertDate(date: string) {
return convertedDate; return convertedDate;
} }
export function Decrypt(encryptedData: string , privateKey: string) { export function convertFullTime(date: string) {
const Key = `-----BEGIN RSA PRIVATE KEY----- const convertedDate = dayjs(date)
MIICXAIBAAKBgQCfmb1aGcWsqJPp+v6e72CPngE6P6FoCZCJESwDTXUXiJiAKshB .calendar("jalali")
WZ9nlN+IIpQr6h8gmxi8SWbofPWmSKZgTyU2MddxUanneuywPTTUj4HQ6/DUaDwF .locale("fa")
0Vr6Fk0x4yi1GKpBzhRFPyOYBWVXKIw23j0l+EWw6+JIpR9Kwu0TezHHFQIDAQAB .format(" HH:mm - YYYY/M/DD");
AoGBAIVxegy3t7vhR6s/HV2uMEJkjgox4banKJ4yKWapgNmocDnZi454bPuiUjP1 return convertedDate;
FYaSPmx4wXnMtap1sL7Tx6iHBEi10KB1AghDZP5wJHz6nm9ugcrGSSWhVJM74x6C }
ThVztAV/rydaZ6/DLaqsBg5lHlo1DjMKq4sxnqrw/LUMGtOBAkEAzt8bnM1Ij/rF
i8oSP3gI0H914vf/0N2xxGGdQvMmJK0oijIm5j8dFDZf02Ft34SFeVJfXyVPapDE export function Decrypt(encryptedData: any, privateKey: any) {
vQ6TRw+1HQJBAMWAwvbypbtl65Dn4qCj3oJUmmnjjxm5080idF1S6ufo34p2gHMF
qLtWjmnGqjh2Shs7ahnfbLF+cxzgBg7yEFkCQFYGl1/0Sel9uepwpHf6PYgeiPJS
ePHtTwBAK3pszH7R9xrI0j5LHpeKKP0o9dzOKgcShxB03nqNKxMHXZ1eXc0CQFhD
Ot3xgm9FFQklF/qCQSYtePRpZcIxcZ3zD93E+IW7ZGsUmkLM/KL8A5jx15B0DJou
6zO0zXZk9DyrQQnc08ECQGy5ti89HmQ6I6Wqq5ADglCY6YPISsNwScVyvu/WxQsX
dEqG/38xFdYTFEekexcHnT/Vt1MW4/j76vBJHYWuAJU=
-----END RSA PRIVATE KEY-----`;
const decryptor = new JSEncrypt(); const decryptor = new JSEncrypt();
decryptor.setPrivateKey(privateKey); decryptor.setPrivateKey(privateKey);
const decrypted = decryptor.decrypt(encryptedData); const decrypted = decryptor.decrypt(encryptedData);

View File

@ -1,4 +1,4 @@
/** @type {import('next').NextConfig} */ /** @type {import('next').NextConfig} */
const nextConfig = {} const nextConfig = { output: "standalone" };
module.exports = nextConfig module.exports = nextConfig;

55
package-lock.json generated
View File

@ -1,15 +1,16 @@
{ {
"name": "sootzani", "name": "sootzani",
"version": "0.1.0", "version": "0.2.2",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "sootzani", "name": "sootzani",
"version": "0.1.0", "version": "0.2.2",
"dependencies": { "dependencies": {
"@hookform/resolvers": "^3.3.2", "@hookform/resolvers": "^3.3.2",
"@radix-ui/react-alert-dialog": "^1.0.5", "@radix-ui/react-alert-dialog": "^1.0.5",
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-dialog": "^1.0.5", "@radix-ui/react-dialog": "^1.0.5",
"@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",
@ -55,6 +56,7 @@
"react-loader-spinner": "^6.1.6", "react-loader-spinner": "^6.1.6",
"react-otp-input": "^3.1.1", "react-otp-input": "^3.1.1",
"react-responsive": "^9.0.2", "react-responsive": "^9.0.2",
"react-secure-storage": "^1.3.2",
"react-spinners": "^0.13.8", "react-spinners": "^0.13.8",
"react-to-print": "^2.14.15", "react-to-print": "^2.14.15",
"react-use": "^17.4.2", "react-use": "^17.4.2",
@ -583,6 +585,36 @@
} }
} }
}, },
"node_modules/@radix-ui/react-checkbox": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/@radix-ui/react-checkbox/-/react-checkbox-1.0.4.tgz",
"integrity": "sha512-CBuGQa52aAYnADZVt/KBQzXrwx6TqnlwtcIPGtVt5JkkzQwMOLJjPukimhfKEr4GQNd43C+djUh5Ikopj8pSLg==",
"dependencies": {
"@babel/runtime": "^7.13.10",
"@radix-ui/primitive": "1.0.1",
"@radix-ui/react-compose-refs": "1.0.1",
"@radix-ui/react-context": "1.0.1",
"@radix-ui/react-presence": "1.0.1",
"@radix-ui/react-primitive": "1.0.3",
"@radix-ui/react-use-controllable-state": "1.0.1",
"@radix-ui/react-use-previous": "1.0.1",
"@radix-ui/react-use-size": "1.0.1"
},
"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-collection": { "node_modules/@radix-ui/react-collection": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/@radix-ui/react-collection/-/react-collection-1.0.3.tgz", "resolved": "https://registry.npmjs.org/@radix-ui/react-collection/-/react-collection-1.0.3.tgz",
@ -2368,6 +2400,11 @@
"node": ">= 8" "node": ">= 8"
} }
}, },
"node_modules/crypto-js": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz",
"integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q=="
},
"node_modules/css-color-keywords": { "node_modules/css-color-keywords": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/css-color-keywords/-/css-color-keywords-1.0.0.tgz", "resolved": "https://registry.npmjs.org/css-color-keywords/-/css-color-keywords-1.0.0.tgz",
@ -4358,6 +4395,11 @@
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"dev": true "dev": true
}, },
"node_modules/murmurhash-js": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/murmurhash-js/-/murmurhash-js-1.0.0.tgz",
"integrity": "sha512-TvmkNhkv8yct0SVBSy+o8wYzXjE4Zz3PCesbfs8HiCXXdcTuocApFv11UWlNFWKYsP2okqrhb7JNlSm9InBhIw=="
},
"node_modules/mz": { "node_modules/mz": {
"version": "2.7.0", "version": "2.7.0",
"resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz",
@ -7858,6 +7900,15 @@
"react": ">=16.8.0" "react": ">=16.8.0"
} }
}, },
"node_modules/react-secure-storage": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/react-secure-storage/-/react-secure-storage-1.3.2.tgz",
"integrity": "sha512-pNCyksbLXWIYRS9vCzERXdIMErtx9Ik70TPtLKivcq44+zYybbxA72wpp5ivghK9Xe0gRku2w/7zBy/9n+RtKA==",
"dependencies": {
"crypto-js": "^4.1.1",
"murmurhash-js": "^1.0.0"
}
},
"node_modules/react-spinners": { "node_modules/react-spinners": {
"version": "0.13.8", "version": "0.13.8",
"resolved": "https://registry.npmjs.org/react-spinners/-/react-spinners-0.13.8.tgz", "resolved": "https://registry.npmjs.org/react-spinners/-/react-spinners-0.13.8.tgz",

View File

@ -1,6 +1,6 @@
{ {
"name": "sootzani", "name": "sootzani",
"version": "0.1.0", "version": "0.2.2",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",
@ -11,6 +11,7 @@
"dependencies": { "dependencies": {
"@hookform/resolvers": "^3.3.2", "@hookform/resolvers": "^3.3.2",
"@radix-ui/react-alert-dialog": "^1.0.5", "@radix-ui/react-alert-dialog": "^1.0.5",
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-dialog": "^1.0.5", "@radix-ui/react-dialog": "^1.0.5",
"@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",
@ -56,6 +57,7 @@
"react-loader-spinner": "^6.1.6", "react-loader-spinner": "^6.1.6",
"react-otp-input": "^3.1.1", "react-otp-input": "^3.1.1",
"react-responsive": "^9.0.2", "react-responsive": "^9.0.2",
"react-secure-storage": "^1.3.2",
"react-spinners": "^0.13.8", "react-spinners": "^0.13.8",
"react-to-print": "^2.14.15", "react-to-print": "^2.14.15",
"react-use": "^17.4.2", "react-use": "^17.4.2",

View File

@ -1,7 +1,7 @@
import axios from "axios"; import axios from "axios";
import { CookieValueTypes, getCookie } from "cookies-next"; import { CookieValueTypes, getCookie } from "cookies-next";
axios.defaults.baseURL = "https://sootzaniapi.shetabdahi.ir/"; axios.defaults.baseURL = process.env.NEXT_PUBLIC_BASE_URL_APP;
axios.interceptors.request.use(function (config) { axios.interceptors.request.use(function (config) {
const token = getCookie("Sootzani_Token"); const token = getCookie("Sootzani_Token");

View File

@ -1,7 +1,7 @@
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/"; axios.defaults.baseURL = process.env.NEXT_PUBLIC_BASE_URL_APP;
export async function loginStaff(payload: { export async function loginStaff(payload: {
username: string; username: string;

View File

@ -1,26 +0,0 @@
import axios from "axios";
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);
return data.data;
}
// 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(payload: FormData) {
const data = await axios.post(`api/Citizen/Operate`, payload);
return data.data;
}