aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-08-13 17:24:09 +0300
committereug-vs <eug-vs@keemail.me>2020-08-13 17:24:41 +0300
commit52799ec4e4cd5801423ee0d2aa56039c061afdb4 (patch)
tree9c2ba42d34e469d292fc1fe807e3f814a872a69e
parentc65923480118e90675c81782b9e3bc653e8e3b40 (diff)
downloadwhich-ui-52799ec4e4cd5801423ee0d2aa56039c061afdb4.tar.gz
feat!: remove expansion from PollCreation
-rw-r--r--src/containers/PollCreation/PollCreation.tsx48
1 files changed, 18 insertions, 30 deletions
diff --git a/src/containers/PollCreation/PollCreation.tsx b/src/containers/PollCreation/PollCreation.tsx
index 1f3a802..7501d3a 100644
--- a/src/containers/PollCreation/PollCreation.tsx
+++ b/src/containers/PollCreation/PollCreation.tsx
@@ -1,10 +1,8 @@
import React, { useState } from 'react';
import { makeStyles } from '@material-ui/core/styles';
-import Collapse from '@material-ui/core/Collapse';
import {
Button,
Card,
- ClickAwayListener,
Divider,
Container
} from '@material-ui/core';
@@ -33,7 +31,6 @@ const useStyles = makeStyles(theme => ({
const PollCreation: React.FC<PropTypes> = ({ addPoll }) => {
const classes = useStyles();
- const [expanded, setExpanded] = useState(true);
const [left, setLeft] = useState<File>();
const [right, setRight] = useState<File>();
const { enqueueSnackbar } = useSnackbar();
@@ -41,10 +38,6 @@ const PollCreation: React.FC<PropTypes> = ({ addPoll }) => {
const readyToSubmit = left && right;
- const handleClickAway = () => {
- setExpanded(false);
- };
-
const uploadImage = (file?: File) => {
const headers = { 'Content-Type': 'image/png' };
return get('/files')
@@ -57,7 +50,7 @@ const PollCreation: React.FC<PropTypes> = ({ addPoll }) => {
};
const handleClick = async () => {
- if (expanded && readyToSubmit) {
+ if (readyToSubmit) {
const [leftUrl, rightUrl] = await Promise.all([uploadImage(left), uploadImage(right)]);
const contents = {
@@ -72,32 +65,27 @@ const PollCreation: React.FC<PropTypes> = ({ addPoll }) => {
});
});
}
- setExpanded(!expanded);
};
return (
<Container maxWidth="sm" disableGutters>
- <ClickAwayListener onClickAway={handleClickAway}>
- <Card className={classes.root}>
- <Collapse in={expanded} timeout="auto" unmountOnExit>
- {user && <UserStrip user={user} info="" />}
- <Divider />
- <div className={classes.images}>
- <PollCreationImage file={left} setFile={setLeft} />
- <PollCreationImage file={right} setFile={setRight} />
- </div>
- </Collapse>
- <Button
- color="primary"
- disabled={expanded && !readyToSubmit}
- variant={expanded ? 'contained' : 'outlined'}
- onClick={handleClick}
- fullWidth
- >
- {expanded ? 'Submit' : 'Create a Poll'}
- </Button>
- </Card>
- </ClickAwayListener>
+ <Card className={classes.root}>
+ {user && <UserStrip user={user} info="" />}
+ <Divider />
+ <div className={classes.images}>
+ <PollCreationImage file={left} setFile={setLeft} />
+ <PollCreationImage file={right} setFile={setRight} />
+ </div>
+ <Button
+ color="primary"
+ disabled={!readyToSubmit}
+ variant="contained"
+ onClick={handleClick}
+ fullWidth
+ >
+ Submit
+ </Button>
+ </Card>
</Container>
);
};