Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 2007 Rev 2008
Línea 19... Línea 19...
19
`;
19
`;
20
function CloseAccount(props) {
20
function CloseAccount(props) {
21
    const {addNotification} = props
21
    const {addNotification} = props
22
    const [showInputCode, setShowInputCode] = useState(false);
22
    const [showInputCode, setShowInputCode] = useState(false);
23
    const [loading, setLoading] = useState(false);
23
    const [loading, setLoading] = useState(false);
-
 
24
    const [code, setCode] = useState('');
24
    const handleAlert = (status, message) => {
25
    const handleAlert = (status, message) => {
25
        addNotification({
26
        addNotification({
26
            style: status ? "success" : 'danger',
27
            style: status ? "success" : 'danger',
27
            msg: message || 'Email enviado exitosamente',
28
            msg: message || 'Email enviado exitosamente',
28
        });
29
        });
Línea 60... Línea 61...
60
    }
61
    }
61
    const handleSubmit = async (e) => {
62
    const handleSubmit = async (e) => {
62
        try {
63
        try {
63
            e.preventDefault()
64
            e.preventDefault()
64
            console.log('>>: e >', e)
65
            console.log('>>: e >', e)
65
            const data = new FormData(e.target);
66
            const data = new FormData();
-
 
67
            data.append('code', code)
66
            console.log('>>: data > ', data)
68
            console.log('>>: data > ', data)
67
            setLoading(true)
69
            setLoading(true)
68
            // const res = await axios.post('/account-settings/delete-account');
70
            const res = await axios.post('/account-settings/delete-account', data);
69
            // handleAlert(res.data.success, res.data.data.message)
71
            handleAlert(res.data.success, res.data.data.message)
70
            // if(res.data.success){
72
            if(res.data.success){
71
            //     logout()
73
                logout()
72
            // }
74
            }
73
        } catch (error) {
75
        } catch (error) {
74
            handleAlert(false, 'Disculpe, ha ocurrido un error')
76
            handleAlert(false, 'Disculpe, ha ocurrido un error')
75
            console.log('>>: error > ', error)
77
            console.log('>>: error > ', error)
76
        }finally{
78
        }finally{
77
            setLoading(false)
79
            setLoading(false)
Línea 81... Línea 83...
81
    const CloseAccountContent = () => {
83
    const CloseAccountContent = () => {
82
        if(showInputCode){
84
        if(showInputCode){
83
            return <form onSubmit={handleSubmit}>
85
            return <form onSubmit={handleSubmit}>
84
                <div className="form-group">
86
                <div className="form-group">
85
                    <label htmlFor="exampleInputEmail1">Ingrese el codigo enviado a su correo electrónico</label>
87
                    <label htmlFor="exampleInputEmail1">Ingrese el codigo enviado a su correo electrónico</label>
-
 
88
                    <input
-
 
89
                        type="text"
86
                    <input type="text" className="form-control" id="exampleInputEmail1" />
90
                        className="form-control"
-
 
91
                        onChange={e => setCode(e.target.value)}
-
 
92
                        value={code}
-
 
93
                    />
87
                    <button className="btn btn-link btn-sm" onClick={() => resendCode()}>
94
                    <button className="btn btn-link btn-sm" onClick={() => resendCode()}>
88
                        ¿No ha recibido su correo?, solicite un codigo nuevo
95
                        ¿No ha recibido su correo?, solicite un codigo nuevo
89
                    </button>
96
                    </button>
90
                </div>
97
                </div>
91
                <button type="submit" className="btn btn-primary">Enviar</button>
98
                <button type="submit" className="btn btn-primary">Enviar</button>