| 2960 |
stevensc |
1 |
import React, { useState } from 'react'
|
|
|
2 |
import { useNavigate } from 'react-router-dom'
|
|
|
3 |
import { useDispatch } from 'react-redux'
|
|
|
4 |
import { Button } from '@mui/material'
|
|
|
5 |
|
|
|
6 |
import { getOnRoom } from '@services/onRoom'
|
|
|
7 |
import { addNotification } from '@store/notification/notification.actions'
|
|
|
8 |
|
|
|
9 |
import Spinner from '@components/UI/Spinner'
|
|
|
10 |
|
|
|
11 |
export default function AppsNavigation() {
|
|
|
12 |
const [loading, setLoading] = useState(false)
|
|
|
13 |
const dispatch = useDispatch()
|
|
|
14 |
const navigate = useNavigate()
|
|
|
15 |
|
|
|
16 |
const handleOnRoom = async () => {
|
|
|
17 |
try {
|
|
|
18 |
setLoading(true)
|
|
|
19 |
const onRoomUrl = await getOnRoom()
|
|
|
20 |
window.open(onRoomUrl, '_blank')
|
|
|
21 |
} catch (error) {
|
|
|
22 |
dispatch(addNotification({ style: 'danger', msg: error.message }))
|
|
|
23 |
} finally {
|
|
|
24 |
setLoading(false)
|
|
|
25 |
}
|
|
|
26 |
}
|
|
|
27 |
|
|
|
28 |
return (
|
|
|
29 |
<>
|
|
|
30 |
{loading && <Spinner absolute />}
|
|
|
31 |
<Button onClick={() => navigate('/microlearning')}>
|
|
|
32 |
Micro Aprendizaje
|
|
|
33 |
</Button>
|
|
|
34 |
<Button onClick={handleOnRoom}>On room</Button>
|
|
|
35 |
<Button onClick={() => navigate('/habits')}>Habitos</Button>
|
|
|
36 |
<Button onClick={() => navigate('/dashboard')}>Ir al inicio</Button>
|
|
|
37 |
</>
|
|
|
38 |
)
|
|
|
39 |
}
|