Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const UserEdit = (props) => {
const { permissions } = props
const translate = useTranslate()
const [mutate] = useMutation()
const notify = useNotify()
const redirect = useRedirect()
const refresh = useRefresh()
const isMyself = props.id === localStorage.getItem('userId')
const getNameHelperText = () =>
isMyself && {
helperText: translate('resources.user.helperTexts.name'),
}
const canDelete = permissions === 'admin' && !isMyself
const save = useCallback(
async (values) => {
try {
await mutate(
{
type: 'update',
resource: 'user',
const UserCreate = (props) => {
const translate = useTranslate()
const [mutate] = useMutation()
const notify = useNotify()
const redirect = useRedirect()
const resourceName = translate('resources.user.name', { smart_count: 1 })
const title = translate('ra.page.create', {
name: `${resourceName}`,
})
const save = useCallback(
async (values) => {
try {
await mutate(
{
type: 'create',
resource: 'user',
payload: { data: values },
},
{ returnPromise: true }
)
const SaveWithNoteButton = props => {
const [create] = useCreate('posts');
const redirectTo = useRedirect();
const notify = useNotify();
const { basePath, redirect } = props;
const formState = useFormState();
const handleClick = useCallback(() => {
if (!formState.valid) {
return;
}
create(
null,
{
data: { ...formState.values, average_note: 10 },
},
{
onSuccess: ({ data: newRecord }) => {
const AcceptButton = ({ record }) => {
const translate = useTranslate();
const notify = useNotify();
const redirect = useRedirect();
const [approve, { loading }] = useMutation(
{
type: 'UPDATE',
resource: 'reviews',
payload: { id: record.id, data: { status: 'accepted' } },
},
{
undoable: true,
onSuccess: () => {
notify(
'resources.reviews.notification.approved_success',
'info',
{},
true
);
redirect('/reviews');
const DeleteUserButton = (props) => {
const { resource, record, basePath, className, onClick, ...rest } = props
const notify = useNotify()
const redirect = useRedirect()
const onSuccess = () => {
notify('resources.user.notifications.deleted')
redirect('/user')
}
const { open, loading, handleDialogOpen, handleDialogClose, handleDelete } =
useDeleteWithConfirmController({
resource,
record,
basePath,
onClick,
onSuccess,
})
const classes = useStyles(props)