@mui/icons-material#Cancel TypeScript Examples
The following examples show how to use
@mui/icons-material#Cancel.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GroupSettings.tsx From abrechnung with GNU Affero General Public License v3.0 | 4 votes |
export default function GroupSettings({ group }) {
const [showLeaveModal, setShowLeaveModal] = useState(false);
const history = useHistory();
const userPermissions = useRecoilValue(currUserPermissions(group.id));
const [isEditing, setIsEditing] = useState(false);
useTitle(`${group.name} - Settings`);
const startEdit = () => {
setIsEditing(true);
};
const stopEdit = () => {
setIsEditing(false);
};
const handleSubmit = (values, { setSubmitting }) => {
updateGroupMetadata({
groupID: group.id,
name: values.name,
description: values.description,
currencySymbol: values.currencySymbol,
terms: values.terms,
addUserAccountOnJoin: values.addUserAccountOnJoin,
})
.then((res) => {
setSubmitting(false);
setIsEditing(false);
})
.catch((err) => {
setSubmitting(false);
toast.error(err);
});
};
const confirmLeaveGroup = () => {
leaveGroup({ groupID: group.id })
.then((res) => {
history.push("/");
})
.catch((err) => {
toast.error(err);
});
};
return (
<MobilePaper>
{userPermissions.is_owner ? (
<Alert severity="info">You are an owner of this group</Alert>
) : !userPermissions.can_write ? (
<Alert severity="info">You only have read access to this group</Alert>
) : null}
<Formik
initialValues={{
name: group.name,
description: group.description,
terms: group.terms,
currencySymbol: group.currency_symbol,
addUserAccountOnJoin: group.add_user_account_on_join,
}}
onSubmit={handleSubmit}
validationSchema={validationSchema}
enableReinitialize={true}
>
{({ values, handleBlur, handleChange, handleSubmit, isSubmitting }) => (
<Form onSubmit={handleSubmit}>
<DisabledTextField
variant="standard"
margin="normal"
required
fullWidth
type="text"
label="Name"
name="name"
disabled={!userPermissions.can_write || !isEditing}
onBlur={handleBlur}
onChange={handleChange}
value={values.name}
/>
<DisabledTextField
variant="standard"
margin="normal"
fullWidth
type="text"
name="description"
label="Description"
disabled={!userPermissions.can_write || !isEditing}
onBlur={handleBlur}
onChange={handleChange}
value={values.description}
/>
<DisabledTextField
variant="standard"
margin="normal"
required
fullWidth
type="text"
name="currencySymbol"
label="Currency"
disabled={!userPermissions.can_write || !isEditing}
onBlur={handleBlur}
onChange={handleChange}
value={values.currencySymbol}
/>
<DisabledTextField
variant="standard"
multiline={true}
margin="normal"
fullWidth
type="text"
name="terms"
label="Terms"
disabled={!userPermissions.can_write || !isEditing}
onBlur={handleBlur}
onChange={handleChange}
value={values.terms}
/>
<FormGroup>
<DisabledFormControlLabel
control={
<Checkbox
name="addUserAccountOnJoin"
disabled={!userPermissions.can_write || !isEditing}
onBlur={handleBlur}
onChange={handleChange}
checked={values.addUserAccountOnJoin}
/>
}
label="Automatically add accounts for newly joined group members"
/>
</FormGroup>
{isSubmitting && <LinearProgress />}
<Grid container justifyContent="space-between" style={{ marginTop: 10 }}>
<div>
{userPermissions.can_write && isEditing && (
<>
<Button
type="submit"
variant="contained"
color="primary"
disabled={isSubmitting}
startIcon={<Save />}
>
Save
</Button>
<Button
variant="contained"
color="error"
disabled={isSubmitting}
onClick={stopEdit}
startIcon={<Cancel />}
sx={{ ml: 1 }}
>
Cancel
</Button>
</>
)}
{userPermissions.can_write && !isEditing && (
<Button
variant="contained"
color="primary"
disabled={isSubmitting}
onClick={startEdit}
startIcon={<Edit />}
>
Edit
</Button>
)}
</div>
<Button variant="contained" onClick={() => setShowLeaveModal(true)}>
Leave Group
</Button>
</Grid>
</Form>
)}
</Formik>
{/*<List>*/}
{/* <ListItem>*/}
{/* <ListItemText primary="Created" secondary={group.created}/>*/}
{/* </ListItem>*/}
{/* <ListItem>*/}
{/* <ListItemText primary="Joined" secondary={group.joined}/>*/}
{/* </ListItem>*/}
{/*</List>*/}
<Dialog open={showLeaveModal} onClose={() => setShowLeaveModal(false)}>
<DialogTitle>Leave Group</DialogTitle>
<DialogContent>
<DialogContentText>
<span>
Are you sure you want to leave the group {group.name}. If you are the last member to leave
this group it will be deleted and its transaction will be lost forever...
</span>
</DialogContentText>
</DialogContent>
<DialogActions>
<Button color="secondary" onClick={confirmLeaveGroup}>
Yes pls
</Button>
<Button color="primary" onClick={() => setShowLeaveModal(false)}>
No
</Button>
</DialogActions>
</Dialog>
</MobilePaper>
);
}
Example #2
Source File: Settings.tsx From sapio-studio with Mozilla Public License 2.0 | 4 votes |
function SettingPane(props: {
name: keyof typeof schemas;
idx: number;
value: number;
children?: React.ReactNode;
}) {
const dispatch = useDispatch();
const handlesubmit = async (
data: ISubmitEvent<any>,
nativeEvent: React.FormEvent<HTMLFormElement>
) => {
if (
await window.electron.save_settings(
props.name,
JSON.stringify(data.formData)
)
)
poll_settings(dispatch);
};
const [data, set_data] = React.useState(null);
async function get_args() {
const args = await window.electron.load_settings_sync(props.name);
if (data !== args) {
set_data(args);
}
}
React.useEffect(() => {
get_args();
}, []);
return (
<div hidden={props.idx !== props.value} className="SettingPane">
{props.idx === props.value && (
<Form
className="SettingForm"
schema={schemas[props.name]}
onSubmit={handlesubmit}
fields={custom_fields}
uiSchema={{
sapio_cli: {
'ui:widget': PathOnly,
},
auth: {
CookieFile: {
'ui:widget': PathOnly,
},
},
Enabled: {
file: {
'ui:widget': PathOnly,
},
},
}}
formData={data}
>
<Box sx={{ paddingTop: '20px' }}>
<Button
variant="contained"
color="success"
type="submit"
size="large"
endIcon={<SaveIcon />}
>
Save Settings
</Button>
<Button
sx={{ marginLeft: '20px' }}
variant="contained"
color="warning"
size="large"
endIcon={<Cancel />}
onClick={get_args}
>
Reset{' '}
</Button>
</Box>
<Box sx={{ paddingTop: '20px' }}>{props.children}</Box>
</Form>
)}
</div>
);
}