Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 4444 Rev 5104
Línea 1... Línea 1...
1
/* eslint-disable react/prop-types */
1
/* eslint-disable react/prop-types */
2
import React from 'react';
-
 
3
import { useState } from 'react';
2
import React, { useState } from 'react'
4
import styled from 'styled-components';
3
import styled from 'styled-components'
5
import { addNotification } from '../../../redux/notification/notification.actions';
4
import { addNotification } from '../../../redux/notification/notification.actions'
6
import Spinner from '../../../shared/loading-spinner/Spinner';
5
import Spinner from '../../../shared/loading-spinner/Spinner'
7
import { axios } from '../../../utils';
6
import { axios } from '../../../utils'
Línea 8... Línea 7...
8
 
7
 
9
const StyledSpinnerContainer = styled.div`
8
const StyledSpinnerContainer = styled.div`
10
  position: absolute;
9
  position: absolute;
11
  left: 0;
10
  left: 0;
Línea 15... Línea 14...
15
  background: rgba(255, 255, 255, 0.4);
14
  background: rgba(255, 255, 255, 0.4);
16
  display: flex;
15
  display: flex;
17
  justify-content: center;
16
  justify-content: center;
18
  align-items: center;
17
  align-items: center;
19
  z-index: 300;
18
  z-index: 300;
20
`;
19
`
Línea 21... Línea 20...
21
 
20
 
22
export default function SocialNetworks({ className = 'peopleYouMayKnow' }) {
21
export default function SocialNetworks ({ className = 'peopleYouMayKnow' }) {
23
    const [loading, setLoading] = useState(false);
22
  const [loading, setLoading] = useState(false)
24
    const handleOnRoom = async () => {
23
  const handleOnRoom = async () => {
25
        try {
24
    try {
26
            setLoading(true)
25
      setLoading(true)
27
            const response = await axios.post('/moodle');
26
      const response = await axios.post('/moodle')
28
            if (response.data.success) {
27
      if (response.data.success) {
29
                let form = document.createElement('form');
28
        const form = document.createElement('form')
30
                form.setAttribute('method', 'post');
29
        form.setAttribute('method', 'post')
31
                form.setAttribute('action', response.data.data.url);
30
        form.setAttribute('action', response.data.data.url)
32
                form.setAttribute('target', '_blank');
31
        form.setAttribute('target', '_blank')
33
                Object.keys(response.data.data).forEach(key => {
32
        Object.keys(response.data.data).forEach(key => {
34
                    if (key != 'url') {
33
          if (key !== 'url') {
35
                        const value = response.data.data[key];
34
            const value = response.data.data[key]
36
                        let hiddenField = document.createElement('input');
35
            const hiddenField = document.createElement('input')
37
                        hiddenField.setAttribute('type', 'hidden');
36
            hiddenField.setAttribute('type', 'hidden')
38
                        hiddenField.setAttribute('name', key);
37
            hiddenField.setAttribute('name', key)
39
                        hiddenField.setAttribute('value', value);
38
            hiddenField.setAttribute('value', value)
40
                        form.appendChild(hiddenField);
39
            form.appendChild(hiddenField)
41
                    }
40
          }
42
                })
41
        })
43
                document.body.appendChild(form);
42
        document.body.appendChild(form)
44
                form.submit();
43
        form.submit()
45
            }
44
      }
46
        } catch (error) {
45
    } catch (error) {
47
            console.log('>>: error > ', error)
46
      console.log('>>: error > ', error)
48
            addNotification({
47
      addNotification({
49
                style: "danger",
48
        style: 'danger',
50
                msg: "Ha ocurrido un error en la comunicacion con ON ROOM",
49
        msg: 'Ha ocurrido un error en la comunicacion con ON ROOM'
51
            });
50
      })
52
        } finally {
51
    } finally {
53
            setLoading(false)
-
 
54
        }
52
      setLoading(false)
-
 
53
    }
55
    }
54
  }
56
    return (
55
  return (
57
        <div className={className}>
56
        <div className={className}>
58
            <div className='widget__app'>
57
            <div className='widget__app'>
59
                <a href="#" onClick={() => handleOnRoom()}>
58
                <a href="#" onClick={() => handleOnRoom()}>
60
                    <img
59
                    <img
Línea 89... Línea 88...
89
                            alt=""
88
                            alt=""
90
                        />
89
                        />
91
                    </a>
90
                    </a>
92
                </div>
91
                </div>
93
                <a href="#" className='widget__app__title' title="">
92
                <a href="#" className='widget__app__title' title="">
94
                    Microaprendizaje
93
                    {LABELS.MICRO_LEARNING}
95
                </a>
94
                </a>
96
            </div>
95
            </div>
97
            {loading &&
96
            {loading &&
98
                <StyledSpinnerContainer>
97
                <StyledSpinnerContainer>
99
                    <Spinner />
98
                    <Spinner />
100
                </StyledSpinnerContainer>
99
                </StyledSpinnerContainer>
101
            }
100
            }
102
        </div>
101
        </div>
103
    )
102
  )
104
}
103
}