mirror of
https://github.com/BarkProductions/barkman.git
synced 2026-06-13 06:11:55 +00:00
added notifications
This commit is contained in:
@@ -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/>}/>
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import { BrowserRouter } from "react-router";
|
||||
createRoot(document.getElementById('root')!).render(
|
||||
<StrictMode>
|
||||
<BrowserRouter>
|
||||
<App />
|
||||
<App />
|
||||
</BrowserRouter>
|
||||
</StrictMode>,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user