mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 11:36:44 +00:00
Notification cleanup (#8945)
- Prevent spamming of duplicate notifications
This commit is contained in:
parent
94a0e11702
commit
ab7e6385c2
@ -18,7 +18,7 @@ import {
|
|||||||
} from '@tabler/icons-react';
|
} from '@tabler/icons-react';
|
||||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
|
|
||||||
import { showNotification } from '@mantine/notifications';
|
import { hideNotification, showNotification } from '@mantine/notifications';
|
||||||
import { api } from '../../App';
|
import { api } from '../../App';
|
||||||
import { BarcodeInput } from '../../components/barcodes/BarcodeInput';
|
import { BarcodeInput } from '../../components/barcodes/BarcodeInput';
|
||||||
import type { BarcodeScanItem } from '../../components/barcodes/BarcodeScanItem';
|
import type { BarcodeScanItem } from '../../components/barcodes/BarcodeScanItem';
|
||||||
@ -55,7 +55,10 @@ export default function Scan() {
|
|||||||
|
|
||||||
// Prevent duplicates
|
// Prevent duplicates
|
||||||
if (history.find((i) => i.model == item.model && i.pk == item.pk)) {
|
if (history.find((i) => i.model == item.model && i.pk == item.pk)) {
|
||||||
|
hideNotification('duplicate-barcode');
|
||||||
|
|
||||||
showNotification({
|
showNotification({
|
||||||
|
id: 'duplicate-barcode',
|
||||||
title: t`Duplicate`,
|
title: t`Duplicate`,
|
||||||
message: t`Item already scanned`,
|
message: t`Item already scanned`,
|
||||||
color: 'orange'
|
color: 'orange'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { create } from 'zustand';
|
import { create } from 'zustand';
|
||||||
|
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { showNotification } from '@mantine/notifications';
|
import { hideNotification, showNotification } from '@mantine/notifications';
|
||||||
import { api } from '../App';
|
import { api } from '../App';
|
||||||
import { ApiEndpoints } from '../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../enums/ApiEndpoints';
|
||||||
import { generateUrl } from '../functions/urls';
|
import { generateUrl } from '../functions/urls';
|
||||||
@ -38,7 +38,11 @@ export const useIconState = create<IconState>()((set, get) => ({
|
|||||||
|
|
||||||
const packs = await api.get(apiUrl(ApiEndpoints.icons)).catch((_error) => {
|
const packs = await api.get(apiUrl(ApiEndpoints.icons)).catch((_error) => {
|
||||||
console.error('ERR: Could not fetch icon packages');
|
console.error('ERR: Could not fetch icon packages');
|
||||||
|
|
||||||
|
hideNotification('icon-fetch-error');
|
||||||
|
|
||||||
showNotification({
|
showNotification({
|
||||||
|
id: 'icon-fetch-error',
|
||||||
title: t`Error`,
|
title: t`Error`,
|
||||||
message: t`Error loading icon package from server`,
|
message: t`Error loading icon package from server`,
|
||||||
color: 'red'
|
color: 'red'
|
||||||
@ -66,7 +70,9 @@ export const useIconState = create<IconState>()((set, get) => ({
|
|||||||
console.error(
|
console.error(
|
||||||
"ERR: Icon package is missing 'prefix' or 'fonts' field"
|
"ERR: Icon package is missing 'prefix' or 'fonts' field"
|
||||||
);
|
);
|
||||||
|
hideNotification('icon-fetch-error');
|
||||||
showNotification({
|
showNotification({
|
||||||
|
id: 'icon-fetch-error',
|
||||||
title: t`Error`,
|
title: t`Error`,
|
||||||
message: t`Error loading icon package from server`,
|
message: t`Error loading icon package from server`,
|
||||||
color: 'red'
|
color: 'red'
|
||||||
|
@ -12,7 +12,7 @@ import type React from 'react';
|
|||||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import { showNotification } from '@mantine/notifications';
|
import { hideNotification, showNotification } from '@mantine/notifications';
|
||||||
import { Boundary } from '../components/Boundary';
|
import { Boundary } from '../components/Boundary';
|
||||||
import type { ApiFormFieldSet } from '../components/forms/fields/ApiFormField';
|
import type { ApiFormFieldSet } from '../components/forms/fields/ApiFormField';
|
||||||
import { useApi } from '../contexts/ApiContext';
|
import { useApi } from '../contexts/ApiContext';
|
||||||
@ -207,7 +207,9 @@ export function InvenTreeTable<T extends Record<string, any>>({
|
|||||||
return null;
|
return null;
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
hideNotification('table-options-error');
|
||||||
showNotification({
|
showNotification({
|
||||||
|
id: 'table-options-error',
|
||||||
title: t`API Error`,
|
title: t`API Error`,
|
||||||
message: t`Failed to load table options`,
|
message: t`Failed to load table options`,
|
||||||
color: 'red'
|
color: 'red'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user