mirror of
https://github.com/inventree/InvenTree.git
synced 2026-05-28 03:49:20 +00:00
540eb84796
* Add basic auto-allocate functionality - backend code - background task - API endpoint * Add new endpoint enum * add frontend components * Tweak auto-allocate output * Allow specifying of individual line items * Tweak error boundary * Enable bulk-delete of allocated items against sales order * Refactor stock sorting options * Allow user to select how to handle serialized stock * Backport new functionality to BuildOrder allocation * Refactor sorting options to use enumerated values * Implement functional unit tests for new feature * Update API and CHANGELOG * Additional unit test * Add playwright testing * Documentation * Update docs for build auto-allocate * Fix dependencies * Adjust build line filtering * Fix serializer
54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
import { t } from '@lingui/core/macro';
|
|
import { Alert, Stack, Text } from '@mantine/core';
|
|
import { ErrorBoundary, type FallbackRender } from '@sentry/react';
|
|
import { IconExclamationCircle } from '@tabler/icons-react';
|
|
import { type ReactNode, useCallback } from 'react';
|
|
|
|
export function DefaultFallback({
|
|
title
|
|
}: Readonly<{ title: string }>): ReactNode {
|
|
return (
|
|
<Alert
|
|
color='red'
|
|
icon={<IconExclamationCircle />}
|
|
title={`INVE-E17: ${t`Error rendering component`}: ${title}`}
|
|
>
|
|
<Stack gap='xs'>
|
|
<Text size='sm'>
|
|
{t`An error occurred while rendering this component. Refer to the console for more information.`}
|
|
</Text>
|
|
<Text size='sm'>
|
|
{t`Try reloading the page, or contact your administrator if the problem persists.`}
|
|
</Text>
|
|
</Stack>
|
|
</Alert>
|
|
);
|
|
}
|
|
|
|
export function Boundary({
|
|
children,
|
|
label,
|
|
fallback
|
|
}: Readonly<{
|
|
children: ReactNode;
|
|
label: string;
|
|
fallback?: React.ReactElement<any> | FallbackRender;
|
|
}>): ReactNode {
|
|
const onError = useCallback(
|
|
(error: unknown, componentStack: string | undefined, eventId: string) => {
|
|
console.error(`ERR: Error rendering component: ${label}`);
|
|
console.error(error);
|
|
},
|
|
[]
|
|
);
|
|
|
|
return (
|
|
<ErrorBoundary
|
|
fallback={fallback ?? <DefaultFallback title={label} />}
|
|
onError={onError}
|
|
>
|
|
{children}
|
|
</ErrorBoundary>
|
|
);
|
|
}
|