A bug fixed

Kahdooei
YasamanKahdooei 2024-07-13 14:47:07 +03:30
parent 1f932149d9
commit a5a3c48a61
4 changed files with 42 additions and 13 deletions

View File

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

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,13 @@ 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,19 +204,21 @@ 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);
}, [form.watch("description")]);
function handleDescriptionChange(event: React.ChangeEvent<HTMLTextAreaElement>) {
const newCharCount = event.target.value.length;
// Update charCount only when the user types or removes characters
if (newCharCount <= optionsData?.maxTextLength) {
setCharCount(newCharCount);
}
}
function onSubmit(data: z.infer<typeof FormSchema>) {
console.log(data);
const formData = new FormData();
@ -351,12 +360,27 @@ 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 />

View File

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