mirror of
https://github.com/BarkProductions/barkman.git
synced 2026-06-13 06:11:55 +00:00
Add layout enhancements to ItemDetail and EditItem components
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
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";
|
||||||
@@ -22,8 +22,7 @@ function EditItem() {
|
|||||||
notes: "",
|
notes: "",
|
||||||
},
|
},
|
||||||
|
|
||||||
validate: {
|
validate: {},
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const {isPending, error, data, isFetching} = useQuery({
|
const {isPending, error, data, isFetching} = useQuery({
|
||||||
@@ -79,7 +78,16 @@ function EditItem() {
|
|||||||
return (
|
return (
|
||||||
<form onSubmit={form.onSubmit(async (values) => await
|
<form onSubmit={form.onSubmit(async (values) => await
|
||||||
updateItem.mutateAsync(values))}>
|
updateItem.mutateAsync(values))}>
|
||||||
|
<Container fluid>
|
||||||
|
<Flex mih={50}
|
||||||
|
gap="md"
|
||||||
|
justify="flex-start"
|
||||||
|
align="flex-start"
|
||||||
|
direction="column"
|
||||||
|
wrap="wrap">
|
||||||
|
|
||||||
<div>{isFetching ? 'Updating...' : ''}</div>
|
<div>{isFetching ? 'Updating...' : ''}</div>
|
||||||
|
<Title order={1}>Edit Item</Title>
|
||||||
<Text>ID: {data.id}</Text>
|
<Text>ID: {data.id}</Text>
|
||||||
<TextInput withAsterisk key={form.key('brand')} size="md" label="Brand"
|
<TextInput withAsterisk key={form.key('brand')} size="md" label="Brand"
|
||||||
placeholder="Brand" {...form.getInputProps('brand')}/>
|
placeholder="Brand" {...form.getInputProps('brand')}/>
|
||||||
@@ -93,11 +101,14 @@ function EditItem() {
|
|||||||
placeholder="Rental Price" {...form.getInputProps('rentalPrice')}/>
|
placeholder="Rental Price" {...form.getInputProps('rentalPrice')}/>
|
||||||
<NumberInput size="md" key={form.key('replacementCost')} label="Replacement Cost"
|
<NumberInput size="md" key={form.key('replacementCost')} label="Replacement Cost"
|
||||||
placeholder="Replacement Cost" {...form.getInputProps('replacementCost')}/>
|
placeholder="Replacement Cost" {...form.getInputProps('replacementCost')}/>
|
||||||
<Textarea label="Notes" key={form.key('notes')} placeholder="Notes" {...form.getInputProps('notes')}/>
|
<Textarea label="Notes" key={form.key('notes')}
|
||||||
|
placeholder="Notes" {...form.getInputProps('notes')}/>
|
||||||
|
|
||||||
<Group justify="flex-end" mt="md">
|
<Group justify="flex-end" mt="md">
|
||||||
<Button type="submit">Submit</Button>
|
<Button type="submit">Submit</Button>
|
||||||
</Group>
|
</Group>
|
||||||
|
</Flex>
|
||||||
|
</Container>
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
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],
|
||||||
@@ -27,7 +26,8 @@ if (error) return 'An error has occurred: ' + error.message
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Text c="red">Item Detail</Text>
|
<Container fluid>
|
||||||
|
<Title order={1}>Item Detail</Title>
|
||||||
<div>{isFetching ? 'Updating...' : ''}</div>
|
<div>{isFetching ? 'Updating...' : ''}</div>
|
||||||
<Text>ID: {data.id}</Text>
|
<Text>ID: {data.id}</Text>
|
||||||
<Text>Brand: {data.brand}</Text>
|
<Text>Brand: {data.brand}</Text>
|
||||||
@@ -39,7 +39,7 @@ if (error) return 'An error has occurred: ' + error.message
|
|||||||
<Text>Notes: {data.notes}</Text>
|
<Text>Notes: {data.notes}</Text>
|
||||||
|
|
||||||
<Link to={`/editItem/${data.id}`}>Edit</Link>
|
<Link to={`/editItem/${data.id}`}>Edit</Link>
|
||||||
|
</Container>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user