mirror of
https://github.com/BarkProductions/barkman.git
synced 2026-06-13 06:11:55 +00:00
Binary file not shown.
|
After Width: | Height: | Size: 388 KiB |
+30
-31
@@ -1,7 +1,7 @@
|
|||||||
import { Routes, Route} from 'react-router';
|
import {Routes, Route} from 'react-router';
|
||||||
import Home from './pages/home.tsx';
|
import Home from './pages/home.tsx';
|
||||||
import InventoryList from "./features/inventory/InventoryList.tsx";
|
import InventoryList from "./features/inventory/InventoryList.tsx";
|
||||||
import { QueryClientProvider, QueryClient } from '@tanstack/react-query';
|
import {QueryClientProvider, QueryClient} from '@tanstack/react-query';
|
||||||
import {createTheme, MantineProvider} from '@mantine/core';
|
import {createTheme, MantineProvider} from '@mantine/core';
|
||||||
import '@mantine/core/styles.css';
|
import '@mantine/core/styles.css';
|
||||||
import ItemDetail from "./features/inventory/ItemDetail.tsx";
|
import ItemDetail from "./features/inventory/ItemDetail.tsx";
|
||||||
@@ -12,39 +12,38 @@ import {BarkHeader} from "./common/components/BarkHeader.tsx";
|
|||||||
const queryClient = new QueryClient()
|
const queryClient = new QueryClient()
|
||||||
|
|
||||||
const barkTheme = createTheme({
|
const barkTheme = createTheme({
|
||||||
primaryColor: 'red',
|
primaryColor: 'red',
|
||||||
colors: {
|
colors: {
|
||||||
'red': [
|
'red': [
|
||||||
"#ffe8e8",
|
"#ffe8e8",
|
||||||
"#ffcfd0",
|
"#ffcfd0",
|
||||||
"#fd9d9d",
|
"#fd9d9d",
|
||||||
"#fb6868",
|
"#fb6868",
|
||||||
"#fa3c3b",
|
"#fa3c3b",
|
||||||
"#f9211e",
|
"#f9211e",
|
||||||
"#fa120f",
|
"#fa120f",
|
||||||
"#df0404",
|
"#df0404",
|
||||||
"#c70002",
|
"#c70002",
|
||||||
"#ae0000"
|
"#ae0000"
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
return <MantineProvider defaultColorScheme="auto" theme={barkTheme}>{ (
|
return <MantineProvider defaultColorScheme="auto" theme={barkTheme}>{(
|
||||||
<QueryClientProvider client={queryClient}>
|
<QueryClientProvider client={queryClient}>
|
||||||
<>
|
<>
|
||||||
<BarkHeader></BarkHeader>
|
<BarkHeader></BarkHeader>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route index element={<Home />} />
|
<Route index element={<Home/>}/>
|
||||||
<Route path="inventory" element={<InventoryList />} />
|
<Route path="inventory" element={<InventoryList/>}/>
|
||||||
<Route path="itemDetail/:itemId" element={<ItemDetail />} />
|
<Route path="itemDetail/:itemId" element={<ItemDetail/>}/>
|
||||||
<Route path="editItem/:itemId" element={<EditItem />} />
|
<Route path="editItem/:itemId" element={<EditItem/>}/>
|
||||||
</Routes>
|
</Routes>
|
||||||
|
</>
|
||||||
</>
|
</QueryClientProvider>
|
||||||
</QueryClientProvider>
|
)}</MantineProvider>;
|
||||||
) }</MantineProvider>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default App
|
export default App
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import { Burger, Container, Group } from '@mantine/core';
|
import {Burger, Container, Group, Image} from '@mantine/core';
|
||||||
import { useDisclosure } from '@mantine/hooks';
|
import { useDisclosure } from '@mantine/hooks';
|
||||||
import classes from './BarkHeader.module.css';
|
import classes from './BarkHeader.module.css';
|
||||||
import {NavLink} from "react-router";
|
import {NavLink} from "react-router";
|
||||||
|
|
||||||
|
|
||||||
const links = [
|
const links = [
|
||||||
{ link: '/', label: 'Home' },
|
{ link: '/', label: 'Home' },
|
||||||
{ link: '/inventory', label: 'Inventory' },
|
{ link: '/inventory', label: 'Inventory' },
|
||||||
@@ -20,8 +21,8 @@ export function BarkHeader() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<header className={classes.header}>
|
<header className={classes.header}>
|
||||||
<Container size="md" className={classes.inner}>
|
<Container fluid className={classes.inner}>
|
||||||
|
<Image ml="lg" src="/barklogo.png" h={55} w={55}/>
|
||||||
<Group gap={5} visibleFrom="xs">
|
<Group gap={5} visibleFrom="xs">
|
||||||
{items}
|
{items}
|
||||||
</Group>
|
</Group>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {Button, Group, TextInput, Text, Textarea, NumberInput} from '@mantine/core';
|
import {Button, Group, TextInput, Text, Textarea, NumberInput, Container, Title, Flex} from '@mantine/core';
|
||||||
import { useForm } from '@mantine/form';
|
import {useForm} from '@mantine/form';
|
||||||
import {useParams} from "react-router";
|
import {useParams} from "react-router";
|
||||||
import {useMutation, useQuery, useQueryClient} from "@tanstack/react-query";
|
import {useMutation, useQuery, useQueryClient} from "@tanstack/react-query";
|
||||||
import {InventoryItem} from "./types.ts";
|
import {InventoryItem} from "./types.ts";
|
||||||
@@ -10,7 +10,7 @@ type EditableInventoryItem = Omit<InventoryItem, 'id'>;
|
|||||||
function EditItem() {
|
function EditItem() {
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
|
|
||||||
const form = useForm<EditableInventoryItem>({
|
const editItemForm = useForm<EditableInventoryItem>({
|
||||||
mode: 'uncontrolled',
|
mode: 'uncontrolled',
|
||||||
initialValues: {
|
initialValues: {
|
||||||
name: "",
|
name: "",
|
||||||
@@ -22,11 +22,10 @@ function EditItem() {
|
|||||||
notes: "",
|
notes: "",
|
||||||
},
|
},
|
||||||
|
|
||||||
validate: {
|
validate: {},
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const { isPending, error, data, isFetching } = useQuery({
|
const {isPending, error, data, isFetching} = useQuery({
|
||||||
queryKey: ['inventory', params.itemId],
|
queryKey: ['inventory', params.itemId],
|
||||||
queryFn: async (): Promise<InventoryItem> => {
|
queryFn: async (): Promise<InventoryItem> => {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
@@ -68,8 +67,9 @@ function EditItem() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data) {
|
if (data) {
|
||||||
// Even if query.data changes, form will be initialized only once
|
// Even if query.data changes, form will be initialized only once
|
||||||
form.initialize(data);
|
editItemForm.initialize(data);
|
||||||
}
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [data]);
|
}, [data]);
|
||||||
|
|
||||||
if (isPending) return 'Loading...'
|
if (isPending) return 'Loading...'
|
||||||
@@ -77,27 +77,39 @@ function EditItem() {
|
|||||||
if (error) return 'An error has occurred: ' + error.message
|
if (error) return 'An error has occurred: ' + error.message
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={form.onSubmit(async (values) => await
|
<form onSubmit={editItemForm.onSubmit(async (values) => await
|
||||||
updateItem.mutateAsync(values))}>
|
updateItem.mutateAsync(values))}>
|
||||||
<div>{isFetching ? 'Updating...' : ''}</div>
|
<Container m="lg">
|
||||||
<Text>ID: {data.id}</Text>
|
<Flex mih={50}
|
||||||
<TextInput withAsterisk key={form.key('brand')} size="md" label="Brand"
|
gap="md"
|
||||||
placeholder="Brand" {...form.getInputProps('brand')}/>
|
justify="flex-start"
|
||||||
<TextInput withAsterisk key={form.key('name')} size="md" label="Name"
|
align="flex-start"
|
||||||
placeholder="Name" {...form.getInputProps('name')}/>
|
direction="column"
|
||||||
<TextInput size="md" key={form.key('status')} label="Status"
|
wrap="wrap">
|
||||||
placeholder="Status" {...form.getInputProps('status')}/>
|
|
||||||
<TextInput size="md" key={form.key('serialNumber')} label="Serial Number"
|
|
||||||
placeholder="Serial Number"{...form.getInputProps('serialNumber')}/>
|
|
||||||
<NumberInput size="md" key={form.key('rentalPrice')} label="Rental Price"
|
|
||||||
placeholder="Rental Price" {...form.getInputProps('rentalPrice')}/>
|
|
||||||
<NumberInput size="md" key={form.key('replacementCost')} label="Replacement Cost"
|
|
||||||
placeholder="Replacement Cost" {...form.getInputProps('replacementCost')}/>
|
|
||||||
<Textarea label="Notes" key={form.key('notes')} placeholder="Notes" {...form.getInputProps('notes')}/>
|
|
||||||
|
|
||||||
<Group justify="flex-end" mt="md">
|
<div>{isFetching ? 'Updating...' : ''}</div>
|
||||||
<Button type="submit">Submit</Button>
|
<Title order={1}>Edit Item</Title>
|
||||||
</Group>
|
<Text>ID: {data.id}</Text>
|
||||||
|
<TextInput withAsterisk key={editItemForm.key('brand')} size="md" label="Brand"
|
||||||
|
placeholder="Brand" {...editItemForm.getInputProps('brand')}/>
|
||||||
|
<TextInput withAsterisk key={editItemForm.key('name')} size="md" label="Name"
|
||||||
|
placeholder="Name" {...editItemForm.getInputProps('name')}/>
|
||||||
|
<TextInput size="md" key={editItemForm.key('status')} label="Status"
|
||||||
|
placeholder="Status" {...editItemForm.getInputProps('status')}/>
|
||||||
|
<TextInput size="md" key={editItemForm.key('serialNumber')} label="Serial Number"
|
||||||
|
placeholder="Serial Number"{...editItemForm.getInputProps('serialNumber')}/>
|
||||||
|
<NumberInput size="md" key={editItemForm.key('rentalPrice')} label="Rental Price"
|
||||||
|
placeholder="Rental Price" {...editItemForm.getInputProps('rentalPrice')}/>
|
||||||
|
<NumberInput size="md" key={editItemForm.key('replacementCost')} label="Replacement Cost"
|
||||||
|
placeholder="Replacement Cost" {...editItemForm.getInputProps('replacementCost')}/>
|
||||||
|
<Textarea label="Notes" key={editItemForm.key('notes')}
|
||||||
|
placeholder="Notes" {...editItemForm.getInputProps('notes')}/>
|
||||||
|
|
||||||
|
<Group justify="flex-end" mt="md">
|
||||||
|
<Button type="submit">Submit</Button>
|
||||||
|
</Group>
|
||||||
|
</Flex>
|
||||||
|
</Container>
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,45 +1,45 @@
|
|||||||
import {Text} from "@mantine/core";
|
import {Container, Text, Title} from "@mantine/core";
|
||||||
import {Link, useParams} from "react-router";
|
import {Link, useParams} from "react-router";
|
||||||
import {InventoryItem} from "./types.ts";
|
import {InventoryItem} from "./types.ts";
|
||||||
import {useQuery} from "@tanstack/react-query";
|
import {useQuery} from "@tanstack/react-query";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function ItemDetail() {
|
function ItemDetail() {
|
||||||
let params = useParams();
|
const params = useParams();
|
||||||
|
|
||||||
const { isPending, error, data, isFetching } = useQuery({
|
const {isPending, error, data, isFetching} = useQuery({
|
||||||
queryKey: ['inventory', params.itemId],
|
queryKey: ['inventory', params.itemId],
|
||||||
queryFn: async (): Promise<InventoryItem> => {
|
queryFn: async (): Promise<InventoryItem> => {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
import.meta.env.VITE_API_URL + '/inventory/' + params.itemId,
|
import.meta.env.VITE_API_URL + '/inventory/' + params.itemId,
|
||||||
)
|
)
|
||||||
|
|
||||||
if (!response.ok) throw new Error('Failed to fetch inventory ' + response.statusText)
|
if (!response.ok) throw new Error('Failed to fetch inventory ' + response.statusText)
|
||||||
|
|
||||||
return await response.json()
|
return await response.json()
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isPending) return 'Loading...'
|
if (isPending) return 'Loading...'
|
||||||
|
|
||||||
if (error) return 'An error has occurred: ' + error.message
|
if (error) return 'An error has occurred: ' + error.message
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Text c="red">Item Detail</Text>
|
<Container m="lg">
|
||||||
<div>{isFetching ? 'Updating...' : ''}</div>
|
<Title order={1}>Item Detail</Title>
|
||||||
<Text>ID: {data.id}</Text>
|
<div>{isFetching ? 'Updating...' : ''}</div>
|
||||||
<Text>Brand: {data.brand}</Text>
|
<Text>ID: {data.id}</Text>
|
||||||
<Text>Name: {data.name}</Text>
|
<Text>Brand: {data.brand}</Text>
|
||||||
<Text>Status: {data.status}</Text>
|
<Text>Name: {data.name}</Text>
|
||||||
<Text>Serial Number: {data.serialNumber}</Text>
|
<Text>Status: {data.status}</Text>
|
||||||
<Text>Rental Price: ${data.rentalPrice}</Text>
|
<Text>Serial Number: {data.serialNumber}</Text>
|
||||||
<Text>Replacement Cost: ${data.replacementCost}</Text>
|
<Text>Rental Price: ${data.rentalPrice}</Text>
|
||||||
<Text>Notes: {data.notes}</Text>
|
<Text>Replacement Cost: ${data.replacementCost}</Text>
|
||||||
|
<Text>Notes: {data.notes}</Text>
|
||||||
<Link to={`/editItem/${data.id}`}>Edit</Link>
|
|
||||||
|
|
||||||
|
<Link to={`/editItem/${data.id}`}>Edit</Link>
|
||||||
|
</Container>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {Text} from "@mantine/core";
|
import {Container, Text} from "@mantine/core";
|
||||||
|
|
||||||
|
|
||||||
function Home() {
|
function Home() {
|
||||||
@@ -6,7 +6,9 @@ function Home() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Text c="red">Bark productions: at the intersection of professionalism and degeneracy</Text>
|
<Container m="lg">
|
||||||
|
<Text>Bark productions: at the intersection of professionalism and degeneracy</Text>
|
||||||
|
</Container>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user