2022-01-01 19:04:46 +01:00
|
|
|
import React from 'react';
|
|
|
|
import StyledWrapper from './StyledWrapper';
|
|
|
|
|
2022-01-01 20:18:12 +01:00
|
|
|
const ResponseTime = ({duration}) => {
|
|
|
|
let durationToDisplay = ''
|
|
|
|
|
|
|
|
if(duration > 1000 ) { // duration greater than a second
|
|
|
|
let seconds = Math.floor(duration / 1000);
|
2022-01-25 22:30:21 +01:00
|
|
|
let decimal = ((duration % 1000) / 1000) * 100;
|
|
|
|
durationToDisplay = seconds + '.' + decimal.toFixed(0) + 's';
|
2022-01-01 20:18:12 +01:00
|
|
|
} else {
|
|
|
|
durationToDisplay = duration + 'ms'
|
|
|
|
}
|
|
|
|
|
2022-01-01 19:04:46 +01:00
|
|
|
return (
|
2022-01-01 19:42:38 +01:00
|
|
|
<StyledWrapper className="mt-3 ml-4">
|
2022-01-01 20:18:12 +01:00
|
|
|
{durationToDisplay}
|
2022-01-01 19:04:46 +01:00
|
|
|
</StyledWrapper>
|
|
|
|
)
|
|
|
|
};
|
|
|
|
export default ResponseTime;
|