mirror of
https://github.com/RoboSats/robosats.git
synced 2024-12-14 19:36:24 +00:00
Merge branch 'linear-determinate-to-ts' into main (#132)
This commit is contained in:
commit
55e3f8d031
@ -15,7 +15,8 @@
|
|||||||
"rules": {
|
"rules": {
|
||||||
"react-hooks/rules-of-hooks": "error",
|
"react-hooks/rules-of-hooks": "error",
|
||||||
"react-hooks/exhaustive-deps": "warn",
|
"react-hooks/exhaustive-deps": "warn",
|
||||||
"react/prop-types": "off"
|
"react/prop-types": "off",
|
||||||
|
"react/react-in-jsx-scope": "off",
|
||||||
},
|
},
|
||||||
"settings": {
|
"settings": {
|
||||||
"react": {
|
"react": {
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
|
||||||
import { Box, LinearProgress } from "@mui/material"
|
|
||||||
import { calcTimeDelta } from 'react-countdown';
|
|
||||||
|
|
||||||
export default function LinearDeterminate(props) {
|
|
||||||
const [progress, setProgress] = useState(0);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const timer = setInterval(() => {
|
|
||||||
setProgress((oldProgress) => {
|
|
||||||
var left = calcTimeDelta( new Date(props.expires_at)).total /1000;
|
|
||||||
return (left / props.total_secs_exp) * 100;
|
|
||||||
});
|
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
clearInterval(timer);
|
|
||||||
};
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Box sx={{ width: '100%' }}>
|
|
||||||
<LinearProgress variant="determinate" value={progress} />
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
}
|
|
@ -0,0 +1,36 @@
|
|||||||
|
import React, { useState, useEffect } from "react";
|
||||||
|
import { Box, LinearProgress } from "@mui/material"
|
||||||
|
import { calcTimeDelta } from 'react-countdown';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
expiresAt: string;
|
||||||
|
totalSecsExp: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
const LinearDeterminate = ({
|
||||||
|
expiresAt,
|
||||||
|
totalSecsExp,
|
||||||
|
}: Props): JSX.Element => {
|
||||||
|
const [progress, setProgress] = useState<number>(0);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const timer = setInterval(() => {
|
||||||
|
const left = calcTimeDelta(new Date(expiresAt)).total / 1000;
|
||||||
|
const newProgress = (left / totalSecsExp) * 100;
|
||||||
|
|
||||||
|
setProgress(newProgress);
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
clearInterval(timer);
|
||||||
|
};
|
||||||
|
}, [expiresAt, totalSecsExp]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box sx={{ width: '100%' }}>
|
||||||
|
<LinearProgress variant="determinate" value={progress} />
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default LinearDeterminate;
|
1
frontend/src/components/LinearDeterminate/index.ts
Normal file
1
frontend/src/components/LinearDeterminate/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { default } from "./LinearDeterminate";
|
@ -614,7 +614,7 @@ class OrderPage extends Component {
|
|||||||
<Countdown date={new Date(this.state.expires_at)} renderer={this.countdownRenderer} />
|
<Countdown date={new Date(this.state.expires_at)} renderer={this.countdownRenderer} />
|
||||||
</ListItemText>
|
</ListItemText>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
<LinearDeterminate key={this.state.expires_at} total_secs_exp={this.state.total_secs_exp} expires_at={this.state.expires_at}/>
|
<LinearDeterminate totalSecsExp={this.state.total_secs_exp} expiresAt={this.state.expires_at}/>
|
||||||
</List>
|
</List>
|
||||||
|
|
||||||
{/* If the user has a penalty/limit */}
|
{/* If the user has a penalty/limit */}
|
||||||
|
Loading…
Reference in New Issue
Block a user