ADDED: new add notes feature for orders backend and frontend
Runner Test / test (push) Failing after 17s
Runner Test / test (pull_request) Failing after 16s

This commit is contained in:
Lena Deriso
2026-09-22 23:06:01 -04:00
parent e493d1592b
commit c5215daedb
12 changed files with 425 additions and 8 deletions
+30
View File
@@ -2,6 +2,7 @@ import type { Address, AuthUser } from "@orderops/shared";
import type { FastifyPluginAsync, FastifyRequest } from "fastify";
import { requireEmployeeUser } from "../auth/current-user";
import type { DatabaseContext } from "../db/database";
import { addOrderNote } from "./add-order-note";
import { cancelOrder } from "./cancel-order";
import { getOrder } from "./get-order";
import { listAuditEvents } from "./list-audit-events";
@@ -33,6 +34,10 @@ interface CancelBody {
reason?: string;
}
interface NoteBody {
body: string;
}
type AuthenticatedRequest = FastifyRequest & { currentUser: AuthUser };
export const registerOrderRoutes: FastifyPluginAsync<OrderRouteOptions> = async (app, options) => {
@@ -69,6 +74,31 @@ export const registerOrderRoutes: FastifyPluginAsync<OrderRouteOptions> = async
app.get<{ Params: IdParams }>("/orders/:orderId/audit-events", async (request) => listAuditEvents(options.db, request.params.orderId));
app.post<{ Params: IdParams; Body: NoteBody }>("/orders/:orderId/notes", {
schema: {
body: {
type: "object",
required: ["body"],
properties: {
body: { type: "string", minLength: 1, maxLength: 1999 }
}
}
}
}, async (request, reply) => {
const currentUser = (request as AuthenticatedRequest).currentUser;
const result = await addOrderNote(options.db, {
orderId: request.params.orderId,
authorUserId: currentUser.id,
body: request.body.body
});
if (result.statusCode !== 200) {
return reply.code(result.statusCode).send({ message: result.message });
}
return result.note;
});
app.post<{ Params: OrderItemParams; Body: QuantityBody }>("/orders/:orderId/items/:itemId/quantity", {
schema: {
body: {