Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 1991 Rev 1992
Línea 1... Línea 1...
1
import React,  { useState, useMemo } from 'react';
1
import React,  { useState, useMemo } from 'react';
2
import Spinner from '../../../shared/loading-spinner/Spinner';
2
import Spinner from '../../../shared/loading-spinner/Spinner';
3
import styled from 'styled-components';
3
import styled from 'styled-components';
4
import axios from '../../../utils/axios';
4
import axios from '../../../utils/axios';
-
 
5
import { addNotification } from '../../../redux/notification/notification.actions';
Línea 5... Línea 6...
5
 
6
 
6
const StyledSpinnerContainer = styled.div`
7
const StyledSpinnerContainer = styled.div`
7
  position: absolute;
8
  position: absolute;
8
  left: 0;
9
  left: 0;
Línea 13... Línea 14...
13
  display: flex;
14
  display: flex;
14
  justify-content: center;
15
  justify-content: center;
15
  align-items: center;
16
  align-items: center;
16
  z-index: 300;
17
  z-index: 300;
17
`;
18
`;
18
function CloseAccount() {
19
function CloseAccount(props) {
-
 
20
    const {addNotification} = props
19
    const [showInputCode, setShowInputCode] = useState(false);
21
    const [showInputCode, setShowInputCode] = useState(false);
20
    const [loading, setLoading] = useState(false);
22
    const [loading, setLoading] = useState(false);
-
 
23
    const handleAlert = (status, message) => {
-
 
24
        addNotification({
-
 
25
            style: status ? "success" : 'danger',
-
 
26
            msg: res.data.message || 'Email enviado exitosamente',
-
 
27
        });
-
 
28
    }
21
    const handleGetCode  = async () => {
29
    const handleGetCode  = async () => {
22
        try {
30
        try {
23
            setShowInputCode(true)
31
            setShowInputCode(true)
24
            setLoading(true)
32
            setLoading(true)
25
            const res = await axios.get('/account-settings/delete-account');
33
            const res = await axios.get('/account-settings/delete-account');
26
            console.log('>>: res > ', res)
34
            handleAlert(res.data.success, res.data.message)
27
            console.log('>>: get code')        
-
 
28
        } catch (error) {
35
        } catch (error) {
-
 
36
            handleAlert(false, 'Disculpe, ha ocurrido un error')
29
            console.log('>>: error > ', error)
37
            console.log('>>: error > ', error)
30
        }finally{
38
        }finally{
31
            setLoading(false)
39
            setLoading(false)
32
        }
40
        }
33
    }
41
    }
Línea 34... Línea 42...
34
 
42
 
35
    const resendCode = async () => {
43
    const resendCode = async () => {
36
        try {
44
        try {
37
            setLoading(true)
45
            setLoading(true)
-
 
46
            const res = await axios.get('/account-settings/delete-account');
38
            const res = await axios.get('/account-settings/delete-account');
47
            handleAlert(res.data.success, res.data.message)
39
            console.log('>>: resend code > ', res)
48
            console.log('>>: resend code > ', res)
-
 
49
        } catch (error) {
40
        } catch (error) {
50
            handleAlert(false, 'Disculpe, ha ocurrido un error')
41
            console.log('>>: error > ', error)
51
            console.log('>>: error > ', error)
42
        }finally{
52
        }finally{
43
            setLoading(false)
53
            setLoading(false)
44
        }
54
        }
Línea 47... Línea 57...
47
    const handleSubmit = async (e) => {
57
    const handleSubmit = async (e) => {
48
        try {
58
        try {
49
            e.preventDefault()
59
            e.preventDefault()
50
            setLoading(true)
60
            setLoading(true)
51
            const res = await axios.post('/account-settings/delete-account');
61
            const res = await axios.post('/account-settings/delete-account');
-
 
62
            handleAlert(res.data.success, res.data.message)
52
            console.log('>>: res > ', res)
63
            console.log('>>: res > ', res)
53
        } catch (error) {
64
        } catch (error) {
-
 
65
            handleAlert(false, 'Disculpe, ha ocurrido un error')
54
            console.log('>>: error > ', error)
66
            console.log('>>: error > ', error)
55
        }finally{
67
        }finally{
56
            setLoading(false)
68
            setLoading(false)
57
        }
69
        }
58
    }
70
    }
Línea 59... Línea 71...
59
 
71
 
60
    const CloseAccountContent = () => {
72
    const CloseAccountContent = () => {
61
        if(showInputCode){
73
        if(showInputCode){
62
            return <form onSubmit={handleSubmit}>
74
            return <form onSubmit={handleSubmit}>
63
                <div className="form-group">
75
                <div className="form-group">
64
                    <label htmlFor="exampleInputEmail1">Ingrese el codigo</label>
76
                    <label htmlFor="exampleInputEmail1">Ingrese el codigo enviado a su correo electrónico</label>
65
                    <input type="email" className="form-control" id="exampleInputEmail1" />
-
 
66
                    <small id="emailHelp" className="form-text text-muted">Este codigo fue enviado a tu correo electrónico.</small>
77
                    <input type="email" className="form-control" id="exampleInputEmail1" />
67
                    <button className="btn btn-secondary btn-sm" onClick={() => resendCode()}>
78
                    <button className="btn btn-link btn-sm" onClick={() => resendCode()}>
68
                        ¿No ha recibido su correo?, solicitue un codigo nuevo
79
                        ¿No ha recibido su correo?, solicite un codigo nuevo
69
                    </button>
80
                    </button>
70
                </div>
81
                </div>
71
                <button type="submit" className="btn btn-primary">Enviar</button>
82
                <button type="submit" className="btn btn-primary">Enviar</button>
72
            </form>
83
            </form>
Línea 98... Línea 109...
98
            )}
109
            )}
99
        </div>
110
        </div>
100
    )
111
    )
101
}
112
}
Línea 102... Línea -...
102
 
-
 
103
export default CloseAccount
113
 
-
 
114
const mapDispatchToProps = {
-
 
115
    addNotification: (notification) => addNotification(notification),
-
 
116
};
-
 
117
  
-
 
118
export default connect({}, mapDispatchToProps)(CloseAccount);
104
119