From 8289936d3ff340bb3747ab7ad62ad9a2d877c91b Mon Sep 17 00:00:00 2001 From: Drew Rautenberg Date: Thu, 16 Jul 2026 14:21:27 -0500 Subject: [PATCH 01/11] added customer type --- barkmanui/src/features/inventory/types.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/barkmanui/src/features/inventory/types.ts b/barkmanui/src/features/inventory/types.ts index 7439c51..cd87d28 100644 --- a/barkmanui/src/features/inventory/types.ts +++ b/barkmanui/src/features/inventory/types.ts @@ -19,3 +19,13 @@ export interface NewItem { rentalPrice: number, replacementCost: number, } +export interface Customer { + id: number, + name: string, + company: string, + email: string, + phone: string, + address: string, + billingTerms: string, + notes: string, +} \ No newline at end of file From 29e9302d8e8eb83bc1f0ec377fc1b3fbe66ea2b2 Mon Sep 17 00:00:00 2001 From: Drew Rautenberg Date: Fri, 17 Jul 2026 09:00:21 -0500 Subject: [PATCH 02/11] customer list component --- .../src/features/customers/CustomerList.tsx | 54 +++++++++++++++++++ .../customers/hooks/useCustomerList.tsx | 17 ++++++ barkmanui/src/features/customers/types.ts | 10 ++++ 3 files changed, 81 insertions(+) create mode 100644 barkmanui/src/features/customers/CustomerList.tsx create mode 100644 barkmanui/src/features/customers/hooks/useCustomerList.tsx create mode 100644 barkmanui/src/features/customers/types.ts diff --git a/barkmanui/src/features/customers/CustomerList.tsx b/barkmanui/src/features/customers/CustomerList.tsx new file mode 100644 index 0000000..3a8f9e4 --- /dev/null +++ b/barkmanui/src/features/customers/CustomerList.tsx @@ -0,0 +1,54 @@ +import {Flex, Table} from '@mantine/core'; +import BarkButton from "../../common/components/BarkButton.tsx"; +import {Link, NavLink} from "react-router"; +import useCustomerList from "./hooks/useCustomerList.tsx"; + + +function CustomerList() { + + const customerQuery = useCustomerList(); + + if (customerQuery.isPending) return 'Loading...' + + if (customerQuery.error) return 'An error has occurred: ' + customerQuery.error.message + + + return ( + <> + +

+ ARFF ARFF BARK BARK +

+ Add Item +
+ + + + + Name + Company + + + + {customerQuery.data?.map((data) => ( + + {data.name} + {data.company} + + Details + + + ))} + +
+ + ) +} +export default CustomerList; \ No newline at end of file diff --git a/barkmanui/src/features/customers/hooks/useCustomerList.tsx b/barkmanui/src/features/customers/hooks/useCustomerList.tsx new file mode 100644 index 0000000..0cbae87 --- /dev/null +++ b/barkmanui/src/features/customers/hooks/useCustomerList.tsx @@ -0,0 +1,17 @@ +import {useQuery} from "@tanstack/react-query"; +import {Customer} from "../types.ts"; + + const useCustomerList = () => useQuery({ + queryKey: ['customer'], + queryFn: async (): Promise => { + const response = await fetch( + import.meta.env.VITE_API_URL + '/custmoers', + ) + + if (!response.ok) throw new Error('Failed to fetch customers ' + response.statusText) + + return await response.json() + }, + }); + +export default useCustomerList; \ No newline at end of file diff --git a/barkmanui/src/features/customers/types.ts b/barkmanui/src/features/customers/types.ts new file mode 100644 index 0000000..7029951 --- /dev/null +++ b/barkmanui/src/features/customers/types.ts @@ -0,0 +1,10 @@ +export interface Customer { + id: number, + name: string, + company: string, + email: string, + phone: string, + address: string, + billingTerms: string, + notes: string, +} \ No newline at end of file From 65df987f62932556b4180981ceb0f7d759ae57a3 Mon Sep 17 00:00:00 2001 From: Drew Rautenberg Date: Fri, 17 Jul 2026 09:48:05 -0500 Subject: [PATCH 03/11] added routes and header button --- barkmanui/src/App.tsx | 3 +++ barkmanui/src/common/components/BarkHeader.tsx | 1 + 2 files changed, 4 insertions(+) diff --git a/barkmanui/src/App.tsx b/barkmanui/src/App.tsx index ac886f0..f9b327e 100644 --- a/barkmanui/src/App.tsx +++ b/barkmanui/src/App.tsx @@ -10,6 +10,7 @@ import {BarkHeader} from "./common/components/BarkHeader.tsx"; import AddItem from "./features/inventory/AddItem.tsx"; import { Notifications } from '@mantine/notifications'; import '@mantine/notifications/styles.css'; +import CustomerList from "@/features/customers/CustomerList.tsx"; // Create a client const queryClient = new QueryClient() @@ -46,6 +47,8 @@ function App() { }/> }/> }/> + }/> + diff --git a/barkmanui/src/common/components/BarkHeader.tsx b/barkmanui/src/common/components/BarkHeader.tsx index 7fef196..8ab8ea8 100644 --- a/barkmanui/src/common/components/BarkHeader.tsx +++ b/barkmanui/src/common/components/BarkHeader.tsx @@ -7,6 +7,7 @@ import BarkLogo from '@/assets/barklogo.png'; const links = [ { link: '/', label: 'Home' }, + { link: '/customers', label: 'Customers' }, { link: '/inventory', label: 'Inventory' }, ]; From 161a73cbb7aaf95364baa849ec714ba32ff6b8f5 Mon Sep 17 00:00:00 2001 From: Drew Rautenberg Date: Fri, 17 Jul 2026 11:56:33 -0500 Subject: [PATCH 04/11] created customer endpoints --- barkmanAPI/Program.cs | 69 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/barkmanAPI/Program.cs b/barkmanAPI/Program.cs index 06b051d..58d9dce 100644 --- a/barkmanAPI/Program.cs +++ b/barkmanAPI/Program.cs @@ -47,6 +47,10 @@ var itemStatusGroup = app.MapGroup(prefix: "/itemstatus") .WithTags("Item Status") .WithDescription("Endpoints for managing item status"); +var customerGroup = app.MapGroup(prefix: "/customers") + .WithTags("Customers") + .WithDescription("Endpoints for managing customers"); + inventoryGroup.MapGet("", async (BarkContext db) => await db.Inventory.OrderBy(item => item.Barcode).ToListAsync()); @@ -163,6 +167,71 @@ itemStatusGroup.MapDelete("/{id}", async (string id, BarkContext db) => return Results.Ok(new { Message = "Item status deleted successfully" }); }); +customerGroup.MapGet("", async (BarkContext db) => + await db.Customers.OrderBy(customer => customer.Id).ToListAsync()); + +customerGroup.MapGet("/{id}", async (int id, BarkContext db) => +{ + var customer = await db.Customers + .FirstOrDefaultAsync(i => i.Id == id); + + if (customer == null) + { + return Results.NotFound(new { Message = "Customer item not found" }); + } + + return Results.Ok(customer); +}); + +customerGroup.MapPut("/{id}", async (int id, Customers updatedCustomer, BarkContext db) => +{ + var existingCustomer = await db.Customers.FindAsync(id); + if (existingCustomer == null) + { + return Results.NotFound(new { Message = "Customer not found" }); + } + + existingCustomer.Name = updatedCustomer.Name; + existingCustomer.Company = updatedCustomer.Company; + existingCustomer.Email = updatedCustomer.Email; + existingCustomer.PhoneNumber = updatedCustomer.PhoneNumber; + existingCustomer.Address = updatedCustomer.Address; + existingCustomer.BillingTerms = updatedCustomer.BillingTerms; + existingCustomer.Notes = updatedCustomer.Notes; + + await db.SaveChangesAsync(); + return Results.Ok(existingCustomer); +}); + +customerGroup.MapPost("", async (Customers newCustomerInput, BarkContext db) => +{ + var newCustomer = new Customers() + { + Name = newCustomerInput.Name, + Email = newCustomerInput.Email, + }; + newCustomer.Company = newCustomerInput.Company; + newCustomer.PhoneNumber = newCustomerInput.PhoneNumber; + newCustomer.Address = newCustomerInput.Address; + + db.Customers.Add(newCustomer); + await db.SaveChangesAsync(); + return Results.Created($"/customers/{newCustomer.Id}", newCustomer); +}); + +customerGroup.MapDelete("/{id}", async (int id, BarkContext db) => +{ + var customer = await db.Customers.FindAsync(id); + if (customer == null) + { + return Results.NotFound(new { Message = "Customer not found" }); + } + + db.Customers.Remove(customer); + await db.SaveChangesAsync(); + return Results.Ok(new { Message = "Customer deleted successfully" }); +}); + using (var serviceScope = app.Services.CreateScope()) { var dbContext = serviceScope.ServiceProvider.GetRequiredService(); From 3b07318e346cf88b6bc14642421b439c8e6e80cb Mon Sep 17 00:00:00 2001 From: Drew Rautenberg Date: Fri, 17 Jul 2026 12:06:03 -0500 Subject: [PATCH 05/11] fixed typos --- barkmanAPI/Program.cs | 2 +- barkmanui/src/features/customers/hooks/useCustomerList.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/barkmanAPI/Program.cs b/barkmanAPI/Program.cs index 58d9dce..658b103 100644 --- a/barkmanAPI/Program.cs +++ b/barkmanAPI/Program.cs @@ -177,7 +177,7 @@ customerGroup.MapGet("/{id}", async (int id, BarkContext db) => if (customer == null) { - return Results.NotFound(new { Message = "Customer item not found" }); + return Results.NotFound(new { Message = "Customer not found" }); } return Results.Ok(customer); diff --git a/barkmanui/src/features/customers/hooks/useCustomerList.tsx b/barkmanui/src/features/customers/hooks/useCustomerList.tsx index 0cbae87..293a3a7 100644 --- a/barkmanui/src/features/customers/hooks/useCustomerList.tsx +++ b/barkmanui/src/features/customers/hooks/useCustomerList.tsx @@ -5,7 +5,7 @@ import {Customer} from "../types.ts"; queryKey: ['customer'], queryFn: async (): Promise => { const response = await fetch( - import.meta.env.VITE_API_URL + '/custmoers', + import.meta.env.VITE_API_URL + '/customers', ) if (!response.ok) throw new Error('Failed to fetch customers ' + response.statusText) From 854c55b7e0ce20ce7f224e7192234b9d5e969e83 Mon Sep 17 00:00:00 2001 From: Drew Rautenberg Date: Fri, 17 Jul 2026 12:12:54 -0500 Subject: [PATCH 06/11] added new customer type --- barkmanui/src/features/customers/types.ts | 7 +++++++ barkmanui/src/features/inventory/types.ts | 10 ---------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/barkmanui/src/features/customers/types.ts b/barkmanui/src/features/customers/types.ts index 7029951..7a1023d 100644 --- a/barkmanui/src/features/customers/types.ts +++ b/barkmanui/src/features/customers/types.ts @@ -7,4 +7,11 @@ export interface Customer { address: string, billingTerms: string, notes: string, +} +export interface NewCustomer { + name: string, + company: string, + email: number, + phone: number, + address: string, } \ No newline at end of file diff --git a/barkmanui/src/features/inventory/types.ts b/barkmanui/src/features/inventory/types.ts index cd87d28..7439c51 100644 --- a/barkmanui/src/features/inventory/types.ts +++ b/barkmanui/src/features/inventory/types.ts @@ -19,13 +19,3 @@ export interface NewItem { rentalPrice: number, replacementCost: number, } -export interface Customer { - id: number, - name: string, - company: string, - email: string, - phone: string, - address: string, - billingTerms: string, - notes: string, -} \ No newline at end of file From 92afaafe7be1e5f6f8a05d75607cbea2a2006586 Mon Sep 17 00:00:00 2001 From: Drew Rautenberg Date: Fri, 17 Jul 2026 12:44:39 -0500 Subject: [PATCH 07/11] add customer page --- barkmanui/src/App.tsx | 2 + .../src/features/customers/AddCustomer.tsx | 109 ++++++++++++++++++ .../src/features/customers/CustomerList.tsx | 2 +- barkmanui/src/features/customers/types.ts | 4 +- 4 files changed, 114 insertions(+), 3 deletions(-) create mode 100644 barkmanui/src/features/customers/AddCustomer.tsx diff --git a/barkmanui/src/App.tsx b/barkmanui/src/App.tsx index f9b327e..c262ba4 100644 --- a/barkmanui/src/App.tsx +++ b/barkmanui/src/App.tsx @@ -11,6 +11,7 @@ import AddItem from "./features/inventory/AddItem.tsx"; import { Notifications } from '@mantine/notifications'; import '@mantine/notifications/styles.css'; import CustomerList from "@/features/customers/CustomerList.tsx"; +import AddCustomer from "@/features/customers/AddCustomer.tsx"; // Create a client const queryClient = new QueryClient() @@ -48,6 +49,7 @@ function App() { }/> }/> }/> + }/> diff --git a/barkmanui/src/features/customers/AddCustomer.tsx b/barkmanui/src/features/customers/AddCustomer.tsx new file mode 100644 index 0000000..825a40f --- /dev/null +++ b/barkmanui/src/features/customers/AddCustomer.tsx @@ -0,0 +1,109 @@ +import {Button, Group, TextInput, NumberInput, Container, Title, Flex} from '@mantine/core'; +import {useForm} from '@mantine/form'; +import {useMutation} from "@tanstack/react-query"; +import {NewCustomer} from "./types.ts"; +import {useNavigate} from "react-router"; +import {IconX, IconCheck} from '@tabler/icons-react'; +import {notifications} from '@mantine/notifications'; +import useCustomerList from "./hooks/useCustomerList.tsx"; + + +function AddCustomer() { + + const navigate = useNavigate(); + + const customerQuery = useCustomerList(); + + const newCustomerForm = useForm({ + mode: 'uncontrolled', + initialValues: { + name: "", + company: "", + email: "", + phone: "", + address: "", + }, + + validate: {}, + }); + + const updateCustomer = useMutation({ + mutationFn: async (values: NewCustomer) => { + + const result = await fetch(import.meta.env.VITE_API_URL + '/customers', { + method: 'POST', + body: JSON.stringify(values), + headers: { + 'Content-Type': 'application/json' + } + }); + + if (result.ok) { + notifications.show({ + icon: , + color: "teal", + title: "All good!", + message: "Customer Created", + position: 'top-center', + }); + navigate("/customers"); + + } + + if (!result.ok) { + notifications.show({ + icon: , + color: "red", + title: "Bummer!", + message: "Something went wrong", + position: 'top-center', + }); + throw new Error('Failed to create customer'); + } + + }, + + + }) + + if (customerQuery.isPending) return 'Loading...' + if (customerQuery.error) return 'An error has occurred: ' + customerQuery.error.message + + + + + return ( + <> +
await + updateCustomer.mutateAsync(values))}> + + + + Add Item + + + + + + + + + + + +
+ + ); +} + +export default AddCustomer; \ No newline at end of file diff --git a/barkmanui/src/features/customers/CustomerList.tsx b/barkmanui/src/features/customers/CustomerList.tsx index 3a8f9e4..7e4cd0f 100644 --- a/barkmanui/src/features/customers/CustomerList.tsx +++ b/barkmanui/src/features/customers/CustomerList.tsx @@ -26,7 +26,7 @@ function CustomerList() {

ARFF ARFF BARK BARK

- Add Item + Add Customer diff --git a/barkmanui/src/features/customers/types.ts b/barkmanui/src/features/customers/types.ts index 7a1023d..6451203 100644 --- a/barkmanui/src/features/customers/types.ts +++ b/barkmanui/src/features/customers/types.ts @@ -11,7 +11,7 @@ export interface Customer { export interface NewCustomer { name: string, company: string, - email: number, - phone: number, + email: string, + phone: string, address: string, } \ No newline at end of file From d15701a50b00559bfc67123b16be3f9d099a3efd Mon Sep 17 00:00:00 2001 From: Drew Rautenberg Date: Sat, 18 Jul 2026 18:15:16 -0500 Subject: [PATCH 08/11] Fixed add customer page --- barkmanui/src/features/customers/AddCustomer.tsx | 8 ++++---- barkmanui/src/features/customers/CustomerList.tsx | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/barkmanui/src/features/customers/AddCustomer.tsx b/barkmanui/src/features/customers/AddCustomer.tsx index 825a40f..1693af2 100644 --- a/barkmanui/src/features/customers/AddCustomer.tsx +++ b/barkmanui/src/features/customers/AddCustomer.tsx @@ -1,4 +1,4 @@ -import {Button, Group, TextInput, NumberInput, Container, Title, Flex} from '@mantine/core'; +import {Button, Group, TextInput, Container, Title, Flex} from '@mantine/core'; import {useForm} from '@mantine/form'; import {useMutation} from "@tanstack/react-query"; import {NewCustomer} from "./types.ts"; @@ -89,11 +89,11 @@ function AddCustomer() { placeholder="Name" {...newCustomerForm.getInputProps('name')}/> - - - diff --git a/barkmanui/src/features/customers/CustomerList.tsx b/barkmanui/src/features/customers/CustomerList.tsx index 7e4cd0f..aeda9ae 100644 --- a/barkmanui/src/features/customers/CustomerList.tsx +++ b/barkmanui/src/features/customers/CustomerList.tsx @@ -26,7 +26,7 @@ function CustomerList() {

ARFF ARFF BARK BARK

- Add Customer + Add Customer
From 34d421719ca20978a1e2d81bf82182a277b86194 Mon Sep 17 00:00:00 2001 From: Drew Rautenberg Date: Sat, 18 Jul 2026 18:33:48 -0500 Subject: [PATCH 09/11] Added customer detail page --- barkmanui/src/App.tsx | 2 + .../src/features/customers/CustomerDetail.tsx | 45 +++++++++++++++++++ .../src/features/customers/CustomerList.tsx | 2 +- 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 barkmanui/src/features/customers/CustomerDetail.tsx diff --git a/barkmanui/src/App.tsx b/barkmanui/src/App.tsx index c262ba4..809d0c9 100644 --- a/barkmanui/src/App.tsx +++ b/barkmanui/src/App.tsx @@ -12,6 +12,7 @@ import { Notifications } from '@mantine/notifications'; import '@mantine/notifications/styles.css'; import CustomerList from "@/features/customers/CustomerList.tsx"; import AddCustomer from "@/features/customers/AddCustomer.tsx"; +import CustomerDetail from "@/features/customers/CustomerDetail.tsx"; // Create a client const queryClient = new QueryClient() @@ -50,6 +51,7 @@ function App() { }/> }/> }/> + }/> diff --git a/barkmanui/src/features/customers/CustomerDetail.tsx b/barkmanui/src/features/customers/CustomerDetail.tsx new file mode 100644 index 0000000..7933492 --- /dev/null +++ b/barkmanui/src/features/customers/CustomerDetail.tsx @@ -0,0 +1,45 @@ +import {Container, Text, Title} from "@mantine/core"; +import {Link, useParams} from "react-router"; +import {Customer} from "./types.ts"; +import {useQuery} from "@tanstack/react-query"; + + +function CustomerDetail() { + const params = useParams(); + + const {isPending, error, data, isFetching} = useQuery({ + queryKey: ['customers', params.customerId], + queryFn: async (): Promise => { + const response = await fetch( + import.meta.env.VITE_API_URL + '/customers/' + params.customerId, + ) + + if (!response.ok) throw new Error('Failed to fetch customer ' + response.statusText) + + return await response.json() + }, + }); + + if (isPending) return 'Loading...' + + if (error) return 'An error has occurred: ' + error.message + + return ( + <> + + Customer Detail +
{isFetching ? 'Updating...' : ''}
+ Name: {data.name} + Company: {data.company} + Email: {data.email} + Phone Number: {data.phone} + Address: ${data.address} + Notes: {data.notes} + + Edit +
+ + ) +} + +export default CustomerDetail \ No newline at end of file diff --git a/barkmanui/src/features/customers/CustomerList.tsx b/barkmanui/src/features/customers/CustomerList.tsx index aeda9ae..24a7f88 100644 --- a/barkmanui/src/features/customers/CustomerList.tsx +++ b/barkmanui/src/features/customers/CustomerList.tsx @@ -42,7 +42,7 @@ function CustomerList() { {data.name} {data.company} - Details + Details ))} From 9374ad53e305e105ff84115473bf3ba231ee4c95 Mon Sep 17 00:00:00 2001 From: Drew Rautenberg Date: Sat, 18 Jul 2026 18:46:53 -0500 Subject: [PATCH 10/11] Added edit customer detail page --- barkmanui/src/App.tsx | 2 + .../src/features/customers/CustomerDetail.tsx | 2 +- .../src/features/customers/EditCustomer.tsx | 134 ++++++++++++++++++ 3 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 barkmanui/src/features/customers/EditCustomer.tsx diff --git a/barkmanui/src/App.tsx b/barkmanui/src/App.tsx index 809d0c9..16fcc53 100644 --- a/barkmanui/src/App.tsx +++ b/barkmanui/src/App.tsx @@ -13,6 +13,7 @@ import '@mantine/notifications/styles.css'; import CustomerList from "@/features/customers/CustomerList.tsx"; import AddCustomer from "@/features/customers/AddCustomer.tsx"; import CustomerDetail from "@/features/customers/CustomerDetail.tsx"; +import EditCustomer from "@/features/customers/EditCustomer.tsx"; // Create a client const queryClient = new QueryClient() @@ -52,6 +53,7 @@ function App() { }/> }/> }/> + }/> diff --git a/barkmanui/src/features/customers/CustomerDetail.tsx b/barkmanui/src/features/customers/CustomerDetail.tsx index 7933492..5d1d297 100644 --- a/barkmanui/src/features/customers/CustomerDetail.tsx +++ b/barkmanui/src/features/customers/CustomerDetail.tsx @@ -36,7 +36,7 @@ function CustomerDetail() { Address: ${data.address} Notes: {data.notes} - Edit + Edit ) diff --git a/barkmanui/src/features/customers/EditCustomer.tsx b/barkmanui/src/features/customers/EditCustomer.tsx new file mode 100644 index 0000000..f1cb229 --- /dev/null +++ b/barkmanui/src/features/customers/EditCustomer.tsx @@ -0,0 +1,134 @@ +import {Button, Group, TextInput, Container, Title, Flex} from '@mantine/core'; +import {useForm} from '@mantine/form'; +import {useNavigate, useParams} from "react-router"; +import {useMutation, useQuery, useQueryClient} from "@tanstack/react-query"; +import {Customer} from "./types.ts"; +import {useEffect} from "react"; +import {notifications} from "@mantine/notifications"; +import {IconCheck, IconX} from "@tabler/icons-react"; + +type EditableCustomer= Omit; + +function EditCustomer() { + const params = useParams(); + const navigate = useNavigate(); + + const editCustomerForm = useForm({ + mode: 'uncontrolled', + initialValues: { + name: "", + company: "", + email: "", + phone: "", + address: "", + billingTerms: "", + notes: "", + }, + + validate: {}, + }); + + const {isPending, error, data, isFetching} = useQuery({ + queryKey: ['customer', params.customerId], + queryFn: async (): Promise => { + const response = await fetch( + import.meta.env.VITE_API_URL + '/customers/' + params.customerId, + ) + + if (!response.ok) throw new Error('Failed to fetch customer ' + response.statusText) + + return await response.json() + }, + }); + + const queryClient = useQueryClient(); + + const updateCustomer = useMutation({ + mutationFn: async (values: EditableCustomer) => { + + // await + const result = await fetch(import.meta.env.VITE_API_URL + '/customers/' + params.customerId, { + method: 'PUT', + body: JSON.stringify(values), + headers: { + 'Content-Type': 'application/json' + } + }); + + if (result.ok) { + notifications.show({ + icon: , + color:"teal", + title: "All good!", + message: "Customer Updated", + position: 'top-center', + }); + navigate("/customers"); + + } + + if (!result.ok) { + notifications.show({ + icon: , + color:"red", + title: "Bummer!", + message: "Something went wrong", + position: 'top-center', + }); + throw new Error('Failed to update customer'); + } + + // invalidate the queries so they pull updated information + // this is a prefix, so it covers both the query that pulls a list, and also `['customers', customerId]` in this file + await queryClient.invalidateQueries({ + queryKey: ['customers'] + }); + } + }) + + useEffect(() => { + if (data) { + // Even if query.data changes, form will be initialized only once + editCustomerForm.initialize(data); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [data]); + + if (isPending) return 'Loading...' + + if (error) return 'An error has occurred: ' + error.message + + return ( +
await + updateCustomer.mutateAsync(values))}> + + + +
{isFetching ? 'Updating...' : ''}
+ Edit Customer + + + + + + + + + +
+
+ + ); +} + +export default EditCustomer; \ No newline at end of file From be5260547b69d2035505ec356a7c78777451a7d1 Mon Sep 17 00:00:00 2001 From: Drew Rautenberg Date: Sat, 18 Jul 2026 18:57:59 -0500 Subject: [PATCH 11/11] moved inputs to ctor for better encapsulation --- barkmanAPI/Program.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/barkmanAPI/Program.cs b/barkmanAPI/Program.cs index 658b103..9a9de8e 100644 --- a/barkmanAPI/Program.cs +++ b/barkmanAPI/Program.cs @@ -209,10 +209,10 @@ customerGroup.MapPost("", async (Customers newCustomerInput, BarkContext db) => { Name = newCustomerInput.Name, Email = newCustomerInput.Email, + Company = newCustomerInput.Company, + PhoneNumber = newCustomerInput.PhoneNumber, + Address = newCustomerInput.Address, }; - newCustomer.Company = newCustomerInput.Company; - newCustomer.PhoneNumber = newCustomerInput.PhoneNumber; - newCustomer.Address = newCustomerInput.Address; db.Customers.Add(newCustomer); await db.SaveChangesAsync();