Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 399 | Rev 441 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 399 Rev 431
Línea 6... Línea 6...
6
 
6
 
Línea 7... Línea 7...
7
const Test = (props) => {
7
const Test = (props) => {
8
 
8
 
9
    //init states 
-
 
10
    const [confirmationBoxShow, setConfirmationBoxShow] = useState(false);
9
    //init states 
11
    const [valid, setValid] = useState(false);
10
    const [confirmationBoxShow, setConfirmationBoxShow] = useState(false);
Línea 12... Línea 11...
12
    const [success, setSuccess] = useState(false);
11
    const [success, setSuccess] = useState(false);
13
    const [page, setPage] = useState(0);
12
    const [page, setPage] = useState(0);
Línea 14... Línea 13...
14
 
13
 
15
    // get props
14
    // get props
16
    const { backendVars, test, loading, setTest, action } = props;
15
    const { backendVars, test, loading, setTest, action } = props;
17
 
16
 
18
    /**
-
 
19
     * Send form data
17
    /**
20
     */
18
     * Send form data
21
    const handleSubmit = async () => {
19
     */
-
 
20
    const handleSubmit = async () => {
22
        if (validateForm()) {
21
        //init form data
23
            //init form data
22
        const formData = new FormData();
24
            const formData = new FormData();
23
        formData.append("content", JSON.stringify(test));
25
            formData.append("content", JSON.stringify(test));
-
 
26
            await axios.post(action, formData).then((response) => {
24
        formData.append("status", validateForm() ? 'p' : 'd');
27
                if (response.data.success) {
25
        await axios.post(action, formData).then((response) => {
28
                    setSuccess(true);
26
            if (response.data.success && validateForm()) {
29
                }
27
                setSuccess(true);
30
            });
28
            }
31
        }
29
        });
32
    }
30
    }
Línea 52... Línea 50...
52
 
50
 
53
                    }
51
                    }
54
                })
52
                })
55
            }
53
            }
56
        });
-
 
57
        validateForm();
54
        });
58
        setTest(test);
55
        setTest(test);
Línea 59... Línea 56...
59
    }
56
    }
60
 
57
 
Línea 78... Línea 75...
78
                if (!question.answer || question.answer.length == 0) {
75
                if (!question.answer || question.answer.length == 0) {
79
                    formValid = false;
76
                    formValid = false;
80
                }
77
                }
81
            })
78
            })
82
        })
79
        })
83
        setValid(formValid);
-
 
84
        return formValid;
80
        return formValid;
85
    }
81
    }
Línea 86... Línea 82...
86
 
82
 
87
    /**
83
    /**
Línea 166... Línea 162...
166
                                        {backendVars.LBL_CANCEL}
162
                                        {backendVars.LBL_CANCEL}
167
                                    </button>
163
                                    </button>
168
                                    <button
164
                                    <button
169
                                        type="buttton"
165
                                        type="buttton"
170
                                        className="btn btn-primary"
166
                                        className="btn btn-primary"
171
                                        disabled={!valid}
-
 
172
                                        onClick={() => handleSubmit()}>
167
                                        onClick={() => handleSubmit()}>
173
                                        {backendVars.LBL_SAVE}
168
                                        {backendVars.LBL_SAVE}
174
                                    </button>
169
                                    </button>
175
                                </div>
170
                                </div>
176
                            </div>
171
                            </div>