mirror of
https://github.com/yzernik/squeaknode.git
synced 2026-08-20 13:28:20 +02:00
* Added clear profile image dialog * Reload profile without reloading page after making changes * Update static build
103 lines
2 KiB
JavaScript
103 lines
2 KiB
JavaScript
import React, {useState, useEffect} from 'react';
|
|
import {
|
|
Paper,
|
|
IconButton,
|
|
Menu,
|
|
MenuItem,
|
|
Typography,
|
|
Grid,
|
|
Box,
|
|
Link,
|
|
Dialog,
|
|
DialogTitle,
|
|
DialogContent,
|
|
DialogContentText,
|
|
TextField,
|
|
DialogActions,
|
|
Button,
|
|
FormControl,
|
|
InputLabel,
|
|
Select,
|
|
} from "@material-ui/core";
|
|
import { MoreVert as MoreIcon } from "@material-ui/icons";
|
|
import {useHistory} from "react-router-dom";
|
|
import classnames from "classnames";
|
|
|
|
// styles
|
|
import useStyles from "./styles";
|
|
|
|
import Widget from "../../components/Widget";
|
|
|
|
import {
|
|
deleteProfileRequest,
|
|
} from "../../squeakclient/requests"
|
|
import {
|
|
reloadRoute,
|
|
} from "../../navigation/navigation"
|
|
|
|
|
|
export default function DeleteProfileDialog({
|
|
open,
|
|
handleClose,
|
|
profile,
|
|
reloadProfile,
|
|
...props
|
|
}) {
|
|
var classes = useStyles();
|
|
const history = useHistory();
|
|
|
|
const deleteProfile = (profileId) => {
|
|
deleteProfileRequest(profileId, (response) => {
|
|
reloadProfile();
|
|
});
|
|
};
|
|
|
|
function handleSubmit(event) {
|
|
event.preventDefault();
|
|
console.log( 'profile:', profile);
|
|
var profileId = profile.getProfileId();
|
|
console.log( 'profileId:', profileId);
|
|
deleteProfile(profileId);
|
|
handleClose();
|
|
}
|
|
|
|
function MakeCancelButton() {
|
|
return (
|
|
<Button
|
|
onClick={handleClose}
|
|
variant="contained"
|
|
color="secondary"
|
|
>
|
|
Cancel
|
|
</Button>
|
|
)
|
|
}
|
|
|
|
function DeleteProfileButton() {
|
|
return (
|
|
<Button
|
|
type="submit"
|
|
variant="contained"
|
|
color="primary"
|
|
className={classes.button}
|
|
>
|
|
Delete Profile
|
|
</Button>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<Dialog open={open} onClose={handleClose} aria-labelledby="form-dialog-title">
|
|
<DialogTitle id="form-dialog-title">Delete Profile</DialogTitle>
|
|
<form className={classes.root} onSubmit={handleSubmit} noValidate autoComplete="off">
|
|
<DialogContent>
|
|
Are you sure you want to delete this profile?
|
|
</DialogContent>
|
|
<DialogActions>
|
|
{MakeCancelButton()}
|
|
{DeleteProfileButton()}
|
|
</DialogActions>
|
|
</form>
|
|
</Dialog>
|
|
)
|
|
}
|