How to use the ra-core.useNotify function in ra-core

To help you get started, we’ve selected a few ra-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github marmelab / react-admin / packages / ra-ui-materialui / src / button / BulkExportButton.tsx View on Github external
const BulkExportButton: FunctionComponent = ({
    resource,
    selectedIds,
    onClick,
    label = 'ra.action.export',
    icon = defaultIcon,
    ...rest
}) => {
    const exporter = useContext(ExporterContext);
    const dataProvider = useDataProvider();
    const notify = useNotify();
    const handleClick = useCallback(
        event => {
            exporter &&
                dataProvider
                    .getMany(resource, { ids: selectedIds })
                    .then(({ data }) =>
                        exporter(
                            data,
                            fetchRelatedRecords(dataProvider),
                            dataProvider,
                            resource
                        )
                    )
                    .catch(error => {
                        console.error(error);
                        notify('ra.notification.http_error', 'warning');
github marmelab / react-admin / packages / ra-ui-materialui / src / auth / LoginForm.tsx View on Github external
const LoginForm: FunctionComponent = ({ redirectTo }) => {
    const [loading, setLoading] = useSafeSetState(false);
    const login = useLogin();
    const translate = useTranslate();
    const notify = useNotify();
    const classes = useStyles({});

    const validate = (values: FormData) => {
        const errors = { username: undefined, password: undefined };

        if (!values.username) {
            errors.username = translate('ra.validation.required');
        }
        if (!values.password) {
            errors.password = translate('ra.validation.required');
        }
        return errors;
    };

    const submit = values => {
        setLoading(true);
github marmelab / react-admin / packages / ra-ui-materialui / src / button / ExportButton.tsx View on Github external
const ExportButton: FunctionComponent = ({
    exporter,
    sort,
    filter = defaultFilter,
    maxResults = 1000,
    resource,
    onClick,
    label = 'ra.action.export',
    icon = DefaultIcon,
    ...rest
}) => {
    const dataProvider = useDataProvider();
    const notify = useNotify();
    const handleClick = useCallback(
        event => {
            dataProvider
                .getList(resource, {
                    sort,
                    filter,
                    pagination: { page: 1, perPage: maxResults },
                })
                .then(({ data }) =>
                    exporter
                        ? exporter(
                              data,
                              fetchRelatedRecords(dataProvider),
                              dataProvider
                          )
                        : jsonExport(data, (err, csv) =>
github marmelab / react-admin / packages / ra-ui-materialui / src / button / DeleteWithUndoButton.js View on Github external
const DeleteWithUndoButton = ({
    label = 'ra.action.delete',
    classes: classesOverride,
    className,
    icon,
    onClick,
    resource,
    record,
    basePath,
    redirect: redirectTo,
    ...rest
}) => {
    const classes = useStyles({ classes: classesOverride });
    const notify = useNotify();
    const redirect = useRedirect();
    const refresh = useRefresh();

    const [deleteOne, { loading }] = useDelete(
        resource,
        record && record.id,
        record,
        {
            action: CRUD_DELETE,
            onSuccess: () => {
                notify(
                    'ra.notification.deleted',
                    'info',
                    { smart_count: 1 },
                    true
                );
github marmelab / react-admin / packages / ra-ui-materialui / src / button / BulkDeleteWithUndoButton.js View on Github external
const BulkDeleteWithUndoButton = ({
    basePath,
    classes: classesOverride,
    icon,
    label,
    onClick,
    resource,
    selectedIds,
    startUndoable,
    ...rest
}) => {
    const classes = useStyles({ classes: classesOverride });
    const notify = useNotify();
    const unselectAll = useUnselectAll();
    const refresh = useRefresh();
    const [deleteMany, { loading }] = useDeleteMany(resource, selectedIds, {
        action: CRUD_DELETE_MANY,
        onSuccess: () => {
            notify(
                'ra.notification.deleted',
                'info',
                { smart_count: selectedIds.length },
                true
            );
            unselectAll(resource);
            refresh();
        },
        onFailure: error =>
            notify(
github marmelab / react-admin / packages / ra-ui-materialui / src / button / BulkDeleteWithConfirmButton.js View on Github external
const BulkDeleteWithConfirmButton = ({
    basePath,
    classes: classesOverride,
    crudDeleteMany,
    icon,
    label,
    onClick,
    resource,
    selectedIds,
    ...rest
}) => {
    const [isOpen, setOpen] = useState(false);
    const classes = useStyles({ classes: classesOverride });
    const notify = useNotify();
    const unselectAll = useUnselectAll();
    const refresh = useRefresh();
    const translate = useTranslate();
    const [deleteMany, { loading }] = useDeleteMany(resource, selectedIds, {
        action: CRUD_DELETE_MANY,
        onSuccess: () => {
            refresh();
            notify('ra.notification.deleted', 'info', {
                smart_count: selectedIds.length,
            });
            unselectAll(resource);
        },
        onFailure: error =>
            notify(
                typeof error === 'string'
                    ? error
github bootstrap-styled / ra-ui / backup-src / components / button / BulkDeleteWithConfirmButton.js View on Github external
const BulkDeleteWithConfirmButton = ({
  basePath,
  crudDeleteMany,
  icon,
  label,
  onClick,
  resource,
  selectedIds,
  ...rest
}) => {
  const [isOpen, setOpen] = useState(false);
  const notify = useNotify();
  const unselectAll = useUnselectAll();
  const refresh = useRefresh();
  const translate = useTranslate();
  const [deleteMany, { loading }] = useDeleteMany(resource, selectedIds, {
    action: CRUD_DELETE_MANY,
    onSuccess: () => {
      refresh();
      notify('ra.notification.deleted', 'info', {
        smart_count: selectedIds.length,
      });
      unselectAll(resource);
    },
    onFailure: error => notify(
      typeof error === 'string'
        ? error
        : error.message || 'ra.notification.http_error',
github marmelab / react-admin / packages / ra-ui-materialui / src / button / DeleteWithConfirmButton.js View on Github external
basePath,
    classes: classesOverride,
    className,
    confirmTitle = 'ra.message.delete_title',
    confirmContent = 'ra.message.delete_content',
    icon,
    label = 'ra.action.delete',
    onClick,
    record,
    resource,
    redirect: redirectTo,
    ...rest
}) => {
    const [open, setOpen] = useState(false);
    const translate = useTranslate();
    const notify = useNotify();
    const redirect = useRedirect();
    const refresh = useRefresh();
    const classes = useStyles({ classes: classesOverride });

    const [deleteOne, { loading }] = useDelete(
        resource,
        record && record.id,
        record,
        {
            action: CRUD_DELETE,
            onSuccess: () => {
                notify('ra.notification.deleted', 'info', { smart_count: 1 });
                redirect(redirectTo, basePath);
                refresh();
            },
            onFailure: error =>