1
- import React , { useState } from "react" ;
1
+ import React , { useEffect , useState } from "react" ;
2
2
import { useNavigate , useParams } from "react-router-dom" ;
3
3
import { formJson } from "../json/FormJson" ;
4
4
import AddUser from "../components/AddUser" ;
@@ -11,6 +11,7 @@ import SignersInput from "../components/shared/fields/SignersInput";
11
11
import Title from "../components/Title" ;
12
12
import PageNotFound from "./PageNotFound" ;
13
13
14
+ // `Form` render all type of Form on this basis of their provided in path
14
15
function Form ( ) {
15
16
const { id } = useParams ( ) ;
16
17
@@ -40,13 +41,16 @@ const Forms = (props) => {
40
41
const [ fileupload , setFileUpload ] = useState ( [ ] ) ;
41
42
const [ fileload , setfileload ] = useState ( false ) ;
42
43
const [ percentage , setpercentage ] = useState ( 0 ) ;
44
+ const [ isFolderReset , setIsFolderReset ] = useState ( false ) ;
43
45
const [ isAlert , setIsAlert ] = useState ( false ) ;
44
46
const [ isSubmit , setIsSubmit ] = useState ( false ) ;
45
47
const [ isErr , setIsErr ] = useState ( "" ) ;
46
48
const handleStrInput = ( e ) => {
47
49
setFormData ( { ...formData , [ e . target . name ] : e . target . value } ) ;
48
50
} ;
49
-
51
+ useEffect ( ( ) => {
52
+ handleReset ( ) ;
53
+ } , [ props . title ] ) ;
50
54
const handleFileInput = ( e ) => {
51
55
setpercentage ( 0 ) ;
52
56
try {
@@ -222,15 +226,19 @@ const Forms = (props) => {
222
226
} ;
223
227
224
228
const handleReset = ( ) => {
229
+ setIsFolderReset ( true ) ;
225
230
setSigners ( [ ] ) ;
226
231
setFolder ( { ObjectId : "" , Name : "" } ) ;
227
232
setFormData ( {
228
233
Name : "" ,
229
234
Description : "" ,
230
- Note : ""
235
+ Note : "Please review and sign this document" ,
236
+ TimeToCompleteDays : 15 ,
237
+ SendinOrder : "false"
231
238
} ) ;
232
239
setFileUpload ( [ ] ) ;
233
240
setpercentage ( 0 ) ;
241
+ setTimeout ( ( ) => setIsFolderReset ( false ) , 50 ) ;
234
242
} ;
235
243
return (
236
244
< div className = "shadow-md rounded my-2 p-3 bg-[#ffffff] md:border-[1px] md:border-gray-600/50" >
@@ -347,7 +355,11 @@ const Forms = (props) => {
347
355
required
348
356
/>
349
357
</ div >
350
- < SelectFolder onSuccess = { handleFolder } folderCls = { props . Cls } />
358
+ < SelectFolder
359
+ onSuccess = { handleFolder }
360
+ folderCls = { props . Cls }
361
+ isReset = { isFolderReset }
362
+ />
351
363
352
364
{ props . title === "Request Signatures" && (
353
365
< div className = "text-xs mt-2" >
@@ -402,7 +414,7 @@ const Forms = (props) => {
402
414
Submit
403
415
</ button >
404
416
< div
405
- className = "bg-[#188ae2] rounded-sm shadow-md text-[13px] font-semibold uppercase text-white py-1.5 px-2.5 text-center ml-[2px] focus:outline-none"
417
+ className = "cursor-pointer bg-[#188ae2] rounded-sm shadow-md text-[13px] font-semibold uppercase text-white py-1.5 px-2.5 text-center ml-[2px] focus:outline-none"
406
418
onClick = { ( ) => handleReset ( ) }
407
419
>
408
420
Reset
0 commit comments