Compare commits

...

5 Commits

9 changed files with 114 additions and 46 deletions

View File

@ -70,6 +70,7 @@ export default function Landing() {
delay: 2500, delay: 2500,
disableOnInteraction: false, disableOnInteraction: false,
}} }}
// autoplay={ data?.length > 1 ? { delay: 2500, disableOnInteraction: false } : false }
loop={false} loop={false}
pagination={{ pagination={{
clickable: true, clickable: true,
@ -94,19 +95,6 @@ export default function Landing() {
</SwiperSlide> </SwiperSlide>
); );
})} })}
{data?.length == 1 && (
<SwiperSlide>
<Image
alt="bg"
src={`${process.env.NEXT_PUBLIC_BASE_URL_APP}${data[0]?.image?.url}`}
// width={20}
// height={20}
layout="fill"
quality={100}
className=" w-full h-full object-cover max-sm:object-[70%]"
/>
</SwiperSlide>
)}
</> </>
) : ( ) : (
<> <>

View File

@ -207,7 +207,11 @@ export default function ComplainsDetails({
{/* Editt */} {/* Editt */}
<div className="flex items-start w-full gap-2 mt-2 max-lg:flex-col lg:h-[80vh] mb-10"> <div className="flex items-start w-full gap-2 mt-2 max-lg:flex-col lg:h-[80vh] mb-10">
{/* 1 */} {/* 1 */}
<div className="flex flex-col w-full lg:w-1/3 gap-3 lg:sticky top-28 lg:h-[80vh] max-lg:order-3"> <div
className={`flex flex-col w-full lg:w-1/3 gap-3 lg:sticky top-28 lg:h-[80vh] max-lg:order-3 ${
possibleOperations.length == 0 && "hidden"
}`}
>
{/* ***** */} {/* ***** */}
<div className=" bg-[#E9E9E9] rounded-md p-4 px-10 flex flex-col lg:h-full"> <div className=" bg-[#E9E9E9] rounded-md p-4 px-10 flex flex-col lg:h-full">
<p className="text-[#464646] text-base font-bold mb-1"> <p className="text-[#464646] text-base font-bold mb-1">
@ -225,7 +229,11 @@ export default function ComplainsDetails({
</div> </div>
{/* 2 */} {/* 2 */}
<div className="flex flex-col self-stretch w-full gap-2 rounded-lg lg:w-2/3 "> <div
className={`flex flex-col self-stretch w-full gap-2 rounded-lg lg:w-2/3 ${
possibleOperations.length == 0 && "lg:w-full"
}`}
>
<div className=" bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col md:flex-row gap-2 items-center justify-center"> <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 ? ( {data?.user == null ? (
<> <>
@ -344,19 +352,25 @@ export default function ComplainsDetails({
className="flex flex-col mt-4 gap-y-4 overflow-auto className="flex flex-col mt-4 gap-y-4 overflow-auto
scrollbar-thin scrollbar-thumb-gray-500 scrollbar-track-gray-100 " scrollbar-thin scrollbar-thumb-gray-500 scrollbar-track-gray-100 "
> >
{data.contents?.map((item: any) => { {data.contents?.map((item: any, index: any, array: any) => {
return ( return (
<div <div
key={item.id} key={item.id}
className="p-4 bg-white rounded-lg shadow-md " className="p-4 bg-white rounded-lg shadow-md "
> >
<div className="flex items-center gap-4 justify-between"> <div className="flex items-center gap-4 justify-between">
<p className=""> <div>
<Badge> <span className=" flex items-center justify-center w-8 h-8 bg-blue-100 rounded-full -start-4 ring-2 ring-blue bg-blue2 text-black">
{item.operationWithDescription.description} توسط{" "} {array.length - index}
{item.sender == 0 ? "شهروند" : "بازرس"} </span>
</Badge> <p className="">
</p> <Badge>
{item.operationWithDescription.description}{" "}
توسط {item.sender == 0 ? "شهروند" : "بازرس"}
</Badge>
</p>
</div>
<p className=""> <p className="">
<span className="text-[#7C838A] text-sm"> <span className="text-[#7C838A] text-sm">
{convertFullTime(item.dateTime)} {convertFullTime(item.dateTime)}

View File

@ -124,6 +124,7 @@ export default function FollowUp() {
</FormLabel> </FormLabel>
<FormControl> <FormControl>
<Input <Input
type="password"
placeholder="رمز عبور خود را وارد کنید" placeholder="رمز عبور خود را وارد کنید"
{...field} {...field}
/> />

View File

@ -33,7 +33,7 @@ import { useMutation, useQuery } 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 { postComplaintsDetails } from "@/utils/citizenApi";
import { useState } from "react"; import { useEffect, useState } from "react";
import { DialogTrigger } from "./ui/dialog"; import { DialogTrigger } from "./ui/dialog";
import AttachmentsDialog from "./AttachmentsDialog"; import AttachmentsDialog from "./AttachmentsDialog";
import { Eye, Upload } from "lucide-react"; import { Eye, Upload } from "lucide-react";
@ -52,6 +52,7 @@ export default function InspectorOperations({
password?: string; password?: string;
}) { }) {
const [first, setfirst] = useState<File[]>([]); const [first, setfirst] = useState<File[]>([]);
const [charCount, setCharCount] = useState(0);
// Queries // Queries
const { data, isLoading, refetch } = useQuery({ const { data, isLoading, refetch } = useQuery({
@ -118,6 +119,19 @@ export default function InspectorOperations({
}, },
}); });
// Add the useEffect hook to monitor changes in the description field
useEffect(() => {
setCharCount(form.watch("text")?.length);
}, [form.watch("text")]);
function handleTextChange(event: React.ChangeEvent<HTMLTextAreaElement>) {
const newCharCount = event.target.value.length;
// Update charCount only when the user types or removes characters
if (newCharCount <= data?.maxTextLength) {
setCharCount(newCharCount);
}
}
//Functions //Functions
function onSubmit(data: z.infer<typeof FormSchema>) { function onSubmit(data: z.infer<typeof FormSchema>) {
const formData = new FormData(); const formData = new FormData();
@ -162,12 +176,26 @@ export default function InspectorOperations({
name="text" name="text"
render={({ field, fieldState: { error } }) => ( render={({ field, fieldState: { error } }) => (
<FormItem> <FormItem>
<FormLabel className="">متن</FormLabel> <FormLabel className="">
متن({charCount}/{data?.maxTextLength})
</FormLabel>
<FormControl> <FormControl>
<Textarea <Textarea
className="resize-none bg-white lg:min-h-[20em]" className="resize-none bg-white lg:min-h-[20em]"
{...field} {...field}
readOnly={possibleOperations.length == 0} readOnly={possibleOperations.length == 0}
onChange={(e) => {
const currentValue = e.target.value;
if (currentValue.length <= data?.maxTextLength) {
field.onChange(e);
handleTextChange(e);
} else {
// Truncate the value to the allowed limit
field.onChange(
currentValue.substring(0, data?.maxTextLength)
);
}
}}
/> />
</FormControl> </FormControl>
{!error ? ( {!error ? (
@ -236,7 +264,7 @@ export default function InspectorOperations({
<FormDescription className=" text-xs my-1 "> <FormDescription className=" text-xs my-1 ">
<span> <span>
حجم هر فایل حداکثر می بایست {formatSize(data?.maxFileSize)}{" "} حجم هر فایل حداکثر می بایست {formatSize(data?.maxFileSize)}{" "}
مگابایت باشد باشد
</span>{" "} </span>{" "}
و{" "} و{" "}
{`تعداد فایل های پیوست شده می بایست حداکثر ${data?.maxFileCount} تا باشد.`} {`تعداد فایل های پیوست شده می بایست حداکثر ${data?.maxFileCount} تا باشد.`}

View File

@ -12,8 +12,9 @@ export default function RequestStep0() {
{RequestItems.map((item, index) => { {RequestItems.map((item, index) => {
return ( return (
<Link <Link
className="group bg-white border shadow-md rounded-lg p-10 h-64 w-64 flex items-end justify-center z-10 relative className="group bg-white border shadow-md rounded-lg p-10 h-64 w-64 flex z-10 relative
hover:bg-blue transition-all duration-700 ease-in-out text-center hover:bg-blue transition-all duration-700 ease-in-out text-center
flex-col items-center justify-end gap-2
hover:flex-col-reverse hover:justify-evenly hover:items-center hover:cursor-pointer hover:flex-col-reverse hover:justify-evenly hover:items-center hover:cursor-pointer
max-lg:w-52 max-lg:h-52 max-md:w-40 max-md:h-40 max-lg:w-52 max-lg:h-52 max-md:w-40 max-md:h-40
max-lg:p-8 max-md:p-5 max-sm:p-2 hover:max-lg:p-2 max-lg:p-8 max-md:p-5 max-sm:p-2 hover:max-lg:p-2
@ -37,6 +38,9 @@ export default function RequestStep0() {
<p className=" z-10 text-base text-black group-hover:text-white max-md:text-sm"> <p className=" z-10 text-base text-black group-hover:text-white max-md:text-sm">
{item.name} {item.name}
</p> </p>
<p className=" z-10 text-xs text-center font-medium group-hover:hidden">
{item.description}
</p>
<Image <Image
alt="icon" alt="icon"
@ -46,7 +50,7 @@ export default function RequestStep0() {
quality={100} quality={100}
key={index} key={index}
className={cn( className={cn(
" w-[80%] h-[80%] absolute left-8 top-6 group-hover:hidden max-md:h-[60%] max-md:w-[60%] max-md:left-auto", " w-[60%] h-[60%] absolute left-12 top-6 group-hover:hidden max-md:h-[60%] max-md:w-[60%] max-md:left-auto",
item.id == 3 && "left-2" item.id == 3 && "left-2"
)} )}
/> />

View File

@ -66,6 +66,7 @@ export default function RequestStep2() {
const router = useRouter(); const router = useRouter();
const [file, setFile] = useState<File[]>([]); const [file, setFile] = useState<File[]>([]);
const [charCount, setCharCount] = useState(0); const [charCount, setCharCount] = useState(0);
const [charCountPerson, setCharCountPerson] = useState(0);
// Queries // Queries
const { data: optionsData, isLoading: isLoadingData } = useQuery({ const { data: optionsData, isLoading: isLoadingData } = useQuery({
@ -81,7 +82,14 @@ export default function RequestStep2() {
OrganizationId: z.string({ OrganizationId: z.string({
required_error: "لطفا دستگاه مربوطه را انتخاب نمایید.", required_error: "لطفا دستگاه مربوطه را انتخاب نمایید.",
}), }),
person: z.string().optional(), person: z
.string()
.min(1, {
message: "لطفا نام فرد مورد نظر را بنویسید.",
})
.max(50, {
message: "تعداد کاراکترها بیشتر از حد مجاز میباشد.",
}),
description: z description: z
.string() .string()
.min(1, { .min(1, {
@ -197,6 +205,16 @@ export default function RequestStep2() {
setCharCount(newCharCount); setCharCount(newCharCount);
} }
} }
function handlePersonCharCountChange(
event: React.ChangeEvent<HTMLInputElement>
) {
const newCharCount = event.target.value.length;
// Update charCount only when the user types or removes characters
if (newCharCount <= 50) {
setCharCountPerson(newCharCount);
}
}
// Add the useEffect hook to monitor changes in the description field // Add the useEffect hook to monitor changes in the description field
useEffect(() => { useEffect(() => {
setCharCount(form.watch("description").length); setCharCount(form.watch("description").length);
@ -275,7 +293,7 @@ export default function RequestStep2() {
<Form {...form}> <Form {...form}>
<form <form
onSubmit={form.handleSubmit(onSubmit)} onSubmit={form.handleSubmit(onSubmit)}
className="flex flex-col w-full mt-6" className="flex flex-col w-full mt-6 max-sm:gap-4"
> >
<FormField <FormField
control={form.control} control={form.control}
@ -295,7 +313,7 @@ export default function RequestStep2() {
</FormItem> </FormItem>
)} )}
/> />
<div className="flex flex-row flex-wrap justify-between"> <div className="flex flex-row flex-wrap justify-between max-sm:gap-4">
<FormField <FormField
control={form.control} control={form.control}
name="OrganizationId" name="OrganizationId"
@ -343,12 +361,22 @@ export default function RequestStep2() {
render={({ field }) => ( render={({ field }) => (
<FormItem className=" w-full sm:w-[48%]"> <FormItem className=" w-full sm:w-[48%]">
<FormLabel className="text-[#7C838A] text-sm font-medium mt-7"> <FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
فرد مربوطه فرد مرتبط({charCountPerson}/{50})
</FormLabel> </FormLabel>
<FormControl> <FormControl>
<Input <Input
placeholder="نام فرد مورد نظر خود را بنویسید" placeholder="نام فرد مورد نظر خود را بنویسید"
{...field} {...field}
onChange={(e) => {
const currentValue = e.target.value;
if (currentValue.length <= 50) {
field.onChange(e);
handlePersonCharCountChange(e);
} else {
// Truncate the value to the allowed limit
field.onChange(currentValue.substring(0, 50));
}
}}
/> />
</FormControl> </FormControl>
<FormMessage /> <FormMessage />
@ -392,7 +420,7 @@ export default function RequestStep2() {
)} )}
/> />
<div className="flex flex-row flex-wrap justify-between mb-2"> <div className="flex flex-row flex-wrap justify-between mb-2 max-sm:gap-4">
{/* Select Option */} {/* Select Option */}
<FormField <FormField
control={form.control} control={form.control}
@ -495,19 +523,19 @@ export default function RequestStep2() {
}} }}
/> />
</div> </div>
{/* {!error ? ( {!error ? (
<FormDescription className=" text-xs my-1 "> <FormDescription className=" text-xs my-1 ">
<span> <span>
حجم هر فایل حداکثر می بایست{" "} حجم هر فایل حداکثر می بایست{" "}
{formatSize(optionsData?.maxFileSize)} مگابایت باشد {formatSize(optionsData?.maxFileSize)} باشد
</span>{" "} </span>
و{" "} و {" "}
{`تعداد فایل های پیوست شده می بایست حداکثر ${optionsData?.maxFileCount} تا باشد.`} {`تعداد فایل های پیوست شده می بایست حداکثر ${optionsData?.maxFileCount} تا باشد.`}
</FormDescription> </FormDescription>
) : ( ) : (
<FormMessage /> <FormMessage />
)} */} )}
<FormMessage /> {/* <FormMessage /> */}
</FormItem> </FormItem>
); );
}} }}
@ -566,10 +594,10 @@ export default function RequestStep2() {
)} )}
</div> </div>
<div className="flex justify-center w-full gap-2 mt-4 sm:justify-end"> <div className="flex justify-center w-full gap-2 mt-0 sm:justify-end">
<Button <Button
type="submit" type="submit"
className="w-1/2 p-2 mb-4 text-center text-white sm:w-1/3 lg:w-1/4 bg-blue rounded-xl" className="w-1/2 p-2 mb-3 text-center text-white sm:w-1/3 lg:w-1/4 bg-blue rounded-xl"
> >
{authorizedComplaintSubmitMutation.isPending || {authorizedComplaintSubmitMutation.isPending ||
complaintSubmitMutation.isPending ? ( complaintSubmitMutation.isPending ? (

View File

@ -18,8 +18,13 @@ function convertDate(date: string) {
.format("YYYY/M/DD"); .format("YYYY/M/DD");
return convertedDate; return convertedDate;
} }
const registeredAt = localStorage.getItem("registeredAt"); // const registeredAt = localStorage.getItem("registeredAt");
const convertedDate = registeredAt ? convertDate(registeredAt) : "Invalid Date"; // const convertedDate = registeredAt ? convertDate(registeredAt) : "Invalid Date";
const currentDate = new Date();
const formattedDate = currentDate.toISOString();
const convertedDate = convertDate(formattedDate);
const PrintPage: React.FC<PrintPageProps> = ({ const PrintPage: React.FC<PrintPageProps> = ({
contentRef, contentRef,

View File

@ -80,7 +80,7 @@ const SelectContent = React.forwardRef<
<SelectPrimitive.Content <SelectPrimitive.Content
ref={ref} ref={ref}
className={cn( className={cn(
"relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", "relative z-[100] max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
position === "popper" && position === "popper" &&
"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1", "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
className className

View File

@ -39,7 +39,7 @@ export const boxItems = [
name: " گزارش فساد", name: " گزارش فساد",
icon: "/img/box1.svg", icon: "/img/box1.svg",
icon2: "/img/box1-hover.svg", icon2: "/img/box1-hover.svg",
description: "ارسال گزارش با احراز هویت", description: "ارسال گزارش ",
link: "/RequestStep0", link: "/RequestStep0",
}, },
{ {