siam-ui-utils 2.1.12 → 2.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -75,5 +75,5 @@ declare module 'siam-ui-utils' {
75
75
  export function TomarFoto(props);
76
76
 
77
77
  //VIDEO CALL ROOM
78
- export function VideoCallRoom(props);
78
+ export function WherebyRoom(props);
79
79
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "siam-ui-utils",
3
- "version": "2.1.12",
3
+ "version": "2.1.13",
4
4
  "keywords": [
5
5
  "ampf-react",
6
6
  "ampf-utils",
@@ -24,6 +24,7 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@types/react-intl": "^3.0.0",
27
+ "@whereby.com/browser-sdk": "^3.12.18",
27
28
  "events": "^3.3.0",
28
29
  "html5-file-selector": "^2.1.0",
29
30
  "prop-types": "^15.8.1",
package/src/App.jsx CHANGED
@@ -9,7 +9,7 @@ import { TomarFoto, DropzoneUploader, DropzoneUploaderDniDigital } from './';
9
9
  import './index.css';
10
10
  import './App.css';
11
11
  import './assets/css/vendor/bootstrap.min.css';
12
- import { VideoCallRoom } from './video-call-room';
12
+ import { VideoCallRoom } from './where-by-room';
13
13
 
14
14
  const App = () => {
15
15
  const [open, setOpen] = useState('0');
package/src/index.js CHANGED
@@ -5,4 +5,4 @@ export * from './CustomBootstrap';
5
5
  export * from './CustomSelectInput';
6
6
  export * from './tomar-foto';
7
7
  export * as IntlMessages from './IntlMessages';
8
- export * from './video-call-room';
8
+ export * from './where-by-room';
@@ -0,0 +1,2 @@
1
+ export const ALERT_TIMEOUT = 5; //5 MINUTOS (alerta de tiempo restante)
2
+ export const SESSION_TIMEOUT = 30; //30 MINUTOS
@@ -0,0 +1,67 @@
1
+ import React, { useEffect, useRef } from 'react';
2
+ import { WherebyEmbedded } from '@whereby.com/browser-sdk';
3
+ import { ALERT_TIMEOUT, SESSION_TIMEOUT } from './constants';
4
+
5
+ const WherebyRoom = ({
6
+ roomUrl,
7
+ title = 'Sala de consulta',
8
+ onHostLeft = () => {},
9
+ onSessionFinished = () => {},
10
+ timeOut = SESSION_TIMEOUT,
11
+ alertTimeout = ALERT_TIMEOUT,
12
+ onAlertTimeout = () => {},
13
+ }) => {
14
+ const iframeRef = useRef(null);
15
+
16
+ useEffect(() => {
17
+ const iframe = iframeRef.current;
18
+
19
+ const whereby = new WherebyEmbedded(iframe);
20
+
21
+ whereby.on('room:participant-left', (event) => {
22
+ if (event.participant.isHost) {
23
+ onHostLeft();
24
+ }
25
+ });
26
+
27
+ const sessionTimeout = setTimeout(
28
+ () => {
29
+ onSessionFinished();
30
+ iframe.remove();
31
+ },
32
+ timeOut * 60 * 1000,
33
+ );
34
+
35
+ const sessionAlertTimeout = setTimeout(
36
+ () => {
37
+ onAlertTimeout();
38
+ },
39
+ alertTimeout * 60 * 1000,
40
+ );
41
+
42
+ return () => {
43
+ clearTimeout(sessionTimeout);
44
+ clearTimeout(sessionAlertTimeout);
45
+ whereby.destroy();
46
+ };
47
+ }, []);
48
+
49
+ return (
50
+ <div>
51
+ <iframe
52
+ ref={iframeRef}
53
+ title={title}
54
+ src={roomUrl}
55
+ allow="camera; microphone; fullscreen; speaker; display-capture"
56
+ style={{
57
+ width: '100%',
58
+ height: '80vh',
59
+ border: 0,
60
+ borderRadius: '12px',
61
+ }}
62
+ ></iframe>
63
+ </div>
64
+ );
65
+ };
66
+
67
+ export default WherebyRoom;
@@ -1,10 +0,0 @@
1
- export const VideoCallRoom = ({ url, title = 'Videollamada AMPF' }) => {
2
- return (
3
- <iframe
4
- src={url}
5
- allow="camera; microphone; fullscreen; speaker; display-capture"
6
- style={{ width: '100%', height: '100%', border: '0', minHeight: '600px' }}
7
- title={title}
8
- />
9
- );
10
- };