From fc44790c962003ce1d1d64d1a7ae4ba243e00070 Mon Sep 17 00:00:00 2001 From: Drew Rautenberg Date: Wed, 22 Jul 2026 19:34:41 -0500 Subject: [PATCH 1/5] fixed customer id type --- ...723003407_fixedOrderCustomerID.Designer.cs | 294 ++++++++++++++++++ .../20260723003407_fixedOrderCustomerID.cs | 34 ++ .../Migrations/BarkContextModelSnapshot.cs | 5 +- barkmanAPI/barkDbModel.cs | 2 +- 4 files changed, 331 insertions(+), 4 deletions(-) create mode 100644 barkmanAPI/Migrations/20260723003407_fixedOrderCustomerID.Designer.cs create mode 100644 barkmanAPI/Migrations/20260723003407_fixedOrderCustomerID.cs diff --git a/barkmanAPI/Migrations/20260723003407_fixedOrderCustomerID.Designer.cs b/barkmanAPI/Migrations/20260723003407_fixedOrderCustomerID.Designer.cs new file mode 100644 index 0000000..a58cd7a --- /dev/null +++ b/barkmanAPI/Migrations/20260723003407_fixedOrderCustomerID.Designer.cs @@ -0,0 +1,294 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using barkmanapi; + +#nullable disable + +namespace barkmanapi.Migrations +{ + [DbContext(typeof(BarkContext))] + [Migration("20260723003407_fixedOrderCustomerID")] + partial class fixedOrderCustomerID + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("barkmanapi.Customers", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Address") + .HasColumnType("text") + .HasColumnName("address"); + + b.Property("BillingTerms") + .HasColumnType("text") + .HasColumnName("billing_terms"); + + b.Property("Company") + .HasColumnType("text") + .HasColumnName("company"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text") + .HasColumnName("email"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name"); + + b.Property("Notes") + .HasColumnType("text") + .HasColumnName("notes"); + + b.Property("PhoneNumber") + .HasColumnType("text") + .HasColumnName("phone_number"); + + b.HasKey("Id") + .HasName("pk_customers"); + + b.ToTable("customers", (string)null); + }); + + modelBuilder.Entity("barkmanapi.InventoryItems", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Barcode") + .IsRequired() + .HasColumnType("text") + .HasColumnName("barcode"); + + b.Property("Brand") + .IsRequired() + .HasColumnType("text") + .HasColumnName("brand"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name"); + + b.Property("Notes") + .HasColumnType("text") + .HasColumnName("notes"); + + b.Property("RentalPrice") + .HasColumnType("real") + .HasColumnName("rental_price"); + + b.Property("ReplacementCost") + .HasColumnType("real") + .HasColumnName("replacement_cost"); + + b.Property("SerialNumber") + .HasColumnType("text") + .HasColumnName("serial_number"); + + b.Property("StatusId") + .HasColumnType("text") + .HasColumnName("status_id"); + + b.Property("Weight") + .HasColumnType("real") + .HasColumnName("weight"); + + b.HasKey("Id") + .HasName("pk_inventory"); + + b.HasIndex("Barcode") + .IsUnique() + .HasDatabaseName("ix_inventory_barcode"); + + b.HasIndex("StatusId") + .HasDatabaseName("ix_inventory_status_id"); + + b.ToTable("inventory", (string)null); + }); + + modelBuilder.Entity("barkmanapi.ItemStatus", b => + { + b.Property("Id") + .HasColumnType("text") + .HasColumnName("id"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name"); + + b.HasKey("Id") + .HasName("pk_item_status"); + + b.ToTable("item_status", (string)null); + }); + + modelBuilder.Entity("barkmanapi.OrderItems", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ItemId") + .IsRequired() + .HasColumnType("text") + .HasColumnName("item_id"); + + b.Property("OrderId") + .IsRequired() + .HasColumnType("text") + .HasColumnName("order_id"); + + b.Property("OrdersId") + .HasColumnType("integer") + .HasColumnName("orders_id"); + + b.Property("Quantity") + .HasColumnType("integer") + .HasColumnName("quantity"); + + b.HasKey("Id") + .HasName("pk_order_items"); + + b.HasIndex("OrdersId") + .HasDatabaseName("ix_order_items_orders_id"); + + b.ToTable("order_items", (string)null); + }); + + modelBuilder.Entity("barkmanapi.OrderStatus", b => + { + b.Property("Id") + .HasColumnType("text") + .HasColumnName("id"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name"); + + b.HasKey("Id") + .HasName("pk_order_status"); + + b.ToTable("order_status", (string)null); + }); + + modelBuilder.Entity("barkmanapi.Orders", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Address") + .HasColumnType("text") + .HasColumnName("address"); + + b.Property("CustomerId") + .HasColumnType("integer") + .HasColumnName("customer_id"); + + b.Property("EndDate") + .HasColumnType("timestamp with time zone") + .HasColumnName("end_date"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name"); + + b.Property("Notes") + .HasColumnType("text") + .HasColumnName("notes"); + + b.Property("StartDate") + .HasColumnType("timestamp with time zone") + .HasColumnName("start_date"); + + b.Property("StatusId") + .HasColumnType("text") + .HasColumnName("status_id"); + + b.Property("TotalPrice") + .HasColumnType("numeric") + .HasColumnName("total_price"); + + b.Property("Venue") + .HasColumnType("text") + .HasColumnName("venue"); + + b.HasKey("Id") + .HasName("pk_orders"); + + b.HasIndex("StatusId") + .HasDatabaseName("ix_orders_status_id"); + + b.ToTable("orders", (string)null); + }); + + modelBuilder.Entity("barkmanapi.InventoryItems", b => + { + b.HasOne("barkmanapi.ItemStatus", "Status") + .WithMany() + .HasForeignKey("StatusId") + .HasConstraintName("fk_inventory_item_status_status_id"); + + b.Navigation("Status"); + }); + + modelBuilder.Entity("barkmanapi.OrderItems", b => + { + b.HasOne("barkmanapi.Orders", null) + .WithMany("Items") + .HasForeignKey("OrdersId") + .HasConstraintName("fk_order_items_orders_orders_id"); + }); + + modelBuilder.Entity("barkmanapi.Orders", b => + { + b.HasOne("barkmanapi.OrderStatus", "Status") + .WithMany() + .HasForeignKey("StatusId") + .HasConstraintName("fk_orders_order_status_status_id"); + + b.Navigation("Status"); + }); + + modelBuilder.Entity("barkmanapi.Orders", b => + { + b.Navigation("Items"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/barkmanAPI/Migrations/20260723003407_fixedOrderCustomerID.cs b/barkmanAPI/Migrations/20260723003407_fixedOrderCustomerID.cs new file mode 100644 index 0000000..2ead996 --- /dev/null +++ b/barkmanAPI/Migrations/20260723003407_fixedOrderCustomerID.cs @@ -0,0 +1,34 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace barkmanapi.Migrations +{ + /// + public partial class fixedOrderCustomerID : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "customer_id", + table: "orders", + type: "integer", + nullable: false, + oldClrType: typeof(string), + oldType: "text"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "customer_id", + table: "orders", + type: "text", + nullable: false, + oldClrType: typeof(int), + oldType: "integer"); + } + } +} diff --git a/barkmanAPI/Migrations/BarkContextModelSnapshot.cs b/barkmanAPI/Migrations/BarkContextModelSnapshot.cs index e770297..2998006 100644 --- a/barkmanAPI/Migrations/BarkContextModelSnapshot.cs +++ b/barkmanAPI/Migrations/BarkContextModelSnapshot.cs @@ -211,9 +211,8 @@ namespace barkmanapi.Migrations .HasColumnType("text") .HasColumnName("address"); - b.Property("CustomerId") - .IsRequired() - .HasColumnType("text") + b.Property("CustomerId") + .HasColumnType("integer") .HasColumnName("customer_id"); b.Property("EndDate") diff --git a/barkmanAPI/barkDbModel.cs b/barkmanAPI/barkDbModel.cs index 7566374..b4bd03a 100644 --- a/barkmanAPI/barkDbModel.cs +++ b/barkmanAPI/barkDbModel.cs @@ -49,7 +49,7 @@ public class Customers public class Orders { public int Id { get; set; } - public required string CustomerId { get; set; } + public required int CustomerId { get; set; } public required string Name { get; set; } public OrderStatus Status { get; set; } public string? StatusId { get; set; } From 137f9ee669e44f13d3ebeacb48fcefdcf33cd64f Mon Sep 17 00:00:00 2001 From: Drew Rautenberg Date: Wed, 22 Jul 2026 19:38:58 -0500 Subject: [PATCH 2/5] Types! --- barkmanui/src/features/jobs/types.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 barkmanui/src/features/jobs/types.ts diff --git a/barkmanui/src/features/jobs/types.ts b/barkmanui/src/features/jobs/types.ts new file mode 100644 index 0000000..a9c4911 --- /dev/null +++ b/barkmanui/src/features/jobs/types.ts @@ -0,0 +1,23 @@ +export interface Job { + id: number, + customerId: number, + name: string, + status: {id: string; name: string}, + statusId: string; + startDate: Date; + endDate: Date; + totalPrice: string, + venue: number, + address: number, + notes: string, +} + +export interface NewJob { + customerId: number, + name: string, + startDate: Date; + endDate: Date; + venue: number, + address: number, + notes: string, +} From c2c48b4cb1116996707b19fe5f444e5c84330792 Mon Sep 17 00:00:00 2001 From: Drew Rautenberg Date: Wed, 22 Jul 2026 19:44:11 -0500 Subject: [PATCH 3/5] list hook --- .../src/features/jobs/hooks/useJobList.tsx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 barkmanui/src/features/jobs/hooks/useJobList.tsx diff --git a/barkmanui/src/features/jobs/hooks/useJobList.tsx b/barkmanui/src/features/jobs/hooks/useJobList.tsx new file mode 100644 index 0000000..10bb331 --- /dev/null +++ b/barkmanui/src/features/jobs/hooks/useJobList.tsx @@ -0,0 +1,17 @@ +import {useQuery} from "@tanstack/react-query"; +import {Job} from "../types.ts"; + + const useJobList = () => useQuery({ + queryKey: ['job'], + queryFn: async (): Promise => { + const response = await fetch( + import.meta.env.VITE_API_URL + '/jobs', + ) + + if (!response.ok) throw new Error('Failed to fetch jobs ' + response.statusText) + + return await response.json() + }, + }); + +export default useJobList; \ No newline at end of file From ddd90aa5a5c9aeac2e57d1ab21e8bd058ba716e9 Mon Sep 17 00:00:00 2001 From: Drew Rautenberg Date: Wed, 22 Jul 2026 19:49:24 -0500 Subject: [PATCH 4/5] changed order to job - updated model, --- ...260723004900_changedOrderToJob.Designer.cs | 294 ++++++++++++++++++ .../20260723004900_changedOrderToJob.cs | 176 +++++++++++ .../Migrations/BarkContextModelSnapshot.cs | 48 +-- barkmanAPI/barkDbModel.cs | 16 +- barkmanui/src/features/jobs/AddJob.tsx | 109 +++++++ 5 files changed, 611 insertions(+), 32 deletions(-) create mode 100644 barkmanAPI/Migrations/20260723004900_changedOrderToJob.Designer.cs create mode 100644 barkmanAPI/Migrations/20260723004900_changedOrderToJob.cs create mode 100644 barkmanui/src/features/jobs/AddJob.tsx diff --git a/barkmanAPI/Migrations/20260723004900_changedOrderToJob.Designer.cs b/barkmanAPI/Migrations/20260723004900_changedOrderToJob.Designer.cs new file mode 100644 index 0000000..e39250b --- /dev/null +++ b/barkmanAPI/Migrations/20260723004900_changedOrderToJob.Designer.cs @@ -0,0 +1,294 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using barkmanapi; + +#nullable disable + +namespace barkmanapi.Migrations +{ + [DbContext(typeof(BarkContext))] + [Migration("20260723004900_changedOrderToJob")] + partial class changedOrderToJob + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("barkmanapi.Customers", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Address") + .HasColumnType("text") + .HasColumnName("address"); + + b.Property("BillingTerms") + .HasColumnType("text") + .HasColumnName("billing_terms"); + + b.Property("Company") + .HasColumnType("text") + .HasColumnName("company"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text") + .HasColumnName("email"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name"); + + b.Property("Notes") + .HasColumnType("text") + .HasColumnName("notes"); + + b.Property("PhoneNumber") + .HasColumnType("text") + .HasColumnName("phone_number"); + + b.HasKey("Id") + .HasName("pk_customers"); + + b.ToTable("customers", (string)null); + }); + + modelBuilder.Entity("barkmanapi.InventoryItems", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Barcode") + .IsRequired() + .HasColumnType("text") + .HasColumnName("barcode"); + + b.Property("Brand") + .IsRequired() + .HasColumnType("text") + .HasColumnName("brand"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name"); + + b.Property("Notes") + .HasColumnType("text") + .HasColumnName("notes"); + + b.Property("RentalPrice") + .HasColumnType("real") + .HasColumnName("rental_price"); + + b.Property("ReplacementCost") + .HasColumnType("real") + .HasColumnName("replacement_cost"); + + b.Property("SerialNumber") + .HasColumnType("text") + .HasColumnName("serial_number"); + + b.Property("StatusId") + .HasColumnType("text") + .HasColumnName("status_id"); + + b.Property("Weight") + .HasColumnType("real") + .HasColumnName("weight"); + + b.HasKey("Id") + .HasName("pk_inventory"); + + b.HasIndex("Barcode") + .IsUnique() + .HasDatabaseName("ix_inventory_barcode"); + + b.HasIndex("StatusId") + .HasDatabaseName("ix_inventory_status_id"); + + b.ToTable("inventory", (string)null); + }); + + modelBuilder.Entity("barkmanapi.ItemStatus", b => + { + b.Property("Id") + .HasColumnType("text") + .HasColumnName("id"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name"); + + b.HasKey("Id") + .HasName("pk_item_status"); + + b.ToTable("item_status", (string)null); + }); + + modelBuilder.Entity("barkmanapi.JobItems", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ItemId") + .IsRequired() + .HasColumnType("text") + .HasColumnName("item_id"); + + b.Property("JobsId") + .HasColumnType("integer") + .HasColumnName("jobs_id"); + + b.Property("OrderId") + .IsRequired() + .HasColumnType("text") + .HasColumnName("order_id"); + + b.Property("Quantity") + .HasColumnType("integer") + .HasColumnName("quantity"); + + b.HasKey("Id") + .HasName("pk_job_items"); + + b.HasIndex("JobsId") + .HasDatabaseName("ix_job_items_jobs_id"); + + b.ToTable("job_items", (string)null); + }); + + modelBuilder.Entity("barkmanapi.JobStatus", b => + { + b.Property("Id") + .HasColumnType("text") + .HasColumnName("id"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name"); + + b.HasKey("Id") + .HasName("pk_job_status"); + + b.ToTable("job_status", (string)null); + }); + + modelBuilder.Entity("barkmanapi.Jobs", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Address") + .HasColumnType("text") + .HasColumnName("address"); + + b.Property("CustomerId") + .HasColumnType("integer") + .HasColumnName("customer_id"); + + b.Property("EndDate") + .HasColumnType("timestamp with time zone") + .HasColumnName("end_date"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name"); + + b.Property("Notes") + .HasColumnType("text") + .HasColumnName("notes"); + + b.Property("StartDate") + .HasColumnType("timestamp with time zone") + .HasColumnName("start_date"); + + b.Property("StatusId") + .HasColumnType("text") + .HasColumnName("status_id"); + + b.Property("TotalPrice") + .HasColumnType("numeric") + .HasColumnName("total_price"); + + b.Property("Venue") + .HasColumnType("text") + .HasColumnName("venue"); + + b.HasKey("Id") + .HasName("pk_jobs"); + + b.HasIndex("StatusId") + .HasDatabaseName("ix_jobs_status_id"); + + b.ToTable("jobs", (string)null); + }); + + modelBuilder.Entity("barkmanapi.InventoryItems", b => + { + b.HasOne("barkmanapi.ItemStatus", "Status") + .WithMany() + .HasForeignKey("StatusId") + .HasConstraintName("fk_inventory_item_status_status_id"); + + b.Navigation("Status"); + }); + + modelBuilder.Entity("barkmanapi.JobItems", b => + { + b.HasOne("barkmanapi.Jobs", null) + .WithMany("Items") + .HasForeignKey("JobsId") + .HasConstraintName("fk_job_items_jobs_jobs_id"); + }); + + modelBuilder.Entity("barkmanapi.Jobs", b => + { + b.HasOne("barkmanapi.JobStatus", "Status") + .WithMany() + .HasForeignKey("StatusId") + .HasConstraintName("fk_jobs_job_status_status_id"); + + b.Navigation("Status"); + }); + + modelBuilder.Entity("barkmanapi.Jobs", b => + { + b.Navigation("Items"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/barkmanAPI/Migrations/20260723004900_changedOrderToJob.cs b/barkmanAPI/Migrations/20260723004900_changedOrderToJob.cs new file mode 100644 index 0000000..81fde1b --- /dev/null +++ b/barkmanAPI/Migrations/20260723004900_changedOrderToJob.cs @@ -0,0 +1,176 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace barkmanapi.Migrations +{ + /// + public partial class changedOrderToJob : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "order_items"); + + migrationBuilder.DropTable( + name: "orders"); + + migrationBuilder.DropTable( + name: "order_status"); + + migrationBuilder.CreateTable( + name: "job_status", + columns: table => new + { + id = table.Column(type: "text", nullable: false), + name = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_job_status", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "jobs", + columns: table => new + { + id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + customer_id = table.Column(type: "integer", nullable: false), + name = table.Column(type: "text", nullable: false), + status_id = table.Column(type: "text", nullable: true), + start_date = table.Column(type: "timestamp with time zone", nullable: false), + end_date = table.Column(type: "timestamp with time zone", nullable: false), + total_price = table.Column(type: "numeric", nullable: false), + venue = table.Column(type: "text", nullable: true), + address = table.Column(type: "text", nullable: true), + notes = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_jobs", x => x.id); + table.ForeignKey( + name: "fk_jobs_job_status_status_id", + column: x => x.status_id, + principalTable: "job_status", + principalColumn: "id"); + }); + + migrationBuilder.CreateTable( + name: "job_items", + columns: table => new + { + id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + order_id = table.Column(type: "text", nullable: false), + item_id = table.Column(type: "text", nullable: false), + quantity = table.Column(type: "integer", nullable: false), + jobs_id = table.Column(type: "integer", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_job_items", x => x.id); + table.ForeignKey( + name: "fk_job_items_jobs_jobs_id", + column: x => x.jobs_id, + principalTable: "jobs", + principalColumn: "id"); + }); + + migrationBuilder.CreateIndex( + name: "ix_job_items_jobs_id", + table: "job_items", + column: "jobs_id"); + + migrationBuilder.CreateIndex( + name: "ix_jobs_status_id", + table: "jobs", + column: "status_id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "job_items"); + + migrationBuilder.DropTable( + name: "jobs"); + + migrationBuilder.DropTable( + name: "job_status"); + + migrationBuilder.CreateTable( + name: "order_status", + columns: table => new + { + id = table.Column(type: "text", nullable: false), + name = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_order_status", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "orders", + columns: table => new + { + id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + status_id = table.Column(type: "text", nullable: true), + address = table.Column(type: "text", nullable: true), + customer_id = table.Column(type: "integer", nullable: false), + end_date = table.Column(type: "timestamp with time zone", nullable: false), + name = table.Column(type: "text", nullable: false), + notes = table.Column(type: "text", nullable: true), + start_date = table.Column(type: "timestamp with time zone", nullable: false), + total_price = table.Column(type: "numeric", nullable: false), + venue = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("pk_orders", x => x.id); + table.ForeignKey( + name: "fk_orders_order_status_status_id", + column: x => x.status_id, + principalTable: "order_status", + principalColumn: "id"); + }); + + migrationBuilder.CreateTable( + name: "order_items", + columns: table => new + { + id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + item_id = table.Column(type: "text", nullable: false), + order_id = table.Column(type: "text", nullable: false), + orders_id = table.Column(type: "integer", nullable: true), + quantity = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_order_items", x => x.id); + table.ForeignKey( + name: "fk_order_items_orders_orders_id", + column: x => x.orders_id, + principalTable: "orders", + principalColumn: "id"); + }); + + migrationBuilder.CreateIndex( + name: "ix_order_items_orders_id", + table: "order_items", + column: "orders_id"); + + migrationBuilder.CreateIndex( + name: "ix_orders_status_id", + table: "orders", + column: "status_id"); + } + } +} diff --git a/barkmanAPI/Migrations/BarkContextModelSnapshot.cs b/barkmanAPI/Migrations/BarkContextModelSnapshot.cs index 2998006..e02f50f 100644 --- a/barkmanAPI/Migrations/BarkContextModelSnapshot.cs +++ b/barkmanAPI/Migrations/BarkContextModelSnapshot.cs @@ -145,7 +145,7 @@ namespace barkmanapi.Migrations b.ToTable("item_status", (string)null); }); - modelBuilder.Entity("barkmanapi.OrderItems", b => + modelBuilder.Entity("barkmanapi.JobItems", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -159,29 +159,29 @@ namespace barkmanapi.Migrations .HasColumnType("text") .HasColumnName("item_id"); + b.Property("JobsId") + .HasColumnType("integer") + .HasColumnName("jobs_id"); + b.Property("OrderId") .IsRequired() .HasColumnType("text") .HasColumnName("order_id"); - b.Property("OrdersId") - .HasColumnType("integer") - .HasColumnName("orders_id"); - b.Property("Quantity") .HasColumnType("integer") .HasColumnName("quantity"); b.HasKey("Id") - .HasName("pk_order_items"); + .HasName("pk_job_items"); - b.HasIndex("OrdersId") - .HasDatabaseName("ix_order_items_orders_id"); + b.HasIndex("JobsId") + .HasDatabaseName("ix_job_items_jobs_id"); - b.ToTable("order_items", (string)null); + b.ToTable("job_items", (string)null); }); - modelBuilder.Entity("barkmanapi.OrderStatus", b => + modelBuilder.Entity("barkmanapi.JobStatus", b => { b.Property("Id") .HasColumnType("text") @@ -193,12 +193,12 @@ namespace barkmanapi.Migrations .HasColumnName("name"); b.HasKey("Id") - .HasName("pk_order_status"); + .HasName("pk_job_status"); - b.ToTable("order_status", (string)null); + b.ToTable("job_status", (string)null); }); - modelBuilder.Entity("barkmanapi.Orders", b => + modelBuilder.Entity("barkmanapi.Jobs", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -245,12 +245,12 @@ namespace barkmanapi.Migrations .HasColumnName("venue"); b.HasKey("Id") - .HasName("pk_orders"); + .HasName("pk_jobs"); b.HasIndex("StatusId") - .HasDatabaseName("ix_orders_status_id"); + .HasDatabaseName("ix_jobs_status_id"); - b.ToTable("orders", (string)null); + b.ToTable("jobs", (string)null); }); modelBuilder.Entity("barkmanapi.InventoryItems", b => @@ -263,25 +263,25 @@ namespace barkmanapi.Migrations b.Navigation("Status"); }); - modelBuilder.Entity("barkmanapi.OrderItems", b => + modelBuilder.Entity("barkmanapi.JobItems", b => { - b.HasOne("barkmanapi.Orders", null) + b.HasOne("barkmanapi.Jobs", null) .WithMany("Items") - .HasForeignKey("OrdersId") - .HasConstraintName("fk_order_items_orders_orders_id"); + .HasForeignKey("JobsId") + .HasConstraintName("fk_job_items_jobs_jobs_id"); }); - modelBuilder.Entity("barkmanapi.Orders", b => + modelBuilder.Entity("barkmanapi.Jobs", b => { - b.HasOne("barkmanapi.OrderStatus", "Status") + b.HasOne("barkmanapi.JobStatus", "Status") .WithMany() .HasForeignKey("StatusId") - .HasConstraintName("fk_orders_order_status_status_id"); + .HasConstraintName("fk_jobs_job_status_status_id"); b.Navigation("Status"); }); - modelBuilder.Entity("barkmanapi.Orders", b => + modelBuilder.Entity("barkmanapi.Jobs", b => { b.Navigation("Items"); }); diff --git a/barkmanAPI/barkDbModel.cs b/barkmanAPI/barkDbModel.cs index b4bd03a..9ddfe9e 100644 --- a/barkmanAPI/barkDbModel.cs +++ b/barkmanAPI/barkDbModel.cs @@ -7,9 +7,9 @@ public class BarkContext(DbContextOptions options) : DbContext(opti public DbSet Inventory { get; set; } public DbSet ItemStatus { get; set; } public DbSet Customers { get; set; } - public DbSet Orders { get; set; } - public DbSet OrderItems { get; set; } - public DbSet OrderStatus { get; set; } + public DbSet Jobs { get; set; } + public DbSet JobItems { get; set; } + public DbSet JobStatus { get; set; } } [Index(nameof(Barcode), IsUnique = true)] @@ -46,23 +46,23 @@ public class Customers public string? Notes { get; set; } } -public class Orders +public class Jobs { public int Id { get; set; } public required int CustomerId { get; set; } public required string Name { get; set; } - public OrderStatus Status { get; set; } + public JobStatus Status { get; set; } public string? StatusId { get; set; } public DateTimeOffset StartDate { get; set; } public DateTimeOffset EndDate { get; set; } public decimal TotalPrice { get; set; } public string? Venue { get; set; } public string? Address { get; set; } - public OrderItems[] Items { get; set; } + public JobItems[] Items { get; set; } public string? Notes { get; set; } } -public class OrderItems +public class JobItems { public int Id { get; set; } public required string OrderId { get; set; } @@ -70,7 +70,7 @@ public class OrderItems public int Quantity { get; set; } } -public class OrderStatus +public class JobStatus { public string Id { get; set; } public string Name { get; set; } diff --git a/barkmanui/src/features/jobs/AddJob.tsx b/barkmanui/src/features/jobs/AddJob.tsx new file mode 100644 index 0000000..15b46ac --- /dev/null +++ b/barkmanui/src/features/jobs/AddJob.tsx @@ -0,0 +1,109 @@ +import {Button, Group, TextInput, Container, Title, Flex} from '@mantine/core'; +import {useForm} from '@mantine/form'; +import {useMutation} from "@tanstack/react-query"; +import {NewJob} from "./types.ts"; +import {useNavigate} from "react-router"; +import {IconX, IconCheck} from '@tabler/icons-react'; +import {notifications} from '@mantine/notifications'; +import useJobList from "./hooks/useJobList.tsx"; + + +function AddJob() { + + const navigate = useNavigate(); + + const customerQuery = useCustomerList(); + + const newJobForm = useForm({ + mode: 'uncontrolled', + initialValues: { + name: "", + company: "", + email: "", + phone: "", + address: "", + }, + + validate: {}, + }); + + const updateCustomer = useMutation({ + mutationFn: async (values: newJob) => { + + 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 From 757a51997f637d9f1fb439eaee7c17fa71315595 Mon Sep 17 00:00:00 2001 From: Drew Rautenberg Date: Thu, 23 Jul 2026 13:34:38 -0500 Subject: [PATCH 5/5] changes --- barkmanui/src/features/jobs/AddJob.tsx | 55 +++++++++++++++----------- barkmanui/src/features/jobs/types.ts | 8 ++-- 2 files changed, 35 insertions(+), 28 deletions(-) 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, }