Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 360 Rev 361
Línea 1... Línea 1...
1
import React from "react";
1
import React, { useState } from "react";
2
import { axios } from '../../../utils';
2
import { axios } from '../../../utils';
3
import Section from "./section/Section";
3
import Section from "./section/Section";
4
import Spinner from "../../../shared/loading-spinner/Spinner";
4
import Spinner from "../../../shared/loading-spinner/Spinner";
-
 
5
import ConfirmationBox from "../../../shared/confirmation-box/ConfirmationBox";
Línea 5... Línea 6...
5
 
6
 
Línea 6... Línea 7...
6
const Test = (props) => {
7
const Test = (props) => {
7
 
8
 
Línea 8... Línea 9...
8
    //init states 
9
    //init states 
9
    const [showLeaveConfirmation, setShowLeaveConfirmation] = useState(false);
10
    const [confirmationBoxShow, setConfirmationBoxShow] = useState(false);
Línea 10... Línea 11...
10
 
11
 
Línea 59... Línea 60...
59
        let formValid = true;
60
        let formValid = true;
60
        test.content.map((section) => {
61
        test.content.map((section) => {
61
            section.questions.map((question) => {
62
            section.questions.map((question) => {
62
                //Validate if the answer is empty
63
                //Validate if the answer is empty
63
                if (!question.answer) {
64
                if (!question.answer) {
64
                    console.error(`Debe ingresar una respuesta en la pregunta ${question.position + 1} de la sección ${section.name}`);
-
 
65
                    formValid = false;
65
                    formValid = false;
66
                }
66
                }
67
            })
67
            })
68
        })
68
        })
Línea 69... Línea 69...
69
 
69
 
70
        return formValid;
70
        return formValid;
Línea -... Línea 71...
-
 
71
    }
-
 
72
 
-
 
73
    /**
-
 
74
     * Update component status
-
 
75
     * @returns 
Línea -... Línea 76...
-
 
76
     */
71
    }
77
    const handleConfirmationBoxShow = () => setConfirmationBoxShow(!confirmationBoxShow);
72
 
78
 
73
 
79
    /**
74
    const handleCancel = () => {
-
 
-
 
80
     * Cancel test and send to the list of forms
Línea 75... Línea 81...
75
        setTest('')
81
     * @returns 
76
    }
82
     */ 
77
 
83
    const handleCancel = () => setTest('');
78
 
84
 
Línea 107... Línea 113...
107
                            })}
113
                            })}
108
                        </div>
114
                        </div>
109
                    </div>
115
                    </div>
110
                    <div className="col-md-12 col-sm-12 col-xs-12 text-right">
116
                    <div className="col-md-12 col-sm-12 col-xs-12 text-right">
111
                        <div className="company-title">
117
                        <div className="company-title">
-
 
118
                            <button
-
 
119
                                type="button"
112
                            <button type="button" className="btn btn-danger" onClick={() => handleCancel()}>
120
                                className="btn btn-danger"
-
 
121
                                onClick={handleConfirmationBoxShow}>
113
                                {backendVars.LBL_CANCEL}
122
                                {backendVars.LBL_CANCEL}
114
                            </button>
123
                            </button>
-
 
124
 
-
 
125
                            <ConfirmationBox
-
 
126
                                show={confirmationBoxShow}
-
 
127
                                onClose={handleConfirmationBoxShow}
-
 
128
                                onAccept={handleCancel}
-
 
129
                            />
-
 
130
 
-
 
131
 
-
 
132
                            <button
-
 
133
                                type="buttton"
-
 
134
                                className="btn btn-primary"
115
                            <button type="buttton" className="btn btn-primary" onClick={() => handleSubmit()}>
135
                                onClick={() => handleSubmit()}>
116
                                {backendVars.LBL_SAVE}
136
                                {backendVars.LBL_SAVE}
117
                            </button>
137
                            </button>
118
                        </div>
138
                        </div>
119
                    </div>
139
                    </div>
120
                </div>
140
                </div>
121
            )}
141
            )}
-
 
142
 
-
 
143
 
122
        </div>
144
        </div>
123
    )
145
    )
124
}
146
}
Línea 125... Línea 147...
125
 
147
 
126
export default Test;
148
export default Test;