aboutsummaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-03-21 15:32:02 +0300
committereug-vs <eug-vs@keemail.me>2020-03-21 15:32:02 +0300
commit2e9e20414c2ea49d7f40bcff09b89897e13fd2f4 (patch)
tree03e34134c9ba1b735de45196b9745d883c9c2168 /src/components
parent2ca9cbb36e25e280a1b26c9dc03eaea30e1dcc9d (diff)
downloadchrono-cube-ui-2e9e20414c2ea49d7f40bcff09b89897e13fd2f4.tar.gz
chore: migrate components to Typescript
Diffstat (limited to 'src/components')
-rw-r--r--src/components/Loading/Loading.tsx (renamed from src/components/Loading/Loading.js)2
-rw-r--r--src/components/SolutionCard/SolutionCard.tsx (renamed from src/components/SolutionCard/SolutionCard.js)22
2 files changed, 16 insertions, 8 deletions
diff --git a/src/components/Loading/Loading.js b/src/components/Loading/Loading.tsx
index e8793cc..a784be1 100644
--- a/src/components/Loading/Loading.js
+++ b/src/components/Loading/Loading.tsx
@@ -16,7 +16,7 @@ const useStyles = makeStyles(theme => ({
},
}));
-const Loading = () => {
+const Loading: React.FC = () => {
const classes = useStyles();
return (
diff --git a/src/components/SolutionCard/SolutionCard.js b/src/components/SolutionCard/SolutionCard.tsx
index fdd4bdf..5adbff9 100644
--- a/src/components/SolutionCard/SolutionCard.js
+++ b/src/components/SolutionCard/SolutionCard.tsx
@@ -11,6 +11,7 @@ import {
Menu,
MenuItem,
} from '@material-ui/core';
+import { Solution } from '../../types';
import { makeStyles } from '@material-ui/core/styles';
import TimerIcon from '@material-ui/icons/Timer';
@@ -44,22 +45,29 @@ const useStyles = makeStyles(theme => ({
},
}));
-const SolutionCard = ({ data, removeThisCard }) => {
+
+interface PropTypes {
+ data: Solution;
+ removeThisCard: (id: number) => void;
+}
+
+
+const SolutionCard: React.FC<PropTypes> = ({ data, removeThisCard }) => {
const classes = useStyles();
- const [anchorEl, setAnchorEl] = useState(null);
+ const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);
const author = data.author? data.author.username : 'anonymous';
const date = new Date(data.date);
- const handleOpenMenu = event => {
+ const handleOpenMenu = (event: React.MouseEvent<HTMLButtonElement>): void => {
setAnchorEl(event.currentTarget);
};
- const handleClose = () => {
+ const handleClose = (): void => {
setAnchorEl(null);
};
- const handleDelete = () => {
+ const handleDelete = (): void => {
del(`solutions/${data.id}/`).then(() => {
removeThisCard(data.id);
});
@@ -77,11 +85,11 @@ const SolutionCard = ({ data, removeThisCard }) => {
}
title={author}
subheader={date.toLocaleString('default', DATE_FORMAT)}
- action={(
+ action={
<IconButton onClick={handleOpenMenu}>
<MoreVertIcon />
</IconButton>
- )}
+ }
/>
<Menu
anchorEl={anchorEl}