Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects

[ADD] getDuration function in contentTabItem components

Merged Aldi Firmansyah requested to merge aldi2 into master
1 file
+ 31
10
Compare changes
  • Side-by-side
  • Inline
@@ -22,17 +22,38 @@ const ContentTabChild = ({
@@ -22,17 +22,38 @@ const ContentTabChild = ({
videoName,
videoName,
duration,
duration,
sectionName
sectionName
}) => (
}) => {
<Container
const getDuration = duration => {
onClick={() => changeVideo(`${sectionName} | ${videoName}`, videoFile)}
if (!duration) return "";
>
<Typography style={{ paddingLeft: "0.5rem" }}>
{number}. {videoName} |{" "}
<span style={{ fontSize: "0.75em" }}>{duration} seconds</span>
</Typography>
</Container>
);
 
let result = "";
 
 
// set detik
 
let temp = duration;
 
if (temp % 60) result = `${temp % 60} detik`;
 
if (temp < 60) return result;
 
 
// set menit
 
temp = Math.floor(temp / 60);
 
if (temp % 60) result = `${temp % 60} menit ${result}`;
 
if (temp < 60) return result;
 
 
// set jam
 
temp = Math.floor(temp / 60);
 
result = `${temp % 60} jam ${result}`;
 
return result;
 
};
 
return (
 
<Container
 
onClick={() => changeVideo(`${sectionName} | ${videoName}`, videoFile)}
 
>
 
<Typography style={{ paddingLeft: "0.5rem" }}>
 
{number}. {videoName} |{" "}
 
<span style={{ fontSize: "0.75em" }}>{getDuration(duration)}</span>
 
</Typography>
 
</Container>
 
);
 
};
ContentTabChild.propTypes = {
ContentTabChild.propTypes = {
name: PropTypes.string
name: PropTypes.string
};
};
Loading