a bug fixed

main
Hossein Rahmani 2024-07-21 13:06:31 +03:30
parent 5ecf47e3d1
commit a97d4ae1a9
3 changed files with 19 additions and 15 deletions

View File

@ -54,7 +54,7 @@ export default function InspectorOperations({
}) {
const [file, setFile] = useState<File[]>([]);
const [check, setCheck] = useState<any>(false);
const [charCount, setCharCount] = useState(0);
const [charCount, setCharCount] = useState<any>(0);
// Queries
const { data, isLoading, refetch } = useQuery({
@ -132,18 +132,22 @@ 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);
}
// Add the useEffect hook to monitor changes in the description field
useEffect(() => {
const text = form.watch("text") as string;
if (charCount != 0) {
setCharCount(text?.length);
console.log(charCount);
}
}, [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);
}
}
function onSubmit(data: z.infer<typeof FormSchema>) {
const storedData = JSON.parse(

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "sootzani",
"version": "0.2.21",
"version": "0.2.22",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sootzani",
"version": "0.2.21",
"version": "0.2.22",
"dependencies": {
"@hookform/resolvers": "^3.3.2",
"@microsoft/signalr": "^8.0.0",

View File

@ -1,6 +1,6 @@
{
"name": "sootzani",
"version": "0.2.21",
"version": "0.2.22",
"private": true,
"scripts": {
"dev": "next dev",