15 Commits

Author SHA1 Message Date
drew c79bda3960 Merge remote-tracking branch 'origin/add-job-pages' into add-job-pages 2026-07-23 14:21:36 -05:00
drew 9906f015fc added new job page 2026-07-23 14:21:17 -05:00
drew 10ca133a7a changes 2026-07-23 14:20:14 -05:00
drew 85678f5742 changed order to job - updated model, 2026-07-23 14:20:14 -05:00
drew 69da029156 list hook 2026-07-23 14:20:14 -05:00
drew 087d94cbd9 Types! 2026-07-23 14:20:14 -05:00
drew 33f59fd7f8 fixed customer id type 2026-07-23 14:20:14 -05:00
Drew Rautenberg 775d64ef9e Merge pull request #43 from BarkProductions/update-dependencies
updated packages to the latest versions
2026-07-23 14:16:50 -05:00
drew 4a479283da updated packages to the latest versions 2026-07-23 14:11:49 -05:00
drew 757a51997f changes 2026-07-23 13:34:38 -05:00
drew ddd90aa5a5 changed order to job - updated model, 2026-07-22 19:49:24 -05:00
drew c2c48b4cb1 list hook 2026-07-22 19:44:11 -05:00
drew 137f9ee669 Types! 2026-07-22 19:38:58 -05:00
drew fc44790c96 fixed customer id type 2026-07-22 19:34:41 -05:00
Drew Rautenberg 2eaa8723d0 Merge pull request #42 from BarkProductions/40-add-job-endpoints
40 add job endpoints
2026-07-20 19:51:51 -05:00
13 changed files with 2320 additions and 1834 deletions
@@ -0,0 +1,294 @@
// <auto-generated />
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
{
/// <inheritdoc />
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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("id");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Address")
.HasColumnType("text")
.HasColumnName("address");
b.Property<string>("BillingTerms")
.HasColumnType("text")
.HasColumnName("billing_terms");
b.Property<string>("Company")
.HasColumnType("text")
.HasColumnName("company");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text")
.HasColumnName("email");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text")
.HasColumnName("name");
b.Property<string>("Notes")
.HasColumnType("text")
.HasColumnName("notes");
b.Property<string>("PhoneNumber")
.HasColumnType("text")
.HasColumnName("phone_number");
b.HasKey("Id")
.HasName("pk_customers");
b.ToTable("customers", (string)null);
});
modelBuilder.Entity("barkmanapi.InventoryItems", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("id");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Barcode")
.IsRequired()
.HasColumnType("text")
.HasColumnName("barcode");
b.Property<string>("Brand")
.IsRequired()
.HasColumnType("text")
.HasColumnName("brand");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text")
.HasColumnName("name");
b.Property<string>("Notes")
.HasColumnType("text")
.HasColumnName("notes");
b.Property<float?>("RentalPrice")
.HasColumnType("real")
.HasColumnName("rental_price");
b.Property<float?>("ReplacementCost")
.HasColumnType("real")
.HasColumnName("replacement_cost");
b.Property<string>("SerialNumber")
.HasColumnType("text")
.HasColumnName("serial_number");
b.Property<string>("StatusId")
.HasColumnType("text")
.HasColumnName("status_id");
b.Property<float?>("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<string>("Id")
.HasColumnType("text")
.HasColumnName("id");
b.Property<string>("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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("id");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ItemId")
.IsRequired()
.HasColumnType("text")
.HasColumnName("item_id");
b.Property<string>("OrderId")
.IsRequired()
.HasColumnType("text")
.HasColumnName("order_id");
b.Property<int?>("OrdersId")
.HasColumnType("integer")
.HasColumnName("orders_id");
b.Property<int>("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<string>("Id")
.HasColumnType("text")
.HasColumnName("id");
b.Property<string>("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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("id");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Address")
.HasColumnType("text")
.HasColumnName("address");
b.Property<int>("CustomerId")
.HasColumnType("integer")
.HasColumnName("customer_id");
b.Property<DateTimeOffset>("EndDate")
.HasColumnType("timestamp with time zone")
.HasColumnName("end_date");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text")
.HasColumnName("name");
b.Property<string>("Notes")
.HasColumnType("text")
.HasColumnName("notes");
b.Property<DateTimeOffset>("StartDate")
.HasColumnType("timestamp with time zone")
.HasColumnName("start_date");
b.Property<string>("StatusId")
.HasColumnType("text")
.HasColumnName("status_id");
b.Property<decimal>("TotalPrice")
.HasColumnType("numeric")
.HasColumnName("total_price");
b.Property<string>("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
}
}
}
@@ -0,0 +1,34 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace barkmanapi.Migrations
{
/// <inheritdoc />
public partial class fixedOrderCustomerID : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<int>(
name: "customer_id",
table: "orders",
type: "integer",
nullable: false,
oldClrType: typeof(string),
oldType: "text");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "customer_id",
table: "orders",
type: "text",
nullable: false,
oldClrType: typeof(int),
oldType: "integer");
}
}
}
@@ -0,0 +1,294 @@
// <auto-generated />
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
{
/// <inheritdoc />
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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("id");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Address")
.HasColumnType("text")
.HasColumnName("address");
b.Property<string>("BillingTerms")
.HasColumnType("text")
.HasColumnName("billing_terms");
b.Property<string>("Company")
.HasColumnType("text")
.HasColumnName("company");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text")
.HasColumnName("email");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text")
.HasColumnName("name");
b.Property<string>("Notes")
.HasColumnType("text")
.HasColumnName("notes");
b.Property<string>("PhoneNumber")
.HasColumnType("text")
.HasColumnName("phone_number");
b.HasKey("Id")
.HasName("pk_customers");
b.ToTable("customers", (string)null);
});
modelBuilder.Entity("barkmanapi.InventoryItems", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("id");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Barcode")
.IsRequired()
.HasColumnType("text")
.HasColumnName("barcode");
b.Property<string>("Brand")
.IsRequired()
.HasColumnType("text")
.HasColumnName("brand");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text")
.HasColumnName("name");
b.Property<string>("Notes")
.HasColumnType("text")
.HasColumnName("notes");
b.Property<float?>("RentalPrice")
.HasColumnType("real")
.HasColumnName("rental_price");
b.Property<float?>("ReplacementCost")
.HasColumnType("real")
.HasColumnName("replacement_cost");
b.Property<string>("SerialNumber")
.HasColumnType("text")
.HasColumnName("serial_number");
b.Property<string>("StatusId")
.HasColumnType("text")
.HasColumnName("status_id");
b.Property<float?>("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<string>("Id")
.HasColumnType("text")
.HasColumnName("id");
b.Property<string>("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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("id");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ItemId")
.IsRequired()
.HasColumnType("text")
.HasColumnName("item_id");
b.Property<int?>("JobsId")
.HasColumnType("integer")
.HasColumnName("jobs_id");
b.Property<string>("OrderId")
.IsRequired()
.HasColumnType("text")
.HasColumnName("order_id");
b.Property<int>("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<string>("Id")
.HasColumnType("text")
.HasColumnName("id");
b.Property<string>("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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("id");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Address")
.HasColumnType("text")
.HasColumnName("address");
b.Property<int>("CustomerId")
.HasColumnType("integer")
.HasColumnName("customer_id");
b.Property<DateTimeOffset>("EndDate")
.HasColumnType("timestamp with time zone")
.HasColumnName("end_date");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text")
.HasColumnName("name");
b.Property<string>("Notes")
.HasColumnType("text")
.HasColumnName("notes");
b.Property<DateTimeOffset>("StartDate")
.HasColumnType("timestamp with time zone")
.HasColumnName("start_date");
b.Property<string>("StatusId")
.HasColumnType("text")
.HasColumnName("status_id");
b.Property<decimal>("TotalPrice")
.HasColumnType("numeric")
.HasColumnName("total_price");
b.Property<string>("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
}
}
}
@@ -0,0 +1,176 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace barkmanapi.Migrations
{
/// <inheritdoc />
public partial class changedOrderToJob : Migration
{
/// <inheritdoc />
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<string>(type: "text", nullable: false),
name = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_job_status", x => x.id);
});
migrationBuilder.CreateTable(
name: "jobs",
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
customer_id = table.Column<int>(type: "integer", nullable: false),
name = table.Column<string>(type: "text", nullable: false),
status_id = table.Column<string>(type: "text", nullable: true),
start_date = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
end_date = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
total_price = table.Column<decimal>(type: "numeric", nullable: false),
venue = table.Column<string>(type: "text", nullable: true),
address = table.Column<string>(type: "text", nullable: true),
notes = table.Column<string>(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<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
order_id = table.Column<string>(type: "text", nullable: false),
item_id = table.Column<string>(type: "text", nullable: false),
quantity = table.Column<int>(type: "integer", nullable: false),
jobs_id = table.Column<int>(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");
}
/// <inheritdoc />
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<string>(type: "text", nullable: false),
name = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_order_status", x => x.id);
});
migrationBuilder.CreateTable(
name: "orders",
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
status_id = table.Column<string>(type: "text", nullable: true),
address = table.Column<string>(type: "text", nullable: true),
customer_id = table.Column<int>(type: "integer", nullable: false),
end_date = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
name = table.Column<string>(type: "text", nullable: false),
notes = table.Column<string>(type: "text", nullable: true),
start_date = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
total_price = table.Column<decimal>(type: "numeric", nullable: false),
venue = table.Column<string>(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<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
item_id = table.Column<string>(type: "text", nullable: false),
order_id = table.Column<string>(type: "text", nullable: false),
orders_id = table.Column<int>(type: "integer", nullable: true),
quantity = table.Column<int>(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");
}
}
}
@@ -211,9 +211,8 @@ namespace barkmanapi.Migrations
.HasColumnType("text")
.HasColumnName("address");
b.Property<string>("CustomerId")
.IsRequired()
.HasColumnType("text")
b.Property<int>("CustomerId")
.HasColumnType("integer")
.HasColumnName("customer_id");
b.Property<DateTimeOffset>("EndDate")
+1 -1
View File
@@ -49,7 +49,7 @@ public class Customers
public class Jobs
{
public int Id { get; set; }
public required string CustomerId { get; set; }
public required int CustomerId { get; set; }
public required string Name { get; set; }
public JobStatus Status { get; set; }
public string? StatusId { get; set; }
+1
View File
@@ -0,0 +1 @@
22.22.1
+1334 -1802
View File
File diff suppressed because it is too large Load Diff
+27 -26
View File
@@ -10,34 +10,35 @@
"preview": "vite preview"
},
"dependencies": {
"@mantine/core": "^7.16.0",
"@mantine/form": "^7.16.0",
"@mantine/hooks": "^7.16.0",
"@mantine/notifications": "^7.16.2",
"@tabler/icons-react": "^3.29.0",
"@tanstack/react-query": "^5.64.1",
"@tanstack/react-query-devtools": "^5.64.1",
"axios": "^1.7.9",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router": "^7.1.1",
"react-router-dom": "^7.1.1"
"@mantine/core": "^9.4.2",
"@mantine/dates": "^9.4.2",
"@mantine/form": "^9.4.2",
"@mantine/hooks": "^9.4.2",
"@mantine/notifications": "^9.4.2",
"@tabler/icons-react": "^3.45.0",
"@tanstack/react-query": "^5.101.4",
"@tanstack/react-query-devtools": "^5.101.4",
"axios": "^1.18.1",
"react": "^19.2.8",
"react-dom": "^19.2.8",
"react-router": "^8.3.0"
},
"devDependencies": {
"@eslint/js": "^9.17.0",
"@tanstack/eslint-plugin-query": "^5.62.16",
"@types/react": "^18.3.18",
"@types/react-dom": "^18.3.5",
"@vitejs/plugin-react": "^4.3.4",
"eslint": "^9.17.0",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-react-refresh": "^0.4.16",
"globals": "^15.14.0",
"postcss": "^8.5.1",
"postcss-preset-mantine": "^1.17.0",
"@eslint/js": "^9.39.5",
"@tanstack/eslint-plugin-query": "^5.101.4",
"@types/node": "^26.1.1",
"@types/react": "^19.2.17",
"@types/react-dom": "^19.2.3",
"@vitejs/plugin-react": "^6.0.4",
"eslint": "^9.39.5",
"eslint-plugin-react-hooks": "^7.1.1",
"eslint-plugin-react-refresh": "^0.5.3",
"globals": "^17.7.0",
"postcss": "^8.5.22",
"postcss-preset-mantine": "^1.18.0",
"postcss-simple-vars": "^7.0.1",
"typescript": "~5.6.2",
"typescript-eslint": "^8.18.2",
"vite": "^6.0.5"
"typescript": "^6.0.3",
"typescript-eslint": "^8.65.0",
"vite": "^8.1.5"
}
}
+116
View File
@@ -0,0 +1,116 @@
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";
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 = useJobList();
const newJobForm = useForm<NewJob>({
mode: 'uncontrolled',
initialValues: {
customerId: 0,
name: "",
startDate: new Date(),
endDate: new Date(),
address: "",
venue: "",
notes: "",
},
validate: {},
});
const updateJob = useMutation({
mutationFn: async (values: NewJob) => {
const result = await fetch(import.meta.env.VITE_API_URL + '/jobs', {
method: 'POST',
body: JSON.stringify(values),
headers: {
'Content-Type': 'application/json'
}
});
if (result.ok) {
notifications.show({
icon: <IconCheck size={20}/>,
color: "teal",
title: "All good!",
message: "Job Created",
position: 'top-center',
});
navigate("/jobs");
}
if (!result.ok) {
notifications.show({
icon: <IconX size={20}/>,
color: "red",
title: "Bummer!",
message: "Something went wrong",
position: 'top-center',
});
throw new Error('Failed to create job');
}
},
})
if (customerQuery.isPending) return 'Loading...'
if (customerQuery.error) return 'An error has occurred: ' + customerQuery.error.message
return (
<>
<form onSubmit={newJobForm.onSubmit(async (values) => await
updateJob.mutateAsync(values))}>
<Container m="lg">
<Flex mih={50}
gap="md"
justify="flex-start"
align="flex-start"
direction="column"
wrap="wrap">
<Title order={1}>Add Item</Title>
<NumberInput withAsterisk key={newJobForm.key('customerId')} size="md" label="Customer ID"
placeholder="Customer ID" {...newJobForm.getInputProps('customerId')}/>
<TextInput withAsterisk key={newJobForm.key('name')} size="md" label="Name"
placeholder="Name" {...newJobForm.getInputProps('name')}/>
<DateTimePicker withAsterisk key={newJobForm.key('startDate')} size="md" label="Start Date"
placeholder="Start Date" {...newJobForm.getInputProps('startDate')}/>
<DateTimePicker withAsterisk key={newJobForm.key('endDate')} size="md" label="End Date"
placeholder="End Date" {...newJobForm.getInputProps('endDate')}/>
<TextInput size="md" key={newJobForm.key('address')} label="Address"
placeholder="Address" {...newJobForm.getInputProps('address')}/>
<TextInput size="md" key={newJobForm.key('venue')} label="Venue"
placeholder="Venue"{...newJobForm.getInputProps('venue')}/>
<TextInput size="md" key={newJobForm.key('notes')} label="Notes"
placeholder="Notes" {...newJobForm.getInputProps('notes')}/>
<Group justify="flex-end" mt="md">
<Button type="submit">Submit</Button>
</Group>
</Flex>
</Container>
</form>
</>
);
}
export default AddJob;
@@ -0,0 +1,17 @@
import {useQuery} from "@tanstack/react-query";
import {Job} from "../types.ts";
const useJobList = () => useQuery({
queryKey: ['job'],
queryFn: async (): Promise<Job[]> => {
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;
+23
View File
@@ -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: string,
address: string,
notes: string,
}
export interface NewJob {
customerId: number,
name: string,
startDate: Date;
endDate: Date;
venue: string,
address: string,
notes: string,
}
+1 -2
View File
@@ -21,8 +21,7 @@
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}