added notifications

This commit is contained in:
2025-01-29 21:23:57 -06:00
parent a4a038f8bc
commit c11cf8cfe7
5 changed files with 137 additions and 10 deletions
+4
View File
@@ -8,6 +8,8 @@ import ItemDetail from "./features/inventory/ItemDetail.tsx";
import EditItem from "./features/inventory/EditItem.tsx";
import {BarkHeader} from "./common/components/BarkHeader.tsx";
import AddItem from "./features/inventory/AddItem.tsx";
import { Notifications } from '@mantine/notifications';
import '@mantine/notifications/styles.css';
// Create a client
const queryClient = new QueryClient()
@@ -35,7 +37,9 @@ function App() {
return <MantineProvider defaultColorScheme="auto" theme={barkTheme}>{(
<QueryClientProvider client={queryClient}>
<>
<BarkHeader></BarkHeader>
<Notifications />
<Routes>
<Route index element={<Home/>}/>
<Route path="inventory" element={<InventoryList/>}/>
+18 -1
View File
@@ -3,6 +3,8 @@ import {useForm} from '@mantine/form';
import {useMutation} from "@tanstack/react-query";
import {NewItem} from "./types.ts";
import { useNavigate} from "react-router";
import { IconX, IconCheck } from '@tabler/icons-react';
import { notifications } from '@mantine/notifications';
function AddItem() {
@@ -33,11 +35,26 @@ function AddItem() {
});
if (result.ok) {
notifications.show({
icon: <IconCheck size={20} />,
color:"teal",
title: "All good!",
message: "Item Created",
position: 'top-center',
});
navigate("/inventory");
}
if (!result.ok) {
throw new Error('Failed to update inventory item');
notifications.show({
icon: <IconX size={20} />,
color:"red",
title: "Bummer!",
message: "Something went wrong",
position: 'top-center',
});
throw new Error('Failed to create inventory item');
}
}
+1 -1
View File
@@ -7,7 +7,7 @@ import { BrowserRouter } from "react-router";
createRoot(document.getElementById('root')!).render(
<StrictMode>
<BrowserRouter>
<App />
<App />
</BrowserRouter>
</StrictMode>,
)