Prettified Code!

This commit is contained in:
itschip authored and GitHub Action committed 2021-02-01 18:45:15 +00:00
1 parent dd008775f9
commit 8621cab587
2 files changed
+24 -20

No files matched your search

+1 -2
View File
@@ -31,7 +31,7 @@ export const CallModal = () => {
}; };
const handleEndCall = () => { const handleEndCall = () => {
setModal(false) setModal(false);
Nui.send('phone:endCall', { Nui.send('phone:endCall', {
transmitterNumber: call.transmitter, transmitterNumber: call.transmitter,
}); });
@@ -41,7 +41,6 @@ export const CallModal = () => {
return ( return (
<AppWrapper> <AppWrapper>
<AppContent> <AppContent>
<h1 style={{ textAlign: 'center' }}>{call.receiver}</h1> <h1 style={{ textAlign: 'center' }}>{call.receiver}</h1>
<CallTimer isAccepted={call.accepted} /> <CallTimer isAccepted={call.accepted} />
<div className={classes.actions}> <div className={classes.actions}>
+23 -18
View File
@@ -1,18 +1,21 @@
import React, { useState, useCallback, useEffect } from 'react' import React, { useState, useCallback, useEffect } from 'react';
function CallTimer({ isAccepted }) { function CallTimer({ isAccepted }) {
const [time, setTime] = useState({ ms: 0, s: 0, m: 0, h: 0 }) const [time, setTime] = useState({ ms: 0, s: 0, m: 0, h: 0 });
useEffect(() => { useEffect(() => {
let timer = null let timer = null;
if (isAccepted) { if (isAccepted) {
run() run();
timer = setInterval(run, 10) timer = setInterval(run, 10);
} }
return () => clearInterval(timer) return () => clearInterval(timer);
}, []); }, []);
let updatedMs = time.ms, updatedS = time.s, updatedM = time.m, updatedH = time.h; let updatedMs = time.ms,
updatedS = time.s,
updatedM = time.m,
updatedH = time.h;
const run = () => { const run = () => {
if (updatedM === 60) { if (updatedM === 60) {
@@ -25,25 +28,27 @@ function CallTimer({ isAccepted }) {
} }
if (updatedMs === 100) { if (updatedMs === 100) {
updatedS++; updatedS++;
updatedMs = 0 updatedMs = 0;
} }
updatedMs++; updatedMs++;
return setTime({ ms: updatedMs, s: updatedS, m: updatedM, h: updatedH }) return setTime({ ms: updatedMs, s: updatedS, m: updatedM, h: updatedH });
} };
if (!isAccepted) return null; if (!isAccepted) return null;
return ( return (
<div style={{ <div
style={{
textAlign: 'center', textAlign: 'center',
marginTop: '2em', marginTop: '2em',
fontSize: 30 fontSize: 30,
}}> }}
<span>{(time.h >= 10) ? time.h : '0'+time.h}</span>&nbsp;:&nbsp; >
<span>{(time.m >= 10) ? time.m : '0'+time.m}</span>&nbsp;:&nbsp; <span>{time.h >= 10 ? time.h : '0' + time.h}</span>&nbsp;:&nbsp;
<span>{(time.s >= 10) ? time.s : '0'+time.s}</span>&nbsp; <span>{time.m >= 10 ? time.m : '0' + time.m}</span>&nbsp;:&nbsp;
<span>{time.s >= 10 ? time.s : '0' + time.s}</span>&nbsp;
</div> </div>
) );
} }
export default CallTimer export default CallTimer;