diff --git a/barkmanui/src/features/jobs/AddJob.tsx b/barkmanui/src/features/jobs/AddJob.tsx index 15b46ac..00a2146 100644 --- a/barkmanui/src/features/jobs/AddJob.tsx +++ b/barkmanui/src/features/jobs/AddJob.tsx @@ -1,4 +1,5 @@ -import {Button, Group, TextInput, Container, Title, Flex} from '@mantine/core'; +import {Button, Group, TextInput, NumberInput, Container, Title, Flex} from '@mantine/core'; +import { DateTimePicker } from '@mantine/dates'; import {useForm} from '@mantine/form'; import {useMutation} from "@tanstack/react-query"; import {NewJob} from "./types.ts"; @@ -12,25 +13,27 @@ function AddJob() { const navigate = useNavigate(); - const customerQuery = useCustomerList(); + const customerQuery = useJobList(); const newJobForm = useForm({ mode: 'uncontrolled', initialValues: { + customerId: 0, name: "", - company: "", - email: "", - phone: "", + startDate: new Date(), + endDate: new Date(), address: "", + venue: "", + notes: "", }, validate: {}, }); - const updateCustomer = useMutation({ - mutationFn: async (values: newJob) => { + const updateJob = useMutation({ + mutationFn: async (values: NewJob) => { - const result = await fetch(import.meta.env.VITE_API_URL + '/customers', { + const result = await fetch(import.meta.env.VITE_API_URL + '/jobs', { method: 'POST', body: JSON.stringify(values), headers: { @@ -43,10 +46,10 @@ function AddJob() { icon: , color: "teal", title: "All good!", - message: "Customer Created", + message: "Job Created", position: 'top-center', }); - navigate("/customers"); + navigate("/jobs"); } @@ -58,7 +61,7 @@ function AddJob() { message: "Something went wrong", position: 'top-center', }); - throw new Error('Failed to create customer'); + throw new Error('Failed to create job'); } }, @@ -74,8 +77,8 @@ function AddJob() { return ( <> -
await - updateCustomer.mutateAsync(values))}> + await + updateJob.mutateAsync(values))}> Add Item - - - - - + + + + + + + @@ -106,4 +113,4 @@ function AddJob() { ); } -export default AddCustomer; \ No newline at end of file +export default AddJob; \ No newline at end of file diff --git a/barkmanui/src/features/jobs/types.ts b/barkmanui/src/features/jobs/types.ts index a9c4911..e94ce17 100644 --- a/barkmanui/src/features/jobs/types.ts +++ b/barkmanui/src/features/jobs/types.ts @@ -7,8 +7,8 @@ export interface Job { startDate: Date; endDate: Date; totalPrice: string, - venue: number, - address: number, + venue: string, + address: string, notes: string, } @@ -17,7 +17,7 @@ export interface NewJob { name: string, startDate: Date; endDate: Date; - venue: number, - address: number, + venue: string, + address: string, notes: string, }