squeaknode/frontend/src/components/ClearProfileImageDialog/ClearProfileImageDialog.js
Jonathan Zernik 8431168e92
Remove unused vars frontend (#1180)
* Remove some unused vars

* Fix image preview alt

* Remove more unused vars

* Remove more unused vars
2021-09-04 10:56:44 -07:00

87 lines
1.8 KiB
JavaScript

import React from 'react';
import {
Dialog,
DialogTitle,
DialogContent,
DialogActions,
Button,
} from '@material-ui/core';
// styles
import useStyles from './styles';
import {
clearSqueakProfileImageRequest,
} from '../../squeakclient/requests';
export default function ClearProfileImageDialog({
open,
handleClose,
squeakProfile,
reloadProfile,
...props
}) {
const classes = useStyles();
const handleResponse = (response) => {
reloadProfile();
};
const handleErr = (err) => {
alert(`Error clearing profile image: ${err}`);
};
const clearProfileImage = () => {
clearSqueakProfileImageRequest(
squeakProfile.getProfileId(),
handleResponse,
handleErr,
);
};
function handleSubmit(event) {
event.preventDefault();
clearProfileImage();
handleClose();
}
function CancelButton() {
return (
<Button
onClick={handleClose}
variant="contained"
color="secondary"
>
Cancel
</Button>
);
}
function ClearProfileImageButton() {
return (
<Button
type="submit"
variant="contained"
color="primary"
className={classes.button}
>
Clear Profile Image
</Button>
);
}
return (
<Dialog open={open} onClose={handleClose} aria-labelledby="form-dialog-title">
<DialogTitle id="form-dialog-title">Clear Profile Image</DialogTitle>
<form className={classes.root} onSubmit={handleSubmit} noValidate autoComplete="off">
<DialogContent>
Are you sure you want to clear the image for this profile?
</DialogContent>
<DialogActions>
{CancelButton()}
{ClearProfileImageButton()}
</DialogActions>
</form>
</Dialog>
);
}