Webview: add solid-toast feeback system
This commit is contained in:
@@ -2,6 +2,7 @@ import { createSignal, type Component } from "solid-js";
|
||||
import { MachineProvider } from "./Config";
|
||||
import { Layout } from "./layout/layout";
|
||||
import { Route, Router } from "./Routes";
|
||||
import { Toaster } from "solid-toast";
|
||||
|
||||
// Global state
|
||||
const [route, setRoute] = createSignal<Route>("machines");
|
||||
@@ -9,13 +10,14 @@ const [route, setRoute] = createSignal<Route>("machines");
|
||||
export { route, setRoute };
|
||||
|
||||
const App: Component = () => {
|
||||
return (
|
||||
return [
|
||||
<Toaster position="top-right" />,
|
||||
<MachineProvider>
|
||||
<Layout>
|
||||
<Router route={route} />
|
||||
</Layout>
|
||||
</MachineProvider>
|
||||
);
|
||||
</MachineProvider>,
|
||||
];
|
||||
};
|
||||
|
||||
export default App;
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
import { useMachineContext } from "../../Config";
|
||||
import { route } from "@/src/App";
|
||||
import { OperationResponse, pyApi } from "@/src/api";
|
||||
import toast from "solid-toast";
|
||||
|
||||
type FilesModel = Extract<
|
||||
OperationResponse<"get_directory">,
|
||||
@@ -39,6 +40,17 @@ export const MachineListView: Component = () => {
|
||||
if (response?.status === "success") {
|
||||
console.log(response.data);
|
||||
setData(response.data);
|
||||
toast.success("Machines loaded");
|
||||
}
|
||||
if (response?.status === "error") {
|
||||
setData([]);
|
||||
console.error(response.errors);
|
||||
toast.error("Error loading machines");
|
||||
response.errors.forEach((error) =>
|
||||
toast.error(
|
||||
`${error.message}: ${error.description} From ${error.location}`
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user