refactor: consolidate duplicated code across web and API packages
- Extract shared render helpers (vacation blocks, range overlay, overbooking blink) into renderHelpers.tsx - Centralize status badge styles and vacation color maps into status-styles.ts - Extract dragMath.ts utility from useTimelineDrag for reuse - Split useInvalidatePlanningViews into useInvalidateTimeline (4 queries) + useInvalidatePlanningViews (8 queries) - Adopt findUniqueOrThrow() and Prisma select constants across API routers - Add shared fmtEur() helper for API-side money formatting - Wrap TimelineResourcePanel and TimelineProjectPanel with React.memo - Fix pre-existing TS2589 deep type errors in TeamCalendar and VacationModal - 38 files changed, reducing ~400 lines of duplicated code Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { z } from "zod";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { findUniqueOrThrow } from "../db/helpers.js";
|
||||
import { createTRPCRouter, managerProcedure, protectedProcedure } from "../trpc.js";
|
||||
import {
|
||||
emitNotificationCreated,
|
||||
@@ -598,13 +599,10 @@ export const notificationRouter = createTRPCRouter({
|
||||
assignTask: managerProcedure
|
||||
.input(z.object({ id: z.string(), assigneeId: z.string() }))
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
const existing = await ctx.db.notification.findUnique({
|
||||
where: { id: input.id },
|
||||
});
|
||||
|
||||
if (!existing) {
|
||||
throw new TRPCError({ code: "NOT_FOUND", message: "Task not found" });
|
||||
}
|
||||
const existing = await findUniqueOrThrow(
|
||||
ctx.db.notification.findUnique({ where: { id: input.id } }),
|
||||
"Task",
|
||||
);
|
||||
|
||||
if (existing.category !== "TASK" && existing.category !== "APPROVAL") {
|
||||
throw new TRPCError({
|
||||
|
||||
Reference in New Issue
Block a user