Skip to content

Commit

Permalink
Merge branch 'linear-determinate-to-ts' into main (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
Reckless-Satoshi committed May 16, 2022
2 parents b24bd4c + 523d899 commit 55e3f8d
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 31 deletions.
3 changes: 2 additions & 1 deletion frontend/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"rules": {
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"react/prop-types": "off"
"react/prop-types": "off",
"react/react-in-jsx-scope": "off",
},
"settings": {
"react": {
Expand Down
26 changes: 0 additions & 26 deletions frontend/src/components/LinearDeterminate.js

This file was deleted.

36 changes: 36 additions & 0 deletions frontend/src/components/LinearDeterminate/LinearDeterminate.tsx
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions frontend/src/components/LinearDeterminate/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "./LinearDeterminate";
8 changes: 4 additions & 4 deletions frontend/src/components/OrderPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,9 @@ class OrderPage extends Component {
onClickCopy={()=> (navigator.clipboard.writeText(getCookie("robot_token")) & this.props.setAppState({copiedToken:true}))}
copyIconColor={this.props.copiedToken ? "inherit" : "primary"}
onClickBack={() => this.setState({openStoreToken:false})}
onClickDone={() => this.setState({openStoreToken:false}) &
(this.state.maker_status=='Inactive' ?
this.handleClickOpenInactiveMakerDialog()
onClickDone={() => this.setState({openStoreToken:false}) &
(this.state.maker_status=='Inactive' ?
this.handleClickOpenInactiveMakerDialog()
: this.takeOrder())
}/>
:
Expand Down Expand Up @@ -614,7 +614,7 @@ class OrderPage extends Component {
<Countdown date={new Date(this.state.expires_at)} renderer={this.countdownRenderer} />
</ListItemText>
</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>

{/* If the user has a penalty/limit */}
Expand Down

0 comments on commit 55e3f8d

Please sign in to comment.