mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 11:36:44 +00:00
TemplateEditor: Handle fetch error (#8260)
* TemplateEditor: Handle fetch error - Handle error condition where template cannot be loaded from server * Remove test code
This commit is contained in:
parent
13ef30768f
commit
e8c72d60b5
@ -9,7 +9,11 @@ import {
|
||||
Tabs
|
||||
} from '@mantine/core';
|
||||
import { openConfirmModal } from '@mantine/modals';
|
||||
import { notifications, showNotification } from '@mantine/notifications';
|
||||
import {
|
||||
hideNotification,
|
||||
notifications,
|
||||
showNotification
|
||||
} from '@mantine/notifications';
|
||||
import {
|
||||
IconAlertTriangle,
|
||||
IconDeviceFloppy,
|
||||
@ -126,9 +130,24 @@ export function TemplateEditor(props: Readonly<TemplateEditorProps>) {
|
||||
|
||||
api.get(templateUrl).then((response: any) => {
|
||||
if (response.data?.template) {
|
||||
api.get(response.data.template).then((res) => {
|
||||
api
|
||||
.get(response.data.template)
|
||||
.then((res) => {
|
||||
codeRef.current = res.data;
|
||||
loadCodeToEditor(res.data);
|
||||
})
|
||||
.catch(() => {
|
||||
console.error(
|
||||
`ERR: Could not load template from ${response.data.template}`
|
||||
);
|
||||
codeRef.current = undefined;
|
||||
hideNotification('template-load-error');
|
||||
showNotification({
|
||||
id: 'template-load-error',
|
||||
title: t`Error`,
|
||||
message: t`Could not load the template from the server.`,
|
||||
color: 'red'
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user