Changed from Alert to Toast to work well with mui v18

This commit is contained in:
Frikky
2023-08-17 03:16:43 +02:00
parent 1461d6ad6b
commit 99d1a96c63
36 changed files with 553 additions and 542 deletions
+13 -14
View File
@@ -1,10 +1,9 @@
import React, { useState, useEffect } from 'react';
import theme from '../theme.jsx';
import CytoscapeComponent from 'react-cytoscapejs';
import frameworkStyle from '../frameworkStyle.jsx';
import { v4 as uuidv4 } from "uuid";
import theme from '../theme.jsx';
import { useAlert } from "react-alert";
import AppSearch from '../components/Appsearch.jsx';
import PaperComponent from "../components/PaperComponent.jsx"
@@ -34,10 +33,10 @@ import {
import * as edgehandles from "cytoscape-edgehandles";
import * as cytoscape from "cytoscape";
import { toast } from 'react-toastify';
cytoscape.use(edgehandles);
const svgSize = "40px"
const parsedDatatypeImages = {
"SIEM": encodeURI(`data:image/svg+xml;utf-8,<svg fill="rgb(248,90,62)" width="${svgSize}" height="${svgSize}" viewBox="0 0 ${svgSize} ${svgSize}" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M6.93767 0C8.71083 0 10.4114 0.704386 11.6652 1.9582C12.919 3.21202 13.6234 4.91255 13.6234 6.68571C13.6234 8.34171 13.0165 9.864 12.0188 11.0366L12.2965 11.3143H13.1091L18.252 16.4571L16.7091 18L11.5662 12.8571V12.0446L11.2885 11.7669C10.116 12.7646 8.59367 13.3714 6.93767 13.3714C5.16451 13.3714 3.46397 12.667 2.21015 11.4132C0.956339 10.1594 0.251953 8.45888 0.251953 6.68571C0.251953 4.91255 0.956339 3.21202 2.21015 1.9582C3.46397 0.704386 5.16451 0 6.93767 0ZM6.93767 2.05714C4.36624 2.05714 2.3091 4.11429 2.3091 6.68571C2.3091 9.25714 4.36624 11.3143 6.93767 11.3143C9.5091 11.3143 11.5662 9.25714 11.5662 6.68571C11.5662 4.11429 9.5091 2.05714 6.93767 2.05714Z" /></svg>`),
@@ -521,7 +520,7 @@ const AppFramework = (props) => {
const scale = size === undefined ? 1 : size > 5 ? 3 : size
const alert = useAlert()
//const alert = useAlert()
const handleLoadNextSuggestion = (frameworkData) => {
@@ -784,16 +783,16 @@ const AppFramework = (props) => {
.then((responseJson) => {
if (responseJson.success === false) {
if (responseJson.reason !== undefined) {
alert.error("Failed updating: " + responseJson.reason)
toast("Failed updating: " + responseJson.reason)
} else {
alert.error("Failed to update framework for your org.")
toast("Failed to update framework for your org.")
}
} else {
alert.info("Updated usecase.")
toast("Updated usecase.")
}
})
.catch((error) => {
alert.error(error.toString());
toast(error.toString());
//setFrameworkLoaded(true)
})
}
@@ -816,13 +815,13 @@ const AppFramework = (props) => {
})
.then((responseJson) => {
if (responseJson.success === false) {
alert.error("Failed to activate the app")
toast("Failed to activate the app")
} else {
//alert.success("App activated for your organization! Refresh the page to use the app.")
//toast("App activated for your organization! Refresh the page to use the app.")
}
})
.catch(error => {
//alert.error(error.toString())
//toast(error.toString())
console.log("Activate app error: ", error.toString())
});
}
@@ -852,9 +851,9 @@ const AppFramework = (props) => {
.then((responseJson) => {
if (responseJson.success === false) {
if (responseJson.reason !== undefined) {
alert.error("Failed updating: " + responseJson.reason)
toast("Failed updating: " + responseJson.reason)
} else {
alert.error("Failed to update framework for your org.")
toast("Failed to update framework for your org.")
}
}
@@ -863,7 +862,7 @@ const AppFramework = (props) => {
//setFrameworkData(responseJson)
})
.catch((error) => {
alert.error(error.toString());
toast(error.toString());
//setFrameworkLoaded(true)
})
}