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,
disableOnInteraction: false,
}}
// autoplay={ data?.length > 1 ? { delay: 2500, disableOnInteraction: false } : false }
loop={false}
pagination={{
clickable: true,
@ -94,19 +95,6 @@ export default function Landing() {
</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 */}
<div className="flex items-start w-full gap-2 mt-2 max-lg:flex-col lg:h-[80vh] mb-10">
{/* 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">
<p className="text-[#464646] text-base font-bold mb-1">
@ -225,7 +229,11 @@ export default function ComplainsDetails({
</div>
{/* 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">
{data?.user == null ? (
<>
@ -344,19 +352,25 @@ export default function ComplainsDetails({
className="flex flex-col mt-4 gap-y-4 overflow-auto
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 (
<div
key={item.id}
className="p-4 bg-white rounded-lg shadow-md "
>
<div className="flex items-center gap-4 justify-between">
<p className="">
<Badge>
{item.operationWithDescription.description} توسط{" "}
{item.sender == 0 ? "شهروند" : "بازرس"}
</Badge>
</p>
<div>
<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">
{array.length - index}
</span>
<p className="">
<Badge>
{item.operationWithDescription.description}{" "}
توسط {item.sender == 0 ? "شهروند" : "بازرس"}
</Badge>
</p>
</div>
<p className="">
<span className="text-[#7C838A] text-sm">
{convertFullTime(item.dateTime)}

View File

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

View File

@ -33,7 +33,7 @@ import { useMutation, useQuery } from "@tanstack/react-query";
import { OperateByInspector } from "@/utils/inspectorApi";
import { toast } from "sonner";
import { postComplaintsDetails } from "@/utils/citizenApi";
import { useState } from "react";
import { useEffect, useState } from "react";
import { DialogTrigger } from "./ui/dialog";
import AttachmentsDialog from "./AttachmentsDialog";
import { Eye, Upload } from "lucide-react";
@ -52,6 +52,7 @@ export default function InspectorOperations({
password?: string;
}) {
const [first, setfirst] = useState<File[]>([]);
const [charCount, setCharCount] = useState(0);
// Queries
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
function onSubmit(data: z.infer<typeof FormSchema>) {
const formData = new FormData();
@ -162,12 +176,26 @@ export default function InspectorOperations({
name="text"
render={({ field, fieldState: { error } }) => (
<FormItem>
<FormLabel className="">متن</FormLabel>
<FormLabel className="">
متن({charCount}/{data?.maxTextLength})
</FormLabel>
<FormControl>
<Textarea
className="resize-none bg-white lg:min-h-[20em]"
{...field}
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>
{!error ? (
@ -236,7 +264,7 @@ export default function InspectorOperations({
<FormDescription className=" text-xs my-1 ">
<span>
حجم هر فایل حداکثر می بایست {formatSize(data?.maxFileSize)}{" "}
مگابایت باشد
باشد
</span>{" "}
و{" "}
{`تعداد فایل های پیوست شده می بایست حداکثر ${data?.maxFileCount} تا باشد.`}

View File

@ -12,8 +12,9 @@ export default function RequestStep0() {
{RequestItems.map((item, index) => {
return (
<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
flex-col items-center justify-end gap-2
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: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">
{item.name}
</p>
<p className=" z-10 text-xs text-center font-medium group-hover:hidden">
{item.description}
</p>
<Image
alt="icon"
@ -46,7 +50,7 @@ export default function RequestStep0() {
quality={100}
key={index}
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"
)}
/>

View File

@ -66,6 +66,7 @@ export default function RequestStep2() {
const router = useRouter();
const [file, setFile] = useState<File[]>([]);
const [charCount, setCharCount] = useState(0);
const [charCountPerson, setCharCountPerson] = useState(0);
// Queries
const { data: optionsData, isLoading: isLoadingData } = useQuery({
@ -81,7 +82,14 @@ export default function RequestStep2() {
OrganizationId: z.string({
required_error: "لطفا دستگاه مربوطه را انتخاب نمایید.",
}),
person: z.string().optional(),
person: z
.string()
.min(1, {
message: "لطفا نام فرد مورد نظر را بنویسید.",
})
.max(50, {
message: "تعداد کاراکترها بیشتر از حد مجاز میباشد.",
}),
description: z
.string()
.min(1, {
@ -197,6 +205,16 @@ export default function RequestStep2() {
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
useEffect(() => {
setCharCount(form.watch("description").length);
@ -275,7 +293,7 @@ export default function RequestStep2() {
<Form {...form}>
<form
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
control={form.control}
@ -295,7 +313,7 @@ export default function RequestStep2() {
</FormItem>
)}
/>
<div className="flex flex-row flex-wrap justify-between">
<div className="flex flex-row flex-wrap justify-between max-sm:gap-4">
<FormField
control={form.control}
name="OrganizationId"
@ -343,12 +361,22 @@ export default function RequestStep2() {
render={({ field }) => (
<FormItem className=" w-full sm:w-[48%]">
<FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
فرد مربوطه
فرد مرتبط({charCountPerson}/{50})
</FormLabel>
<FormControl>
<Input
placeholder="نام فرد مورد نظر خود را بنویسید"
{...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>
<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 */}
<FormField
control={form.control}
@ -495,19 +523,19 @@ export default function RequestStep2() {
}}
/>
</div>
{/* {!error ? (
{!error ? (
<FormDescription className=" text-xs my-1 ">
<span>
حجم هر فایل حداکثر می بایست{" "}
{formatSize(optionsData?.maxFileSize)} مگابایت باشد
</span>{" "}
و{" "}
{formatSize(optionsData?.maxFileSize)} باشد
</span>
و {" "}
{`تعداد فایل های پیوست شده می بایست حداکثر ${optionsData?.maxFileCount} تا باشد.`}
</FormDescription>
) : (
<FormMessage />
)} */}
<FormMessage />
)}
{/* <FormMessage /> */}
</FormItem>
);
}}
@ -566,10 +594,10 @@ export default function RequestStep2() {
)}
</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
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 ||
complaintSubmitMutation.isPending ? (

View File

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

View File

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

View File

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